код
import optparse
import subprocess
import re
def get_arguments():
parser = optparse.OptionParser()
parser.add_option('-i', '--interface', dest='interface', help='Interface to change its MAC address')
parser.add_option('-m', '--mac', dest='new_mac', help='New MAC address')
(options, argument) = parser.parse_args()
if not options.interface:
parser.error('[-] ispolzyw --help dla more info')
elif not options.new_mac:
parser.error('[-] ispolzyw --help dla more info')
return options
def change_mac(interface, new_mac):
print('[+] You pomenal MAC address for' + interface + ' na ' + new_mac)
[subprocess.call](http://subprocess.call)(['ifconfig', interface, 'down'])
[subprocess.call](http://subprocess.call)(['ifconfig', interface, 'hw', 'ether', new_mac])
[subprocess.call](http://subprocess.call)(['ifconfig', interface, 'up'])
options = get_arguments()
ifconfig_res = subprocess.check_output(['ifconfig', options.interface])
print(ifconfig_res)
mac_address_res = [re.search](http://re.search)(r'\w\w:\w\w:\w\w:\w\w:\w\w:\w\w', ifconfig_res)
print(mac_address_res.group(0))
ошыбка
Traceback (most recent call last):
File "/home/kali/project/hacerrr/hacyr.py", line 25, in <module>
mac_address_res = [re.search](http://re.search)(r'\w\w:\w\w:\w\w:\w\w:\w\w:\w\w', ifconfig_res)
File "/usr/lib/python3.9/re.py", line 201, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object