Skip to content

Instantly share code, notes, and snippets.

@mannytoledo
Created February 21, 2013 21:37
Show Gist options
  • Save mannytoledo/5008487 to your computer and use it in GitHub Desktop.
Save mannytoledo/5008487 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import cgi
import cgitb; cgitb.enable()
import socket
# addressing information of target
IPADDR = '8.4.2.1'
PORTNUM = 10000
# enter the data content of the UDP packet as hex
PACKETDATA = 'f1a525da11f6'.decode('hex')
# initialize a socket, think of it as a cable
# SOCK_DGRAM specifies that this is UDP
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
# connect the socket, think of it as connecting the cable to the address location
s.connect((IPADDR, PORTNUM))
# send the command
s.send(PACKETDATA)
# close the socket
s.close()
print "Content-type: text/html"
print
print """
<html>
<head><title>Sample CGI Script</title></head>
<body>
<p>Packet Sent</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment