当前位置 : 主页 > 编程语言 > python >

使用Python实现路由追踪脚本

来源:互联网 收集:自由互联 发布时间:2022-06-18
from scapy . all import * import sys from socket import * import os from threading import * screenlock = Semaphore ( value = 500 ) def gsd (): print '[*]TCP routing' try : r2 , unans = traceroute ([ sys . argv [ 1 ]], dport = [ sys . argv [


from scapy.all import *
import sys
from socket import *
import os
from threading import *
screenlock=Semaphore(value=500)
def gsd():
print '[*]TCP routing'
try:
r2,unans=traceroute([sys.argv[1]],dport=[sys.argv[2]],maxttl=20)
except Exception,e:
print '[-]I\'m sorry for the mistake. The reason is:{}'.format(e)
def IPall():
try:
a = IP(dst=sys.argv[1]+'/30')
print '[*]Target all IP'
print [p for p in a]
except Exception,a:
print '[-]Im sorry for the mistake. The reason is:{}'.format(a)
def os(host,port):
try:
s=socket(AF_INET,SOCK_STREAM)
s.connect((host,port))
print('[+] %d open' % port)
s.close()
except:
pass
gsd()
IPall()
if __name__ == '__main__':
setdefaulttimeout(1)
for p in range(1,1024):
t=Thread(target=os,args=(sys.argv[1],p))
t.start()

其实就是实现cmd情况下的traceroute的路由追踪。可以用于网络数据取证和数据收集阶段。



【文章原创作者:防ddos攻击 http://www.558idc.com/shsgf.html 复制请保留原URL】
网友评论