python 使用nmap 模块
官网 https://pypi.org/project/python-nmap/
>>> import nmap
>>> nm = nmap.PortScannerScanner()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'nmap' has no attribute 'PortScannerScanner'
>>> nm = nmap.PortScanner()
>>> nm.scan('127.0.0.1','22-443')
{'nmap': {'command_line': 'nmap -oX - -p 22-443 -sV 127.0.0.1', 'scaninfo': {'tcp': {'method': 'syn', 'services': '22-443'}}, 'scanstats': {'timestr': 'Wed Oct 23 17:25:01 2019', 'elapsed': '6.20', 'uphosts': '1', 'downhosts': '0', 'totalhosts': '1'}}, 'scan': {'127.0.0.1': {'hostnames': [{'name': 'localhost', 'type': 'PTR'}], 'addresses': {'ipv4': '127.0.0.1'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'localhost-response'}, 'tcp': {22: {'state': 'open', 'reason': 'syn-ack', 'name': 'ssh', 'product': 'OpenSSH', 'version': '7.4', 'extrainfo': 'protocol 2.0', 'conf': '10', 'cpe': 'cpe:/a:openbsd:openssh:7.4'}, 25: {'state': 'open', 'reason': 'syn-ack', 'name': 'smtp', 'product': 'Postfix smtpd', 'version': '', 'extrainfo': '', 'conf': '10', 'cpe': 'cpe:/a:postfix:postfix'}, 111: {'state': 'open', 'reason': 'syn-ack', 'name': 'rpcbind', 'product': '', 'version': '2-4', 'extrainfo': 'RPC #100000', 'conf': '10', 'cpe': ''}}}}}
>>> nm.command_line
<bound method PortScanner.command_line of <nmap.nmap.PortScanner object at 0x2ba54ca28978>>
>>> nm.command_line()
'nmap -oX - -p 22-443 -sV 127.0.0.1'
>>> nm.scaninfo
<bound method PortScanner.scaninfo of <nmap.nmap.PortScanner object at 0x2ba54ca28978>>
>>> nm.scaninfo()
{'tcp': {'method': 'syn', 'services': '22-443'}}
>>> nm.scaninfo()['tcp']
{'method': 'syn', 'services': '22-443'}
>>> nm.scaninfo()['tcp']['method']
'syn'
>>> nm.all_hosts()
['127.0.0.1']
>>> nm['127.0.0.1'].hostname()
'localhost'
>>> nm['127.0.0.1'].hostnames()
[{'name': 'localhost', 'type': 'PTR'}]
>>> nm.scan(hosts="192.168.1.0/24",arguments="-n -sP -PE")
{'nmap': {'command_line': 'nmap -oX - -n -sP -PE 192.168.1.0/24', 'scaninfo': {}, 'scanstats': {'timestr': 'Wed Oct 23 17:29:13 2019', 'elapsed': '1.07', 'uphosts': '15', 'downhosts': '241', 'totalhosts': '256'}}, 'scan': {'192.168.1.1': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.1'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.43': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.43'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.50': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.50'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.72': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.72'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.74': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.74'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.77': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.77'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.80': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.80'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.103': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.103'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.203': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.203'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.204': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.204'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.211': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.211'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.222': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.222'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.243': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.243'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.245': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.245'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}, '192.168.1.255': {'hostnames': [{'name': '', 'type': ''}], 'addresses': {'ipv4': '192.168.1.255'}, 'vendor': {}, 'status': {'state': 'up', 'reason': 'echo-reply'}}}}
>>> nm.all_hosts()
['192.168.1.1', '192.168.1.103', '192.168.1.203', '192.168.1.204', '192.168.1.211', '192.168.1.222', '192.168.1.243', '192.168.1.245', '192.168.1.255', '192.168.1.43', '192.168.1.50', '192.168.1.72', '192.168.1.74', '192.168.1.77', '192.168.1.80']
python 使用nmap 模块的更多相关文章
- 端口扫描器--利用python的nmap模块
安装nmap模块挺麻烦的,搞了半天 不仅要安装pip install nmap 还要sudo apt install nmap 给出代码,没有设多线程,有点慢,注意端口的类型转换,搞了很久 #!/us ...
- python(nmap模块、多线程模块)
http://xael.org/pages/python-nmap-en.html nmap模块 http://www.tutorialspoint.com/python/python_m ...
- 7.python实现高效端口扫描器之nmap模块
对于端口扫描,使用的最多的就是nmap这个工具,不想python已经强大到,提供了nmap这个扫描端口的模块. 本片文章主要介绍nmap模块的两个常用类: PortScanner()类,实现一个nma ...
- python nmap模块使用进行主机探测(ICMP)
终于审核通过了......第一次用博客,想记录自己的学习情况,分享知识. 废话不多说,第一篇blog,大牛请轻喷. 资产清点首先需要进行主机探测,将存活主机统计下来再进行进一步的指纹识别及端口探测.若 ...
- python nmap模块 端口探测
今天添加端口探测功能,主要实现方式是通过nmap模块调用,扫描1-65535端口.上一篇中已经将UP的PC机全部获取到,这里直接从已知在线的PC中进行端口扫描就可以了,会节省很多时间. 代码如下,还是 ...
- Python调用nmap扫描网段主机信息生成xml
#!/usr/bin/env python # -*- coding: utf_8 -*- # Date: 2015年10月23日 # Author:蔚蓝行 # 博客 http://www.cnblo ...
- 7.安装pycharm----导入Nmap模块----netcat反向shell----metasploitable靶机环境
安装pycharm www.jetbrains.com/pycharm/ tar -zxvf p补全 ls cd p补全 ls cd bin ls ./pycharm.sh 新建项目 pythonRo ...
- python之platform模块
python之platform模块 ^_^第三个模块从天而降喽!! 函数列表 platform.system() 获取操作系统类型,windows.linux等 platform.platform() ...
- python之OS模块详解
python之OS模块详解 ^_^,步入第二个模块世界----->OS 常见函数列表 os.sep:取代操作系统特定的路径分隔符 os.name:指示你正在使用的工作平台.比如对于Windows ...
随机推荐
- [转] Performance_js中计算网站性能监控利器
1.Performance方法 Performance提供的方法可以灵活使用,获取到页面加载等标记的耗时情况. performance.now() //返回当前到页面打开时刻的耗时,精确到千分之一毫秒 ...
- Linux 笔记 - 第二十三章 MySQL 主从复制配置
一.前言 MySQL Replication,也被称为主从复制.AB 复制.简单来说就是 A 和 B 两台服务器做主从后,在 A 服务器上写入数据,B 服务器上也会跟着写入输入,两者之间的数据是实时同 ...
- Macro的写法 `( , ,@ )
另外的注意点: 1. 同名符号的 “变量捕捉” (varible capture) 解决方式: with-gensym 生成几个unique name-s, 然后将它们各自绑定上参数值 2. 多次 ...
- 3-awk
1.输出双引号:awk '{print "\""}' #放大:awk '{print " \" "}'使用“”双引号把一个 ...
- template might not exist or might not be accessible by any of the configured Template Resolvers 完美解决
初学者在maven spring boot web项目中使用thymeleaf 模板,经常会遇到 “template might not exist or might not be accessib ...
- contos7自启动django服务
研究了很多种办法 1.新建一个sh 文件 vi django_autostart.sh 2.编辑文件内容 #!/bin/bash #chkconfig:345 61 61 //此行的345参数表示,在 ...
- C#实现outlook自动签名
Outlook下实现自动签名的方式 网上找到一篇资料是在outlook里用vba实现的,但是这样实现的方式由于数字认证的问题不便于部署 在此介绍一种C#下实现的方式,目前确定的outlook版本为 ...
- 安装MySQL-8.0.13
安装1.去官网下载对应的MySQL版本http://downloads.mysql.com/archives/community/ 2.将下载下来的MySQL解压到你想要安装的目录下安装MySQL8. ...
- 《Android开发艺术探索》读书笔记之IntentFillter的匹配规则
使用intent启动不同组件的方法 组件类型 启动方法 Activity startActivity(Intent intent) startActivityForResult(Intent inte ...
- svn更换repos时保留svn log
两种情况 1. 直接移动库 问题:svn如何把A服务器上的reposA上传到B服务器的reposB并保留各种上传更新记录? 这个问题要感想敢干,直接复制改名即可 #登录到B服务器 scp -r cmo ...