mechanize python XE #24
def check():
# Browser
br = mechanize.Browser()
# Cookie Jar
# cj = cookielib.LWPCookieJar()
# br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
#br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
# br.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36')]
br.addheaders = [('User-agent', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ENUSMSNIP)')]
try:
FILE = open ("domains.txt","r" )
hosts = FILE.readlines()
FILE.close()
except IOError:
print "[+] domains.txt not found!\n"
sys.exit(1)
for host in hosts:
try:
print "[*] Connecting to:", host.strip()
br.open(host.strip(), timeout=1.0)
response = br.response()
find_script(response.read(), host.strip())
find_iframe(response.read(), host.strip())
# sys.exit(1)
except Exception, e:
if debug:
log("|Connection error: " + str(e))
print "[*] Connection error:", str(e)
pass