Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import re
- import optparse
- def get_arguments():
- parser = optparse.OptionParser()
- parser.add_option('-i', '--interface', dest='interface', help="--help for more info")
- parser.add_option('-m', '--mac', dest='new_mac', help="--help for more info")
- (options, arguments) = parser.parse_args()
- return options
- def change_mac(interface, new_mac):
- subprocess.call(['ifconfig', options.interface, 'down'])
- subprocess.call(['ifconfig', options.interface, 'hw', 'ether', options.new_mac])
- subprocess.call(['ifconfig', options.interface, 'up'])
- def get_current_mac(interface):
- ifconfig_result = subprocess.check_output(['ifconfig', interface])
- mac_address_result = re.search(r'\w\w:\w\w:\w\w:\w\w:\w\w:\w\w', ifconfig_result)
- if mac_address_result:
- return mac_address_result.group(0)
- else:
- print('[-] Could not find MAC address')
- options = get_arguments()
- current_mac = get_current_mac(options.interface)
- change_mac(options.interface, options.new_mac)
- print(get_current_mac(options.interface))
- print('Your new mac address is {}'.format(current_mac))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement