Ejemplo n.º 1
0
def change_mac(interface: str):
    with Halo(text='Disconnecting interface') as s:
        res = subprocess.run(['sudo', 'ifconfig', interface, 'down'],
                             stdout=PIPE,
                             stderr=PIPE)
        if res.returncode:
            s.fail(res.stderr.decode('ascii'))
        else:
            s.succeed('Device {} disconnected'.format(interface))

    with Halo(text='Changing MAC address') as s:
        mac = random_mac_address()
        set_interface_mac(interface, mac)
        s.succeed('Changed MAC address to {}'.format(mac))

    with Halo(text='Connecting interface') as s:
        res = subprocess.run(['sudo', 'ifconfig', interface, 'up'],
                             stdout=PIPE,
                             stderr=PIPE)
        if res.returncode:
            s.warn(res.stderr.decode('ascii'))
        else:
            s.succeed('Device {} connected'.format(interface))

    return mac
Ejemplo n.º 2
0
 def spoof(self):
     '''
     :return: Nothing. Sets mac on interface
     '''
     self.mac = spoofmac.random_mac_address()
     spoofmac.set_interface_mac(self.interface, spoofmac.random_mac_address())
     self.log.debug('Changed mac of {} to: {}'.format(self.interface, self.mac))
Ejemplo n.º 3
0
def mac_changer_ip_getter(mac):

    #change mac address
    import spoofmac
    spoofmac.set_interface_mac("wlan0", mac)

    #aquire ip address from the router
    import os
    os.system("dhclient wlan0")

    #get the gateway
    def gate():
        import netifaces
        d = netifaces.gateways()
        for v in d.itervalues():
            if type(v) == list:
                return v[0][0]

    #Send http request to get internet
    import requests
    n_mac = mac.upper()
    url = "http://%s/login?dst=&username=T-%s" % (gate(), n_mac)
    try:
        requests.get(url)
    except requests.exceptions.ConnectionError:
        print "Please wait ...\nReconnecting..."
        os.system('ifconfig wlan0 down')
        os.system('ifconfig wlan0 up')
Ejemplo n.º 4
0
def client():
    parser = ArgumentParser()
    parser.add_argument('iface', metavar='interface', type=str)
    parser.add_argument('-p', '--port', metavar='PORT', type=int, default=8888, dest='port')
    parser.add_argument('--host', metavar='PORT', type=str, dest='host')
    args = parser.parse_args()

    elevate(graphical=False)

    while True:
        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
            sock.connect((args.host, args.port))
            print('⭘ Connected to {}:{}'.format(args.host, args.port))
            mac = sock.recv(17).decode('ascii')
            time_left = int(sock.recv(10).decode('ascii'))
            print('⭘ Received pass for MAC', mac)

            set_interface_mac(args.iface, mac)

        with Halo(spinner='clock') as s:
            for i in reversed(range(time_left)):
                s.text = 'Waiting {}m {}s until next pass... [q]uit | [r]efresh'.format(int(i / 60), i % 60)
                rlist, _, _ = select([sys.stdin], [], [], 0)
                if rlist:
                    key = sys.stdin.readline()[0]
                    if key == 'q':
                        return
                    elif key == 'r':
                        break
                    else:
                        s.text = 'Command not recognized: {}'.format(key)

                time.sleep(1)
Ejemplo n.º 5
0
def revert_mac_addresses():
    print_and_log("* trying to revert mac addresses back to default *", "info")

    with open(current_dir + os.sep + "logs" + os.sep + "interfaces",
              "r") as file:
        for line in file:
            line = line.strip()
            splitted = line.split()
            interface = splitted[0]
            mac = splitted[1]
            spoofmac.set_interface_mac(interface, mac)

    print_and_log("* mac addresses were reverted to default *", "info")
Ejemplo n.º 6
0
def spoof_mac_addresses():
    print_and_log("* trying to spoof mac address *", "info")
    interfaces_gen = spoofmac.find_interfaces()
    found_interfaces = []
    for interface in interfaces_gen:
        found_interfaces.append(interface)

    vmware_mac = "00:0c:29:"
    for interface in found_interfaces:
        splitted = interface[2].split(":")[3:]
        mac = ":".join(splitted)
        mac = vmware_mac + mac
        spoofmac.set_interface_mac(interface[1], mac)

    with open(current_dir + os.sep + "logs" + os.sep + "interfaces",
              "w") as file:
        for interface in interfaces_gen:
            file.write(interface[1] + " " + interface[2] + "\n")

    print_and_log("* mac address spoofed successfully *", "info")