Skip to content

Commit

Permalink
Merge pull request #53 from KingAkeem/dev
Browse files Browse the repository at this point in the history
Clearing up flags explanation and code
  • Loading branch information
PSNAppz authored Jan 15, 2018
2 parents d4da8fe + be5816e commit 55342c6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 44 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ Before you run the torBot make sure the following things are done properly:
[-l] [-i]

optional arguments:
-h, --help show this help message and exit
-h, --help Show this help message and exit
-v, --version Show current version of TorBot.
--update Update TorBot to the latest stable version
-q, --quiet
-u URL, --url URL Specifiy a website link to crawl
-s, --save Save results in a file
-q, --quiet Prevent header from displaying
-u URL, --url URL Specifiy a website link to crawl, currently returns links on that page
-s, --save Save results to a file in json format
-m, --mail Get e-mail addresses from the crawled sites
-e EXTENSION, --extension EXTENSION
Specifiy additional website extensions to the
Expand All @@ -124,6 +124,8 @@ optional arguments:
-i, --info Info displays basic info of the scanned site (very
slow)` </pre>

* NOTE: All flags under -u URL, --url URL must also be passed a -u flag.

Read more about torrc here : [Torrc](https://github.com/DedSecInside/TorBoT/blob/master/Tor.md)

## TO-DO
Expand Down
25 changes: 16 additions & 9 deletions modules/pagereader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,34 @@
from modules.bcolors import Bcolors


def readPage(site, printIP=0):
b_colors = Bcolors()
def readPage(site):
headers = {'User-Agent':
'TorBot - Onion crawler | www.github.com/DedSecInside/TorBot'}
req = urllib.request.Request(site, None, headers)
attempts_left = 3

while (attempts_left):

try:
response = urllib.request.urlopen(req)
page = BeautifulSoup(response.read(), 'html.parser')
if printIP:
pg = page.find('strong')
IP = pg.renderContents()
print(b_colors.WARNING + b_colors.BOLD + IP.decode("utf-8") +
b_colors.ENDC)
return page

except Exception as e:
attempts_left -= 1
error = e

raise error


def get_ip():
"""Returns users tor ip address
https://check.torproject.org/ tells you if you are using tor and it
displays your IP address which we scape and return
"""

b_colors = Bcolors()
page = readPage('https://check.torproject.org/')
pg = page.find('strong')
ip_addr = pg.renderContents()

return b_colors.WARNING+b_colors.BOLD+ip_addr.decode("utf-8")+b_colors.ENDC
59 changes: 28 additions & 31 deletions torBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def header():
D3DSEC = b_color.FAIL + " D3DSEC " + b_color.WHITE
INS1DE = b_color.FAIL + " INS1DE " + b_color.WHITE

header = """
header = r"""
######################################################
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWMMMMMMMMMMMMMM
Expand Down Expand Up @@ -98,9 +98,9 @@ def header():
# GitHub : https://github.com/DedsecInside/TorBot #
# Help : use -h for help text #
#######################################################
{FAIL} + "LICENSE: GNU Public License" + {ENDC}""".format(
{FAIL} + "LICENSE: GNU Public License" + {END}""".format(
D3DSEC=D3DSEC, INS1DE=INS1DE, FAIL=b_color.FAIL,
BOLD=b_color.BOLD, VERSION=__VERSION, ENDC=b_color.ENDC,
BOLD=b_color.BOLD, VERSION=__VERSION, END=b_color.ENDC,
On_Black=b_color.On_Black
)
print(header)
Expand Down Expand Up @@ -140,44 +140,41 @@ def main():
"scanned site, (very slow)")))
args = parser.parse_args()

# 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:
updater.updateTor()
exit()

if not args.quiet:
header()

print("Tor Ip Address :")
link = args.url
defaultLink = "http://torlinkbgs6aabns.onion/"

pagereader.readPage("https://check.torproject.org/", 1)

if link is not None:
b = pagereader.readPage(link)

else:
b = pagereader.readPage(defaultLink, 0)
link = defaultLink

if args.mail and b is not None:
emails = getemails.getMails(b)
print(emails)
if args.save:
savefile.saveJson('Extracted-Mail-IDs', emails)

if args.info:
info.executeAll(link)

# 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:
links = getweblinks.getLinks(b)
print(links)
if args.save:
savefile.saveJson("Onions links", links)
print("Tor IP Address :", pagereader.get_ip())
link = args.url
html_content = pagereader.readPage(link)
# -m/--mail
if args.mail:
emails = getemails.getMails(html_content)
print(emails)
if args.save:
savefile.saveJson('Emails', emails)
# -i/--info
elif args.info:
info.executeAll(link)
if args.save:
print('Nothing to save.\n')
else:
links = getweblinks.getLinks(html_content)
print(links)
if args.save:
savefile.saveJson("Links", links)
else:
print("You must pass a url with these flags.")

print("\n\n")

Expand Down

0 comments on commit 55342c6

Please sign in to comment.