python延迟5s_Python做扫描,发包速度实在是太慢了,有优化的方案吗?
用python做 syn scan
但是这个速度实在是太感人了,有没有优化的方案?不想写C的
代码如下:
#coding: utf-8
import threading,time,os,argparse,subprocess,re,platform
from scapy.all import *
def port_service(port):
return port_dict[port] if port in port_dict else 'Unknown'
def send_syn(ip,port):
send(IP(dst=ip)/TCP(dport=port,sport=RandShort(),flags=2),verbose=False)
def get_ip_address(iface):
if os.name=='posix':
ipre = '%s.*?inet.*?(([0-9]{1,3}\.){3}[0-9]{1,3})'%iface
ipconfig_process = subprocess.Popen("ifconfig", stdout=subprocess.PIPE)
else:
ipre = 'IPv4.*?(([0-9]{1,3}\.){3}[0-9]{1,3})'%iface
ipconfig_process = subprocess.Popen("ipconfig", stdout=subprocess.PIPE)
output = ipconfig_process.stdout.read()
ip_pattern = re.compile(ipre,re.S)
result=ip_pattern.search(output.decode('utf-8'))
if len(result.groups())==2:
return result.group(1)
def catcher(packet):
global result_dict
ip=packet.getlayer(IP).src
port=packet.getlayer(TCP).sport
if ip in result_dict:
result_dict[ip]['count']+=1
result_dict[ip]['ports'].append(port)
else:
result_dict[ip]={"count":1,"ports":[port]}
print("[+] IP %s | Port %s "%(ip,port))
def sniffer(iface,userIp,targetIpList):
print("[*] Get your ip %s in iface %s , Simple Sniffer starting ......."%(userIp,iface))
fs="".join(["src %s or "%stip for stip in targetIpList])
sniff(iface=iface, filter='tcp and dst %s and tcp[13:1] & 18==18 and (%s)'%(userIp,fs[:len(fs)-3]), prn=catcher)
if __name__ == '__main__':
port_dict={
19:'CG',
21:'FTP',
22:'SSH',
23:'TELNET',
25:'SMTP',
31:'MSG',
53:'DNS',
67:'BPS',
80:'HTTP',
110:'POP3',
443:'HTTPS',
1433:'Microsoft SQL Server',
1521:'Oracle DataBase',
1863:'MSN Message',
1883:'MQTT',
2181:'ZooKeeper',
3306:'Mysql Server',
3389:'Miscrosoft RDP',
4000:'Tencent QQ Client',
5000:'DB2',
6379:'Redis',
8000:'Tencent OICQ',
8080:'Http WWW Proxy',
8161:'Activemq Jetty Service',
11211:'Memcached',
27017:'MongoDB',
61616:'Activemq JMS'
}
result_dict={}
threads=[]
parser=argparse.ArgumentParser(description="PortScanner Via MultiThread , MultiProcess and Coroutine version you can find in the same repository .")
parser.add_argument('-i','--ip_list',dest='ip_list',required=True,type=str,help='Privider the IP list for scan , use "," to split each ip.')
parser.add_argument('-n','--net_iface',dest='net_iface',required=True,type=str,help='Privider the net work iface , i will get you ip.')
parser.add_argument('-r','--if_show',action='store_false',dest='if_show',default=True,help='Design if show the result after ports scan complete .')
parser.add_argument('-p','--if_print',action='store_false',dest='if_print',default=False,help='Design if print the result while scaning the open port')
args=parser.parse_args()
ip_list=args.ip_list.split(',')
if_show=args.if_show
if_print=args.if_print
iface = args.net_iface
userIP = get_ip_address(iface)
if userIP is None:
print('[!] Can not ge ip from iface : %s'%iface)
os._exit(1)
sniffer_thread=threading.Thread(target=sniffer,args=(iface,userIP,ip_list))
sniffer_thread.start()
time.sleep(0.2)
for ip in ip_list:
for port in range(1,65535):
t=threading.Thread(target=send_syn,args=(ip,port,))
threads.append(t)
t.start()
for t in threads:
t.join()
time.sleep(0.2)
if if_show:
for (key,value) in result_dict.items():
print("[+] IP : %s has %d opened port."%(key,value['count']))
for port in value['ports']:
print("-------> %5s | %s "%(port,port_service(port)))
os._exit(0)
我试过把scapy换掉,自己组报文用Raw Socket发,还是这么慢......
python延迟5s_Python做扫描,发包速度实在是太慢了,有优化的方案吗?相关推荐
- 教你些技巧,用 Python 自动化办公做一些有趣的事情!太方便了
不知道大家听没听过这么一句话:所有需要重复做两次的事情,都可以用程序代替我来完成. 是的,说的没错,在现在互联网飞速发展的时代,许多繁琐的事情都可以写一些代码来完成,而Python就是其中之一! 学习 ...
- python 发包的方法_有没有快一点的Python扫描发包方法,原来的速度好慢
用python做 syn scan 但是这个速度实在是太感人了,有没有优化的方案?不想写C的 代码如下: #coding: utf-8 import threading,time,os,argpars ...
- 网页打开共享目录_你会做Excel文件目录吗?真的太太太太太简单了!
点击蓝字发送[2020]免费领 100+图表模板!本文作者:长小安本文编辑:尔冬哈喽大家好!我是长小安,一名和秋叶一起学了多年 Excel.现在成功出道投稿的同学~让我来猜猜,你的电脑是不是也像我的一 ...
- 学会python之后可以做哪些兼职?
前言 以我差不多四年的 Python 使用经验来看,大概可以按以下这些路子来赚到钱,但编程技能其实只是当中必不可少的一部分,搭配其它技能栈食用风味更佳. 1.爬虫 很多人入门 Python 的必修课之 ...
- Python主要可以做什么?
python主要可以做Web 和 Internet开发.科学计算和统计.桌面界面开发.软件开发.后端开发等领域的工作. Python是一种解释型脚本语言.Python可以应用于众多领域,如:数据分析. ...
- 参加完Python培训可以做什么
大家都知道Python在互联网行业是很吃香的,但是参加完Python培训之后,很多人都不知道该从哪个职业方向做起,下面小编就为大家详细的介绍一下参加完Python培训可以做什么? 参加完Python培 ...
- python游戏中调整箭头下落速度_入门 | 三行Python代码,让数据预处理速度提高2到6倍...
原标题:入门 | 三行Python代码,让数据预处理速度提高2到6倍 选自TowardsDataScience 作者:George Seif,机器之心编译 在 Python 中,我们可以找到原生的并行 ...
- python语言能干什么-python语言能做什么
python语言可以用来做许多事,常见的一般有web开发.爬虫开发.人工智能以及游戏开发和构建桌面软件等等 Python是一个非常好用的编程语言而且开发速度快,语法简单通俗易懂,容易上手.非常适合初学 ...
- python语言能干什么-学Python语言可以做什么?
Python因为入门简单.功能强大,已经成为使用率增长最快的编程语言之一.大量的人才涌入到Python学习的浪潮之中.大家都知道Python是人工智能的首选语言,Python在其他那些领域被广泛应用呢 ...
最新文章
- 白话Elasticsearch24- 深度探秘搜索技术之TFIDF算法/向量空间模型算法/lucene的相关度分数算法
- python处理文本格式_python linecache 处理固定格式文本数据的方法
- Thinkphp 逻辑与,逻辑或的复合查询
- 【网工必备】网络端口号大全......
- python实时监控_使用Python监控Linux系统
- 在workflow中,无法为实例 ID“...”传递接口类型“...”上的事件“...” 问题的解决方法。...
- 【CodeForces - 1062C】Banh-mi (贪心,数学,找规律,快速幂)
- php使用七牛直播,七牛上传文件,PHP版本
- [2021] node连接oracle数据库示例[使用oracle官方组件]
- 验证方式二 html标签验证码,Django标签、转义及验证码生成
- Axure RP9 自学之路1-软件初识
- Python办公自动化(八)|使用Python转换PDF,Word/Excel/PPT/md/HTML都能转
- 平滑线反锯齿工具_Photoshop中的华丽渐变工具的使用
- JAVA JDBC常见面试题及答案
- ilitek win10 触摸屏驱动_德国布拉本达(Brabender)触摸屏维修常见故障
- 终结者2免费教程_如何在模拟器上玩(匹配的还是手机服)_适用最新客户端
- 模块化的ESP8266小电视设计与制作
- 阿诺德图像加密c语言,三维arnold变换图像加密算法
- ThinkPHP内核全行业小程序运营管理系统源码 自由DIY布局 一键生成小程序
- 绝对地址、相对地址、/、./、../之间的区别
热门文章
- 百度智能云一周连签三个新基建大单,“非对称竞争”优势凸显?
- java entries_Java leveldb遍历特定前缀的entries
- html5调用系统声音1s响一次_记录一次系统性能调优过程
- linux 查看flash大小,Linux OpenWRT查看CPU,RAM,Flash信息参数
- uboot启动流程概述_uboot 分析之 启动流程
- mysql默认排序规则_mysql 字符集与排序规则的简单了解
- Python基础教程:列表、字典、集合推导式
- Python基础教程: import与from import使用
- Python 下JSON的两种编解码方式实例解析
- C语言 结构体里的元素前面有一点“.”代表什么意思?