NetScan is a comprehensive RESTful API and Telegram Bot designed for automated infrastructure scanning and asset management.
Built with FastAPI for high performance, this project allows security teams and administrators to track targets, manage domains and IP addresses, and perform asynchronous scans (port discovery, SSL certificate parsing) using Celery and Redis.
- 🎯 Asset Management: Complete CRUD operations for Targets, Domains, and IP addresses with cascading database relations.
- 🔍 Automated Scanning Engine:
- Port discovery and banner grabbing.
- Automated SSL/TLS certificate parsing (Issuer, Expiration dates, etc.).
- 🤖 Telegram Bot Integration (
aiogram):- Manage scans and retrieve target information directly from Telegram.
- Asynchronous polling tightly integrated with the FastAPI lifespan.
- ⚡ Background Tasks (Celery + Redis):
- Heavy scanning operations are offloaded to background workers to ensure the API remains blazing fast.
- 🛡️ Bulletproof Data Validation: Strict Pydantic schemas and database constraints to prevent data duplication.
- 🐳 Fully Dockerized: Ready for deployment with isolated containers for the Web API, DB, Redis, and Celery Worker.
A quick overview of the core application structure:
.
├── .env
├── .env_sample
├── .gitignore
├── Dockerfile
├── README.md
├── alembic.ini
├── app/
│ ├── __init__.py
│ ├── config/
│ │ ├── __init__.py
│ │ ├── dependencies.py
│ │ └── settings.py
│ ├── database/
│ │ ├── __init__.py
│ │ ├── models/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── domain.py
│ │ │ ├── ip_address.py
│ │ │ ├── port.py
│ │ │ ├── ssl_cert.py
│ │ │ └── target.py
│ │ └── session_postgresql.py
│ ├── main.py
│ ├── routes/
│ │ ├── __init__.py
│ │ ├── api.py
│ │ ├── domain.py
│ │ ├── ip.py
│ │ ├── port.py
│ │ ├── ssl_certificate.py
│ │ └── target.py
│ ├── scanner/
│ │ ├── __init__.py
│ │ ├── banner_port.py
│ │ ├── core.py
│ │ ├── dns_resolver.py
│ │ ├── port_scanner.py
│ │ └── ssl_parser.py
│ ├── schemas/
│ │ ├── __init__.py
│ │ ├── domain.py
│ │ ├── ip.py
│ │ ├── port.py
│ │ ├── ssl_certificate.py
│ │ └── target.py
│ ├── services/
│ │ ├── __init__.py
│ │ └── scanner_service.py
│ ├── tests/
│ │ ├── __init__.py
│ │ ├── api/
│ │ │ ├── test_certificates.py
│ │ │ ├── test_domains.py
│ │ │ ├── test_ips.py
│ │ │ ├── test_port.py
│ │ │ └── test_target.py
│ │ ├── bot/
│ │ │ └── test_validators.py
│ │ ├── conftest.py
│ │ ├── models/
│ │ │ ├── test_domain.py
│ │ │ ├── test_ips.py
│ │ │ ├── test_queries.py
│ │ │ ├── test_relations.py
│ │ │ ├── test_services.py
│ │ │ └── test_target.py
│ │ └── test_schemas.py
│ ├── tg_bot/
│ │ ├── __init__.py
│ │ ├── handlers/
│ │ │ ├── base.py
│ │ │ └── targets.py
│ │ ├── keyboards/
│ │ │ ├── inline.py
│ │ │ └── reply.py
│ │ ├── main.py
│ │ ├── middlewares/
│ │ │ └── __init__.py
│ │ ├── states.py
│ │ └── utils/
│ │ ├── formatters.py
│ │ └── validators.py
│ └── worker/
│ ├── __init__.py
│ ├── celery_app.py
│ └── tasks.py
├── celerybeat-schedule
├── docker-compose.yml
├── migrations/
│ ├── README
│ ├── env.py
│ ├── script.py.mako
│ └── versions/
│ └── f7c91d8e156f_init_db.py
├── pytest.ini
├── requirements.txt
└── test_main.http
21 directories, 83 files
- Docker & Docker Compose
- Git
git clone [https://github.com/Psychox1k/NetRecon.git](https://github.com/Psychox1k/NetRecon.git)
cd NetReconCreate a .env file in the project root directory and add the following variables:
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_secure_password
POSTGRES_DB=NetScan_db
POSTGRES_HOST=db
POSTGRES_PORT=5432
REDIS_URL=redis://redis:6379/0
BOT_TOKEN=your_telegram_bot_token
BOT_MODE=polling
LOG_LEVEL=INFO
Start the application suite (FastAPI, PostgreSQL, Redis, Celery) with Docker Compose:
docker compose up -d --buildInitialize the database schema using Alembic:
docker compose exec web alembic upgrade head(Note: Replace web with the name of your FastAPI service in docker-compose.yml if different).
The project includes auto-generated interactive API documentation powered by OpenAPI (Swagger). Once the server is running, access it here:
Swagger UI: http://127.0.0.1:8000/docs
ReDoc: http://127.0.0.1:8000/redoc
The project is covered by a comprehensive test suite using Pytest. Tests run in an isolated in-memory SQLite database to ensure the production data remains untouched.
To run the tests locally or inside the Docker container:
docker compose exec web pytest -v