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.

22 lines
994 B

  1. import socket
  2. s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
  3. s.bind(("wlp1s0", 8000))
  4. ethernet = b'\x00\x0c\x29\xd3\xbe\xd6' # MAC Address Destination
  5. ethernet += b'\x00\x0c\x29\xe0\xc4\xaf' # MAC Address Source
  6. ethernet += b'\x08\x00' # Protocol-Type: IPv4
  7. ip_header = b'\x45\x00\x00\x28' # Version, IHL, Type of Service | Total Length
  8. ip_header += b'\xab\xcd\x00\x00' # Identification | Flags, Fragment Offset
  9. ip_header += b'\x40\x06\xa6\xec' # TTL, Protocol | Header Checksum
  10. ip_header += b'\x0a\x0a\x0a\x02' # Source Address
  11. ip_header += b'\x0a\x0a\x0a\x01' # Destination Address
  12. tcp_header = b'\x30\x39\x00\x50' # Source Port | Destination Port
  13. tcp_header += b'\x00\x00\x00\x00' # Sequence Number
  14. tcp_header += b'\x00\x00\x00\x00' # Acknowledgement Number
  15. tcp_header += b'\x50\x02\x71\x10' # Data Offset, Reserved, Flags | Window Size
  16. tcp_header += b'\xe6\x32\x00\x00' # Checksum | Urgent Pointer
  17. packet = ethernet + ip_header + tcp_header
  18. s.send(packet)