Skip to content

Instantly share code, notes, and snippets.

@thepacketgeek
Created October 7, 2013 23:19
Show Gist options
  • Save thepacketgeek/6876699 to your computer and use it in GitHub Desktop.
Save thepacketgeek/6876699 to your computer and use it in GitHub Desktop.
Using the scapy 'prn' argument, pass multiple arguments along with packet in a sniff(), s(), or sr() function.
# define API options
url = "http://hosted.app/api/packets"
token = "supersecretusertoken"
# create parent function with passed in arguments
def customAction(url,token):
# uploadPacket function has access to the url & token parameters because they are 'closed' in the nested function
def uploadPacket(packet):
# upload packet, using passed arguments
headers = {'content-type': 'application/json'}
r = requests.post(url, data=json.dumps(packet,token), headers=headers)
return uploadPacket
sniff(prn=customAction(url,token))
@99stealth
Copy link

Thanks a lot, man!

@rggassner
Copy link

Very clever solution, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment