예제 #1
0
def scan_ports(host, from_port, to_port, sig):
    if is_connection_ok():
        ip_res = get_ip(host)

        if ip_res == 'INVALID_HOST_NAME':
            return 'INVALID_HOST_NAME'
        else:
            if from_port <= to_port:

                for port in range(from_port, to_port):
                    client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    client.settimeout(1)

                    print(give_color(' Scanning PORT {}'.format(port), 'cyan'))

                    result = client.connect_ex((ip_res, port))
                    if result == 0:
                        print(
                            give_color('PORT {} is open'.format(port), 'cyan'))
                    client.close()
                    if sig.kill:
                        #print('killll')
                        break
                return "DONE"

    else:
        return 'CONNECTION_NOT_FOUND'
예제 #2
0
파일: main.py 프로젝트: telkomdev/keris
    def scan():
        host = input(
            give_color('input target domain [eg: www.example.com]:', 'red'))

        if len(host) <= 0:
            print(give_color('invalid host', 'red'))
            return

        if not common.is_valid_url(host):
            print(give_color('invalid host', 'red'))
            return

        from_port = input(give_color('from port [eg: 8000]:', 'red'))
        if (not from_port.isdigit()):
            print(give_color('invalid port number', 'red'))
            return

        to_port = input(give_color('to port [eg: 9000]:', 'red'))
        if (not to_port.isdigit()):
            print(give_color('invalid port number', 'red'))
            return

        result = scan_ports(host, int(from_port), int(to_port), sig)
        if (result != "DONE"):
            print(give_color('error {}'.format(result), 'red'))
            return
예제 #3
0
파일: main.py 프로젝트: telkomdev/keris
def menu_whois():
    host = input(
        give_color('input target domain [eg: www.example.com]:', 'red'))
    if len(host) <= 0:
        print(give_color('invalid host', 'red'))
        return

    if not common.is_valid_url(host):
        print(give_color('invalid host', 'red'))
        return

    lines = common.who_is(host)
    for line in lines:
        print(line)
예제 #4
0
파일: main.py 프로젝트: telkomdev/keris
def main_menu():
    for menu in menus:
        print('[' + give_color(str(menus.index(menu)), 'red') + '] ' +
              list(menu.keys())[0])
예제 #5
0
파일: main.py 프로젝트: telkomdev/keris
def manu_exit():
    print(give_color('bye..', 'cyan'))
    sys.exit(0)
예제 #6
0
파일: main.py 프로젝트: telkomdev/keris
def menu_ssh():
    host = input(
        give_color('input target domain for brute ssh [eg: www.example.com]: ',
                   'red'))
예제 #7
0
파일: main.py 프로젝트: telkomdev/keris
menus = [{
    'show whois data': menu_whois
}, {
    'brute ssh': menu_ssh
}, {
    'port scanner': menu_port_scanner(sig)
}, {
    'exit': manu_exit
}]


def main_menu():
    for menu in menus:
        print('[' + give_color(str(menus.index(menu)), 'red') + '] ' +
              list(menu.keys())[0])


if __name__ == '__main__':
    while True:
        print(give_color(BANNER, 'red'))
        main_menu()

        choice = input('>> ')
        try:
            if int(choice) < 0: raise ValueError

            menu = menus[int(choice)]
            list(menu.values())[0]()
        except (ValueError, IndexError):
            main_menu()