示例#1
0
def test_print():
    timer = 1
    timer *= 3600
    threading.Timer(timer, test_print).start()
    target_mac = random_mac_address('randomize')
    set_interface_mac('Ethernet', target_mac)
    print "IP changing"
示例#2
0
def main(args, root_or_admin):
    spoofer = None

    try:
        spoofer = get_os_spoofer()
    except NotImplementedError:
        return UNSUPPORTED_PLATFORM

    if args['list']:
        list_interfaces(args, spoofer)
    elif args['randomize'] or args['set'] or args['reset']:
        for target in args['<devices>']:
            # Fill out the details for `target`, which could be a Hardware
            # Port or a literal device.
            #print("Debuf:",target)
            result = find_interface(target)
            if result is None:
                print('- couldn\'t find the device for {target}'.format(
                    target=target
                ))
                return INVALID_TARGET

            port, device, address, current_address = result
            if args['randomize']:
                target_mac = random_mac_address(args['--local'])
            elif args['set']:
                target_mac = args['<mac>']
            elif args['reset']:
                if address is None:
                    print('- {target} missing hardware MAC'.format(
                        target=target
                    ))
                    continue
                target_mac = address

            if not MAC_ADDRESS_R.match(target_mac):
                print('- {mac} is not a valid MAC address'.format(
                    mac=target_mac
                ))
                return INVALID_MAC_ADDR

            if not root_or_admin:
                if sys.platform == 'win32':
                    print('Error: Must run this with administrative privileges to set MAC addresses')
                    return NON_ROOT_USER
                else:
                    print('Error: Must run this as root (or with sudo) to set MAC addresses')
                    return NON_ROOT_USER

            set_interface_mac(device, target_mac, port)
    elif args['normalize']:
        print(normalize_mac_address(args['<mac>']))

    else:
        print('Error: Invalid arguments - check help usage')
        return INVALID_ARGS

    del spoofer

    return SUCCESS
示例#3
0
def fakemac(target='eth0'):
    root = os.geteuid() == 0
    if root:
        port, device, _, mac = find_interface(target)
        target_mac = random_mac_address()
        set_interface_mac(device, target_mac, port)
        print('{0} mac changed {1} -> {2}'.format(target, mac, target_mac))
    else:
        print('no mac changed')
示例#4
0
def fakemac(target='eth0'):
    root = os.geteuid() == 0
    if root:
        port, device, _, mac = find_interface(target)
        target_mac = random_mac_address()
        set_interface_mac(device, target_mac, port)
        print('{0} mac changed {1} -> {2}'.format(target, mac, target_mac))
    else:
        print('no mac changed')
示例#5
0
    def changemac(self, widget):
        global tmac
        print "change mac"
        try:
            root_or_admin = os.geteuid() == 0
        except AttributeError:
            root_or_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0

        spoofer = None

        try:
            spoofer = get_os_spoofer()
        except NotImplementedError:
            return UNSUPPORTED_PLATFORM
        result = find_interface(self.entry.entry.get_text())
        if result is None:
            print('- couldn\'t find the device for {target}'.format(
                target=target))
            self.statelbl.set_text("Couldn't find device ")
            return INVALID_TARGET

        port, device, address, current_address = result
        target_mac = tmac
        if int(target_mac[1], 16) % 2:
            self.statelbl.set_text("It's Multicast Address")
            print(
                'Warning: The address you supplied is a multicast address and thus can not be used as a host address.'
            )

        if not MAC_ADDRESS_R.match(target_mac):
            print('- {mac} is not a valid MAC address'.format(mac=target_mac))
            return INVALID_MAC_ADDR
        if not root_or_admin:
            if sys.platform == 'win32':
                print(
                    'Error: Must run this with administrative privileges to set MAC addresses'
                )
                self.statelbl.set_text("You Need to run as admin")
                return NON_ROOT_USER
            else:
                print(
                    'Error: Must run this as root (or with sudo) to set MAC addresses'
                )
                self.statelbl.set_text("You Need to run as root")
                return NON_ROOT_USER
        asd = set_interface_mac(device, target_mac, port)
        time.sleep(10)
        self.statelbl.set_text("Mac Spoofed")
        self.getifinfo(widget)
        if checkcon():
            intsp = getintspeed()
            self.intsplbl.set_text("Download rate :" + intsp[0] +
                                   "Upload rate :" + intsp[1])
        else:
            self.intsplbl.set_text("No Internet Connection")
