wificurse

wifi jamming tool
git clone git://git.2f30.org/wificurse.git
Log | Files | Refs | README | LICENSE

commit 9b7d18fa2111607ef1392cee18e4a8a1b12640fb
parent 54d4e1d66f3dd1c37faaa4909aeb77798a86a02a
Author: oblique <psyberbits@gmail.com>
Date:   Fri Mar  2 23:07:23 +0200

add iw_can_change_channel, fix a bug in channel changing

Diffstat:
README | 5++---
patches/cfg80211_monitor_mode_channel_-1_fix.patch | 14--------------
patches/cfg80211_monitor_mode_channel_fix.patch | 14++++++++++++++
wificurse.c | 36+++++++++++++++++++++++++++++++++---
4 files changed, 49 insertions(+), 20 deletions(-)
diff --git a/README b/README @@ -8,10 +8,10 @@ purposes only. It works only in Linux and requires wireless card drivers capable of injecting packets in wireless networks. If your Linux kernel is version 2.6.35 or above, you have to -apply the patch patches/cfg80211_monitor_mode_channel_-1_fix.patch +apply the patch patches/cfg80211_monitor_mode_channel_fix.patch to the kernel. How to use it: Just run it as root and put as first argument the card interface. It will put your interface in monitor mode automatically, it will start DoSing and change channel every 3 seconds. The channel -range is 1 - 13.- \ No newline at end of file +range is 1 - 13. diff --git a/patches/cfg80211_monitor_mode_channel_-1_fix.patch b/patches/cfg80211_monitor_mode_channel_-1_fix.patch @@ -1,14 +0,0 @@ -diff --git a/net/wireless/chan.c b/net/wireless/chan.c -index 2fcfe09..3f63fae 100644 ---- a/net/wireless/chan.c -+++ b/net/wireless/chan.c -@@ -85,9 +85,6 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev, - struct ieee80211_channel *chan; - int result; - -- if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR) -- wdev = NULL; -- - if (wdev) { - ASSERT_WDEV_LOCK(wdev); - diff --git a/patches/cfg80211_monitor_mode_channel_fix.patch b/patches/cfg80211_monitor_mode_channel_fix.patch @@ -0,0 +1,14 @@ +diff --git a/net/wireless/chan.c b/net/wireless/chan.c +index 2fcfe09..3f63fae 100644 +--- a/net/wireless/chan.c ++++ b/net/wireless/chan.c +@@ -85,9 +85,6 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev, + struct ieee80211_channel *chan; + int result; + +- if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR) +- wdev = NULL; +- + if (wdev) { + ASSERT_WDEV_LOCK(wdev); + diff --git a/wificurse.c b/wificurse.c @@ -176,6 +176,25 @@ ssize_t iw_read(int fd, void *buf, size_t count, uint8_t **pkt, size_t *pkt_sz) return r; } +int iw_can_change_channel(struct dev *dev) { + struct iwreq iwr; + ssize_t ret; + + /* set channel */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev->ifname, sizeof(iwr.ifr_name)-1); + iwr.u.freq.flags = IW_FREQ_FIXED; + iwr.u.freq.m = 1; + + if (ioctl(dev->fd, SIOCSIWFREQ, &iwr) < 0) + return 0; + if (ioctl(dev->fd, SIOCGIWFREQ, &iwr) < 0) + return 0; + + /* channel 1 frequency is 2412 */ + return iwr.u.freq.m == 2412; +} + int iw_set_channel(struct dev *dev, int chan) { struct iwreq iwr; ssize_t ret; @@ -311,6 +330,13 @@ int main(int argc, char *argv[]) { goto _errout; } + if (!iw_can_change_channel(&dev)) { + fprintf(stderr, "%s cannot change channels in monitor mode.\n" + "Maybe you will need to patch your kernel with:\n" + " patches/cfg80211_monitor_mode_channel_fix.patch\n", dev.ifname); + goto _errout; + } + pfd[1].fd = dev.fd; pfd[1].revents = 0; pfd[1].events = POLLIN; @@ -351,15 +377,19 @@ int main(int argc, char *argv[]) { /* change channel every 3 seconds */ if (time(NULL) - tm1 >= 3) { - chan = (chan % 13) + 1; - if (iw_set_channel(&dev, chan) < 0) { + int n = 0; + do { + chan = (chan % 13) + 1; + ret = iw_set_channel(&dev, chan); + /* if fails try next channel */ + } while(++n < 13 && ret < 0); + if (ret < 0) { print_error(); goto _errout; } printf("Channel: %d\n", dev.chan); tm1 = time(NULL); } - } printf("\nExiting..\n");