示例#1
0
def main():
    """
    TorBot's Core
    """
    args = get_args()
    connect(args.ip, args.port)
    print("--------------------------------", type(args.depth))
    print("--------------------------------", args.depth)
    # 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()
    # 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)
            result_emails = {'emails':node.emails}
            if args.save:
                saveJson('Emails', node.emails)
        # -i/--info
        if args.info:
            execute_all(node.uri)
            if args.save:
                print('Nothing to save.\n')
        if args.visualize:
            if args.depth:
                tree = LinkTree(node, stop_depth=args.depth)
            else:    
                tree = LinkTree(node)
            tree.show()
        if args.download:
            tree = LinkTree(node)
            file_name = str(input("File Name (.pdf/.png/.svg): "))
            tree.save(file_name)
        else:
            '''print("--------------------------------", type(node.links))
            print("--------------------------------", node.links)'''
            LinkIO.display_children(node)
            print(LinkIO.results)
            if args.save:
                saveJson("Links", node.links)
    else:
        print("usage: See torBot.py -h for possible arguments.")

    print("\n\n")
示例#2
0
def main():
    args = get_args()
    connect(args.ip, args.port)
    link = args.url

    # 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()
    # 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:
        print("Tor IP Address :", pagereader.get_ip())
        html_content, response = pagereader.read_first_page(link)
        print("Connection successful.")
        # -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, html_content, response)
            if args.save:
                print('Nothing to save.\n')
        else:
            links = getweblinks.get_links(soup=html_content,
                                          live=args.live,
                                          ext=args.extension)
            if args.save:
                savefile.saveJson("Links", links)
    else:
        print("usage: torBot.py [-h] [-v] [--update] [-q] [-u URL] [-s] [-m]",
              "[-e EXTENSION] [-l] [-i]")

    print("\n\n")
示例#3
0
def main(conn=False):

    if conn:
        connect(LOCALHOST, PORT)

    parser = argparse.ArgumentParser()
    parser.add_argument("-v",
                        "--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("-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("-l",
                        "--live",
                        action="store_true",
                        help="Check if websites are live or not (slow)")
    parser.add_argument("-i",
                        "--info",
                        action="store_true",
                        help=' '.join(("Info displays basic info of the",
                                       "scanned site, (very slow)")))
    args = parser.parse_args()

    link = args.url

    # 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()
    # 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:
        print("Tor IP Address :", pagereader.get_ip())
        html_content = pagereader.readPage(link, args.extension)
        # -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(soup=html_content,
                                         live=args.live,
                                         ext=args.extension)
            if args.save:
                savefile.saveJson("Links", links)
    else:
        print(
            "usage: torBot.py [-h] [-v] [--update] [-q] [-u URL] [-s] [-m] [-e EXTENSION] [-l] [-i]"
        )

    print("\n\n")