Example #1
0
def crawler3(web):

    try:
        print(GR + ' [*] Loading (Level 3) crawler...')
        time.sleep(0.5)

        #print(R+'\n    ==========================')
        #print(R+'     C R A W L E R  (Depth 3)')
        #print(R+'    ==========================')
        from core.methods.print import pscan
        pscan("crawler (depth 3)")
        time.sleep(0.7)
        print(O + ' [This crawler will recursively crawl')
        print(O + ' all the links of the website as well as all')
        print(O + '   links within each of the pages]\n')
        time.sleep(0.7)
        print(R + '  WARNING : Use this with CAUTION!\n')
        if properties["LIMIT"][1] == " ":
            m = input(GR + ' [#] No. of links to be crawled (eg 100) :> ')
        else:
            m = properties["LIMIT"][1]
        print(O + ' [!] Crawling limit set to : ' + C + str(m))
        w = int(m)
        crawler20x00(web, w)
        out(web, actual_uri)

    except Exception as e:
        print(R + ' [-] Further crawl aborted due to Exception!')
        print(R + ' [-] Exception : ' + str(e))
        time.sleep(0.7)
        print(GR + ' [*] Saving the links obtained...')
        out(web, actual_uri)
        print(G + ' [+] Saved!')
Example #2
0
def osdetect(web):
    try:
        time.sleep(0.4)
        #print(R+'\n     ===================================')
        #print(R+'      O S   F I N G E R P R I N T I N G')
        #print(R+'     ===================================\n')
        from core.methods.print import pscan
        pscan("os fingerprinting")
        web = web.replace('http://', '')
        web = web.replace('https://', '')
        print(GR + ' [*] Initialising Module [1]...')
        flag = getos0x00(web)
        print(C + '\n [+] Module [1] Completed!')
        if flag == 0x01:
            q = input(
                C +
                ' [!] OS Identified!\n [?] Move on to to module [2]? (y/N) :> '
            )
            if q == 'Y' or q == 'y':
                print(GR + '\n [*] Initialising Module [2]...')
                port0x00(web)
            elif q == 'N' or q == 'n':
                print(C + ' [+] Done!')
        elif flag == 0x00:
            print(GR + ' [*] Initialising Module [2]...')
            port0x00(web)
        else:
            print(R + ' [-] F**k, something went wrong!')
            print(flag)

    except Exception as e:
        print(R + ' [-] Unhandled Exception occured...')
        print(R + ' [-] Exception : ' + str(e))
    print(G + ' [+] OS Fingerprinting Module Completed!' + C + color.TR2 + C +
          '\n')
Example #3
0
def waf(web):
    global name
    name = targetname(web)
    global lvl2
    lvl2 = inspect.stack()[0][3]
    global module
    module = "ScanANDEnum"
    global lvl1
    lvl1 = "Scanning & Enumeration"
    global lvl3
    lvl3 = ""
    check = 0x00
    time.sleep(0.7)
    #print(R+'\n    ===============================')
    #print(R+'     W A F   E N U M E R A T I O N ')
    #print(R+'    ===============================\n')
    from core.methods.print import pscan
    pscan("waf enumeration")
    time.sleep(0.7)
    print(GR + ' [*] Testing the firewall/loadbalancer...')
    time.sleep(1)
    head, con = getReq0x00(web)
    waftypes = detectWaf0x00(head, con)
    for i in range(0, len(waftypes)):
        try:
            if waftypes[i] != None and waftypes[i] != '':
                print(
                    GR +
                    '\n [*] Response seems to be matching a WAF signature...')
                time.sleep(0.6)
                print(C + ' [+] The website seems to be behind a WAF...')
                time.sleep(0.6)
                print(B + ' [+] Firewall Detected : ' + C + waftypes[i])
                check = 0x01
                save_data(database, module, lvl1, lvl2, lvl3, name,
                          waftypes[i])
                break

            else:
                print(B + ' [+] Matching signatures for : ' + C + wafs[i],
                      end='',
                      flush=True)
                time.sleep(0.1)

        except Exception as e:
            pass

    if check == 0x00:
        save_data(database, module, lvl1, lvl2, lvl3, name,
                  "Generic detection failed to fingerprint WAF.")
        print(R + ' [-] Generic detection failed to fingerprint WAF...')

    print('\n' + G + ' [+] WAF Fingerprinting module completed!' + C +
          color.TR2 + C + '\n')
Example #4
0
def photon(web):
    global name
    name = targetname(web)
    global lvl2
    lvl2 = inspect.stack()[0][3]
    global module
    module = "ScanANDEnum"
    global lvl1
    lvl1 = "Crawling"
    global lvl3
    lvl3 = ""
    time.sleep(0.5)
    pscan("photon")
    if properties["ROOT"][1] == " ":
        root = input(" [§] Enter the root URL :> ")
    else:
        root = properties["ROOT"][1]

    if properties["ARGS"][1] == " ":
        try:
            try:
                help_photon = subprocess.call(["photon", "--help"])
            except:
                #in case of buggy photon pip installation
                help_photon = subprocess.call(
                    ["python3", "core/lib/Photon/photon.py", "--help"])
            arguments = input(
                " [§] Enter arguments (as you would after $photon -u ROOT on the commandline) :> "
            )
            assert "-u" not in arguments and "--url" not in arguments
        except AssertionError:
            arguments = input(
                " [-] Argument '-u' already present in command string.\n [§] Enter arguments (as you would after $photon -u ROOT on the commandline) :> "
            )
    else:
        arguments = properties["ARGS"][1]

    arglist = re.split("\s+", arguments)
    print(
        " [+] Starting Photon Scan (this will take a while, output piped into variable)"
    )
    try:
        #command = "photon -u " + root + " " + arguments
        command = ["photon", "-u", root] + arglist
        results_photon = subprocess.check_output(command)
    except:
        command = ["python3", "core/lib/Photon/photon.py", "-u", root
                   ] + arglist
        results_photon = subprocess.check_output(command)
    data = results_photon.decode().replace("<<", "").replace(">>", "")
    print(data)
    gprint("\n [+] Photon Scan finished! Saving to database...")
    save_data(database, module, lvl1, lvl2, lvl3, root, data)
Example #5
0
def webtech(web):

    #print(R+'\n    =================================')
    #print(R+'     W E B   T E C H N O L O G I E S')
    #print(R+'    =================================\n')

    from core.methods.print import pscan
    pscan("web technologies")

    check0x00(web)
    apircv(web)
    print(O+' [+] Fingerprinting Done!')
Example #6
0
def bannergrab(web):

    #print(R+'\n    ===============================')
    #print(R+'     B A N N E R   G R A B B I N G')
    #print(R+'    ===============================\n')
    from core.methods.print import pscan
    pscan("banner grabbing")

    print(GR+' [*] Parsing Url...')
    web = web.replace('http://','')
    web = web.replace('https://','')
    grab(web)
    print(G+'\n [+] Banner Grabbing Done!'+C+color.TR2+C)
Example #7
0
def crawler2(web):
    global name
    name = targetname(web)
    global lvl2
    lvl2 = "crawler2"
    global module
    module = "ScanANDEnum"
    global lvl1
    lvl1 = "Crawling"
    global lvl3
    lvl3 = ""
    time.sleep(0.6)
    totlinks = []
    #print(R+'\n    =========================')
    #print(R+'     C R A W L E R (Depth 2)')
    #print(R+'    =========================')
    from core.methods.print import pscan
    pscan("crawler (depth 2)")
    time.sleep(0.7)
    print(C+' [This module will fetch both ext. ')
    print(C+' and internal links from a website]\n')
    print(GR+' [*] Initiating the crawling...')
    time.sleep(0.7)
    try:
        print(C+' [*] Starting internal links gathering...')
        intlinks = internalcrawl(web)
        print(G+' [+] Finished internal links crawling...'+C+color.TR2+C)
        print(C+'\n [*] Starting external links gathering...')
        extlinks = externalcrawl(web)
        print(G+' [+] Finished external links crawling...'+C+color.TR2+C)

    except Exception as e:
        print(R+' [-] Exception : '+str(e))
        pass

    print(R+'   EXTERNAL LINKS')
    print(R+'  ---<>----<>----<')
    print(R+'   |')

    for lenk in extlinks:
        print(GR+'   + '+lenk)

    print(R+'\n   INTERNAL LINKS')
    print(R+'  ---<>----<>----<')
    print(R+'   |')

    for lenk in intlinks:
        print(GR+'   + '+O+lenk)
    totlinks = list(set(intlinks + extlinks))
    out(web, totlinks)
Example #8
0
def osdetect(web):
    global name
    name = targetname(web)
    global lvl2
    lvl2 = inspect.stack()[0][3]
    global module
    module = "ScanANDEnum"
    global lvl1
    lvl1 = "Scanning & Enumeration"
    global lvl3
    lvl3 = ""
    try:
        time.sleep(0.4)
        #print(R+'\n     ===================================')
        #print(R+'      O S   F I N G E R P R I N T I N G')
        #print(R+'     ===================================\n')
        from core.methods.print import pscan
        pscan("os fingerprinting")
        web = web.replace('http://', '')
        web = web.replace('https://', '')
        print(GR + ' [*] Initialising Module [1]...')
        flag, os1 = getos0x00(web)
        print(C + '\n [+] Module [1] Completed!')
        if flag == 0x01:
            save_data(database, module, lvl1, lvl2, lvl3, name, os1)
            q = input(
                C +
                ' [!] OS Identified!\n [?] Move on to to module [2]? (y/N) :> '
            )
            if q == 'Y' or q == 'y':
                print(GR + '\n [*] Initialising Module [2]...')
                port0x00(web)
            elif q == 'N' or q == 'n':
                print(C + ' [+] Done!')
        elif flag == 0x00:
            print(GR + ' [*] Initialising Module [2]...')
            port0x00(web)
        else:
            print(R + ' [-] F**k, something went wrong!')
            print(flag)

    except Exception as e:
        print(R + ' [-] Unhandled Exception occured...')
        print(R + ' [-] Exception : ' + str(e))
    print(G + ' [+] OS Fingerprinting Module Completed!' + C + color.TR2 + C +
          '\n')
