Skip to content

Skip Nmap on empty Masscan results; handle TCP/UDP-only scans; fix ping args#4

Open
jph4cks wants to merge 1 commit into
masterfrom
codex/fix-errors-in-new-github-code
Open

Skip Nmap on empty Masscan results; handle TCP/UDP-only scans; fix ping args#4
jph4cks wants to merge 1 commit into
masterfrom
codex/fix-errors-in-new-github-code

Conversation

@jph4cks
Copy link
Copy Markdown
Owner

@jph4cks jph4cks commented Apr 30, 2026

Motivation

  • Prevent runtime errors and invalid commands when masscan returns no results for a target.
  • Ensure nmap invocation is correct for TCP-only, UDP-only, and mixed port discoveries.
  • Fix incorrect subprocess argument formatting for ping to avoid unexpected behavior.

Description

  • Added a guard in main() to skip nmap_scan and nmap_vuln_scan when masscan() returns an empty result for a target. (jpscan.py)
  • Reworked nmap_scan() and nmap_vuln_scan() to use target_ports[ip].get('tcp', []) and get('udp', []), skip empty entries, and build protocol-specific nmap commands for TCP-only, UDP-only, and mixed cases. (jpscan.py)
  • Corrected the get_mac() ping call to pass -c and 1 as separate argv entries in Popen (Popen(["ping", "-c", "1", IP])). (jpscan.py)
  • Removed redundant UDP append loop and ensured command strings use the appropriate -pT:/-pU: forms when only one protocol is present. (jpscan.py)

Testing

  • Ran python3 -m py_compile jpscan.py which completed successfully. (passed)
  • Executed python3 jpscan.py -t 127.0.0.1 -p 1-10 -r 1000 -w 1 in the CI environment where masscan is not installed, and the script handled the no-results path and skipped nmap scans without crashing. (behavior verified)

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant