# simple python script to search ips, hostnames, or domains for page titles
import argparse
from urllib.request import urlopen
from urllib.request import urlretrieve
import re
import sys
import os
#arguments
arguments = argparse.ArgumentParser("Search for websites, pass 1 file of hostnames, ips, or domains")
arguments.add_argument("-f", "--filepath", type=str, required=True, help="Path to list of hostnames, ips, or domains 1 per line")
settings = arguments.parse_args()
filepath = settings.filepath
with open(filepath) as fp:
theurl = fp.readline()
while theurl:
try:
theurl = 'http://' + theurl.strip()
html = urlopen(theurl, timeout=2)
val = html.read()
titles = re.findall(r'(?i)<title>(.*?)</title>',str(val))
if len(titles) > 0:
print("found '{0}' at '{1}'".format(titles[0], theurl))
theurl = 'https://' + theurl.strip()
html = urlopen(theurl, timeout=3)
val = html.read()
titles = re.findall(r'(?i)<title>(.*?)</title>',str(val))
if len(titles) > 0:
print("found '{0}' at '{1}'".format(titles[0], theurl))
except Exception as e:
moveon = 1
#print("failed '{0}' with '{1}'".format(theurl, str(e)))
theurl = fp.readline()
No comments:
Post a Comment