Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External Wifi Adapter Support #8240

Open
morpheuslord opened this issue Apr 7, 2022 · 42 comments
Open

External Wifi Adapter Support #8240

morpheuslord opened this issue Apr 7, 2022 · 42 comments
Labels

Comments

@morpheuslord
Copy link

morpheuslord commented Apr 7, 2022

hello,
I am a tester and I find using WSL over any other virtualization easy and when I am doing WIFI pentesting I need to use a external adapter which can support monitor mode but I looked up every single blog on the internet and none have pleasing results please help.

@akuropka
Copy link

akuropka commented Apr 7, 2022

https://github.com/dorssel/usbipd-win for attaching external USB devices. You should’ve come across if you checked every single piece of the i-net.

@morpheuslord
Copy link
Author

Well I have tried it and this also has a lot of issues like I could not understand how should I update my kernel and secondly the build libraries for the adapter also won't install as the general libraries for the specific kernel is not present in the repository and in short I wanted to say that:

kernel update or upgrade is a hassle
kernel repository not found
mirrors not getting installed

The above won't allow me to link the usb adapter and them install the drivers for the adapters.

Thank you and hope you understand

@EDLLT
Copy link

EDLLT commented Apr 28, 2022

Well I have tried it and this also has a lot of issues like I could not understand how should I update my kernel and secondly the build libraries for the adapter also won't install as the general libraries for the specific kernel is not present in the repository and in short I wanted to say that:

kernel update or upgrade is a hassle
kernel repository not found
mirrors not getting installed

The above won't allow me to link the usb adapter and them install the drivers for the adapters.

Thank you and hope you understand

Hey bro, I am facing the exact same problem
did you find any solution to the problem?

Currently, I am messing around with the WSL kernel build trying to get my driver load in but with no avail

@morpheuslord
Copy link
Author

No bro

@EDLLT
Copy link

EDLLT commented Apr 28, 2022

No bro

I MADE IT! IT WORKED!!!

THIS WAS ONE OF THE MOST COMPLICATED THINGS IN MY LIFE PROBABLY LOL

Okay so, holy crap that wasn't easy I had to stay up late till night for about 4 days trying to figure out how to do this as I had never compiled a kernel before. it was a very very steep learning curve for me

Now, everything works wlan0 is appearing as an external wifi adapter, injections work etc etc

I am gonna create a fork of that original project put everything there along with how to do it

ngl, I thought that it was impossible and was just playing around, and suddenly everything clicked and it worked

@EDLLT
Copy link

EDLLT commented Apr 28, 2022

@morpheuslord
Copy link
Author

bro can you make a detailed a youtube vid on the installation and everything this will be a life save for hackers man

@GamerGirlandCo
Copy link

bro can you make a detailed a youtube vid on the installation and everything this will be a life save for hackers man

just clone https://github.com/microsoft/WSL2-Linux-Kernel.git and apply this patch :)

@morpheuslord
Copy link
Author

Gonna try it and will update of it worked

@morpheuslord
Copy link
Author

I am a complete noob when it comes to working with makefiles and their patches 😢 help please

@akuropka
Copy link

@morpheuslord: Hmm, a "hacker" should be aware of such basics. The link in #8240 (comment) should bring you further without building by yourself.

@morpheuslord
Copy link
Author

@akuropka it's not like I don't understand the process or how it's done but when it comes to C programming and concepts like bug fixing in C is really not the strong suite I tried compiling and made sure it works for my WLS once but I could not successfully imply these patches I always ran into some weird errors which had no certain answer.

@ishaan-kapoor
Copy link

hey, could you get it to work?

@morpheuslord
Copy link
Author

nope not working.

@TheAjaykrishnanR
Copy link

It works ! for anybody wondering. Tried it with rtl8821au. You are a legend @EDLLT

@TheAjaykrishnanR
Copy link

nope not working.

https://youtu.be/l7VQQJdePlk

@morpheuslord
Copy link
Author

morpheuslord commented Jun 14, 2024

nope not working.

https://youtu.be/l7VQQJdePlk

hey so I tried it but was not able to find the drivers for Qualcomm Atheros AR9271 to run it according to the video 🥹. I am facing a compilation issue.

@TheAjaykrishnanR
Copy link

nope not working.

https://youtu.be/l7VQQJdePlk

hey so I tried it but was not able to find the drivers for Qualcomm Atheros AR9271 to run it according to the video 🥹

https://cateee.net/lkddb/web-lkddb/ATH9K_HTC.html - i think its in there by default, https://github.com/EDLLT/WSL2-Linux-Kernel/tree/linux-msft-wsl-5.10.y/drivers/net/wireless/ath/ath9k

image

