Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 80856b0

Browse files
authoredJul 8, 2023
Create nmapb.py
1 parent d313e74 commit 80856b0

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
 

‎nmapb.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# NPM Black Python (lite)
2+
import subprocess
3+
import csv
4+
import xml.etree.ElementTree as ET
5+
6+
# Read the text file with domain names
7+
with open('domainlist.txt', 'r') as file:
8+
domain_list = file.readlines()
9+
domain_list = [domain.strip() for domain in domain_list]
10+
11+
# Loop through domain names and perform Nmap scanning
12+
for domain in domain_list:
13+
# Run Nmap command and capture output
14+
# Set ports you want scan with nmap for faster results
15+
cmd = f'nmap -p 1-65535 -oX {domain}.xml {domain}'
16+
subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
17+
18+
# Removed #########################################################
19+
# logic ='removed to prevent abuse please create your own logic!' #
20+
# logics tipp: Hydra can handel 64 Proxies/Tunnels at on time and #
21+
# Nikto loves to work with MSF+ i mean they cam mary :smile:# #
22+
# Without this logic this script is powerfull enought for research#
23+
# No quesstion please, you must learn programming logic #
24+
###################################################################
25+
26+
# Parse XML output
27+
tree = ET.parse(f'{domain}.xml')
28+
root = tree.getroot()
29+
30+
# Extract all relevant information from XML
31+
open_ports = []
32+
vulnerabilities = []
33+
for host in root.findall('host'):
34+
for port in host.findall('ports/port'):
35+
port_id = port.get('portid')
36+
open_ports.append(port_id)
37+
for script in host.findall('hostscript/script'):
38+
output = script.get('output')
39+
vulnerabilities.append(output)
40+
41+
# Work finished ! you can handelnow the .xml or u export it to csv below
42+
# you can use .join(open_ports) or .join(vulnerabilities) handel with your on script with the xml with your own logic
43+
44+
###############################################
45+
# Handel removed! Creat your own! ###########
46+
###############################################
47+
48+
# or write extracted information to CSV (needed if you want use in other tools, cause they need most time .txt or .csv
49+
with open(f'{domain}.csv', 'w', newline='') as csvfile:
50+
fieldnames = ['Domain', 'Open Ports', 'Vulnerabilities']
51+
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
52+
writer.writeheader()
53+
writer.writerow({'Domain': domain, 'Open Ports': ', '.join(open_ports), 'Vulnerabilities': ', '.join(vulnerabilities)})
54+
55+
56+
## get csv output and use it in your next script /tool or exucute your own handel/mechanizem

0 commit comments

Comments
 (0)
Please sign in to comment.