Filter out ad domains for URLSpy

Final fix for #47
This commit is contained in:
David Dworken 2014-11-09 17:13:17 -05:00
parent eb38dc481e
commit 59ffefbccb

32
LANs.py
View file

@ -166,23 +166,24 @@ def LANsMain(args):
ipr = Popen(['/sbin/ip', 'route'], stdout=PIPE, stderr=DN)
ipr = ipr.communicate()[0]
iprs = ipr.split('\n')
routerIP = None
ipr = ipr.split()
if args.routerip:
routerIP = args.routerip
else:
try:
routerIP = ipr[2]
except:
exit("You must be connected to the internet to use this.")
for r in iprs:
if '/' in r:
IPprefix = r.split()[0]
if r.startswith('default'):
if not args.interface:
interface = r.split()[4]
if not args.routerip:
routerIP = r.split()[2]
if args.routerip:
routerIP = args.routerip
if not routerIP:
exit("[-] You must be connected to the internet to use this.")
if args.interface:
interface = args.interface
else:
interface = ipr[4]
if 'eth' in interface or 'p3p' in interface:
exit('[-] Wired interface found as default route, please connect wirelessly and retry, or specify the active interface with the -i [interface] option. See active interfaces with [ip addr] or [ifconfig].')
exit(
'[-] Wired interface found as default route, please connect wirelessly and retry, or specify the active interface with the -i [interface] option. See active interfaces with [ip addr] or [ifconfig].')
if args.ipaddress:
victimIP = args.ipaddress
else:
@ -670,14 +671,18 @@ class Parser():
logger.write('[*] ' + url + '\n')
if self.args.urlspy:
fileFilterList = ['.jpg', '.jpeg', '.gif', '.png', '.css', '.ico', '.js', '.svg', '.woff']
domainFilterList = ['adzerk.net', 'adwords.google.com', 'googleads.g.doubleclick.net', 'pagead2.googlesyndication.com']
tempURL = url
tempURL = tempURL.split("?")[0] #Strip all data (e.g. www.google.com/?g=5 goes to www.google.com/)
tempURL = tempURL.strip("/") #Strip all /
fileFilterList = ['.jpg', '.jpeg', '.gif', '.png', '.css', '.ico', '.js', '.svg', '.woff']
printURL = True # default to printing URL
for fileType in fileFilterList:
for fileType in fileFilterList: #Used to check if it is one of the blacklisted file types
if tempURL.endswith(fileType):
printURL = False #Don't print if it is one of the bad file types
for blockedDomain in domainFilterList:
if blockedDomain in tempURL:
printURL = False #Don't print if it is one of the blocked domains
if printURL:
if len(url) > 146:
print '[*] ' + url[:145]
@ -1275,7 +1280,6 @@ def iwconfig():
DN = open(os.devnull, 'w')
proc = Popen(['iwconfig'], stdout=PIPE, stderr=DN)
for line in proc.communicate()[0].split('\n'):
print line
if len(line) == 0: continue # Isn't an empty string
if line[0] != ' ': # Doesn't start with space
wired_search = re.search('eth[0-9]|em[0-9]|p[1-9]p[1-9]', line)