can you try enabling this ?

@morpheuslord
Copy link
Author

morpheuslord commented Jun 14, 2024

nope not working.

https://youtu.be/l7VQQJdePlk

hey so I tried it but was not able to find the drivers for Qualcomm Atheros AR9271 to run it according to the video 🥹

https://cateee.net/lkddb/web-lkddb/ATH9K_HTC.html - i think its in there by default, https://github.com/EDLLT/WSL2-Linux-Kernel/tree/linux-msft-wsl-5.10.y/drivers/net/wireless/ath/ath9k

image

can you try enabling this ?

I had to elaborate, i did this but this is the issue during compilation "
AR init/built-in.a
LD vmlinux.o
ld: warning: arch/x86/lib/retpoline.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
MODPOST vmlinux.symvers
MODINFO modules.builtin.modinfo
GEN modules.builtin
LD .tmp_vmlinux.btf
ld: warning: arch/x86/lib/retpoline.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
ld: warning: .tmp_vmlinux.btf has a LOAD segment with RWX permissions
BTF .btf.vmlinux.bin.o
LD .tmp_vmlinux.kallsyms1
ld: warning: .btf.vmlinux.bin.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
ld: warning: .tmp_vmlinux.kallsyms1 has a LOAD segment with RWX permissions
KSYMS .tmp_vmlinux.kallsyms1.S
AS .tmp_vmlinux.kallsyms1.S
LD .tmp_vmlinux.kallsyms2
ld: warning: .btf.vmlinux.bin.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
ld: warning: .tmp_vmlinux.kallsyms2 has a LOAD segment with RWX permissions
KSYMS .tmp_vmlinux.kallsyms2.S
AS .tmp_vmlinux.kallsyms2.S
LD vmlinux
ld: warning: .btf.vmlinux.bin.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
ld: warning: vmlinux has a LOAD segment with RWX permissions
BTFIDS vmlinux
FAILED: load BTF from vmlinux: Unknown error -22make: *** [Makefile:1179: vmlinux] Error 255

"

I am using kali-linux for this process.

@TheAjaykrishnanR
Copy link

@morpheuslord ignoring the compiler's warning flags, this is the main error :
FAILED: load BTF from vmlinux: Unknown error -22make: *** [Makefile:1179: vmlinux] Error 255
Where are you running this on ? Do you have around 10 GBs of RAM ?

@morpheuslord
Copy link
Author

@morpheuslord ignoring the compiler's warning flags, this is the main error : FAILED: load BTF from vmlinux: Unknown error -22make: *** [Makefile:1179: vmlinux] Error 255 Where are you running this on ? Do you have around 10 GBs of RAM ?

on a VM and I have 16Gb of RAM on it.

@TheAjaykrishnanR
Copy link

@morpheuslord ignoring the compiler's warning flags, this is the main error : FAILED: load BTF from vmlinux: Unknown error -22make: *** [Makefile:1179: vmlinux] Error 255 Where are you running this on ? Do you have around 10 GBs of RAM ?

on a VM and I have 16Gb of RAM on it.

can you try changing CONFIG_DEBUG_INFO_BTF=y to CONFIG_DEBUG_INFO_BTF=n in Microsoft/config-wsl ? Are you really giving 16 gbs of ram on your VM ?

@morpheuslord
Copy link
Author

@morpheuslord ignoring the compiler's warning flags, this is the main error : FAILED: load BTF from vmlinux: Unknown error -22make: *** [Makefile:1179: vmlinux] Error 255 Where are you running this on ? Do you have around 10 GBs of RAM ?

on a VM and I have 16Gb of RAM on it.

can you try changing CONFIG_DEBUG_INFO_BTF=y to CONFIG_DEBUG_INFO_BTF=n in Microsoft/config-wsl ? Are you really giving 16 gbs of ram on your VM ?

Yes I have 16GB on a VM, its currently late in the night so I will test it and update it tomorrow.

@TheAjaykrishnanR
Copy link

@morpheuslord ignoring the compiler's warning flags, this is the main error : FAILED: load BTF from vmlinux: Unknown error -22make: *** [Makefile:1179: vmlinux] Error 255 Where are you running this on ? Do you have around 10 GBs of RAM ?

on a VM and I have 16Gb of RAM on it.

can you try changing CONFIG_DEBUG_INFO_BTF=y to CONFIG_DEBUG_INFO_BTF=n in Microsoft/config-wsl ? Are you really giving 16 gbs of ram on your VM ?

Yes I have 16GB on a VM, its currently late in the night so I will test it and update it tomorrow.

sure ! im building it myself, will share it if it works

@morpheuslord
Copy link
Author