def crawler2(web):

    print(GR + ' [*] Loading Level 2 Crawler...')
    time.sleep(0.6)
    totlinks = []
    #print(R+'\n    =========================')
    #print(R+'     C R A W L E R (Depth 2)')
    #print(R+'    =========================')
    from core.methods.print import pscan
    pscan("crawler (depth 2)")
    time.sleep(0.7)
    print(O + ' [This module will fetch both ext. ')
    print(O + ' and internal links from a website]\n')
    print(GR + ' [*] Initiating the crawling...')
    time.sleep(0.7)
    try:
        print(O + ' [*] Starting internal links gathering...')
        intlinks = internalcrawl(web)
        print(G + ' [+] Finished internal links crawling...')
        print(O + '\n [*] Starting external links gathering...')
        extlinks = externalcrawl(web)
        print(G + ' [+] Finished external links crawling...')

    except Exception as e:
        print(R + ' [-] Exception : ' + str(e))
        pass

    print(R + '   EXTERNAL LINKS')
    print(R + '  ================')
    print(O + '   |')

    for lenk in extlinks:
        print(GR + '   + ' + lenk)

    print(R + '\n   INTERNAL LINKS')
    print(R + '  ================')
    print(O + '   |')

    for lenk in intlinks:
        print(GR + '   + ' + O + lenk)
    totlinks = list(set(intlinks + extlinks))
    out(web, totlinks)
Example #10
0
def crawler3(web):
    global name
    name = targetname(web)
    global lvl2
    lvl2 = "crawler3"
    global module
    module = "ScanANDEnum"
    global lvl1
    lvl1 = "Crawling"
    global lvl3
    lvl3 = ""
    try:
        time.sleep(0.5)

        #print(R+'\n    ==========================')
        #print(R+'     C R A W L E R  (Depth 3)')
        #print(R+'    ==========================')
        from core.methods.print import pscan
        pscan("crawler (depth 3)")
        time.sleep(0.7)
        print(C+' [This crawler will recursively crawl')
        print(C+' all the links of the website as well as all')
        print(C+'   links within each of the pages]\n')
        time.sleep(0.7)
        print(R+'  WARNING : Use this with CAUTION!\n')
        if properties["LIMIT"][1] == " ":
            m = input(GR+' [§] No. of links to be crawled (eg 100) :> ')
        else:
            m = properties["LIMIT"][1]
        print(O+' [!] Crawling limit set to :'+C+color.TR3+C+G+str(m)+C+color.TR2+C)
        w = int(m)
        crawler20x00(web, w)
        out(web, actual_uri)

    except Exception as e:
        print(R+' [-] Further crawl aborted due to Exception!')
        print(R+' [-] Exception : '+str(e))
        time.sleep(0.7)
        print(GR+' [*] Saving the links obtained...')
        out(web, actual_uri)
        print(G+' [+] Saved!'+C+color.TR2+C)
Example #11
0
def crawler10x00(web):
    requests = session()
    time.sleep(0.5)
    #print(R+'\n    ===========================')
    #print(R+'     C R A W L E R  (Depth 1)')
    #print(R+'    ==========================\n')
    from core.methods.print import pscan
    pscan("crawler (depth 1)")
    print(C + ' [This module will fetch all links')
    print(C + ' from an online API and then crawl ')
    print(C + '         them one by one]      ')
    time.sleep(0.4)
    print('' + GR + ' [*] Parsing the web URL... ')
    time.sleep(0.3)
    print('' + B + ' [!] URL successfully parsed...')
    print('' + GR + ' [*] Getting links...')
    time.sleep(0.4)
    text = requests.get('http://api.hackertarget.com/pagelinks/?q=' + web).text
    lol = str(text)
    linksall = lol.splitlines()
    for m in linksall:
        if 'http' in m and 'https' not in m:
            cis.append(m)

    flag = 0x00
    for x in cis:
        try:
            print(O + ' [+] Crawling link :>' + C + color.TR3 + C + G +
                  str(x) + C + color.TR2 + C)
            br.open(x)
            flag = 0x01
            crawled.append(x)

        except Exception as e:
            print(R + ' [-] Exception : ' + str(e) + '\n')

    if flag == 0x00:
        print(R + ' [-] Unable to find any links...')
        print(C + ' [+] Please use the second crawler... :)')

    return crawled
Example #12
0
File: waf.py Project: zmarouf/Vaile
def waf(web):

    check = 0x00
    print(GR + ' [*] Loading module...')
    time.sleep(0.7)
    #print(R+'\n    ===============================')
    #print(R+'     W A F   E N U M E R A T I O N ')
    #print(R+'    ===============================\n')
    from core.methods.print import pscan
    pscan("waf enumeration")
    time.sleep(0.7)
    print(GR + ' [*] Testing the firewall/loadbalancer...')
    time.sleep(1)
    head, con = getReq0x00(web)
    waftypes = detectWaf0x00(head, con)
    for i in range(0, len(waftypes)):
        try:
            if waftypes[i] != None and waftypes[i] != '':
                print(
                    GR +
                    '\n [*] Response seems to be matching a WAF signature...')
                time.sleep(0.6)
                print(O + ' [+] The website seems to be behind a WAF...')
                time.sleep(0.6)
                print(B + ' [+] Firewall Detected : ' + C + waftypes[i])
                check = 0x01
                break

            else:
                print(B + ' [+] Matching signatures for : ' + C + wafs[i],
                      end='',
                      flush=True)
                time.sleep(0.1)

        except Exception as e:
            pass

    if check == 0x00:
        print(R + ' [-] Generic detection failed to fingerprint WAF...')

    print(G + '\n [+] WAF Fingerprinting module completed!\n')
Example #13
0
def webtech(web):
    global name
    name = targetname(web)
    global lvl2
    lvl2 = inspect.stack()[0][3]
    global module
    module = "ScanANDEnum"
    global lvl1
    lvl1 = "Scanning & Enumeration"
    global lvl3
    lvl3 = ""
    #print(R+'\n    =================================')
    #print(R+'     W E B   T E C H N O L O G I E S')
    #print(R+'    =================================\n')

    from core.methods.print import pscan
    pscan("web technologies")

    check0x00(web)
    apircv(web)
    print(C + ' [+] Fingerprinting Done!')
Example #14
0
def scan0x00(target):

    try:

        #print(R+'\n    =================================')
        #print(R+'     T C P   C O N N E C T   S C A N ')
        #print(R+'    =================================\n')
        from core.methods.print import pscan
        pscan("tcp connect scan")
        min_port = input(O + " [#] Enter Minumum Port Number -> ")
        max_port = input(O + " [#] Enter Maximum Port Number -> ")
        open_ports = []
        closed_ports = []
        ip_host = socket.gethostbyname(target)
        chk = input(C +
                    ' [#] Do you want a verbose output? (enter if not) :> ')
        verbose = chk is not ""
        print(GR + ' [*] Checking port range...')
        if int(min_port) >= 0 and int(max_port) >= 0 and int(max_port) >= int(
                min_port) and int(max_port) <= 65536:
            print('\033[1;32m [!] Port range detected valid...')
            time.sleep(0.3)
            print(GR + ' [*] Preparing for the the Scan...')

            ports = range(int(min_port),
                          int(max_port) +
                          1)  # Build range from given port numbers
            prtlst = listsplit(ports, round(len(ports) / processes))
            starting_time = time.time()  # Start clock for scan time
            SYNACK = 0x12  # Set flag values for later reference
            RSTACK = 0x14

            checkhost(ip_host)  # Run checkhost() function from earlier
            print(O + " [*] Scanning initiated at " + strftime("%H:%M:%S") +
                  "!\n")  # Confirm scan start

            with Pool(processes=processes) as pool:
                res = [
                    pool.apply_async(portloop, args=(
                        l,
                        verbose,
                        ip_host,
                    )) for l in prtlst
                ]
                #res1 = pool.apply_async(portloop, )
                for i in res:
                    j = i.get()
                    open_ports += j[0]
                    closed_ports += j[1]

            print(O + "\n [!] Scanning completed at %s" %
                  (time.strftime("%I:%M:%S %p")))
            ending_time = time.time()
            total_time = ending_time - starting_time
            print(GR + ' [*] Preparing report...\n')
            time.sleep(1)
            #print(O+'    +-------------+')
            #print(O+'    | '+R+'SCAN REPORT '+O+'|')
            print(O + '      ' + R + 'SCAN REPORT ' + O + ' ')
            #print(O+'    +-------------+')
            print(O + '    ––·‹›·––·‹›·–––')
            #print(O+'    |')
            print()
            print(O + '    +--------+------------------+')
            print(O + '    |  ' + GR + 'PORT  ' + O + '|       ' + GR +
                  'STATE      ' + O + '|')
            print(O + '    +--------+------------------+')

            if open_ports:
                for i in sorted(open_ports):

                    c = str(i)
                    if len(c) == 1:
                        print(O + '    |   ' + C + c + O + '    |       ' + G +
                              'OPEN       ' + O + '|')
                        print(O + '    +--------+------------------+')
                        time.sleep(0.2)
                    elif len(c) == 2:
                        print(O + '    |   ' + C + c + '   ' + O + '|       ' +
                              G + 'OPEN       ' + O + '|')
                        print(O + '    +--------+------------------+')
                        time.sleep(0.2)
                    elif len(c) == 3:
                        print(O + '    |  ' + C + c + '   ' + O + '|       ' +
                              G + 'OPEN       ' + O + '|')
                        print(O + '    +--------+------------------+')
                        time.sleep(0.2)
                    elif len(c) == 4:
                        print(O + '    |  ' + C + c + '  ' + O + '|       ' +
                              G + 'OPEN       ' + O + '|')
                        print(O + '    +--------+------------------+')
                        time.sleep(0.2)
                    elif len(c) == 5:
                        print(O + '    | ' + C + c + '  ' + O + '|       ' +
                              G + 'OPEN       ' + O + '|')
                        print(O + '    +--------+------------------+')
                        time.sleep(0.2)
                print('')
            else:
                print(R + ' [-] No open ports found!')

            print(O + ' [!] ' + str(len(closed_ports)) +
                  ' closed ports not shown')
            print(C + " [!] Host %s scanned in %s seconds.\n" %
                  (target, total_time))

        else:  # If range didn't raise error, but didn't meet criteria
            print("\n\033[91m [!] Invalid Range of Ports")
            print(" [!] Exiting...")
            quit()
    except Exception as e:  # If input range raises an error
        print(e)
        quit()