示例#6
0
def main(args, root_or_admin):
    spoofer = None

    try:
        spoofer = get_os_spoofer()
    except NotImplementedError:
        return UNSUPPORTED_PLATFORM

    if args['list']:
        list_interfaces(args, spoofer)
    elif args['randomize'] or args['set'] or args['reset']:
        for target in args['<devices>']:
            # Fill out the details for `target`, which could be a Hardware
            # Port or a literal device.
            #print("Debuf:",target)
            result = find_interface(target)
            if result is None:
                print('- couldn\'t find the device for {target}'.format(
                    target=target))
                return INVALID_TARGET

            port, device, address, current_address = result
            if args['randomize']:
                target_mac = random_mac_address(args['--local'])
            elif args['set']:
                target_mac = args['<mac>']
                if int(target_mac[1], 16) % 2:
                    print(
                        'Warning: The address you supplied is a multicast address and thus can not be used as a host address.'
                    )
            elif args['reset']:
                if address is None:
                    print('- {target} missing hardware MAC'.format(
                        target=target))
                    continue
                target_mac = address

            if not MAC_ADDRESS_R.match(target_mac):
                print('- {mac} is not a valid MAC address'.format(
                    mac=target_mac))
                return INVALID_MAC_ADDR

            if not root_or_admin:
                if sys.platform == 'win32':
                    print(
                        'Error: Must run this with administrative privileges to set MAC addresses'
                    )
                    return NON_ROOT_USER
                else:
                    print(
                        'Error: Must run this as root (or with sudo) to set MAC addresses'
                    )
                    return NON_ROOT_USER

            set_interface_mac(device, target_mac, port)
    elif args['normalize']:
        print(normalize_mac_address(args['<mac>']))

    else:
        print('Error: Invalid arguments - check help usage')
        return INVALID_ARGS

    del spoofer

    return SUCCESS
示例#7
0
def main(args, root_or_admin):
    spoofer = None

    try:
        spoofer = get_os_spoofer()
    except NotImplementedError:
        return UNSUPPORTED_PLATFORM

    if args['list']:
        list_interfaces(args, spoofer)
    elif args['randomize'] or args['set'] or args['reset']:
        for target in args['<devices>']:
            # Fill out the details for `target`, which could be a Hardware
            # Port or a literal device.
            #print("Debuf:",target)
            result = find_interface(target)
            if result is None:
                print('- couldn\'t find the device for {target}'.format(
                    target=target))
                return INVALID_TARGET

            port, device, address, current_address = result
            if args['randomize']:
                target_mac = random_mac_address(args['--local'])
            elif args['set']:
                target_mac = args['<mac>']
                if int(target_mac[1], 16) % 2:
                    print(
                        'Warning: The address you supplied is a multicast address and thus can not be used as a host address.'
                    )
            elif args['reset']:
                if address is None:
                    print('- {target} missing hardware MAC'.format(
                        target=target))
                    continue
                target_mac = address

            if not MAC_ADDRESS_R.match(target_mac):
                print('- {mac} is not a valid MAC address'.format(
                    mac=target_mac))
                return INVALID_MAC_ADDR

            if not root_or_admin:
                if sys.platform == 'win32':
                    print(
                        'Error: Must run this with administrative privileges to set MAC addresses'
                    )
                    return NON_ROOT_USER
                else:
                    print(
                        'Error: Must run this as root (or with sudo) to set MAC addresses'
                    )
                    return NON_ROOT_USER

            # Expand acceptable input MAC is displayed with atleast the
            # following (-: )
            p = re.compile('[^0-9A-Z]')
            target_mac = p.sub(':', target_mac.upper())
            (prt, dev, addr, cur_addr) = spoofer.find_interface(device)
            etime = time.strftime('%X')

            if target_mac != cur_addr:
                set_interface_mac(device, target_mac, prt)
                print etime + " " + port + " [" + device + "] set to " + target_mac
            else:
                if args['--force']:
                    set_interface_mac(device, target_mac, prt)
                    print etime + " " + prt + " [" + device + "] forced to " + target_mac
                elif '--maintain' not in args:
                    print(
                        'Error: Already the current MAC addresses, use --force to force the address again'
                    )
                    # return EXISTING_MAC_ADDR
            if args['--maintain']:
                sys.stdout.write("\r" + etime + " " + prt + " [" + device +
                                 "] " + cur_addr)
                sys.stdout.flush()

    elif args['normalize']:
        print(normalize_mac_address(args['<mac>']))

    else:
        print('Error: Invalid arguments - check help usage')
        return INVALID_ARGS

    del spoofer

    return SUCCESS
示例#8
0
from spoofmac.util import random_mac_address
from spoofmac.interface import set_interface_mac

target_mac = random_mac_address('randomize')
set_interface_mac('Ethernet', target_mac)