@TheAjaykrishnanR yup it's built with no errors, but wsl won't boot. It has now been 30min and there has been no reaction from wsl.

@TheAjaykrishnanR
Copy link

@TheAjaykrishnanR yup it's built with no errors, but wsl won't boot. It has now been 30min and there has been no reaction from wsl.

can you run wsl -l -v to make sure you are running wsl 2 ?
anyways i had built it without changing that flag, check this kernel image after extracting the archive : https://www.dropbox.com/scl/fi/3cm7twaf4inlf4zqwviid/kernel_plus_modules_ath9k.tar.gz?rlkey=987wkudxvusrqms8ezzulfz5v&st=pge88leq&dl=0

@morpheuslord
Copy link
Author

morpheuslord commented Jun 15, 2024

@

**TheAjaykrishnanR ** commented

It worked, thanks man. I dont know what was wrong with my current build but yours did work. now its booting.
but drivers wont work.

$ iwconfig
lo        no wireless extensions.

bond0     no wireless extensions.

dummy0    no wireless extensions.

tunl0     no wireless extensions.

sit0      no wireless extensions.

eth0      no wireless extensions.

I lost hope at this point 🥹 .

dmesg | grep ath

[   15.420949] usb 1-1: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested
[   15.421674] usbcore: registered new interface driver ath9k_htc
[   15.422262] usb 1-1: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[   15.422953] usb 1-1: ath9k_htc: Firmware htc_9271.fw requested
[   15.424404] usb 1-1: ath9k_htc: Failed to get firmware htc_9271.fw
[   15.424946] usb 1-1: ath9k_htc: USB layer deinitialized

I installed the firmware firmware-atheros and restarted wsl but still no luck.

@TheAjaykrishnanR
Copy link

TheAjaykrishnanR commented Jun 15, 2024

@

**TheAjaykrishnanR ** commented

It worked, thanks man. I dont know what was wrong with my current build but yours did work. now its booting. but drivers wont work.

$ iwconfig
lo        no wireless extensions.

bond0     no wireless extensions.

dummy0    no wireless extensions.

tunl0     no wireless extensions.

sit0      no wireless extensions.

eth0      no wireless extensions.

I lost hope at this point 🥹 .

dmesg | grep ath

[   15.420949] usb 1-1: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested
[   15.421674] usbcore: registered new interface driver ath9k_htc
[   15.422262] usb 1-1: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[   15.422953] usb 1-1: ath9k_htc: Firmware htc_9271.fw requested
[   15.424404] usb 1-1: ath9k_htc: Failed to get firmware htc_9271.fw
[   15.424946] usb 1-1: ath9k_htc: USB layer deinitialized

I installed the firmware firmware-atheros and restarted wsl but still no luck.

bro did you follow the entire tutorial ? Did you install the built modules ? copy the wsl2-modules into /lib. You have to use modprobe to load the .ko file each time you log onto wsl. Also use USB IPD to share the adapter with wsl. Follow the steps exactly. Also where does it say to install the firmware-atheros ?

All you have to do is :

  1. cd /lib/modules/5.10.102.1-microsoft-standard-WSL2+/kernel/drivers/net/wireless/ath/
  2. sudo modprobe ath9k_htc
  3. lsmod to check if the module is loaded

@morpheuslord
Copy link
Author

morpheuslord commented Jun 16, 2024

@TheAjaykrishnanR yes its loaded.

image

image

@TheAjaykrishnanR
Copy link

TheAjaykrishnanR commented Jun 16, 2024

@morpheuslord do you have the htc_9271.fw file in /lib/firmware ?

Anyways, I added the firmware directly to the kernel using CONFIG_EXTRA_FIRMWARE and compiled it again.

Use this kernel and it should hopefully work : https://www.dropbox.com/scl/fi/ik09bxk2uga3w3pniw6oe/kernel-plus-modules-ath9k-htc9271-fw.tar.gz?rlkey=uulfkbsonwe9hlwero73kv6ca&st=u1eltkxr&dl=0

@morpheuslord
Copy link
Author

@morpheuslord do you have the htc_9271.fw file in /lib/firmware ?

Anyways, I added the firmware directly to the kernel using CONFIG_EXTRA_FIRMWARE and compiled it again.

Use this kernel and it should hopefully work : https://www.dropbox.com/scl/fi/ik09bxk2uga3w3pniw6oe/kernel-plus-modules-ath9k-htc9271-fw.tar.gz?rlkey=uulfkbsonwe9hlwero73kv6ca&st=u1eltkxr&dl=0

Yes I tried both types of the .fx files but now worked I managed to get it to load but the dmesg says another story.

@TheAjaykrishnanR
Copy link

