Advertisement
Yonka2019

udpbuilder

Nov 10th, 2022
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. from socket import *
  2. import struct
  3. s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP)
  4. data = 'string'
  5. sport = 4711    # arbitrary source port
  6. dport = 45134   # arbitrary destination port
  7. length = 8+len(data);
  8. checksum = 0
  9. udp_header = struct.pack('!HHHH', sport, dport, length, checksum)
  10. s.sendto(udp_header+str.encode(data), ("127.0.0.1",7070))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement