Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #39667
    Peter Queen
    Participant

    Hello,

    After the lesson MAC changer I was practicing and I try to code the setting of wireless adapter in monitor mode. If I run it I get the error bufsize must be an integer.

    Can you help?
    Thanks

    #!/usr/bin/env python
    
    import subprocess
    import optparse
    
    def get_arguments():
        parser = optparse.OptionParser()
        parser.add_option("-i", "--interface", dest="interface", help="Interface to change to monitor mode")
        (options, arguments) = parser.parse_args()
        if not options.interface:
            parser.error("[-] Please specify an interface, use --help for info")
        return options
    
    def monitor_mode(interface):
        print("Setting {} to monitor mode".format(interface))
        subprocess.call("ifconfig", interface, "down")
        subprocess.call("iwconfig", interface, "mode", "monitor")
        subprocess.call("ifconfig", interface, "up")
    
    options = get_arguments()
    monitor_mode(options.interface)
    #39736
    Diego PérezDiego Pérez
    Participant

    Hi Simo!
    Can you share a screenshot of the error so I can see the full traceback?

    Let me know.
    Diego

    #39753
    Peter Queen
    Participant

    .

    #39763
    Peter Queen
    Participant

    file:///root/Pictures/Screenshot%20from%202020-06-11%2006-18-59.png

    #39765
    Peter Queen
    Participant

    root@kali:~/PycharmProjects/mac_changer# ls
    mac_changer.py set_monitor_mode.py venv
    root@kali:~/PycharmProjects/mac_changer# python set_monitor_mode.py
    Usage: set_monitor_mode.py [options]

    set_monitor_mode.py: error: [-] Please specify an interface, use –help for info
    root@kali:~/PycharmProjects/mac_changer# python set_monitor_mode.py -i wlan0
    Setting wlan0 to monitor mode
    Traceback (most recent call last):
    File “set_monitor_mode.py”, line 20, in <module>
    monitor_mode(options.interface)
    File “set_monitor_mode.py”, line 14, in monitor_mode
    subprocess.call(“ifconfig”, interface, “down”)
    File “/usr/lib/python2.7/subprocess.py”, line 172, in call
    return Popen(*popenargs, **kwargs).wait()
    File “/usr/lib/python2.7/subprocess.py”, line 343, in __init__
    raise TypeError(“bufsize must be an integer”)
    TypeError: bufsize must be an integer

    #39840
    Diego PérezDiego Pérez
    Participant

    Hi Simo!

    If you want to use that synthax with subprocess you have to use square brackets as well. Like:
    subprocess.call([“ifconfig”, interface, “down”])

    Let me know how it goes!
    Diego

    #39856
    Peter Queen
    Participant

    Thanks Diego,

    It works perfectly!

    #39908
    Diego PérezDiego Pérez
    Participant

    Hi Simo!

    Cool you got it!
    Diego

Viewing 8 posts - 1 through 8 (of 8 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.