-
Notifications
You must be signed in to change notification settings - Fork 16
/
PhishingKitSearch.py
84 lines (84 loc) · 2.94 KB
/
PhishingKitSearch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from urllib.request import urlopen
from urllib.request import urlretrieve
import re
import sys
import os
quietmode = 1
printstatus = 1
searchcount = 0
filepath = 'urls.txt'
with open(filepath) as fp:
theurl = fp.readline()
while theurl:
searchcount = searchcount + 1
if printstatus == 1:
if searchcount % 10 == 0:
print("STATUS: %s" % str(searchcount))
if(not theurl.startswith('http')):
if(":443" in theurl):
theurl = 'https://' + theurl.strip()
else:
theurl = 'http://' + theurl.strip()
theurl = theurl.strip()
if(theurl.endswith("/") or theurl.endswith("\\")):
theurl = theurl[:-1]
stopnow = 0
while stopnow == 0:
try:
domain = theurl.split("//")[-1].split("/")[0]
currentfolder = theurl.split("/")[-1]
html = urlopen(theurl, timeout=3)
val = html.read()
titles = re.findall(r'(?i)<title>(.*?)</title>',str(val))
if len(titles) > 0:
if titles[0].startswith('Index of'):
print("-OPENDIR-," + titles[0] + "," + theurl)
zipfiles = re.findall(r'(?i)href\=\"[^\"]+\.php\"\>',str(val))
if len(zipfiles) > 0:
for zipfile in zipfiles:
zipfile = zipfile.replace('\"', '').replace('href=', '').replace('>','').replace("&", "&")
if theurl.endswith('/'):
phishkit = theurl + zipfile
else:
phishkit = theurl + "/" + zipfile
print("**FILE**," + phishkit)
zipfiles = re.findall(r'(?i)href\=\"[^\"]+\.txt\"\>',str(val))
if len(zipfiles) > 0:
for zipfile in zipfiles:
zipfile = zipfile.replace('\"', '').replace('href=', '').replace('>','').replace("&", "&")
if theurl.endswith('/'):
phishkit = theurl + zipfile
else:
phishkit = theurl + "/" + zipfile
print("**FILE**," + phishkit)
zipfiles = re.findall(r'(?i)href\=\"[^\"]+\.zip\"\>',str(val))
if len(zipfiles) > 0:
for zipfile in zipfiles:
zipfile = zipfile.replace('\"', '').replace('href=', '').replace('>','').replace("&", "&")
if theurl.endswith('/'):
phishkit = theurl + zipfile
else:
phishkit = theurl + "/" + zipfile
print("**FILE**," + phishkit)
zipfiles = re.findall(r'(?i)href\=\"[^\"]+\.log\"\>',str(val))
if len(zipfiles) > 0:
for zipfile in zipfiles:
zipfile = zipfile.replace('\"', '').replace('href=', '').replace('>','').replace("&", "&")
if theurl.endswith('/'):
phishkit = theurl + zipfile
else:
phishkit = theurl + "/" + zipfile
print("**FILE**," + phishkit)
else:
print("-PAGE-," + titles[0] + "," + theurl)
theurl = re.sub(r'\/[^\/]*$', '', theurl)
if theurl.endswith('http:/') or theurl.endswith('https:/'):
stopnow = 1
except Exception as e:
if "no host given" in str(e):
stopnow = 1
else:
if quietmode == 0:
print("-FAILED-," + str(e) + "," + theurl)
theurl = re.sub(r'\/[^\/]*$', '', theurl)
theurl = fp.readline()