2007年01月19日 星期五 17:12
ʹÓÃdpkt×éÖ¯Á˱¨Îĺó£¬ÈçºÎ½«Ö®·¢³ö£¬²¢½ÓÊÜÓ¦´ð±¨ÎÄ£¿ ʹÓÃsocket½¨Á¢raw_socketÂð£¿ÏÂÃæ²»ÏþµÃ¸ÃÔõô°ìÁË¡£ from dpkt.ip import IP from dpkt.icmp import ICMP import socket ip = IP(src='\x0a\x1f\x55\x58', dst='\x0a\x1f\x58\x58', p=1) icmp = ICMP(type=8, data=ICMP.Echo(id=123, seq=1, data='alanalanalanalanalanalanalanalanalan')) ip.data=icmp ip.len += len(ip.data) pkt = str(ip) pingSocket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("icmp")) Powered by MessageSoft SMG SPAM, virus-free and secure email http://www.messagesoft.net -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070119/8ab77152/attachment.htm
2007年01月20日 星期六 10:16
ÊÔ×ÅÈçϲÙ×÷£º try: pingSocket.sendto(pkt, ('10.31.88.88', 1)) except socket.error, e: _error("socket error: %s" % e) timeout = 2 # wait until there is data in the socket while 1: # input, output, exceptional conditions iwtd, owtd, ewtd = select.select([pingSocket], [], [], timeout) break # no data and timout occurred # data on socket - this means we have an answer if iwtd: # ok, data on socket endtime = time.time() # time packet received # read data (we only need the header) pong, address = pingSocket.recvfrom(1024) print pong else: print 'time out...' ×ÜÊdz¬Ê±¡£¡£¡£ ¸÷λµã²¦Ò»¶þ°É :) ----- Original Message ----- From: alan To: python-chinese在lists.python.cn Sent: Friday, January 19, 2007 5:12 PM Subject: [python-chinese] Çë½Ì¸÷λdpkt×é°ü·¢Ëͱ¨ÎĵÄÎÊÌâ ʹÓÃdpkt×éÖ¯Á˱¨Îĺó£¬ÈçºÎ½«Ö®·¢³ö£¬²¢½ÓÊÜÓ¦´ð±¨ÎÄ£¿ ʹÓÃsocket½¨Á¢raw_socketÂð£¿ÏÂÃæ²»ÏþµÃ¸ÃÔõô°ìÁË¡£ from dpkt.ip import IP from dpkt.icmp import ICMP import socket ip = IP(src='\x0a\x1f\x55\x58', dst='\x0a\x1f\x58\x58', p=1) icmp = ICMP(type=8, data=ICMP.Echo(id=123, seq=1, data='alanalanalanalanalanalanalanalanalan')) ip.data=icmp ip.len += len(ip.data) pkt = str(ip) pingSocket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("icmp")) Powered by MessageSoft SMG SPAM, virus-free and secure email http://www.messagesoft.net Powered by MessageSoft SMG SPAM, virus-free and secure email http://www.messagesoft.net ------------------------------------------------------------------------------ _______________________________________________ python-chinese Post: send python-chinese在lists.python.cn Subscribe: send subscribe to python-chinese-request在lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese Powered by MessageSoft SMG SPAM, virus-free and secure email http://www.messagesoft.net -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070120/8c33ca68/attachment.html
2007年01月20日 星期六 19:49
ÊDz»ÊÇdpkt¹ýʱûÈËÓÃÁË£¿»¹Âé·³´ó¼Ò¸æËßÔÚÏ£¬ÎҺ÷ÅÆú¡£¡£¡£ ----- Original Message ----- From: alan To: python-chinese在lists.python.cn Sent: Saturday, January 20, 2007 10:16 AM Subject: Re: [python-chinese]Çë½Ì¸÷λdpkt×é°ü·¢Ëͱ¨ÎĵÄÎÊÌâ ÊÔ×ÅÈçϲÙ×÷£º try: pingSocket.sendto(pkt, ('10.31.88.88', 1)) except socket.error, e: _error("socket error: %s" % e) timeout = 2 # wait until there is data in the socket while 1: # input, output, exceptional conditions iwtd, owtd, ewtd = select.select([pingSocket], [], [], timeout) break # no data and timout occurred # data on socket - this means we have an answer if iwtd: # ok, data on socket endtime = time.time() # time packet received # read data (we only need the header) pong, address = pingSocket.recvfrom(1024) print pong else: print 'time out...' ×ÜÊdz¬Ê±¡£¡£¡£ ¸÷λµã²¦Ò»¶þ°É :) ----- Original Message ----- From: alan To: python-chinese在lists.python.cn Sent: Friday, January 19, 2007 5:12 PM Subject: [python-chinese] Çë½Ì¸÷λdpkt×é°ü·¢Ëͱ¨ÎĵÄÎÊÌâ ʹÓÃdpkt×éÖ¯Á˱¨Îĺó£¬ÈçºÎ½«Ö®·¢³ö£¬²¢½ÓÊÜÓ¦´ð±¨ÎÄ£¿ ʹÓÃsocket½¨Á¢raw_socketÂð£¿ÏÂÃæ²»ÏþµÃ¸ÃÔõô°ìÁË¡£ from dpkt.ip import IP from dpkt.icmp import ICMP import socket ip = IP(src='\x0a\x1f\x55\x58', dst='\x0a\x1f\x58\x58', p=1) icmp = ICMP(type=8, data=ICMP.Echo(id=123, seq=1, data='alanalanalanalanalanalanalanalanalan')) ip.data=icmp ip.len += len(ip.data) pkt = str(ip) pingSocket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("icmp")) Powered by MessageSoft SMG SPAM, virus-free and secure email http://www.messagesoft.net Powered by MessageSoft SMG SPAM, virus-free and secure email http://www.messagesoft.net ---------------------------------------------------------------------------- _______________________________________________ python-chinese Post: send python-chinese在lists.python.cn Subscribe: send subscribe to python-chinese-request在lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese Powered by MessageSoft SMG SPAM, virus-free and secure email http://www.messagesoft.net Powered by MessageSoft SMG SPAM, virus-free and secure email http://www.messagesoft.net ------------------------------------------------------------------------------ _______________________________________________ python-chinese Post: send python-chinese在lists.python.cn Subscribe: send subscribe to python-chinese-request在lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese Powered by MessageSoft SMG SPAM, virus-free and secure email http://www.messagesoft.net -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070120/2e8096c2/attachment.html
Zeuux © 2025
京ICP备05028076号