forked from cybersecurity-team/TorBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtorBot.py
More file actions
149 lines (132 loc) · 5.11 KB
/
Copy pathtorBot.py
File metadata and controls
149 lines (132 loc) · 5.11 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
"""
MAIN MODULE
"""
import argparse
from requests.exceptions import HTTPError
from modules.analyzer import LinkTree
from modules.color import color
from modules.link_io import LinkIO
from modules.link import LinkNode
from modules.updater import updateTor
from modules.savefile import saveJson
from modules.info import execute_all
from modules.server.ws_server import start_wsserver
# GLOBAL CONSTS
LOCALHOST = "127.0.0.1"
DEFPORT = 9050
# TorBot VERSION
__VERSION = "1.3.1"
def header():
"""
Prints out header ASCII art
"""
license_msg = color("LICENSE: GNU Public License", "red")
banner = r"""
__ ____ ____ __ ______
/ /_/ __ \/ __ \/ /_ ____/_ __/
/ __/ / / / /_/ / __ \/ __ \/ /
/ /_/ /_/ / _, _/ /_/ / /_/ / /
\__/\____/_/ |_/_____/\____/_/ V{VERSION}
""".format(VERSION=__VERSION)
banner = color(banner, "red")
title = r"""
{banner}
#######################################################
# TorBot - An OSINT Tool for Deep Web #
# GitHub : https://github.com/DedsecInside/TorBot #
# Help : use -h for help text #
#######################################################
{license_msg}
"""
title = title.format(license_msg=license_msg, banner=banner)
print(title)
def get_args():
"""
Parses user flags passed to TorBot
"""
parser = argparse.ArgumentParser(prog="TorBot",
usage="Gather and analayze data from Tor sites.")
parser.add_argument("--version", action="store_true",
help="Show current version of TorBot.")
parser.add_argument("--update", action="store_true",
help="Update TorBot to the latest stable version")
parser.add_argument("-q", "--quiet", action="store_true")
parser.add_argument("-u", "--url", help="Specifiy a website link to crawl")
parser.add_argument("--ip", help="Change default ip of tor")
parser.add_argument("-p", "--port", help="Change default port of tor")
parser.add_argument("-s", "--save", action="store_true",
help="Save results in a file")
parser.add_argument("-m", "--mail", action="store_true",
help="Get e-mail addresses from the crawled sites")
parser.add_argument("-e", "--extension", action='append', dest='extension',
default=[],
help=' '.join(("Specifiy additional website",
"extensions to the list(.com , .org, .etc)")))
parser.add_argument("-i", "--info", action="store_true",
help=' '.join(("Info displays basic info of the",
"scanned site")))
parser.add_argument("-v", "--visualize", action="store_true",
help="Visualizes tree of data gathered.")
parser.add_argument("-d", "--download", action="store_true",
help="Downloads tree of data gathered.")
parser.add_argument("--server", action="store_true",
help="Start TorBot WebSocket server.")
return parser.parse_args()
def main():
"""
TorBot's Core
"""
args = get_args()
if args.server:
start_wsserver()
# If flag is -v, --update, -q/--quiet then user only runs that operation
# because these are single flags only
if args.version:
print("TorBot Version:" + __VERSION)
exit()
if args.update:
updateTor()
exit()
if not args.quiet:
header()
try:
node = LinkNode(args.url, tld=args.extension)
except (ValueError, HTTPError, ConnectionError) as err:
raise err
# If url flag is set then check for accompanying flag set. Only one
# additional flag can be set with -u/--url flag
if args.url:
try:
node = LinkNode(args.url)
except (ValueError, HTTPError, ConnectionError) as err:
raise err
LinkIO.display_ip()
# -m/--mail
if args.mail:
print(node.emails)
if args.save:
saveJson('Emails', node.emails)
# -i/--info
elif args.info:
execute_all(node.uri)
if args.save:
print('Nothing to save.\n')
elif args.visualize:
tree = LinkTree(node)
tree.show()
elif args.download:
tree = LinkTree(node)
file_name = str(input("File Name (.pdf/.png/.svg): "))
tree.save(file_name)
else:
LinkIO.display_children(node)
if args.save:
saveJson("Links", node.links)
else:
print("usage: See torBot.py -h for possible arguments.")
print("\n\n")
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print("Interrupt received! Exiting cleanly...")