Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #36348
    Jay2thaworld
    Participant

    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…

    #36353
    Jay2thaworld
    Participant

    This 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)

    #36392
    Diego PérezDiego Pérez
    Participant

    Hi Jay!
    This looks like a syntax error.
    Can you share your code please?

    Thanks!
    Diego

    #39024
    Bornrich
    Participant

    `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 optparse

    def 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’

    #39095
    Diego PérezDiego Pérez
    Participant

    Hi!
    You are missing a comma between “hw” and “ether”.

    Change it and let me know how it goes!
    Diego

    #39120
    Bornrich
    Participant

    Thank you. I got it to work.

    #39173
    Diego PérezDiego Pérez
    Participant

    Hi!
    Cool you got it!
    Diego

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Privacy Overview
ZSecurity logo featuring a stylized red letter Z

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

3rd Party Cookies

This website uses Google Analytics and Linkedin to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping these cookies enabled helps us to improve our website.