import urllib import sqlite3 import re import sys links = [] colur_red = '\033[31m' colur_end = '\033[0m' color_green = '\033[32m' def findurl(text): if str(text).find("http") == 0: return True elif str(text).find("ftp") == 0: return True elif str(text).find("https") == 0: return True else: return False def openurl(url): try: html = urllib.urlopen(url).read() getlinks = re.findall(r"""<\s*a\s*href=["']([^=]+)["']""", html) for link in getlinks: a = findurl(link) if a == True: links.append(link) except: print(colur_red + "[-] Error Loading {}".format(str(url)) + colur_end) def main(site): print(color_green + "[+] Starting Scan on {}".format(site) + colur_end) openurl(site) for url in links: print url if len(url) == 0: print(colur_red + "[-] No URLs Found" + colur_end) elif sys.stdin.read(1) == 'q': print(color_green + "[+] Stopping Scan" + colur_end) else: print(color_green + "[+] Found URl and adding it to database" + colur_end) #hostname = str(url).replace(':/', '').split('/')[1] #db = sqlite3.connect('database.db') #cursor = db.cursor() #cursor.execute('''INSERT INTO data_1(urls, hostname)VALUES(?,?)''', (url, hostname)) #db.commit() #db.close() openurl(url) # i need to add away of exiting by pressing 'q' command = sys.argv length = len(command) num = 0 if len(command) == 1: print('please use -u <url>') else: for i in command: if i == "-u": num = num + 1 starturl = command[num] main(starturl) else: num = num + 1
openurl(url)
links
main
openurl
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)