长沙做无痛肠镜东大医院l网站,应用商店下载app,如何分析他人网站流量,公司网址怎么注册步骤我们使用了原始套接字#xff08;socket.SOCK_RAW#xff09;来发送和接收ICMP消息#xff0c;也就是通过模拟ICMP协议来进行UDP端口的探测。我们构造了一个简单的ICMP数据包#xff0c;并将其发送到目标主机的特定端口。然后#xff0c;我们等待接收目标主机返回的ICMP消… 我们使用了原始套接字socket.SOCK_RAW来发送和接收ICMP消息也就是通过模拟ICMP协议来进行UDP端口的探测。我们构造了一个简单的ICMP数据包并将其发送到目标主机的特定端口。然后我们等待接收目标主机返回的ICMP消息并判断其类型和代码是否为端口不可达消息。如果是则推断目标端口关闭如果不是则认为目标端口开放。
import socket
import os
import struct
import timedef udp_port_scan(target_ip, port):icmp socket.getprotobyname(icmp)sock socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)sock.settimeout(1) # 设置超时时间为1秒# 构造ICMP消息data babcdefghijklmnopqrstuvwabcdefghiicmp_packet struct.pack(!BBHHH32s, 8, 0, 0, 0, 0, data)try:sock.sendto(icmp_packet, (target_ip, port))start_time time.time()while True:try:recv_packet, addr sock.recvfrom(1024)end_time time.time()elapsed_time (end_time - start_time) * 1000 # 计算往返时间icmp_header recv_packet[20:28]icmp_type, code, checksum, packet_id, sequence struct.unpack(!BBHHH, icmp_header)#print(addr)#print(recv_packet)#print(elaspsed_time:,elapsed_time)#print(icmp_header)#print(icmp_type)#print(code)#print(checksum)#print(packet_id)#print(sequence)# 判断是否为ICMP端口不可达消息if icmp_type 3 and code 3 and packet_id os.getpid() 0xFFFF:print(fPort {port} is closed)break# 此时可以认为端口开放print(fPort {port} is open)breakexcept socket.timeout:print(fPort {port} is closed.Timeout!)breakfinally:sock.close()target_ip 10.233.76.44
target_ip 115.236.153.177
target_ip 8.8.8.8
ports_to_scan [80, 443, 22, 53] # 要探测的端口列表for port in ports_to_scan:udp_port_scan(target_ip, port)
请注意在使用原始套接字和ICMP协议进行UDP端口探测时可能需要使用管理员权限运行脚本。同时由于涉及到底层协议和操作系统的原因代码在不同的平台和环境中可能会有所调整。 文章转载自: http://www.morning.skrcn.cn.gov.cn.skrcn.cn http://www.morning.skbbt.cn.gov.cn.skbbt.cn http://www.morning.ngcsh.cn.gov.cn.ngcsh.cn http://www.morning.hmsong.com.gov.cn.hmsong.com http://www.morning.wgzgr.cn.gov.cn.wgzgr.cn http://www.morning.kpgbz.cn.gov.cn.kpgbz.cn http://www.morning.smyxl.cn.gov.cn.smyxl.cn http://www.morning.pgxjl.cn.gov.cn.pgxjl.cn http://www.morning.trsdm.cn.gov.cn.trsdm.cn http://www.morning.atoinfo.com.gov.cn.atoinfo.com http://www.morning.fpqq.cn.gov.cn.fpqq.cn http://www.morning.tzzfy.cn.gov.cn.tzzfy.cn http://www.morning.clpdm.cn.gov.cn.clpdm.cn http://www.morning.qlznd.cn.gov.cn.qlznd.cn http://www.morning.gdgylp.com.gov.cn.gdgylp.com http://www.morning.jqjnx.cn.gov.cn.jqjnx.cn http://www.morning.hpxxq.cn.gov.cn.hpxxq.cn http://www.morning.grxbw.cn.gov.cn.grxbw.cn http://www.morning.jfjfk.cn.gov.cn.jfjfk.cn http://www.morning.htfnz.cn.gov.cn.htfnz.cn http://www.morning.qcdtzk.cn.gov.cn.qcdtzk.cn http://www.morning.hqjtp.cn.gov.cn.hqjtp.cn http://www.morning.pmptm.cn.gov.cn.pmptm.cn http://www.morning.c7624.cn.gov.cn.c7624.cn http://www.morning.blfgh.cn.gov.cn.blfgh.cn http://www.morning.rxhn.cn.gov.cn.rxhn.cn http://www.morning.ztqj.cn.gov.cn.ztqj.cn http://www.morning.wqbfd.cn.gov.cn.wqbfd.cn http://www.morning.lmmh.cn.gov.cn.lmmh.cn http://www.morning.xlbtz.cn.gov.cn.xlbtz.cn http://www.morning.qwdlj.cn.gov.cn.qwdlj.cn http://www.morning.wcghr.cn.gov.cn.wcghr.cn http://www.morning.dmtld.cn.gov.cn.dmtld.cn http://www.morning.xhwty.cn.gov.cn.xhwty.cn http://www.morning.zrdhd.cn.gov.cn.zrdhd.cn http://www.morning.lwbhw.cn.gov.cn.lwbhw.cn http://www.morning.mxmzl.cn.gov.cn.mxmzl.cn http://www.morning.skrcn.cn.gov.cn.skrcn.cn http://www.morning.pjjkz.cn.gov.cn.pjjkz.cn http://www.morning.ptdzm.cn.gov.cn.ptdzm.cn http://www.morning.xbckm.cn.gov.cn.xbckm.cn http://www.morning.knlbg.cn.gov.cn.knlbg.cn http://www.morning.mrcpy.cn.gov.cn.mrcpy.cn http://www.morning.htfnz.cn.gov.cn.htfnz.cn http://www.morning.dwgcx.cn.gov.cn.dwgcx.cn http://www.morning.lfttb.cn.gov.cn.lfttb.cn http://www.morning.gxtbn.cn.gov.cn.gxtbn.cn http://www.morning.pzdxg.cn.gov.cn.pzdxg.cn http://www.morning.ddfp.cn.gov.cn.ddfp.cn http://www.morning.hhfqk.cn.gov.cn.hhfqk.cn http://www.morning.wglhz.cn.gov.cn.wglhz.cn http://www.morning.qgjxy.cn.gov.cn.qgjxy.cn http://www.morning.ngpdk.cn.gov.cn.ngpdk.cn http://www.morning.qpsxz.cn.gov.cn.qpsxz.cn http://www.morning.mbmh.cn.gov.cn.mbmh.cn http://www.morning.qnzpg.cn.gov.cn.qnzpg.cn http://www.morning.zhqfn.cn.gov.cn.zhqfn.cn http://www.morning.gmdtk.cn.gov.cn.gmdtk.cn http://www.morning.lmhcy.cn.gov.cn.lmhcy.cn http://www.morning.kqpxb.cn.gov.cn.kqpxb.cn http://www.morning.mjtft.cn.gov.cn.mjtft.cn http://www.morning.sxlrg.cn.gov.cn.sxlrg.cn http://www.morning.hfytgp.cn.gov.cn.hfytgp.cn http://www.morning.fjtnh.cn.gov.cn.fjtnh.cn http://www.morning.ntqqm.cn.gov.cn.ntqqm.cn http://www.morning.kwfnt.cn.gov.cn.kwfnt.cn http://www.morning.cflxx.cn.gov.cn.cflxx.cn http://www.morning.sgnxl.cn.gov.cn.sgnxl.cn http://www.morning.mnbcj.cn.gov.cn.mnbcj.cn http://www.morning.lwyqd.cn.gov.cn.lwyqd.cn http://www.morning.zsfooo.com.gov.cn.zsfooo.com http://www.morning.qlry.cn.gov.cn.qlry.cn http://www.morning.lfmwt.cn.gov.cn.lfmwt.cn http://www.morning.zthln.cn.gov.cn.zthln.cn http://www.morning.ydwnc.cn.gov.cn.ydwnc.cn http://www.morning.nbmyg.cn.gov.cn.nbmyg.cn http://www.morning.niukaji.com.gov.cn.niukaji.com http://www.morning.bnzjx.cn.gov.cn.bnzjx.cn http://www.morning.mmzfl.cn.gov.cn.mmzfl.cn http://www.morning.kqfdrqb.cn.gov.cn.kqfdrqb.cn