Python论坛  - 讨论区

标题:[python-chinese] 请教各位dpkt组包发送报文的问题

2007年01月19日 星期五 17:12

alan alan在nj.cebbank.com
星期五 一月 19 17:12:28 HKT 2007

ʹÓÃ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 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年01月20日 星期六 10:16

alan alan在nj.cebbank.com
星期六 一月 20 10:16:15 HKT 2007

ÊÔ×ÅÈçϲÙ×÷£º

    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 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年01月20日 星期六 19:49

alan alan在nj.cebbank.com
星期六 一月 20 19:49:56 HKT 2007

Ê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 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号