Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Change Interface Channel

I am writing a Python program that sends raw 802.11x packets. I would like to change the channel of the monitor interface multiple times throughout the program. I am using the Scapy library. Is there a way that I can do this without running a shell command like iwconfig?

If there are multiple ways which is the best?

like image 237
735Tesla Avatar asked Jan 13 '14 00:01

735Tesla


2 Answers

A year and a half too late (and possibly a shameless plug for my project) but I ran into the same problem as you. I got tired of searching/waiting for a native solution and decided to code my own - the source is on github at https://github.com/wraith-wireless/PyRIC/ check out the function chset in pyw.py. I am currently on version 1.1 which you can install via pip.

like image 62
WraithWireless Avatar answered Oct 19 '22 20:10

WraithWireless


I am assuming you want to do this all on a Linux system based on you mentioning iwconfig.

Looking at the Linux Kernel Wireless documentation the only complete (as in not under development) way to interact with the wireless interfaces making changes to the modes and channels is through two command line utilities, iwconfig that you mentioned and the new iw. The command line utility iw is replacing iwconfig with many changes.

The iwlib library is what you need to interface with, whether through iw or a Python module like python-iwlib.

The Python iwlib module is not complete and at this time does not provide the functionality you need. It can only tell you about the current configuration of the wireless interfaces.

The only other utility which you might consider using is airmon-ng. This utility interfaces with the previously mentioned command line tools, requiring you to call the shell commands.

Apologies for not being able to provide you with a complete solution. Perhaps you have the cycles to improve the python-iwlib module, since that seems to be your best bet if you are looking at not using shell commands.

like image 43
RyPeck Avatar answered Oct 19 '22 19:10

RyPeck