Created
October 7, 2013 23:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
Very clever solution, thanks a lot!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot, man!