Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
network_mode: "host"
environment:
PORTS: "80,443,22,21,25565,27017,143,6379"
NETWORKS: "10.0.0.0/8 192.168.0.0/16"
depends_on:
rabbitmq:
condition: service_healthy
Expand Down
8 changes: 8 additions & 0 deletions rigour/common/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ def get_mongo_db(default: str = "rigour") -> str:
def get_rabbitmq_uri(default: str = "amqp://localhost:5672/") -> str:
return os.environ.get("RABBITMQ_URL", default)

@staticmethod
def get_networks(default: str = "10.0.0.0/8") -> str:
return os.environ.get("NETWORKS", default)

@staticmethod
def get_ports(default: str = "80") -> str:
return os.environ.get("PORTS", default)

@staticmethod
def get_scan_collection() -> str:
return "scans"
7 changes: 4 additions & 3 deletions rigour/ports/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import asyncio
import os
from dataclasses import asdict
from datetime import datetime

import geoip2.database
import geoip2.errors
from common import utils
from common.config import Config
from common.database.mongodb import Database
from common.queue.rabbitmq_asyncio import AsyncRabbitMQQueueManager
from common.types import Host, HostMessage, Location
Expand Down Expand Up @@ -46,7 +46,8 @@ def main():
db = Database()
queue = AsyncRabbitMQQueueManager()
reader = geoip2.database.Reader("geolite2-city.mmdb")
ports = os.getenv("PORTS", "80")
ports = Config.get_ports()
networks = Config.get_networks()

logger.info(f"Starting port scanner for port/s: {ports}")

Expand All @@ -60,7 +61,7 @@ async def callback(result: ZMapResult) -> None:
await queue.publish(route_key, asdict(host))
save(db, host)

command = ZMapCommand(ports)
command = ZMapCommand(ports, networks)
zmap = ZMap(command)
loop = asyncio.get_event_loop()
loop.run_until_complete(zmap.run(callback))
Expand Down
4 changes: 3 additions & 1 deletion rigour/ports/zmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@


class ZMapCommand:
def __init__(self, ports: str):
def __init__(self, ports: str, networks: str):
self.ports = ports
self.networks = networks

def build(self):
return [
Expand All @@ -16,6 +17,7 @@ def build(self):
"--quiet", # Suppress status updates
"--rate=200", # Send 100 packets per second
'--output-filter="success = 1"', # Filter successful results
self.networks,
]


Expand Down
Loading