代码拉取完成,页面将自动刷新
同步操作将从 现任明教教主-乾颐堂/qytang_Python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/python3.4
# -*- coding=utf-8 -*-
import nmap
import sys
def nmap_A_scan(network_prefix):
nm = nmap.PortScanner()
scan_raw_result = nm.scan(hosts=network_prefix, arguments='-v -n -A')
# print(len(scan_raw_result))
# print(scan_raw_result['scan'])
# print(len(scan_raw_result['scan']))
for host in scan_raw_result['scan']:
if scan_raw_result['scan'][host]['status']['state'] == 'up':
print('#'*17 + 'Host:' + host + '#'*17)
#print('Host: %s' % host)
# print('='*20 + '开放端口清单' + '='*20)
#print(scan_raw_result['scan'][host]['portused'])
# for port in scan_raw_result['scan'][host]['portused']:
# if port['state'] == 'open':
# print('开放端口号: ' + port['proto'] + '/' + port['portid'])
print('-'*20 + '操作系统猜测' + '-'*20)
#print(scan_raw_result['scan'][host]['osmatch'])
for os in scan_raw_result['scan'][host]['osmatch']:
print('操作系统为: ' + os['name'] + ' 准确度为: ' + os['accuracy'])
#print('='*50 + 'vendor' + '='*50)
#print(scan_raw_result['scan'][host]['vendor'])
#print('='*50 + 'uptime' + '='*50)
#print(scan_raw_result['scan'][host]['uptime'])
idno = 1
try:
for port in scan_raw_result['scan'][host]['tcp']:
try:
print('-'*17 + 'TCP服务详细信息' + '[' + str(idno) + ']' + '-'*17)
idno = idno + 1
print('TCP端口号:' + str(port))
try:
print('状态: ' + scan_raw_result['scan'][host]['tcp'][port]['state'])
except:
pass
try:
print('原因: ' + scan_raw_result['scan'][host]['tcp'][port]['reason'])
except:
pass
try:
print('额外信息: ' + scan_raw_result['scan'][host]['tcp'][port]['extrainfo'])
except:
pass
try:
print('名字: ' + scan_raw_result['scan'][host]['tcp'][port]['name'])
except:
pass
try:
print('版本: ' + scan_raw_result['scan'][host]['tcp'][port]['version'])
except:
pass
try:
print('产品: ' + scan_raw_result['scan'][host]['tcp'][port]['product'])
except:
pass
try:
print('CPE: ' + scan_raw_result['scan'][host]['tcp'][port]['cpe'])
except:
pass
try:
print('脚本: ' + scan_raw_result['scan'][host]['tcp'][port]['script'])
except:
pass
except:
pass
except:
pass
idno = 1
try:
for port in scan_raw_result['scan'][host]['udp']:
try:
print('-'*17 + 'UDP服务详细信息' + '[' + str(idno) + ']' + '-'*17)
idno = idno + 1
print('UDP端口号:' + str(port))
try:
print('状态: ' + scan_raw_result['scan'][host]['udp'][port]['state'])
except:
pass
try:
print('原因: ' + scan_raw_result['scan'][host]['udp'][port]['reason'])
except:
pass
try:
print('额外信息: ' + scan_raw_result['scan'][host]['udp'][port]['extrainfo'])
except:
pass
try:
print('名字: ' + scan_raw_result['scan'][host]['udp'][port]['name'])
except:
pass
try:
print('版本: ' + scan_raw_result['scan'][host]['udp'][port]['version'])
except:
pass
try:
print('产品: ' + scan_raw_result['scan'][host]['udp'][port]['product'])
except:
pass
try:
print('CPE: ' + scan_raw_result['scan'][host]['udp'][port]['cpe'])
except:
pass
try:
print('脚本: ' + scan_raw_result['scan'][host]['udp'][port]['script'])
except:
pass
except:
pass
except:
pass
#print('='*50 + 'hostnames' + '='*50)
#print(scan_raw_result['scan'][host]['hostnames'])
print('-'*20 + '地址详细信息' + '-'*20)
try:
print('IP地址: ' + scan_raw_result['scan'][host]['addresses']['ipv4'])
print('MAC地址: ' + scan_raw_result['scan'][host]['addresses']['mac'])
except:
pass
# for IP in scan_raw_result['scan']:
# if scan_raw_result['scan'][IP]['status']['state'] == 'up':
# print( '%-20s %5s' % (scan_raw_result['scan'][IP]['addresses']['ipv4'],'is UP'))
if __name__ == '__main__':
nmap_A_scan(sys.argv[1])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。