Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 11/1/2018 version 2.0
- https://neonprimetime.blogspot.com/2018/01/python-script-search-open-directories.html
- from urllib.request import urlopen
- from urllib.request import urlretrieve
- import re
- import sys
- import os
- filepath = 'urls.txt'
- with open(filepath) as fp:
- theurl = fp.readline()
- while theurl:
- 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:
- 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," + theurl + "(" + titles[0] + ")")
- 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
- try:
- urlretrieve(phishkit, zipfile)
- print("phishkit," + phishkit)
- except Exception as e:
- print("failedphishkit," + phishkit + "(" + str(e) + ")")
- exefiles = re.findall(r'(?i)href\=\"[^\"]+\.exe\"\>',str(val))
- if len(exefiles) > 0:
- for exefile in exefiles:
- exefile = exefile.replace('\"', '').replace('href=', '').replace('>','').replace("&", "&")
- if theurl.endswith('/'):
- malware = theurl + exefile
- else:
- malware = theurl + "/" + exefile
- try:
- urlretrieve(malware, exefile)
- print("malware," + malware)
- except Exception as e:
- print("failedmalware," + malware + "(" + str(e) + ")")
- panels = re.findall(r'(?i)href\=\"(panel|webpanel|fre\.php)\"\>',str(val))
- if len(panels) > 0:
- for panel in panels:
- panel = panel.replace('\"', '').replace('href=' ,'').replace('>', '').replace("&", "&")
- if theurl.endswith('/'):
- panelurl = theurl + panel
- else:
- panelurl = theurl + "/" + panel
- print("panel," + panelurl)
- else:
- print("webpage," + theurl + "(" + titles[0] + ")")
- 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:
- print("failedurl," + theurl + "(" + str(e) + ")")
- theurl = re.sub(r'\/[^\/]*$', '', theurl)
- theurl = fp.readline()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement