Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customized subnet list for nmap #53

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion actions/scanning.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def __init__(self, shared_data):
self.blacklistcheck = shared_data.blacklistcheck
self.mac_scan_blacklist = shared_data.mac_scan_blacklist
self.ip_scan_blacklist = shared_data.ip_scan_blacklist
self.use_custom_subnets = shared_data.use_custom_subnets
self.custom_subnet_list = shared_data.custom_subnet_list
self.console = Console()
self.lock = threading.Lock()
self.currentdir = shared_data.currentdir
Expand Down Expand Up @@ -368,7 +370,11 @@ def scan_network_and_write_to_csv(self):
self.outer_instance.logger.error(f"Error in scan_network_and_write_to_csv (initial write): {e}")

# Use nmap to scan for live hosts
self.outer_instance.nm.scan(hosts=str(self.network), arguments='-sn')
subnets = str(self.network)
if self.outer_instance.use_custom_subnets:
subnets = " ".join(self.outer_instance.custom_subnet_list)

self.outer_instance.nm.scan(hosts=subnets, arguments='-sn')
for host in self.outer_instance.nm.all_hosts():
t = threading.Thread(target=self.scan_host, args=(host,))
t.start()
Expand Down
4 changes: 4 additions & 0 deletions config/shared_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
"nmap_scan_aggressivity": "-T2",
"portstart": 1,
"portend": 2,
"use_custom_subnets": false,
"custom_subnet_list": [
"192.168.1.0/24"
],
"__title_timewaits__": "Time Wait Settings",
"timewait_smb": 0,
"timewait_ssh": 0,
Expand Down
2 changes: 2 additions & 0 deletions shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def get_default_config(self):
"nmap_scan_aggressivity": "-T2",
"portstart": 1,
"portend": 2,
"use_custom_subnets": False,
"custom_subnet_list": ["192.168.1.0/24"],

"__title_timewaits__": "Time Wait Settings",
"timewait_smb": 0,
Expand Down
1 change: 1 addition & 0 deletions web/scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function generateConfigForm(config) {
"ip_scan_blacklist",
"steal_file_names",
"steal_file_extensions",
"custom_subnet_list",
];

formData.forEach((value, key) => {
Expand Down