Example #15
0
def attack(web):
    from core.methods.print import pscan
    pscan("arp-scan")
    arp()
def scan0x00(host):

    #print(R+'\n   =======================================')
    #print(R + "    S I M P L E   P O R T   S C A N N E R")
    #print(R + '   =======================================\n')
    from core.methods.print import pscan
    pscan("simple port scanner")
    start_port = input(O + ' [#] Enter initial port :> ')
    end_port = input(O + ' [#] Enter ending port :> ')

    start_port = int(start_port)
    end_port = int(end_port)

    try:
        ip = socket.gethostbyname(host)
        print(G + '\n [+] Target server detected up and running...')
        print(GR + ' [*] Preparing for scan...')
        pass
    except:
        print(R + ' [-] Server not responding...')
        time.sleep(0.3)
        print(R + ' [*] Exiting...')
        quit()

    open_ports = []
    closed_ports = []

    mn = input(O + '\n [*] Do you want a verbose output (enter if not) :> ')
    verbose = mn is not ""
    if verbose:
        print('' + G + '\n [+] Verbose mode selected !\n')
        print(GR + " [!] Scanning %s from port %s - %s: " %
              (host, start_port, end_port))
    print(B + " [*] Scanning started at %s" % (time.strftime("%I:%M:%S %p")))
    starting_time = time.time()
    try:
        if verbose:
            print(O + " [*] Scan in progress..")
            time.sleep(0.8)
        portrange = range(start_port, end_port + 1)
        prtlst = listsplit(portrange, round(len(portrange) / processes))
        with Pool(processes=processes) as pool:
            res = [
                pool.apply_async(portloop, args=(
                    l,
                    host,
                    verbose,
                )) for l in prtlst
            ]
            #res1 = pool.apply_async(portloop, )
            for i in res:
                j = i.get()
                open_ports += j[0]
                closed_ports += j[1]

        print(G + "\n [+] Scanning completed at %s" %
              (time.strftime("%I:%M:%S %p")))
        ending_time = time.time()
        total_time = ending_time - starting_time
        print(G + ' [*] Preparing report...\n')
        time.sleep(1)
        #print(O+'    +-------------+')
        #print(O+'    | '+R+'SCAN REPORT '+O+'|')
        print(O + '      ' + R + 'SCAN REPORT ' + O + ' ')
        #print(O+'    +-------------+')
        print(O + '    ––·‹›·––·‹›·–––')
        #print(O+'    |')
        print()
        print(O + '    +--------+----------+')
        print(O + '    |  ' + GR + 'PORT  ' + O + '|  ' + GR + 'STATE   ' + O +
              '|')
        print(O + '    +--------+----------+')

        if open_ports:
            for i in sorted(open_ports):
                c = str(i)
                if len(c) == 1:
                    print(O + '    |   ' + C + c + O + '    |   ' + G +
                          'OPEN   ' + O + '|')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(O + '    |   ' + C + c + '   ' + O + '|   ' + G +
                          'OPEN   ' + O + '| ')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(O + '    |  ' + C + c + '   ' + O + '|   ' + G +
                          'OPEN   ' + O + '| ')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(O + '    |  ' + C + c + '  ' + O + '|   ' + G +
                          'OPEN   ' + O + '| ')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(O + '    | ' + C + c + '  ' + O + '|   ' + G +
                          'OPEN   ' + O + '| ')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
        else:
            print(R + "\n [-] No open ports found.!!\n")
        print(B + '\n [!] ' + str(len(closed_ports)) +
              ' closed ports not shown')
        print(G + " [+] Host %s scanned in %s seconds\n" % (host, total_time))

    except KeyboardInterrupt:
        print(R + "\n [-] User requested shutdown... ")
        print(' [-] Exiting...\n')
        quit()
