Last active
August 29, 2015 13:57
-
-
Save kanazux/9744940 to your computer and use it in GitHub Desktop.
Get packets from url with list of packets for freebsd or another unix distro
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
#!/usr/local/bin/env python | |
# | |
# written by kanazuchi | |
# | |
import re | |
import sys | |
from urllib2 import urlopen | |
def search_pkts(url, pkt): | |
try: | |
list_pkts = list(urlopen("%s" % sys.argv[1])) | |
except Exception, error: | |
print ("Not's possible to connect on url '%s'" % sys.argv[1]) | |
print (error) | |
exit(0) | |
pkt_pattern = r'.*%s.*' % pkt | |
return [line.split()[-1] for line in list_pkts if re.match(pkt_pattern, line, re.IGNORECASE)] | |
if __name__ == "__main__": | |
if len(sys.argv) < 3: | |
print ("Usage: search_pkt.py 'url' 'packet'") | |
print ("Eg. search_pkt.py ftp://ftp.pkts.org squid") | |
exit(0) | |
pkts = search_pkts(sys.argv[1], sys.argv[2]) | |
for pkt in pkts: | |
print pkt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment