- This topic has 6 replies, 3 voices, and was last updated 4 years, 6 months ago by Diego Pérez.
- AuthorPosts
- May 9, 2020 at 7:20 pm #36348Jay2thaworldParticipant
Hello,
I was following along with writing variables, when I updated the new mac address variable and ran the script to assign, I can see that the print displayed the correct new mac address, but it did not update.
I ran the process manually in terminator and got a message stating “Cannot assign requested address”.
I’ve tried a few different strings with no results. Any idea why this is happening?
After the first initial change it will not let me change it again…
May 9, 2020 at 8:10 pm #36353Jay2thaworldParticipantThis is the message that displays:
/root/PycharmProjects/hello/venv/bin/python /root/PycharmProjects/hello/mac_changer.py
interface > eth0
new_mac > 00:11:22:33:44:55
[+] Changing MAC Address for eth0 to 00:11:22:33:44:55
Usage:
ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
[add <address>[/<prefixlen>]]
[del <address>[/<prefixlen>]]
[[-]broadcast [<address>]] [[-]pointopoint [<address>]]
[netmask <address>] [dstaddr <address>] [tunnel <address>]
[outfill <NN>] [keepalive <NN>]
[hw <HW> <address>] [mtu <NN>]
[[-]trailers] [[-]arp] [[-]allmulti]
[multicast] [[-]promisc]
[mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]
[txqueuelen <NN>]
[[-]dynamic]
[up|down] …<HW>=Hardware Type.
List of possible hardware types:
loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP)
slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP)
ash (Ash) ether (Ethernet) ax25 (AMPR AX.25)
netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel)
ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB)
arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device)
sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI)
irda (IrLAP) ec (Econet) x25 (generic X.25)
eui64 (Generic EUI-64)
<AF>=Address family. Default: inet
List of possible address families:
unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6)
ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE)
ipx (Novell IPX) ddp (Appletalk DDP) ec (Econet)
ash (Ash) x25 (CCITT X.25)May 10, 2020 at 6:29 am #36392Diego PérezModeratorHi Jay!
This looks like a syntax error.
Can you share your code please?Thanks!
DiegoJune 4, 2020 at 1:07 pm #39024BornrichParticipant`There should be a new tutorial for python 3 because it’s really head scratching trying to figure out things ourselves online. I ran this code exactly as it was taught in the tutoring but it’s giving me error.the error is at the bottom.
#!/usr/bin/env python
import subprocess
import optparsedef get_argument():
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” )
return parser.parse_args()def change_mac():
print(“[+] Changing Mac address for” + interface + “to” + new_mac)
subprocess.call([“ifconfig”, interface, “down”])
subprocess.call([“ifconfig”, interface, “hw” “ether”, new_mac])
subprocess.call([“ifconfig”, interface, “up”])(options, arguments) = get_argument()
change_mac(options.interface, options.new_mac)Traceback (most recent call last):
File “main.py”, line 20, in <module>
change_mac(options.interface, options.new_mac)
AttributeError: Values instance has no attribute ‘new_mac’June 5, 2020 at 5:22 am #39095Diego PérezModeratorHi!
You are missing a comma between “hw” and “ether”.Change it and let me know how it goes!
DiegoJune 5, 2020 at 11:18 am #39120BornrichParticipantThank you. I got it to work.
June 6, 2020 at 4:27 am #39173Diego PérezModeratorHi!
Cool you got it!
Diego - AuthorPosts
- You must be logged in to reply to this topic.