Advertisement
Guest User

rawudp

a guest
Feb 23rd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 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+data, ('', 0));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement