-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
31 lines (27 loc) · 1.22 KB
/
test.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
import os, re
def run(dir, root):
try:
for page in os.listdir(dir):
try:
content = open(dir + "/" + page).read()
for link in re.findall("action=\"([^\"?#]*)", content)+re.findall("href=\"([^\"?#']*)", content)+re.findall("src=\"([^\"'http:]*)\"", content)+re.findall("\$_SERVER\[\'SERVER_NAME\'\] . \"([^\"?#']*)", content):
if(link == "#" or link == ""):
continue
elif(link[0] == "/"):
path = root+link
else:
path = dir + "/" + link
try:
try:
open(path).read()
except Exception as e:
open(path+"/index.php")
except Exception as e:
print("Unable to find file: " + path[len(root):] + "\t\t in file: " + dir[len(root):]+"/"+page)
return False
except Exception as e:
if not run(dir + "/" + page, root):
return False
except Exception as e:
print("Unable to open " + dir[len(root):] + " moving on")
return True