在使用nmap参数运行Python3时,输出仅显示为-1
try:
import os, sys, time
except:
sys.exit("[!] Install 'os, sys, time' modules: pip3 install os -|- check whether 'Nmap' is installed: https://nmap.org/")
class recon_scanner():
def nMap(self):
tgtHost = input("Enter the target: ")
tgtPort = input("Enter the target port: ")
options = input("""\n Please choose an option:
[1] TCP NULL|sN|+|Pn|+|sV|+|sC|+|O|+|version-intensity 9|+|reason|
[2] TCP FIN|sF|+|Pn|+|sV|+|sC|+|O|+|version-intensity 9|+|reason|
[3] TCP XMAS|sX|+|Pn|+|sV|+|sC|+|O|+|version-intensity 9|+|reason| \n""")
print("You have selected option: ",options, '\n')
if options == '1':
scanner1 = os.system("nmap -Pn -sN -A -v --version-intensity 9 --reason" + str(tgtHost) + str(tgtPort))
print(scanner1)
scan_result = recon_scanner()
scan_result.nMap()
尝试使用os.popen而不是
os.system
,以获取字符串形式的输出:scanner1 = os.popen("nmap -Pn -sN -A -v version-intensity 9 reason" + str(tgtHost) + str(tgtPort)).read()
然后你可以像其他字符串一样打印它
相关问题 更多 >
编程相关推荐