
The idea of transferring the phone's network card to monitor mode has collapsed due to its own naivety and ignorance of basic information that the vast majority of mobile network cards do not support this very monitor mode.
The idea of implementing the idea using an external wireless Wi-Fi adapter or a “whistle” that supports the desired monitor mode has collapsed dozens of times due to new and new errors and the loss of faith that this is generally possible, but has grown into this article.
')
So, how to connect an external Wi-Fi adapter to a device on Android or running with obstacles at a distance of “inserted - netcfg wlan0 up”:
Must be available:
- Android phone
- OTG support and OTG itself
- Terminal emulator
- ROOT
- Kernel sources
FAQ - the structure looks like this:
- External Wi-Fi adapter ("whistle")
- His firmware
- Linux distribution
- ADB (optional, but more convenient)
My case:
- Samsung GT-P5100 Galaxy Tab 2 10.1, Android 4.2.2
- OTG "30-pin - USB"
- Terminal Emulator for Android
- ROOT
- Sources of the stock kernel 3.0.31-1919150 from the Samsung website
- TP-LINK TL-WN722N adapter on AR9271 chipset
- ath9k_htc / htc_9271.fw
- Ubuntu 15.04 distribution in VMware
- android-tools-adb
I'll start. But I will ask you to take into account that everything is considered further for the above set and the algorithm is most likely not universal, but the deviations are
minor .
I. Start
The first thing you need to get the firmware of your adapter. I insert the adapter into the computer and execute the
dmesg
. I find:
... [ 256.815266] usbcore: registered new interface driver ath9k_htc ...
Where the word is more right than the word
driver is the required information. I have this -
ath9k_htc . I google for it firmware. I shake. I upload the .fw file to the phone in
/ system / etc / firmwareThen install ADB:
apt-get install android-tools-adb
The third stage I download the toolchain (compiler for ARM)
from here . There is a large archive, I just need the android-platform_prebuilt-android-sdk-adt_r20-0-ga4062cc.zip \ android-platform_prebuilt-a4062cc \ linux-x86 \ toolchain \
arm-eabi-4.4.3 folder , which I unpack to any location .
Ii. Overclocking
To begin with, I am writing a terminal:
export ARCH=arm export CROSS_COMPILE=~/ /arm-eabi-4.4.3/bin/arm-eabi-
Then I go to the terminal in the directory with the kernel sources downloaded earlier, I write
make help
and get a cloud of information, among which you need to find something ending in
_defconfig , I have this:
... android_espresso10_omap4430_r02_user_defconfig - Build for android_espresso10_omap4430_r02_user ...
Copied, then:
make android_espresso10_omap4430_r02_user_defconfig
And at the end I launch the graphical configuration of the kernel:
make menuconfig
This window appears:
Moving along the routes:
- Networking support → Wireless
I go down to the Generic IEEE 802.11 Networking stack (mac80211) and click on the spacebar, watching the appearance of the M icon in front of this item
- Device Drivers -> Network device support → Wireless LAN
I put M on my chipset, in my case - Atheros Wireless Cards
Then I turn to this section myself and inside I mark with the same space and M as the item I need.
- Exit → save your new configuration? → Yes
Then I go into the folder with the kernel sources and open the
Makefile file. I find the line
CFLAGS_MODULE = and
append -fno-pic so that it
turns out:
CFLAGS_MODULE = -fno-pic
Save. Returning to the terminal, and if you closed it, then in the source directory too, and execute
make modules_prepare
first, and then just
make
. The result will require a wait. My final set:
MODPOST 8 modules CC drivers/net/wireless/ath/ath.mod.o LD [M] drivers/net/wireless/ath/ath.ko CC drivers/net/wireless/ath/ath9k/ath9k_common.mod.o LD [M] drivers/net/wireless/ath/ath9k/ath9k_common.ko CC drivers/net/wireless/ath/ath9k/ath9k_htc.mod.o LD [M] drivers/net/wireless/ath/ath9k/ath9k_htc.ko CC drivers/net/wireless/ath/ath9k/ath9k_hw.mod.o LD [M] drivers/net/wireless/ath/ath9k/ath9k_hw.ko CC drivers/net/wireless/bcmdhd/dhd.mod.o LD [M] drivers/net/wireless/bcmdhd/dhd.ko CC drivers/scsi/scsi_wait_scan.mod.o LD [M] drivers/scsi/scsi_wait_scan.ko CC net/mac80211/mac80211.mod.o LD [M] net/mac80211/mac80211.ko CC net/wireless/cfg80211.mod.o LD [M] net/wireless/cfg80211.ko
Modules (.ko files) are required that include the word
ath and
mac80211.ko . I transfer them to the phone.
You can use adb, working through a computer, and you can not use and work through the terminal of the phone, typing commands with your fingers across the screen. I chose adb.
Let me remind you how it works. I connect the phone via USB (debugging is, of course, enabled) and execute:
adb start-server
adb shell
su
I'm on the phone and under the root.
I look at which modules are already available with the
lsmod
command and unload them all, if possible, with the
rmmod
Then go to the directory with the above modules:
cd /sdcard/ /
You can verify their presence with the
ls
.
a@ubuntu:~/Kernel$ adb start-server * daemon not running. starting it now on port 5037 * * daemon started successfully * a@ubuntu:~/Kernel$ adb shell shell@android:/ $ su root@android:/ # cd /sdcard/temp root@android:/sdcard/temp # ls ath.ko ath9k_common.ko ath9k_htc.ko ath9k_hw.ko mac80211.ko
I load them with the
insmod
command
insmod
in this and only this sequence (otherwise it just won't load, producing an error):
ath.ko
ath9k_hw.ko
ath9k_common.ko
mac80211.ko
ath9k_htc.ko
Iii. Obstacles
In this and all the salt, without which the article would be too simple.
1. Versions
Naturally, the first error occurs at the first stage.
insmod ath.ko
insmod: init_module 'ath.ko' failed (Exec format error)
See what the kernel message buffer says about it by running the
dmesg
:
... ath: version magic '3.0.31 SMP preempt mod_unload modversions ARMv7 p2v8' should be '3.0.31-1919150 SMP preempt mod_unload modversions ARMv7 p2v8'
Version does not match.
3.0.31 is not
3.0.31-1919150 .
Decision:
I open the same
Makefile in the kernel source and at the very top of the file I find:
VERSION = 3
PATCHLEVEL = 0
SUBLEVEL = 31
EXTRAVERSION =
NAME = Sneaky Weasel
I add to
EXTRAVERSION = the missing piece of version
-1919150 so that it
turns out:
VERSION = 3
PATCHLEVEL = 0
SUBLEVEL = 31
EXTRAVERSION = -1919150
NAME = Sneaky Weasel
And save.
The final stage will take place in the
/ include / config directory, where in the file
kernel.release I will change
3.0.31 to
3.0.31-1919150Again
make modules_prepare
,
make
and further on the previous item.
2. ewma
Downloading
mac80211.ko again has an error, about which
dmesg
will say the following:
<4>[ 3491.160949] C1 [ insmod] mac80211: Unknown symbol ewma_add (err 0) <4>[ 3491.161865] C1 [ insmod] mac80211: Unknown symbol ewma_init (err 0)
Decision:
Miraculously reading on one of the English-language forums is a dangerous, but the only on the Internet, “solution”, I go to
/ net / mac80211 / and in the
rx.c and
sta_info.c files and just delete [or comment (//)] the lines
ewma_add ( & sta-> avg_signal, -status-> signal); and
ewma_init (sta sta-> avg_signal, 1024, 8); respectively.
Again I recompile the modules and move on.
3. LED
When downloading
ath9k_htc.ko and
mac80211.ko, the next errors are, for
mac80211.ko this is:
dmesg <4>[ 2435.271636] C1 [ insmod] mac80211: Unknown symbol led_trigger_unregister (err 0) <4>[ 2435.271820] C1 [ insmod] mac80211: Unknown symbol led_brightness_set (err 0) <4>[ 2435.271972] C1 [ insmod] mac80211: Unknown symbol led_blink_set (err 0) <4>[ 2435.272033] C1 [ insmod] mac80211: Unknown symbol led_trigger_register (err 0) <4>[ 2435.272155] C1 [ insmod] mac80211: Unknown symbol led_trigger_event (err 0)
And
ath9k_htc.ko is:
dmesg <4>[ 2709.396392] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_start_tx_ba_cb_irqsafe (err 0) <4>[ 2709.396972] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_free_hw (err 0) <4>[ 2709.397155] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_alloc_hw (err 0) <4>[ 2709.397216] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_start_tx_ba_session (err 0) <4>[ 2709.397369] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_register_hw (err 0) <4>[ 2709.397430] C1 [ insmod] ath9k_htc: Unknown symbol led_classdev_unregister (err 0) <4>[ 2709.397491] C1 [ insmod] ath9k_htc: Unknown symbol __ieee80211_create_tpt_led_trigger (err 0) <4>[ 2709.397766] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_get_buffered_bc (err 0) <4>[ 2709.397827] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_find_sta (err 0) <4>[ 2709.398284] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_stop_tx_ba_cb_irqsafe (err 0) <4>[ 2709.398376] C1 [ insmod] ath9k_htc: Unknown symbol wiphy_to_ieee80211_hw (err 0) <4>[ 2709.398498] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_queue_delayed_work (err 0) <4>[ 2709.398712] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_rx (err 0) <4>[ 2709.398895] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_wake_queues (err 0) <4>[ 2709.399230] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_tx_status (err 0) <4>[ 2709.399291] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_stop_queues (err 0) <4>[ 2709.399505] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_iterate_active_interfaces_atomic (err 0) <4>[ 2709.399597] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_unregister_hw (err 0) <4>[ 2709.399749] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_beacon_get_tim (err 0) <4>[ 2709.399871] C1 [ insmod] ath9k_htc: Unknown symbol led_classdev_register (err 0) <4>[ 2709.399932] C1 [ insmod] ath9k_htc: Unknown symbol ieee80211_queue_work (err 0)
If the
ieee80211_ error from
ath9k_htc.ko is because I'm trying to download it to
mac80211.ko , then
led_- errors from both modules from the fact that the phone does not understand what to do with the LED on my adapter. There are two scenarios.
In the first one, the
[*] icon is simply removed from the graphical configuration of the kernel.
Networking support → Wireless → Enable LED triggers and
Device Drivers → LED Support .
And in the second, this very icon is frozen and cannot be removed. This means that when you select my adapter, the “support” of the LED is automatically selected, which cannot be removed. Of course, this is my case:
Decision:
Help Button for
Device Drivers → LED Support displays the following section information:
I'm interested in:
Defined at drivers / leds / Kconfig
So all the settings are stored in this file. For a long time I was torturing
Kconfig in
/ drivers / leds / until I thought of seeing the same file in my
/ drivers / net / wireless / ath / ath9k , where I found the answer to my question:
...
config ATH9K_HTC
tristate "Atheros HTC based wireless cards support"
depends on USB && MAC80211
select ATH9K_HW
select MAC80211_LEDS
select LEDS_CLASS
select NEW_LEDS
select ATH9K_COMMON
...
Immediately delete the lines that include the scary word
LED , I get
...
config ATH9K_HTC
tristate "Atheros HTC based wireless cards support"
depends on USB && MAC80211
select ATH9K_HW
select ATH9K_COMMON
...
and save. Now you can remove the tick:
Screenshots
Here the point disappeared altogether:

Again and again recompilation, new modules, etc.
Voila All modules are loaded. I turn off Wi-Fi on the phone and connect the adapter. But the LED on it, as you already guessed, will not work. It is not necessary.
4. Firmware version
If all the necessary modules are loaded, but after connecting the adapter to the phone you do not see anything new in the output of the
netcfg
command, then the same
dmesg
comes to the rescue.
...
[7582.477874] C0 [khubd] ath9k_htc 1-1: 1.0: ath9k_htc: Please upgrade to FW version 1.3
...
Decision:
Just download another firmware user, but already the required version, and put it instead of the past.
Iv. The finish
Now there should be no problems. I turn off native Wi-Fi, all modules are loaded, the firmware of the desired version. I insert the adapter and
netcfg brings happiness for the first time. I set the monitor mode for the appeared network interface and raise it. Success!

Well, how and why the monitor mode is often used, you already know everything. Thanks for attention!