Example #17
0
def scan0x00(host):

    #print(R+'\n   =========================')
    #print(R+'    P O R T   S C A N N E R')
    #print(R+'   =========================\n')
    from core.methods.print import pscan
    pscan("port scanner")
    print(GR + ' [*] Using most common ports...')

    ports = [
        20, 21, 23, 25, 53, 67, 68, 69, 80, 109, 110, 111, 123, 137, 143, 156,
        161, 162, 179, 389, 443, 445, 512, 513, 546, 547, 636, 993, 995, 1099,
        2121, 2049, 3306, 5432, 5900, 6000, 6667, 8080, 8180, 8443, 10000
    ]
    mlprts = listsplit(ports, round(len(ports) / processes))
    #print(mlprts)
    print(C + ' [+] Scanning %s ports...' % len(ports))
    try:
        ip = socket.gethostbyname(host)
        print(G + '\n [+] Target server detected up and running...' + C +
              color.TR2 + C)
        print(O + ' [*] Preparing for scan...' + C)
        pass
    except Exception:
        print(R + ' [-] Server not responding...')
        time.sleep(0.3)
        print(R + ' [*] Exiting...')
        quit()

    open_ports = []
    closed_ports = []

    print(G + " [*] Scanning started at %s" % (time.strftime("%I:%M:%S %p")) +
          C + color.TR2 + C)
    starting_time = time.time()
    try:
        print(O + " [*] Scan in progress.." + C)
        time.sleep(0.8)
        with Pool(processes=processes) as pool:
            res = [
                pool.apply_async(portloop, args=(
                    l,
                    host,
                )) for l in mlprts
            ]
            #res1 = pool.apply_async(portloop, )
            for i in res:
                j = i.get()
                open_ports += j[0]
                closed_ports += j[1]

        print(G + "\n [+] Scanning completed at %s" %
              (time.strftime("%I:%M:%S %p")) + C + color.TR2 + C)
        ending_time = time.time()
        total_time = ending_time - starting_time
        print(P + ' [*] Preparing report...\n' + C)
        time.sleep(1)

        openports = "   {}{}{}{}{}{}{}{} ports open.".format(
            color.TR5, C, G, str(len(open_ports)), color.END, color.TR2,
            color.END, color.CURSIVE)
        summary("simpleport", openports)
        print()
        print(P + '    +--------+----------+')
        print(P + '    |  ' + C + 'PORT' + P + '  ' + '|  ' + C + 'STATE' + P +
              '   ' + '|')
        print(P + '    +--------+----------+')
        lvl2 = "getports"
        module = "ScanANDEnum"
        lvl1 = "Scanning & Enumeration"
        lvl3 = ""
        if open_ports:
            for i in sorted(open_ports):
                c = str(i)
                if len(c) == 1:
                    print(P + '    |   ' + C + c + P + '    |   ' + C +
                          'OPEN' + P + '   ' + '|')
                    print(P + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(P + '    |   ' + C + c + P + '   ' + P + '|   ' + C +
                          'OPEN' + P + '   ' + '| ')
                    print(P + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(P + '    |  ' + C + c + P + '   ' + '|   ' + C +
                          'OPEN' + P + '   ' + '| ')
                    print(P + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(P + '    |  ' + C + c + P + '  ' + '|   ' + C +
                          'OPEN' + P + '   ' + '| ')
                    print(P + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(P + '    | ' + C + c + P + '  ' + '|   ' + C +
                          'OPEN' + P + '   ' + '| ')
                    print(P + '    +--------+----------+')
                    time.sleep(0.2)
            data = "Open Ports: " + str(open_ports)
            save_data(database, module, lvl1, lvl2, lvl3, name, data)
        else:
            save_data(database, module, lvl1, lvl2, lvl3, name,
                      "No open ports found.")
            print(R + "\n [-] No open ports found.!!\n")
        print(B + '\n [!] ' + str(len(closed_ports)) +
              ' closed ports not shown')
        print(G + " [+] Host %s scanned in %s seconds" % (host, total_time) +
              C + color.TR2 + C + "\n")

    except KeyboardInterrupt:
        print(R + "\n [-] User requested shutdown... ")
        print(' [-] Exiting...\n')
        quit()
def scan0x00(target):
    try:

        #print(R+'\n        ===================')
        #print(R+'         X M A S   S C A N ')
        #print(R+'        ===================\n')
        from core.methods.print import pscan
        pscan("xmas scan")
        print(R + '   [Reliable only in LA Networks]\n')
        min_port = input(O + " [#] Enter Minumum Port Number -> ")
        max_port = input(O + " [#] Enter Maximum Port Number -> ")
        openfil_ports = []
        filter_ports = []
        closed_ports = []
        ip_host = socket.gethostbyname(target)
        chk = input(C +
                    ' [#] Do you want a verbose output? (enter if not) :> ')
        verbose = chk is not ""

        try:
            print(GR + ' [*] Checking port range...')
            if int(min_port) >= 0 and int(max_port) >= 0 and int(
                    max_port) >= int(min_port) and int(max_port) <= 65536:
                print(G + '\033[1;32m [+] Port range detected valid...')
                time.sleep(0.3)
                print(GR + ' [*] Preparing for the the FIN Scan...')
                pass
            else:
                print(R + "\n [!] Invalid Range of Ports")
                print(" [!] Exiting...")
                quit()
        except Exception:  # If input range raises an error
            print("\n\033[91m [!] Invalid Range of Ports")
            print(" [!] Exiting...")
            quit()

        ports = range(int(min_port),
                      int(max_port) + 1)  # Build range from given port numbers
        prtlst = listsplit(ports, round(len(ports) / processes))
        starting_time = time.time()  # Start clock for scan time
        SYNACK = 0x12  # Set flag values for later reference
        RSTACK = 0x14

        def checkhost(ip):  # Function to check if target is up
            conf.verb = 0  # Hide output
            try:
                ping = sr1(IP(dst=ip) / ICMP())  # Ping the target
                print("\n\033[1;32m [!] Target server detected online...")
                time.sleep(0.6)
                print(' [*] Beginning scan...')
            except Exception:  # If ping fails
                print("\n\033[91m [!] Couldn't Resolve Target")
                print(" [!] Exiting...")
                quit()

        checkhost(ip_host)  # Run checkhost() function from earlier
        print(G + " [*] Scanning initiated at " + strftime("%H:%M:%S") +
              "!\n")  # Confirm scan start

        with Pool(processes=processes) as pool:
            res = [
                pool.apply_async(portloop, args=(
                    l,
                    verbose,
                    ip_host,
                )) for l in prtlst
            ]
            #res1 = pool.apply_async(portloop, )
            for i in res:
                j = i.get()
                openfil_ports += j[0]
                filter_ports += j[1]
                closed_ports += j[2]

        print("\n [!] Scanning completed at %s" %
              (time.strftime("%I:%M:%S %p")))
        ending_time = time.time()
        total_time = ending_time - starting_time
        print(GR + ' [*] Preparing report...\n')
        time.sleep(1)
        #print(O+'    +-------------+')
        #print(O+'    | '+R+'SCAN REPORT '+O+'|')
        print(O + '      ' + R + 'SCAN REPORT ' + O + ' ')
        #print(O+'    +-------------+')
        print(O + '    ––·‹›·––·‹›·–––')
        #print(O+'    |')
        print()
        print(O + '    +--------+------------------+')
        print(O + '    |  ' + GR + 'PORT  ' + O + '|       ' + GR +
              'STATE      ' + O + '|')
        print(O + '    +--------+------------------+')

        if openfil_ports:
            for i in sorted(openfil_ports):

                c = str(i)
                if len(c) == 1:
                    print(O + '    |   ' + C + c + O + '    |       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(O + '    |   ' + C + c + '   ' + O + '|       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(O + '    |  ' + C + c + '   ' + O + '|       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(O + '    |  ' + C + c + '  ' + O + '|       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(O + '    | ' + C + c + '  ' + O + '|       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)

        if filter_ports:
            for i in sorted(filter_ports):
                c = str(i)
                if len(c) == 1:
                    print(O + '    |   ' + C + c + O + '    |     ' + GR +
                          'FILTERED     ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(O + '    |   ' + C + c + '   ' + O + '|     ' + GR +
                          'FILTERED     ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(O + '    |  ' + C + c + '   ' + O + '|     ' + GR +
                          'FILTERED     ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(O + '    |  ' + C + c + '  ' + O + '|     ' + GR +
                          'FILTERED     ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(O + '    | ' + C + c + '  ' + O + '|     ' + GR +
                          'FILTERED     ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)

        else:
            print('' + R + " [-] No filtered ports found.!!" + O + '')
        print(B + "\n [!] " + str(len(closed_ports)) +
              ' closed ports not shown')
        print(O + " [!] Host %s scanned in %s seconds\n" %
              (target, total_time))

    except KeyboardInterrupt:  # In case the user wants to quit
        print("\n\033[91m [*] User Requested Shutdown...")
        print(" [*] Exiting...")
        quit()
Example #19
0
def webscan(web):
    requests = session()
    try:
        #print(R+'\n    ===========================================')
        #print(R+'     W E B S E R V E R   E N U M E R A T I O N')
        #print(R+'    ===========================================')
        from core.methods.print import pscan
        pscan("webserver enumeration")
        print(C + ' [This module will scan the whole CENSYS database for')
        print(C + '      collecting domain based IP Addresses and ')
        print(C + '           fingerprint them accordingly]\n')
        time.sleep(0.6)
        print(R + ' [-] WARNING: Use this module with caution!')
        print(GR + ' [*] Importing API Key...')
        try:
            from files.API_KEYS import CENSYS_UID, CENSYS_SECRET
        except (IOError, ImportError):
            print(R + ' [-] Error while importing key...')

        web = web.split('//')[1]
        print(C + ' [!] Obtaining reverse DNS lookup...')
        time.sleep(0.7)
        ip = web
        print(O + ' [+] Identified IP :' + C + color.TR3 + C + G + str(ip) +
              C + color.TR2 + C)
        print(GR + ' [*] Starting internet wide server scan...')
        if CENSYS_SECRET != '' and CENSYS_UID != '':

            print(O + ' [+] Found Censys UID Key :' + C + color.TR3 + C + G +
                  CENSYS_UID + C + color.TR2 + C)
            print(O + ' [+] Found Censys Secret Token :' + C + color.TR3 + C +
                  G + CENSYS_SECRET + C + color.TR2 + C)

            pages = float('inf')
            page = 1

            print(GR + ' [*] Setting scan parameters...')
            while page <= pages:

                base_url = 'https://www.censys.io/api/v1'
                params = {'query': ip, 'page': page}
                res = requests.post(base_url + "/search/ipv4",
                                    json=params,
                                    auth=(CENSYS_UID, CENSYS_SECRET))
                payload = res.json()

                for r in payload['results']:

                    ip = r["ip"]
                    proto = r["protocols"]
                    proto = [p.split("/")[0] for p in proto]
                    proto.sort(key=float)
                    protoList = ','.join(map(str, proto))

                    print(B + ' [+] IP : ' + C + str(ip) + C +
                          ' - Protocols : ' + str(protoList))

                    if '80' in protoList:
                        view(ip, base_url, CENSYS_UID, CENSYS_SECRET, requests)

                pages = payload['metadata']['pages']
                page += 1

        else:
            print(R + ' [-] CENSYS API TOKENs not set!')
            print(R + ' [-] This module cannot be used!')

    except Exception as e:
        print(R + ' [-] Unhandled Exception Encountered!')
        print(R + ' [-] Error : ' + str(e))
def ssltlsscan(web):
    global name
    name = targetname(web)
    global lvl2
    lvl2 = inspect.stack()[0][3]
    global module
    module = "ScanANDEnum"
    global lvl1
    lvl1 = "Scanning & Enumeration"
    global lvl3
    lvl3 = ""
    target = web.split('//')[1]
    #print(R+'\n    ===============================')
    #print(R+'     S S L   E N U M E R A T I O N')
    #print(R+'    ===============================\n')
    from core.methods.print import pscan
    pscan("ssl enumeration")
    print(GR + ' [*] Testing server SSL status...')
    try:
        req = requests.get('https://' + target)
        print(G + ' [+] SSL Working Properly...' + color.TR2 + C)
        time.sleep(0.6)
        print(C + " [!] Running SSL Enumeration...\n")
        try:
            server_tester = ServerConnectivityTester(hostname=target)
            server_info = server_tester.perform()
            scanner = SynchronousScanner()

            command = Tlsv10ScanCommand()
            scan_result = scanner.run_scan_command(server_info, command)
            print(G + " [+] Available TLS v1.0 Ciphers:" + color.TR2 + C)
            for cipher in scan_result.accepted_cipher_list:
                print(C + '    {}'.format(cipher.name))
            print('')
            data = "TLS 1.0 :> " + str(scan_result.accepted_cipher_list)
            save_data(database, module, lvl1, lvl2, lvl3, name, data)

            command = Tlsv11ScanCommand()
            scan_result = scanner.run_scan_command(server_info, command)
            print(G + " [+] Available TLS v1.1 Ciphers:" + color.TR2 + C)
            for cipher in scan_result.accepted_cipher_list:
                print(C + '    {}'.format(cipher.name))
            print('')
            data = "TLS 1.1 :> " + str(scan_result.accepted_cipher_list)
            save_data(database, module, lvl1, lvl2, lvl3, name, data)

            command = Tlsv12ScanCommand()
            scan_result = scanner.run_scan_command(server_info, command)
            print(G + " [+] Available TLS v1.2 Ciphers:" + color.TR2 + C)
            for cipher in scan_result.accepted_cipher_list:
                print(C + '    {}'.format(cipher.name))
            print('')
            data = "TLS 1.2 :> " + str(scan_result.accepted_cipher_list)
            save_data(database, module, lvl1, lvl2, lvl3, name, data)

            command = CertificateInfoScanCommand()
            scan_result = scanner.run_scan_command(server_info, command)
            print(G + ' [+] Certificate Information:' + color.TR2 + C)
            for entry in scan_result.as_text():
                if entry != '':
                    if 'certificate information' in entry.lower():
                        pass
                    elif ':' in entry:
                        print(GR + '    [+] ' +
                              entry.strip().split(':', 1)[0].strip() + ' : ' +
                              C + entry.strip().split(':', 1)[1].strip())
                    else:
                        print(C + '\n  [+] ' + entry.strip())
            print('')
            data = "Cert Info :> " + str(scan_result.as_text())
            save_data(database, module, lvl1, lvl2, lvl3, name, data)

            command = HttpHeadersScanCommand()
            scan_result = scanner.run_scan_command(server_info, command)
            print(G + ' [+] HTTP Results:' + C + color.TR2 + C)
            for entry in scan_result.as_text():
                if 'http security' not in entry.strip().lower(
                ) and entry != '':
                    if '-' in entry:
                        print(GR + '    [+] ' +
                              entry.split('-', 1)[0].strip() + ' - ' + C +
                              entry.split('-', 1)[1].strip())
                    elif ':' in entry:
                        print(GR + '    [+] ' +
                              entry.strip().split(':', 1)[0].strip() + ' : ' +
                              C + entry.strip().split(':', 1)[1].strip())
                    else:
                        print(C + '\n  [+] ' + entry.strip())
            print('')
            data = "HTTP :> " + str(scan_result.as_text())
            save_data(database, module, lvl1, lvl2, lvl3, name, data)

        except Exception as e:
            print(R + ' [-] Unhandled SSL Runtime Exception : ' + str(e))
            pass

    except requests.exceptions.SSLError as e:
        print(R + ' [-] Distant Server SSL not working : ' + str(e))

    print(G + ' [+] SSlScan Module Completed!' + C + color.TR2 + C)
Example #21
0
def scan0x00(target):
    try:
        from core.methods.print import pscan
        pscan("fin scan")
        #print(''+R+'\n          =================')
        #print(''+R + '           F I N   S C A N ')
        #print(''+R + '          =================')
        print(''+R + '   [Reliable only in LA Networks]\n')

        if properties["INIT"][1] == " ":
            min_port = input(C+' [§] Enter initial port :> ')
        else:
            min_port = properties["INIT"][1]
        if properties["FIN"][1] == " ":
            max_port = input(C+' [§] Enter ending port :> ')
        else:
            max_port = properties["FIN"][1]
        openfil_ports = []
        filter_ports = []
        closed_ports = []
        ip_host = socket.gethostbyname(target)

        if properties["VERBOSE"][1] == " ":
            chk = input(C+' [?] Do you want a verbose output? (enter if not) :> ')
            verbose = chk != ""
        else:
            verbose = properties["VERBOSE"][1] == "1"

        try:
            print(GR+' [*] Checking port range...')
            if int(min_port) >= 0 and int(max_port) >= 0 and int(max_port) >= int(min_port) and int(max_port) <= 65536:
                print(P+' [!] Port range detected valid...'+C)
                time.sleep(0.3)
                print(GR+' [*] Preparing for the the FIN Scan...')
                pass
            else: # If range didn't raise error, but didn't meet criteria
                print(R+"\n [!] Invalid Range of Ports")
                print(R+" [!] Exiting...")
                quit()
        except Exception: # If input range raises an error
            print(R+"\n [!] Invalid Range of Ports")
            print(R+" [!] Exiting...")
            quit()


        ports = range(int(min_port), int(max_port)+1) # Build range from given port numbers
        starting_time = time.time() # Start clock for scan time

        checkhost(ip_host) # Run checkhost() function from earlier
        print(G+" [!] Scanning initiated at " + strftime("%H:%M:%S") + "!"+C+color.TR2+C+"\n") # Confirm scan start


        prtlst = listsplit(ports, round(len(ports)/processes))
        with Pool(processes=processes) as pool:
            res = [pool.apply_async(portloop, args=(l,verbose,ip_host,)) for l in prtlst]
            #res1 = pool.apply_async(portloop, )
            for i in res:
                j = i.get()
                openfil_ports += j[0]
                closed_ports += j[1]
                filter_ports += j[2]


        print(G+"\n [!] Scanning completed at %s" %(time.strftime("%I:%M:%S %p"))+C+color.TR2+C)
        ending_time = time.time()
        total_time = ending_time - starting_time
        print(P+' [*] Preparing report...\n'+C)
        time.sleep(1)
        openports = "   {}{}{}{}{}{}{}{} ports open.".format(color.TR5,C, G, str(len(openfil_ports)), color.END, color.TR2, color.END, color.CURSIVE)
        summary("finscan", openports)
        print()
        print(P+'    +--------+------------------+')
        print(P+'    |  '+C+'PORT  '+P+'|       '+C+'STATE      '+P+'|')
        print(P+'    +--------+------------------+')

        if openfil_ports:
            for i in sorted(openfil_ports):

                c = str(i)
                if len(c) == 1:
                    print(P+'    |   '+C+c+P+'    |       '+C+'OPEN       '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(P+'    |   '+C+c+'   '+P+'|       '+C+'OPEN       '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(P+'    |  '+C+c+'   '+P+'|       '+C+'OPEN       '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(P+'    |  '+C+c+'  '+P+'|       '+C+'OPEN       '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(P+'    | '+C+c+'  '+P+'|       '+C+'OPEN       '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
            data = "Open Ports: " + str(openfil_ports)
            save_data(database, module, lvl1, lvl2, lvl3, name, data)

        if filter_ports:
            for i in sorted(filter_ports):
                c = str(i)
                if len(c) == 1:
                    print(P+'    |   '+C+c+P+'    |       '+C+'FILTERED   '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(P+'    |   '+C+c+'   '+P+'|       '+C+'FILTERED   '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(P+'    |  '+C+c+'   '+P+'|       '+C+'FILTERED   '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(P+'    |  '+C+c+'  '+P+'|       '+C+'FILTERED   '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(P+'    | '+C+c+'  '+P+'|       '+C+'FILTERED   '+P+'|')
                    print(P+'    +--------+------------------+')
                    time.sleep(0.2)
            data = "Filtered Ports: " + str(filter_ports)
            save_data(database, module, lvl1, lvl2, lvl3, name, data)
            print('')
        else:
            print(''+R+" [-] No open/filtered ports found.!!"+'')
            save_data(database, module, lvl1, lvl2, lvl3, name, "No open/filtered ports found.")
        print(B+"\n [!] " + str(len(closed_ports)) + ' closed ports not shown')
        print(G+" [+] Host %s scanned in %s seconds" %(target, total_time)+C+color.TR2+C+"\n")
    except KeyboardInterrupt:
        print(R+"\n [-] User Requested Shutdown...")
        print(" [*] Exiting...")
        quit()
Example #22
0
def search(inp):
    names = []
    descs = []

    passivenames = []
    passivedescs = []
    activenames = []
    activedescs = []
    discnames = []
    discdescs = []
    scannames = []
    scandescs = []
    portnames = []
    portdescs = []
    crawlnames = []
    crawldescs = []
    misnames = []
    misdescs = []
    brutenames = []
    brutedescs = []
    severenames = []
    severedescs = []
    sploitnames = []
    sploitdescs = []
    aidnames = []
    aiddescs = []

    def filematch(id, filenames):
        patt = '.*{}.*'.format(id)
        found = []
        for filename in filenames:
            if (re.match(patt, os.path.basename(filename))):
                found.append(filename)
        return found

    filenames = []
    foundfiles = []

    idlist = inp.split(" ")
    for filen in Path(vars.modir).glob("**/*.py"):
        filenames.append(str(filen))
    for id in idlist:
        foundfiles += filematch(id, filenames)
    for filen in filenames:
        module1 = filen.split(".py")[0]
        if os.name == 'nt':
            module2 = module1.split("modules/")[-1]
        else:
            module2 = module1.split("modules/")[-1]
        module2 = module2.replace("/", ".")
        module2 = module2.replace("\\", ".")
        module2 = "modules." + module2
        # print(module2)
        try:
            if ("__init__" not in module2 and "colors" not in module2
                    and "wafimpo" not in module2
                    and "DNSDumpsterAPI" not in module2
                    and "Form" not in module2 and "uri" not in module2
                    and "Crawler" not in module2
                    and "subdom0x00" not in module2
                    and "errorsql" not in module2 and "blindsql" not in module2
                    and "files.subdom" not in module2
                    and "fileo.subdom" not in module2
                    and "signatures" not in module2):
                module = imp.import_module(module2)
                j = module.info
                for id in idlist:
                    if id.lower() in str(j).lower():
                        if filen not in foundfiles:
                            foundfiles.append(str(filen))
        except ImportError:
            pass
    for file in foundfiles:
        if os.name == 'nt':
            list1 = file.split("\\modules\\")
        else:
            list1 = file.split("/modules/")
        if len(list1) != 2:
            print("[-] PathError. Length: {}, expected: 2".format(len(list1)))
        else:
            parsedfile = list1[1].split(".py")[0]
            parsedfile = "modules." + parsedfile
            parsedfile = parsedfile.replace("/", ".")
            parsedfile = parsedfile.replace("\\", ".")
            try:
                if ("__init__" not in parsedfile and "colors" not in parsedfile
                        and "wafimpo" not in parsedfile
                        and "DNSDumpsterAPI" not in parsedfile
                        and "Form" not in parsedfile
                        and "uri" not in parsedfile
                        and "Crawler" not in parsedfile
                        and "subdom0x00" not in parsedfile
                        and "errorsql" not in parsedfile
                        and "blindsql" not in parsedfile
                        and "files.subdom" not in parsedfile
                        and "fileo.subdom" not in parsedfile
                        and "signatures" not in parsedfile):
                    j = imp.import_module(parsedfile)
                    i = j.searchinfo
                    names.append(parsedfile.split(".")[-1])
                    descs.append(i)
                    if "ActiveRecon" in parsedfile:
                        activenames.append(parsedfile.split(".")[-1])
                        activedescs.append(i)
                    elif "PassiveRecon" in parsedfile:
                        passivenames.append(parsedfile.split(".")[-1])
                        passivedescs.append(i)
                    elif "InfoDisclose" in parsedfile:
                        discnames.append(parsedfile.split(".")[-1])
                        discdescs.append(i)
                    elif "ScanningEnumeration" in parsedfile and "0x01-PortScanning" not in parsedfile and "0x02-WebCrawling" not in parsedfile:
                        scannames.append(parsedfile.split(".")[-1])
                        scandescs.append(i)
                    elif "ScanningEnumeration" in parsedfile and "0x01-PortScanning" in parsedfile:
                        portnames.append(parsedfile.split(".")[-1])
                        portdescs.append(i)
                    elif "ScanningEnumeration" in parsedfile and "0x02-WebCrawling" in parsedfile:
                        crawlnames.append(parsedfile.split(".")[-1])
                        crawldescs.append(i)
                    elif "PassiveRecon" in parsedfile:
                        names.append(parsedfile.split(".")[-1])
                        descs.append(i)
                    elif "SploitLoot" in parsedfile:
                        sploitnames.append(parsedfile.split(".")[-1])
                        sploitdescs.append(i)
                    elif "Aid" in parsedfile:
                        aidnames.append(parsedfile.split(".")[-1])
                        aiddescs.append(i)
                    elif "VlnAnalysis.Severe" in parsedfile:
                        severenames.append(parsedfile.split(".")[-1])
                        severedescs.append(i)
                    elif "VlnAnalysis.Other" in parsedfile:
                        brutenames.append(parsedfile.split(".")[-1])
                        brutedescs.append(i)
                    elif "VlnAnalysis.Misconfig" in parsedfile:
                        misnames.append(parsedfile.split(".")[-1])
                        misdescs.append(i)
            except ImportError:
                pass

    if len(passivenames) > 0 or len(activenames) > 0 or len(discdescs) > 0:
        prnt.posint("Phase 1")
        if len(passivenames) > 0:
            cprint("OSINT/Footprinting: ", "Passive Recon")
            listdisplay(passivenames, passivedescs)
        if len(activenames) > 0:
            cprint("OSINT/Footprinting: ", "Active Recon")
            listdisplay(activenames, activedescs)
        if len(discnames) > 0:
            cprint("OSINT/Footprinting: ", "Information Disclosure")
            listdisplay(discnames, discdescs)
    if len(scannames) > 0 or len(portnames) > 0 or len(crawldescs) > 0:
        prnt.pscan("Phase 2")
        if len(scannames) > 0:
            cprint("Scanning/Enumeration: ", "General Scanning")
            listdisplay(scannames, scandescs)
        if len(portnames) > 0:
            cprint("Scanning/Enumeration: ", "Port Scanners")
            listdisplay(portnames, portdescs)
        if len(crawldescs) > 0:
            cprint("Scanning/Enumeration: ", "Web Crawlers")
            listdisplay(crawlnames, crawldescs)
    if len(severenames) > 0 or len(misnames) > 0 or len(brutedescs) > 0:
        prnt.pvln("Phase 3")
        if len(misnames) > 0:
            cprint("Vulnerability Analysis: ", "Misconfiguration")
            listdisplay(misnames, misdescs)
        if len(severenames) > 0:
            cprint("Vulnerability Analysis: ", "Severe Issues")
            listdisplay(severenames, severedescs)
        if len(brutedescs) > 0:
            cprint("Vulnerability Analysis: ", "Weak Credentials")
            listdisplay(brutenames, brutedescs)
    if len(sploitdescs) > 0:
        prnt.psploit("Phase 4")
        cprint("Exploitation: ", "Exploits")
        listdisplay(sploitnames, sploitdescs)
    if len(aidnames) > 0:
        print("\nAdditional Modules")
        listdisplay(aidnames, aiddescs)
Example #23
0
def list(arg, display, single=True):
    names = []
    descs = []
    dir = ""

    passivenames = []
    passivedescs = []
    activenames = []
    activedescs = []
    discnames = []
    discdescs = []
    scannames = []
    scandescs = []
    portnames = []
    portdescs = []
    crawlnames = []
    crawldescs = []
    misnames = []
    misdescs = []
    brutenames = []
    brutedescs = []
    severenames = []
    severedescs = []
    sploitnames = []
    sploitdescs = []
    aidnames = []
    aiddescs = []

    if arg == "all":
        dir = vars.modir
    elif arg == "aid":
        dir = vars.aidir
    elif arg == "osint-passive":
        dir = vars.pasdir
    elif arg == "osint-active":
        dir = vars.acdir
    elif arg == "scan":
        dir = vars.scadir
    elif arg == "sploit":
        dir = vars.sploidir
    elif arg == "vlnysis":
        dir = vars.vlndir
    elif arg == "infdisc":
        dir = vars.infdir
    else:
        print(catlist)
        return

    for filen in sorted(Path(dir).glob("**/*.py")):
        module1 = str(filen).split(".py")[0]
        if os.name == 'nt':
            module2 = module1.split("modules/")[-1]
        else:
            module2 = module1.split("modules/")[-1]
        module2 = module2.replace("/", ".")
        module2 = module2.replace("\\", ".")
        module2 = "modules." + module2
        try:
            if ("__init__" not in module2 and "colors" not in module2
                    and "wafimpo" not in module2
                    and "DNSDumpsterAPI" not in module2
                    and "Form" not in module2 and "uri" not in module2
                    and "Crawler" not in module2
                    and "subdom0x00" not in module2
                    and "errorsql" not in module2 and "blindsql" not in module2
                    and "files.subdom" not in module2
                    and "fileo.subdom" not in module2
                    and "signatures" not in module2):
                j = imp.import_module(module2)
                i = j.searchinfo
                #names.append(module2.split(".")[-1])
                names.append(module2)
                descs.append(i)
                if "ActiveRecon" in module2:
                    activenames.append(module2.split(".")[-1])
                    activedescs.append(i)
                elif "PassiveRecon" in module2:
                    passivenames.append(module2.split(".")[-1])
                    passivedescs.append(i)
                elif "InfoDisclose" in module2:
                    discnames.append(module2.split(".")[-1])
                    discdescs.append(i)
                elif "ScanningEnumeration" in module2 and "0x01-PortScanning" not in module2 and "0x02-WebCrawling" not in module2:
                    scannames.append(module2.split(".")[-1])
                    scandescs.append(i)
                elif "ScanningEnumeration" in module2 and "0x01-PortScanning" in module2:
                    portnames.append(module2.split(".")[-1])
                    portdescs.append(i)
                elif "ScanningEnumeration" in module2 and "0x02-WebCrawling" in module2:
                    crawlnames.append(module2.split(".")[-1])
                    crawldescs.append(i)
                elif "PassiveRecon" in module2:
                    names.append(module2.split(".")[-1])
                    descs.append(i)
                elif "SploitLoot" in module2:
                    sploitnames.append(module2.split(".")[-1])
                    sploitdescs.append(i)
                elif "Aid" in module2:
                    aidnames.append(module2.split(".")[-1])
                    aiddescs.append(i)
                elif "VlnAnalysis.Severe" in module2:
                    severenames.append(module2.split(".")[-1])
                    severedescs.append(i)
                elif "VlnAnalysis.Other" in module2:
                    brutenames.append(module2.split(".")[-1])
                    brutedescs.append(i)
                elif "VlnAnalysis.Misconfig" in module2:
                    misnames.append(module2.split(".")[-1])
                    misdescs.append(i)

        except ImportError:
            pass
    if display:
        if len(passivenames) > 0 or len(activenames) > 0 or len(discdescs) > 0:
            prnt.posint("Phase 1")
            if len(passivenames) > 0:
                cprint("OSINT/Footprinting: ", "Passive Recon")
                listdisplay(passivenames, passivedescs)
            if len(activenames) > 0:
                cprint("OSINT/Footprinting: ", "Active Recon")
                listdisplay(activenames, activedescs)
            if len(discnames) > 0:
                cprint("OSINT/Footprinting: ", "Information Disclosure")
                listdisplay(discnames, discdescs)
        if len(scannames) > 0 or len(portnames) > 0 or len(crawldescs) > 0:
            prnt.pscan("Phase 2")
            if len(scannames) > 0:
                cprint("Scanning/Enumeration: ", "General Scanning")
                listdisplay(scannames, scandescs)
            if len(portnames) > 0:
                cprint("Scanning/Enumeration: ", "Port Scanners")
                listdisplay(portnames, portdescs)
            if len(crawldescs) > 0:
                cprint("Scanning/Enumeration: ", "Web Crawlers")
                listdisplay(crawlnames, crawldescs)
        if len(severenames) > 0 or len(misnames) > 0 or len(brutedescs) > 0:
            prnt.pvln("Phase 3")
            if len(misnames) > 0:
                cprint("Vulnerability Analysis: ", "Misconfiguration")
                listdisplay(misnames, misdescs)
            if len(severenames) > 0:
                cprint("Vulnerability Analysis: ", "Severe Issues")
                listdisplay(severenames, severedescs)
            if len(brutedescs) > 0:
                cprint("Vulnerability Analysis: ", "Weak Credentials")
                listdisplay(brutenames, brutedescs)
        if len(sploitdescs) > 0:
            prnt.psploit("Phase 4")
            cprint("Exploitation: ", "Exploits")
            listdisplay(sploitnames, sploitdescs)
        if len(aidnames) > 0:
            print("\nAdditional Modules")
            listdisplay(aidnames, aiddescs)
    if single:
        return names
    else:
        return (passivenames, activenames, discnames, scannames, portnames,
                crawlnames, misnames, severenames, brutenames, sploitnames,
                aidnames)
Example #24
0
def scan0x00(target):

    try:

        #print(R+'\n    =================================')
        #print(R+'     T C P   C O N N E C T   S C A N ')
        #print(R+'    =================================\n')
        from core.methods.print import pscan
        pscan("tcp connect scan")
        if properties["INIT"][1] == " ":
            min_port = input(C + ' [§] Enter initial port :> ')
        else:
            min_port = properties["INIT"][1]
        if properties["FIN"][1] == " ":
            max_port = input(C + ' [§] Enter ending port :> ')
        else:
            max_port = properties["FIN"][1]
        open_ports = []
        closed_ports = []
        ip_host = socket.gethostbyname(target)
        if properties["VERBOSE"][1] == " ":
            chk = input(
                C + ' [?] Do you want a verbose output? (enter if not) :> ')
            verbose = chk is not ""
        else:
            verbose = properties["VERBOSE"][1] == "1"
        print(GR + ' [*] Checking port range...')
        if int(min_port) >= 0 and int(max_port) >= 0 and int(max_port) >= int(
                min_port) and int(max_port) <= 65536:
            print(P + ' [!] Port range detected valid...' + C)
            time.sleep(0.3)
            print(GR + ' [*] Preparing for the scan...')

            ports = range(int(min_port),
                          int(max_port) +
                          1)  # Build range from given port numbers
            prtlst = listsplit(ports, round(len(ports) / processes))
            starting_time = time.time()  # Start clock for scan time
            SYNACK = 0x12  # Set flag values for later reference
            RSTACK = 0x14

            checkhost(ip_host)  # Run checkhost() function from earlier
            print(G + " [!] Scanning initiated at " + strftime("%H:%M:%S") +
                  "!" + C + color.TR2 + C + "\n")  # Confirm scan start

            with Pool(processes=processes) as pool:
                res = [
                    pool.apply_async(portloop, args=(
                        l,
                        verbose,
                        ip_host,
                    )) for l in prtlst
                ]
                #res1 = pool.apply_async(portloop, )
                for i in res:
                    j = i.get()
                    open_ports += j[0]
                    closed_ports += j[1]

            print(G + "\n [!] Scanning completed at %s" %
                  (time.strftime("%I:%M:%S %p")) + C + color.TR2 + C)
            ending_time = time.time()
            total_time = ending_time - starting_time
            print(P + ' [*] Preparing report...\n' + C)
            time.sleep(1)
            openports = "   {}{}{}{}{}{}{}{} ports open.".format(
                color.TR5, C, G, str(len(open_ports)), color.END, color.TR2,
                color.END, color.CURSIVE)
            summary("tcp connect", openports)
            print()
            print(P + '    +--------+------------------+')
            print(P + '    |  ' + GR + 'PORT  ' + P + '|       ' + C +
                  'STATE      ' + P + '|')
            print(P + '    +--------+------------------+')

            if open_ports:
                for i in sorted(open_ports):

                    c = str(i)
                    if len(c) == 1:
                        print(P + '    |   ' + C + c + P + '    |       ' + C +
                              'OPEN       ' + P + '|')
                        print(P + '    +--------+------------------+')
                        time.sleep(0.2)
                    elif len(c) == 2:
                        print(P + '    |   ' + C + c + '   ' + P + '|       ' +
                              C + 'OPEN       ' + P + '|')
                        print(P + '    +--------+------------------+')
                        time.sleep(0.2)
                    elif len(c) == 3:
                        print(P + '    |  ' + C + c + '   ' + P + '|       ' +
                              C + 'OPEN       ' + P + '|')
                        print(P + '    +--------+------------------+')
                        time.sleep(0.2)
                    elif len(c) == 4:
                        print(P + '    |  ' + C + c + '  ' + P + '|       ' +
                              C + 'OPEN       ' + P + '|')
                        print(P + '    +--------+------------------+')
                        time.sleep(0.2)
                    elif len(c) == 5:
                        print(P + '    | ' + C + c + '  ' + P + '|       ' +
                              C + 'OPEN       ' + P + '|')
                        print(P + '    +--------+------------------+')
                        time.sleep(0.2)
                print('')
            else:
                print(R + ' [-] No open ports found!')

            print(B + ' [!] ' + str(len(closed_ports)) +
                  ' closed ports not shown')
            print(G + " [+] Host %s scanned in %s seconds" %
                  (target, total_time) + C + color.TR2 + C + "\n")

        else:  # If range didn't raise error, but didn't meet criteria
            print(R + "\n [!] Invalid Range of Ports")
            print(" [!] Exiting...")
            quit()
    except Exception as e:  # If input range raises an error
        print(e)
        quit()
Example #25
0
def scan0x00(host):

    #print(R+'\n   =========================')
    #print(R+'    P O R T   S C A N N E R')
    #print(R+'   =========================\n')
    from core.methods.print import pscan
    pscan("port scanner")
    print(GR + ' [*] Using most common ports...')

    ports = [
        20, 21, 23, 25, 53, 67, 68, 69, 80, 109, 110, 111, 123, 137, 143, 156,
        161, 162, 179, 389, 443, 445, 512, 513, 546, 547, 636, 993, 995, 1099,
        2121, 2049, 3306, 5432, 5900, 6000, 6667, 8080, 8180, 8443, 10000
    ]
    mlprts = listsplit(ports, round(len(ports) / processes))
    #print(mlprts)
    print(O + ' [+] Scanning %s ports...' % len(ports))
    try:
        ip = socket.gethostbyname(host)
        print(G + '\n [+] Target server detected up and running...')
        print(GR + ' [*] Preparing for scan...')
        pass
    except:
        print(R + ' [-] Server not responding...')
        time.sleep(0.3)
        print(R + ' [*] Exiting...')
        quit()

    open_ports = []
    closed_ports = []

    print(B + " [*] Scanning started at %s" % (time.strftime("%I:%M:%S %p")))
    starting_time = time.time()
    try:
        print(O + " [*] Scan in progress..")
        time.sleep(0.8)
        with Pool(processes=processes) as pool:
            res = [
                pool.apply_async(portloop, args=(
                    l,
                    host,
                )) for l in mlprts
            ]
            #res1 = pool.apply_async(portloop, )
            for i in res:
                j = i.get()
                open_ports += j[0]
                closed_ports += j[1]

        print(C + "\n [+] Scanning completed at %s" %
              (time.strftime("%I:%M:%S %p")))
        ending_time = time.time()
        total_time = ending_time - starting_time
        print(O + ' [*] Preparing report...\n')
        time.sleep(1)

        print(O + '    +--------+----------+')
        print(O + '    |  ' + GR + 'PORT  ' + O + '|  ' + GR + 'STATE   ' + O +
              '|')
        print(O + '    +--------+----------+')

        if open_ports:
            for i in sorted(open_ports):
                c = str(i)
                if len(c) == 1:
                    print(O + '    |   ' + C + c + O + '    |   ' + G +
                          'OPEN   ' + O + '|')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(O + '    |   ' + C + c + '   ' + O + '|   ' + G +
                          'OPEN   ' + O + '| ')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(O + '    |  ' + C + c + '   ' + O + '|   ' + G +
                          'OPEN   ' + O + '| ')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(O + '    |  ' + C + c + '  ' + O + '|   ' + G +
                          'OPEN   ' + O + '| ')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(O + '    | ' + C + c + '  ' + O + '|   ' + G +
                          'OPEN   ' + O + '| ')
                    print(O + '    +--------+----------+')
                    time.sleep(0.2)
        else:
            print(R + "\n [-] No open ports found.!!\n")
        print(B + '\n [!] ' + str(len(closed_ports)) +
              ' closed ports not shown')
        print(G + " [+] Host %s scanned in %s seconds\n" % (host, total_time))

    except KeyboardInterrupt:
        print(R + "\n [-] User requested shutdown... ")
        print(' [-] Exiting...\n')
        quit()
def service0x00(host):

    #print(R+'\n   ===================================')
    #print(R + "    S E R V I C E   D E T E C T I O N")
    #print(R + '   ===================================\n')
    from core.methods.print import pscan
    pscan("service detection")
    if properties["INIT"][1] == " ":
        start_port = input(C+' [§] Enter initial port :> ')
    else:
        start_port = properties["INIT"][1]
    if properties["FIN"][1] == " ":
        end_port = input(C+' [§] Enter ending port :> ')
    else:
        end_port = properties["FIN"][1]

    start_port = int(start_port)
    end_port = int(end_port)

    open_ports = []
    closed_ports = []

    try:
        ip = socket.gethostbyname(host)
        print(G+'\n [+] Target server detected up and running...'+C+color.TR2+C)
        print(O+' [*] Preparing for scan...'+C)
        pass
    except Exception:
        print(R+' [-] Server not responding...')
        time.sleep(0.3)
        print(R+' [*] Exiting...')
        quit()

    if properties["VERBOSE"][1] == " ":
        mn = input(C+'\n [?] Do you want a verbose output (enter if not) :> ')
        verbose = mn != ""
    else:
        verbose = properties["VERBOSE"][1] == "1"
    if verbose:
        print(''+P+'\n [+] Verbose mode selected !\n')
        print(GR+" [!] Scanning %s from port %s - %s: " % (host, start_port, end_port))
    print(G+" [*] Scanning started at %s" %(time.strftime("%I:%M:%S %p"))+C+color.TR2+C)
    starting_time = time.time()
    try:
        if verbose:
            print(O+" [*] Scan in progress.."+C)
            time.sleep(0.8)
        portrange = range(start_port, end_port+1)
        prtlst = listsplit(portrange, round(len(portrange)/processes))
        with Pool(processes=processes) as pool:
            res = [pool.apply_async(portloop, args=(l,host,verbose,)) for l in prtlst]
            #res1 = pool.apply_async(portloop, )
            for i in res:
                j = i.get()
                open_ports += j[0]
                closed_ports += j[1]

        print(G+"\n [+] Scanning completed at %s" %(time.strftime("%I:%M:%S %p"))+C+color.TR2+C)
        ending_time = time.time()
        total_time = ending_time - starting_time
        print(P+' [*] Preparing report...\n'+C)
        time.sleep(1)
        openports = "   {}{}{}{}{}{}{}{} ports open.".format(color.TR5,C, G, str(len(open_ports)), color.END, color.TR2, color.END, color.CURSIVE)
        summary("servicedetect", openports)
        print()

        print(P+'    +--------+----------+-----------+')
        print(P+'    |  '+C+'PORT  '+P+'|  '+C+'STATE   '+P+'|  '+C+'SERVICE  '+P+'|')
        print(P+'    +--------+----------+-----------+')

        if open_ports:
            data = "Port:Service >>\n"
            for i in sorted(open_ports):
                service = get_servicev(i)
                if not service:
                    service = "Unknown"
                m = str(service)
                c = str(i)
                data = data + "\n" + c + ":" + m
                if len(c) == 1:
                    print(P+'    |   '+C+c+P+'    |   '+C+'OPEN   '+P+'|  '+C+m+'')
                    print(P+'    +--------+----------+-----------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(P+'    |   '+C+c+'   '+P+'|   '+C+'OPEN   '+P+'|   '+C+m+'')
                    print(P+'    +--------+----------+-----------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(P+'    |  '+C+c+'   '+P+'|   '+C+'OPEN   '+P+'|   '+C+m+'')
                    print(P+'    +--------+----------+-----------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(P+'    |  '+C+c+'  '+P+'|   '+C+'OPEN   '+P+'|   '+C+m+'')
                    print(P+'    +--------+----------+-----------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(P+'    | '+C+c+'  '+P+'|   '+C+'OPEN   '+P+'|   '+C+m+'')
                    print(P+'    +--------+----------+-----------+')
                    time.sleep(0.2)
            save_data(database, module, lvl1, lvl2, lvl3, name, data)
        else:
            save_data(database, module, lvl1, lvl2, lvl3, name, "No open ports found.")
            print(R+"\n [-] No open ports found.!!\n")
        print(B+'\n [!] ' + str(len(closed_ports)) + ' closed ports not shown')
        print(G+" [+] Host %s scanned in %s seconds" %(host, total_time)+C+color.TR2+C+"\n")

    except KeyboardInterrupt:
        print(R+"\n [-] User requested shutdown... ")
        print(' [-] Exiting...\n')
        quit()
Example #27
0
def scan0x00(target):

    try:

        #print(R+'\n    =================================')
        #print(R+'     T C P   S T E A L T H   S C A N ')
        #print(R+'    =================================\n')
        from core.methods.print import pscan
        pscan("tcp stealth scan")
        if properties["INIT"][1] == " ":
            min_port = input(C + ' [§] Enter initial port :> ')
        else:
            min_port = properties["INIT"][1]
        if properties["FIN"][1] == " ":
            max_port = input(C + ' [§] Enter ending port :> ')
        else:
            max_port = properties["FIN"][1]
        open_ports = []
        closed_ports = []
        ip_host = socket.gethostbyname(target)
        if properties["VERBOSE"][1] == " ":
            chk = input(
                C + ' [?] Do you want a verbose output? (enter if not) :> ')
            verbose = chk != ""
        else:
            verbose = properties["VERBOSE"][1] == "1"

        try:
            print(GR + ' [*] Checking port range...')
            if int(min_port) >= 0 and int(max_port) >= 0 and int(
                    max_port) >= int(min_port) and int(max_port) <= 65536:
                print(P + ' [!] Port range detected valid...' + C)
                time.sleep(0.3)
                print(GR + ' [*] Preparing for the scan...')
                pass
            else:
                print(R + "\n [!] Invalid Range of Ports")
                print(" [!] Exiting...")
                quit()
        except Exception:
            print(R + "\n [!] Invalid Range of Ports")
            print(" [!] Exiting...")
            quit()

        ports = range(int(min_port), int(max_port) + 1)
        prtlst = listsplit(ports, round(len(ports) / processes))
        starting_time = time.time()
        SYNACK = 0x12
        RSTACK = 0x14

        checkhost(target)
        print(G + " [!] Scanning initiated at " + strftime("%H:%M:%S") + "!" +
              C + color.TR2 + C + "\n")  # Confirm scan start

        with Pool(processes=processes) as pool:
            res = [
                pool.apply_async(portloop, args=(
                    l,
                    verbose,
                    ip_host,
                )) for l in prtlst
            ]
            #res1 = pool.apply_async(portloop, )
            for i in res:
                j = i.get()
                open_ports += j[0]
                closed_ports += j[1]

        print(G + "\n [!] Scanning completed at %s" %
              (time.strftime("%I:%M:%S %p")) + C + color.TR2 + C)
        ending_time = time.time()
        total_time = ending_time - starting_time
        print(P + ' [*] Preparing report...\n' + C)
        time.sleep(1)
        openports = "   {}{}{}{}{}{}{}{} ports open.".format(
            color.TR5, C, G, str(len(open_ports)), color.END, color.TR2,
            color.END, color.CURSIVE)
        summary("tcp stealth", openports)
        print()
        print(P + '    +--------+------------------+')
        print(P + '    |  ' + GR + 'PORT  ' + P + '|       ' + C +
              'STATE      ' + P + '|')
        print(P + '    +--------+------------------+')
        if open_ports:

            for i in sorted(open_ports):

                c = str(i)
                if len(c) == 1:
                    print(P + '    |   ' + C + c + P + '    |       ' + C +
                          'OPEN       ' + P + '|')
                    print(P + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(P + '    |   ' + C + c + '   ' + P + '|       ' + C +
                          'OPEN       ' + P + '|')
                    print(P + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(P + '    |  ' + C + c + '   ' + P + '|       ' + C +
                          'OPEN       ' + P + '|')
                    print(P + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(P + '    |  ' + C + c + '  ' + P + '|       ' + C +
                          'OPEN       ' + P + '|')
                    print(P + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(P + '    | ' + C + c + '  ' + P + '|       ' + C +
                          'OPEN       ' + P + '|')
                    print(P + '    +--------+------------------+')
                    time.sleep(0.2)
            print('')
            data = "Open Ports: " + str(open_ports)
            save_data(database, module, lvl1, lvl2, lvl3, name, data)
        else:
            save_data(database, module, lvl1, lvl2, lvl3, name,
                      "No open ports found.")
            print('' + R + " [-] Sorry, No open ports found.!!")
        print(C + '\n [!] ' + str(len(closed_ports)) +
              ' closed ports not shown')
        print(G + " [+] Host %s scanned in %s seconds" % (target, total_time) +
              C + color.TR2 + C + "\n")

    except KeyboardInterrupt:
        print(R + "\n [-] User Requested Shutdown...")
        print(" [*] Exiting...")
        quit()
Example #28
0
def scan0x00(target):

    try:

        #print(R+'\n    =================================')
        #print(R+'     T C P   S T E A L T H   S C A N ')
        #print(R+'    =================================\n')
        from core.methods.print import pscan
        pscan("tcp stealth scan")
        if properties["INIT"][1] == " ":
            min_port = input(O + ' [#] Enter initial port :> ')
        else:
            min_port = properties["INIT"][1]
        if properties["FIN"][1] == " ":
            max_port = input(O + ' [#] Enter ending port :> ')
        else:
            max_port = properties["FIN"][1]
        open_ports = []
        closed_ports = []
        ip_host = socket.gethostbyname(target)
        if properties["VERBOSE"][1] == " ":
            chk = input(
                C + ' [#] Do you want a verbose output? (enter if not) :> ')
            verbose = chk is not ""
        else:
            verbose = properties["VERBOSE"][1] == "1"

        try:
            print(GR + ' [*] Checking port range...')
            if int(min_port) >= 0 and int(max_port) >= 0 and int(
                    max_port) >= int(min_port) and int(max_port) <= 65536:
                print('\033[1;32m [!] Port range detected valid...')
                time.sleep(0.3)
                print(GR + ' [*] Preparing for the the Scan...')
                pass
            else:
                print("\n\033[91m [!] Invalid Range of Ports")
                print(" [!] Exiting...")
                quit()
        except Exception:
            print("\n\033[91m [!] Invalid Range of Ports")
            print(" [!] Exiting...")
            quit()

        ports = range(int(min_port), int(max_port) + 1)
        prtlst = listsplit(ports, round(len(ports) / processes))
        starting_time = time.time()
        SYNACK = 0x12
        RSTACK = 0x14

        checkhost(target)
        print(O + " [*] Scanning initiated at " + strftime("%H:%M:%S") + "!\n")

        with Pool(processes=processes) as pool:
            res = [
                pool.apply_async(portloop, args=(
                    l,
                    verbose,
                    ip_host,
                )) for l in prtlst
            ]
            #res1 = pool.apply_async(portloop, )
            for i in res:
                j = i.get()
                open_ports += j[0]
                closed_ports += j[1]

        print(O + "\n [!] Scanning completed at %s" %
              (time.strftime("%I:%M:%S %p")))
        ending_time = time.time()
        total_time = ending_time - starting_time
        print(GR + ' [*] Preparing report...\n')
        time.sleep(1)
        print(O + ' ——·+-------------+')
        print(O + '    [ SCAN REPORT ]    stealthscan')
        print(O + '    +-------------+   --------------')
        print(O + '             ')
        print(O + '    +--------+------------------+')
        print(O + '    |  ' + GR + 'PORT  ' + O + '|       ' + GR +
              'STATE      ' + O + '|')
        print(O + '    +--------+------------------+')

        if open_ports:

            for i in sorted(open_ports):

                c = str(i)
                if len(c) == 1:
                    print(O + '    |   ' + C + c + O + '    |       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 2:
                    print(O + '    |   ' + C + c + '   ' + O + '|       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 3:
                    print(O + '    |  ' + C + c + '   ' + O + '|       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 4:
                    print(O + '    |  ' + C + c + '  ' + O + '|       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)
                elif len(c) == 5:
                    print(O + '    | ' + C + c + '  ' + O + '|       ' + G +
                          'OPEN       ' + O + '|')
                    print(O + '    +--------+------------------+')
                    time.sleep(0.2)

        else:
            print('' + R + " [-] Sorry, No open ports found.!!")
        print(O + '\n [!] ' + str(len(closed_ports)) +
              ' closed ports not shown')
        print(C + " [!] Host %s scanned in %s seconds" % (target, total_time))

    except KeyboardInterrupt:
        print(R + "\n [-] User Requested Shutdown...")
        print(" [*] Exiting...")
        quit()