Debug Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
898 B

  1. import socket
  2. s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
  3. s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
  4. # b converts string into byte format
  5. ip_header = b'\x45\x00\x00\x28' # Version, IHL, Type of Service | Total Length
  6. ip_header += b'\xab\xcd\x00\x00' # Identification | Flags, Fragment Offset
  7. ip_header += b'\x40\x06\xa6\xec' # TTL, Protocol | Header Checksum
  8. ip_header += b'\x0a\x0a\x0a\x02' # Source Address
  9. ip_header += b'\x0a\x0a\x0a\x01' # Destination Address
  10. tcp_header = b'\x30\x39\x00\x50' # Source Port | Destination Port
  11. tcp_header += b'\x00\x00\x00\x00' # Sequence Number
  12. tcp_header += b'\x00\x00\x00\x00' # Acknowledgement Number
  13. tcp_header += b'\x50\x02\x71\x10' # Data Offset, Reserved, Flags | Window Size
  14. tcp_header += b'\xe6\x32\x00\x00' # Checksum | Urgent Pointer
  15. packet = ip_header + tcp_header
  16. s.sendto(packet, ('10.10.10.1', 0))