@morpheuslord do you have the htc_9271.fw file in /lib/firmware ?
Anyways, I added the firmware directly to the kernel using CONFIG_EXTRA_FIRMWARE and compiled it again.
Use this kernel and it should hopefully work : https://www.dropbox.com/scl/fi/ik09bxk2uga3w3pniw6oe/kernel-plus-modules-ath9k-htc9271-fw.tar.gz?rlkey=uulfkbsonwe9hlwero73kv6ca&st=u1eltkxr&dl=0

Yes I tried both types of the .fx files but now worked I managed to get it to load but the dmesg says another story.

you dont need the .fw files anymore, its embedded in the kernel image

@morpheuslord
Copy link
Author

morpheuslord commented Jun 17, 2024

@morpheuslord do you have the htc_9271.fw file in /lib/firmware ?
Anyways, I added the firmware directly to the kernel using CONFIG_EXTRA_FIRMWARE and compiled it again.
Use this kernel and it should hopefully work : https://www.dropbox.com/scl/fi/ik09bxk2uga3w3pniw6oe/kernel-plus-modules-ath9k-htc9271-fw.tar.gz?rlkey=uulfkbsonwe9hlwero73kv6ca&st=u1eltkxr&dl=0

Yes I tried both types of the .fx files but now worked I managed to get it to load but the dmesg says another story.

you dont need the .fw files anymore, its embedded in the kernel image

your new kernel worked, as I was talking about before.
image

Thanks for that man, really appreciate it 👍.

@snehashis365
Copy link

It works ! for anybody wondering. Tried it with rtl8821au. You are a legend @EDLLT

Hey man I have been trying to compile for this chipset but I keep running into memory bottleneck since you have already compiled for this can you share me the final tarball with the 8821au module, I tried by disabling the debug btf flag but it won't boot in that case

@TheAjaykrishnanR
Copy link

It works ! for anybody wondering. Tried it with rtl8821au. You are a legend @EDLLT

Hey man I have been trying to compile for this chipset but I keep running into memory bottleneck since you have already compiled for this can you share me the final tarball with the 8821au module, I tried by disabling the debug btf flag but it won't boot in that case

yeah here you go : https://www.dropbox.com/scl/fi/ex9q3ba9rqz3tt3w37k0l/wsl2-kernel-plus-modules-rtl8821au.tar.gz?rlkey=yhbjc00cls7iecu2u2b97h8ak&st=672dtq1d&dl=0

@Geofferey
Copy link

Geofferey commented Jun 29, 2024

I was able to sucessfully compile the latest WSL kernel relatively easily given all the information here. However, I experienced issue where flipping into monitor mode would crash WSL. Turns out the driver I had used wasn't good for whatever reason.

Here is the driver that worked for me:
https://github.com/ivanovborislav/rtl8821au

The driver I initially chose:
https://github.com/aircrack-ng/rtl8812au

@mieucun123
Copy link

It works ! for anybody wondering. Tried it with rtl8821au. You are a legend @EDLLT

can you please help me with the TL-WN722N V1?

@TheAjaykrishnanR
Copy link

It works ! for anybody wondering. Tried it with rtl8821au. You are a legend @EDLLT

can you please help me with the TL-WN722N V1?

Isn't the chipset atheros 9271 ? or is it realtek ?

@mieucun123
Copy link

It works ! for anybody wondering. Tried it with rtl8821au. You are a legend @EDLLT

can you please help me with the TL-WN722N V1?

Isn't the chipset atheros 9271 ? or is it realtek ?

It atheros 9271

@TheAjaykrishnanR
Copy link

TheAjaykrishnanR commented Sep 18, 2024

@morpheuslord do you have the htc_9271.fw file in /lib/firmware ?

Anyways, I added the firmware directly to the kernel using CONFIG_EXTRA_FIRMWARE and compiled it again.

Use this kernel and it should hopefully work : https://www.dropbox.com/scl/fi/ik09bxk2uga3w3pniw6oe/kernel-plus-modules-ath9k-htc9271-fw.tar.gz?rlkey=uulfkbsonwe9hlwero73kv6ca&st=u1eltkxr&dl=0

@mieucun123 have you tried this ?

@h471x
Copy link

h471x commented Dec 11, 2024

Hello, I have just intalled Kali Linux WSL2 a week ago and now I want to use wireless USB adapter on it.
I'm kinda noob with all of these and I know it's a bit too late for asking that but,
anyway, will this youtube video tutorial work for Ralink ?

( Yes I already consulted here https://github.com/EDLLT/WSL2-Linux-Kernel/tree/linux-msft-wsl-5.10.y/drivers/net/wireless/ralink/rt2x00 but I am just kindly asking for a confirmation from you guys as noob as I am )

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests