Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Getting RTL8188 to work with Kali in monitor mode

  1. #1
    Junior Member
    Join Date
    Sep 2017
    Posts
    3

    Getting RTL8188 to work with Kali in monitor mode

    tldr: RTL8188 now works in Kali 2017.2 with monitor mode support. "Some assembly required" (although not that kind of assembly)

    The Realtek RTL8188EU(S) chipset is featured in quite a few USB WiFi adapters, including the TP LINK TL-WN722N v2 (but not v1). Until recently, this chipset has not worked well with Kali, but a solution for older kernels was posted on github a while back:

    https://github.com/mfruba/kernel

    Unfortunately, this solution only works on kernel version 4.9 and 4.10 (and possibly 4.11), whereas the latest Kali (2017.2) uses the 4.12 kernel.

    I have now managed to get that driver compiled and running on the 4.12 kernel and can confirm that monitor mode absolutely works. In order to do so, two source files must be changed, but it really isn't difficult for anyone who knows their way around an editor.

    Please note that the code snippets below aren't original. They were pretty much pulled straight from other github Realtek WiFi driver projects after going sifting through their bug fixes for kernel 4.12 related issues (several projects with more or less identical changes, seemingly independent). Attribution: https://patchwork.kernel.org/patch/9714419/

    Don't be discouraged by the superficial complexity. This really is only a matter of changing a few lines of code and typing in a handful of commands in the terminal. If there are any questions, please ask and I'll do my best to help.

    Steps to get RTL8188EUS working on linux kernel 4.12

    1. Download source from https://github.com/mfruba/kernel and cd to kernel-master/drivers/TL-WN722N_v2.0-Ralink/rtl8188EUS_linux_v4.3.0.8_13968.20150417

    2. Install kernel headers (if you don't, you'll get the errors paladin gets above)
    Code:
    # apt-get install linux-headers-amd64
    3. MODIFY CODE for 4.12 kernel. This may sound intimidating, but in reality it consists of just a few lines in two files (use whatever editor you wish):
    Makefile --> Add the following line somewhere among the other EXTRA_CFLAGS
    (Or patch with this diff: Makefile.diff.txt)
    Code:
    EXTRA_CFLAGS += -Wno-incompatible-pointer-types
    os_dep/linux/ioctl_cfg80211.c --> Find the section that starts with:
    (Or patch with this diff: ioctl_cfg80211.diff.txt)
    Code:
    if (rtw_to_roam(padapter) > 0) {
    (line 854)
    and ADD the following line of code
    Code:
    struct cfg80211_roam_info roam_info = {};
    (good practice would be to add it among the other definitions, so e.g. after the u16 channel = .... line)
    finally, a bit of code a few lines further down in the same file needs to be replaced.
    DELETE (or comment out) the following lines of code:
    Code:
    cfg80211_roamed(padapter->pnetdev
    			#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39) || defined(COMPAT_KERNEL_RELEASE)
    			, notify_channel
    			#endif
    			, cur_network->network.MacAddress
    			, pmlmepriv->assoc_req+sizeof(struct rtw_ieee80211_hdr_3addr)+2
    			, pmlmepriv->assoc_req_len-sizeof(struct rtw_ieee80211_hdr_3addr)-2
    			, pmlmepriv->assoc_rsp+sizeof(struct rtw_ieee80211_hdr_3addr)+6
    			, pmlmepriv->assoc_rsp_len-sizeof(struct rtw_ieee80211_hdr_3addr)-6
    			, GFP_ATOMIC);
    and ADD the following lines instead:
    Code:
    roam_info.channel = notify_channel;
    roam_info.channel = notify_channel;
    roam_info.bssid = cur_network->network.MacAddress;
    roam_info.req_ie = pmlmepriv->assoc_req+sizeof(struct ieee80211_hdr_3addr)+2;
    roam_info.req_ie_len = pmlmepriv->assoc_req_len-sizeof(struct ieee80211_hdr_3addr)-2;
    roam_info.resp_ie = pmlmepriv->assoc_rsp+sizeof(struct ieee80211_hdr_3addr)+6;
    roam_info.resp_ie_len = pmlmepriv->assoc_rsp_len-sizeof(struct ieee80211_hdr_3addr)-6;
    cfg80211_roamed(padapter->pnetdev, &roam_info, GFP_ATOMIC);
    4. Compile and install:
    Code:
    # make
    # make install
    There should be no errors, although there are a few warnings. It does take a little bit of time, so be patient.

    5. Load dependent modules, as per the original instructions (won't hurt, but these should already be loaded).
    Code:
    # modprobe lib80211
    # modprobe cfg80211
    6. Insert the newly compiled module into the kernel:
    Code:
    # insmod 8188eu.ko
    7. If there was already a driver loaded for the RTL8188EUS device, remove it. This could possibly be done before inserting the module into the kernel, in which case you might not have to remove and reinsert the device to get the newly compiled module bound to the device. To verify which kernel module (driver) is being used, you can install and use lshw:
    Code:
    # apt-get install lshw
    # lshw -c net
    Find the right networking device and look under "configuration". It should say "driver=rtl8188eu". If it says "r8188eu" that's the old one. Remove it:
    Code:
    # modprobe -r r8188eu
    Removing and reinserting the device might be necessary to get the kernel to bind the new driver. There are other ways to do it, but this is fairly foolproof. Verify with lshw that the correct driver is being used.

    THAT'S IT!

    Tested on a clean install of "Kali 64 bit 2017.2" dd'ed to a USB drive with an additional partition added for persistence and booted in persistence mode. Switching to monitor mode works and functions as intended. Changes, settings, and full functionality survive boot.[/quote]
    Makefile.diff.txt
    Last edited by qmech; 2017-10-19 at 09:21 AM. Reason: minor formatting, attribution, diff files

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Posts
    112
    If you can provide a diff, it will be a lot easier and less error-prone from inexperienced users. Applying diff/patch is super easy.

  3. #3
    Junior Member
    Join Date
    Sep 2017
    Posts
    3
    Quote Originally Posted by Mister_X View Post
    If you can provide a diff, it will be a lot easier and less error-prone from inexperienced users. Applying diff/patch is super easy.
    For a few lines of code, I'm not convinced that someone completely new to programming would find it easier to apply a diff. Easier to just copy and paste a few lines.

    The diffs are nice for more experienced users and should have been included, so I've updated the post with diffs.

  4. #4
    Junior Member
    Join Date
    Oct 2017
    Posts
    2
    Hello,

    I'm new to Kali and pen testing, I use Linux for some time but I still consider myself a beginner.

    I'm struggling to make my WN722N v2 work, and after a couple of days I still don't manage.

    I tried first on kali 2017.2 live usb installation, when I ran
    Code:
    # apt-get install linux-headers-amd64
    I got (4.13+86+kali1) headers which is why I suppose it wouldn't compile in the beginning.
    Code:
    # make
    "******************************************"
    "NO SKRC,we will use default KSRC"
    "******************************************"
    make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/4.12.0-kali1-amd64/build M=/root/Downloads/kernel-master/drivers/TL-WN722N_v2.0-Ralink/rtl8188EUS_linux_v4.3.0.8_13968.20150417  modules
    make[1]: *** /lib/modules/4.12.0-kali1-amd64/build: No such file or directory.  Stop.
    Makefile:1370: recipe for target 'modules' failed
    make: *** [modules] Error 2
    I made a link to new headers, and I managed to compile but then I couldn't insert 8188eu.ko module into the kernel. Probably because headers and kernel have to be the same version (?)

    Then I tried to update my kernel but without success. I tried everything

    Code:
    # apt-get update
    # apt-get upgrade
    # apt-get dist-upgrade
    # apt-get full-upgrade
    I tried also installing another linux image, but couldn't make kali boot it, although it showed on the list of images. Whatever I did, I kept getting
    Code:
    # uname -r
    4.12.0-kali1-amd64
    I don't understand if I did something wrong or it isn't possible to upgrade kernel with live USB, but I guess I'll make another post to find that out...

    Anyways, after failing to update kernel I made another live USB with weekly release W43, where headers corresponded the kernel version, and I did manage to compile and insert the module but WN722N won't go to monitor mode. So, I guess it doesn't work with v 4.13 ?

    In the meantime I ordered another WiFi card, but I'm still curious to know if it is possible to make WN722N work and if I did something wrong for the sake of learning

    Any help would be highly appreciated

    Thanks in advance

  5. #5
    Junior Member
    Join Date
    Oct 2017
    Posts
    1
    you need manual install linux headers amd64 for 4.12
    here
    http://http.kali.org/kali/pool/main/l/linux/

  6. #6
    Junior Member
    Join Date
    Oct 2017
    Posts
    2
    Thanks for your reply pogo !

    I've installed the headers for 4.12 and I've recompiled everything and managed to insert 8188eu.ko into the kernel, however I still can't put my card in monitor mode... :/

    When I type lshw -c net, I get

    Code:
    # lshw -c net
      *-network                 
           description: Ethernet interface
           product: RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller
           vendor: Realtek Semiconductor Co., Ltd.
           physical id: 0
           bus info: pci@0000:02:00.0
           logical name: eth0
           version: 02
           serial: 00:1e:33:71:ae:12
           size: 10Mbit/s
           capacity: 100Mbit/s
           width: 64 bits
           clock: 33MHz
           capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
           configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half latency=0 link=no multicast=yes port=MII speed=10Mbit/s
           resources: irq:26 ioport:2000(size=256) memory:d0410000-d0410fff memory:d0400000-d040ffff
      *-network:0
           description: Wireless interface
           physical id: 2
           bus info: usb@6:2
           logical name: wlan0
           serial: d4:6e:0e:16:ea:8d
           capabilities: ethernet physical wireless
           configuration: broadcast=yes driver=rtl8188eu multicast=yes wireless=unassociated
      *-network:1
           description: Wireless interface
           physical id: 3
           bus info: usb@6:6
           logical name: wlan1
           serial: 62:23:1c:4e:91:33
           capabilities: ethernet physical wireless
           configuration: broadcast=yes driver=rtl8187 driverversion=4.12.0-kali1-amd64 firmware=N/A link=no multicast=yes wireless=IEEE 802.11
    So this should mean that the driver is good, right ?

    However, when I type airmon-ng, I get

    Code:
    # airmon-ng
    
    PHY	Interface	Driver		Chipset
    
    phy2	wlan0		??????		 
    phy1	wlan1		rtl8187		Realtek Semiconductor Corp. RTL8187B
    Anyone has an idea what I am doing wrong ?

    Thanks in advance

  7. #7
    I am having the same problem

    root@kali:~/Downloads/kernel-master/drivers/TL-WN722N_v2.0-Ralink/rtl8188EUS_linux_v4.3.0.8_13968.20150417# airmon-ng

    PHY Interface Driver Chipset

    phy0 wlan0 iwlwifi Intel Corporation Centrino Advanced-N 6205 [Taylor Peak] (rev 34)
    phy1 wlan1 ??????


    root@kali:~/Downloads/kernel-master/drivers/TL-WN722N_v2.0-Ralink/rtl8188EUS_linux_v4.3.0.8_13968.20150417# uname -r
    4.13.0-kali1-amd64

  8. #8
    Junior Member
    Join Date
    Oct 2017
    Posts
    1
    what is the wifi card that you are using now

  9. #9
    Junior Member
    Join Date
    Oct 2017
    Posts
    1
    I still getting "r8188eu" i cant remove im going to reinstall all the system to stay clean an i will use 4.12 , i use right now 4.13

  10. #10
    Junior Member
    Join Date
    Apr 2013
    Posts
    13
    I simply added the "working" driver to https://github.com/kimocoder/rtl8188eu for simple patching reasons.
    Supports kernel v4.13 + Makefile addition added, but as I've said in the bugtracker, this is a dirty driver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •