- This topic has 7 replies, 2 voices, and was last updated 4 years, 6 months ago by Diego Pérez.
- AuthorPosts
- June 11, 2020 at 11:53 am #39667Peter QueenParticipant
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)
June 12, 2020 at 4:56 am #39736Diego PérezModeratorHi Simo!
Can you share a screenshot of the error so I can see the full traceback?Let me know.
DiegoJune 12, 2020 at 9:38 am #39753Peter QueenParticipant.
June 12, 2020 at 11:48 am #39763Peter QueenParticipantfile:///root/Pictures/Screenshot%20from%202020-06-11%2006-18-59.png
June 12, 2020 at 12:19 pm #39765Peter QueenParticipantroot@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 integerJune 13, 2020 at 4:13 am #39840Diego PérezModeratorHi 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!
DiegoJune 13, 2020 at 8:56 am #39856Peter QueenParticipantThanks Diego,
It works perfectly!
June 14, 2020 at 5:21 am #39908Diego PérezModeratorHi Simo!
Cool you got it!
Diego - AuthorPosts
- You must be logged in to reply to this topic.