Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 输出未正确显示_Python_Python 3.x_Nmap - Fatal编程技术网

Python 输出未正确显示

Python 输出未正确显示,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

在使用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.system
,以获取字符串形式的输出:

scanner1=os.popen(“nmap-Pn-sN-A-v——版本强度9——原因”+str(tgtHost)+str(tgtPort)).read()


然后你可以像其他字符串一样打印它

嗨,亚当,谢谢你的评论。所以我可以通过打印(str(scanner1))获得输出