This project implements a distributed TCP port scanner using RabbitMQ for task distribution and result collection. It consists of a server (task manager) that distributes scanning tasks to workers via RabbitMQ queues and collects the results.
flowchart LR
subgraph Server[Server / Task Manager]
R[Read targets file]
E[Enqueue each target]
C[Collect results]
O[Print to stdout]
end
subgraph Broker[RabbitMQ]
Q1[(scan_task)]
Q2[(scan_result)]
end
subgraph Workers[Workers]
subgraph W1[Worker 1]
W1c[Consume task]
W1s[Attempt TCP connect]
W1p[Publish result]
end
subgraph W2[Worker 2]
W2c[Consume task]
W2s[Attempt TCP connect]
W2p[Publish result]
end
subgraph W3[Worker 3]
W3c[Consume task]
W3s[Attempt TCP connect]
W3p[Publish result]
end
end
T[targets.txt] --> R --> E --> Q1
Q1 --> W1c
Q1 --> W2c
Q1 --> W3c
W1c --> W1s --> W1p --> Q2
W2c --> W2s --> W2p --> Q2
W3c --> W3s --> W3p --> Q2
Q2 --> C --> O
- Distributes port scanning tasks using RabbitMQ message queues
- Collects and displays results from workers
- Supports batch task submission from a file
- Configurable output file for results
- Python 3.x
- pika (Python RabbitMQ client)
- RabbitMQ server running and accessible
-
Install dependencies:
pip install pika
-
Configure RabbitMQ credentials:
- Edit
server.pyand replaceUSERNAMEandPASSWORDwith your RabbitMQ credentials.
- Edit
-
Start RabbitMQ server (if not already running):
sudo systemctl start rabbitmq-server
Create a text file (e.g., targets.txt) with each line containing an ip:port pair:
192.168.1.1:80
10.0.0.2:22
python server.py -f targets.txt -o results.txt-f/--file: Path to the file containing the list ofip:porttargets (one per line)-o/--output: Path to the output file for results (currently not written to, see below)
You need to implement and run worker(s) that consume tasks from the scan_task queue and publish results to the scan_result queue. (This repository currently provides only the server/task manager.)
- The server reads the target list and submits each as a task to the
scan_taskqueue. - Workers (not included here) pick up tasks, perform the scan, and send results to the
scan_resultqueue. - The server collects and prints results as they arrive.
- The output file specified with
-ois not currently written to; results are printed to stdout. You can extend the code to write results to the file as needed. - Make sure RabbitMQ is running and accessible with the credentials you provide.
MIT License