Python 输出未正确显示
在使用nmap参数运行Python3时,输出仅显示为-1Python 输出未正确显示,python,python-3.x,nmap,Python,Python 3.x,Nmap,在使用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): tgt
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.system
,以获取字符串形式的输出:
scanner1=os.popen(“nmap-Pn-sN-A-v——版本强度9——原因”+str(tgtHost)+str(tgtPort)).read()
然后你可以像其他字符串一样打印它嗨,亚当,谢谢你的评论。所以我可以通过打印(str(scanner1))获得输出