forked from DedSecInside/TorBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.py
More file actions
91 lines (74 loc) · 2.66 KB
/
Copy pathinfo.py
File metadata and controls
91 lines (74 loc) · 2.66 KB
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
85
86
87
88
89
90
91
from urllib.parse import urlsplit
from bs4 import BeautifulSoup
from termcolor import cprint
from requests.exceptions import HTTPError
import requests
from .link_io import LinkIO
def execute_all(link, *, display_status=False):
page, response = LinkIO.read(link, response=True, show_msg=display_status)
soup = BeautifulSoup(page, 'html.parser')
validation_functions = [get_robots_txt, get_dot_git, get_dot_svn, get_dot_git]
for validate_func in validation_functions:
try:
validate_func(link)
except (ConnectionError, HTTPError):
cprint('Error', 'red')
display_webpage_description(soup)
display_headers(response)
def display_headers(response):
print('''
RESPONSE HEADERS
__________________
''')
for key, val in response.headers.items():
print('*', key, ':', val)
def get_robots_txt(target):
cprint("[*]Checking for Robots.txt", 'yellow')
url = target
target = "{0.scheme}://{0.netloc}/".format(urlsplit(url))
requests.get(target+"/robots.txt")
cprint(r'blue')
def get_dot_git(target):
cprint("[*]Checking for .git folder", 'yellow')
url = target
target = "{0.scheme}://{0.netloc}/".format(urlsplit(url))
req = requests.get(target+"/.git/")
status = req.status_code
if status == 200:
cprint("Alert!", 'red')
cprint(".git folder exposed publicly", 'red')
else:
cprint("NO .git folder found", 'blue')
def get_dot_svn(target):
cprint("[*]Checking for .svn folder", 'yellow')
url = target
target = "{0.scheme}://{0.netloc}/".format(urlsplit(url))
req = requests.get(target+"/.svn/entries")
status = req.status_code
if status == 200:
cprint("Alert!", 'red')
cprint(".SVN folder exposed publicly", 'red')
else:
cprint("NO .SVN folder found", 'blue')
def get_dot_htaccess(target):
cprint("[*]Checking for .htaccess", 'yellow')
url = target
target = "{0.scheme}://{0.netloc}/".format(urlsplit(url))
req = requests.get(target+"/.htaccess")
statcode = req.status_code
if statcode == 403:
cprint("403 Forbidden", 'blue')
elif statcode == 200:
cprint("Alert!!", 'blue')
cprint(".htaccess file found!", 'blue')
else:
cprint("Status code", 'blue')
cprint(statcode)
def display_webpage_description(soup):
cprint("[*]Checking for description meta tag", 'yellow')
metatags = soup.find_all('meta')
for meta in metatags:
if meta.has_attr('name'):
attributes = meta.attrs
if attributes['name'] == 'description':
cprint("Page description: " + attributes['content'])