Over the past year I have come across many stories using passive WiFi tracking. Basically, everyone focuses on security and privacy issues, but few tell us how it works. I made a whole project of Casual Encounters and I can share information about how the system works, how to avoid surveillance, and how to build it (for research purposes, of course). Do not try this at home.
Trial requests
When a WiFi client tries to connect with a known network, it has two options. The first is used by laptops and other devices that are not smartphones. It includes the search for signal packets (Beacon Frames). These packets send routers to announce their presence. The client finds the already known network and connects to it. The second option, which is usually used by smartphones, includes periodic distribution of trial requests (Probe Requests), containing a unique client MAC-address and sometimes the name of the network that it knows. The advantage of the second approach is that it works faster. And besides this, it is much easier to use for their own purposes.
Listening Mode (Monitor Mode)
WiFi devices can work in six modes. To listen to the traffic, the device must switch to the listening mode. After that, it does not advertise itself, so the presence of such devices is very difficult to install.
Protection
Theoretically, it is very easy to protect against these bugs. If you turn off WiFi on your phone when it is not needed (that is, you are far from places where there are trusted networks), the phone will stop sending requests and you will not be able to track down. Almost every time to turn off WiFi would be pretty tedious.
')
For android there are several applications to facilitate the process. For example, AVG PrivacyFix allows you to configure a list of trusted networks, in the presence of which your WiFi will be enabled. There are other applications on this topic.
In the case of iOS, your choice is limited. If you do not use jailbroken, the protected mode of the apple will not allow applications to the WiFi switch. In iOS 7, there was perhaps more convenient access to the WiFi menu, but you still need to do it manually.
We build a tracker
You can, of course, just use a laptop - even a MacBook. Install Wireshark and configure the filter for test requests. But this is not so interesting, besides, if you want to build a whole network of trackers, it will be quite expensive to use laptops for this.
For such non-master purposes, the Raspberry Pi with a wireless adapter, or (which I prefer), TP-LINK MR-3020 router with a special firmware is enough. These options are small and can be powered by a 5-volt battery.
Setting Pi will be quite simple, because there is already a working file system, but I prefer the MR-3020 router. It is an inexpensive and standalone solution. Therefore, I will describe the configuration of the router, and if you want to use Pi, then:
- you can skip steps to Listening mode settings
- these two devices have different versions of Linux, so some configuration files may be in different places and they may have different package managers.
- more powerful AWUS036H type radios may require an external powered USB hub
Configure the router
You will need:
- TP-LINK MR-3020 router ($ 34.99 on Amazon). Should work and analogues, such as TP-LINK TL-WR703N
- USB flash drive (2-4 GB)
- Ethernet cable
The first part of the instructions is taken from
the PirateBox project , since the initial configuration of the devices is identical.
1. Download a
copy of OpenWrt for the MR3020 (a modification from Matthias Strubel includes all the necessary kernel modules).
More information:
forum.daviddarts.com/read.php?2 , 3974,4009 # msg-4009
Discussion firmware:
forum.openwrt.org/viewtopic.php?pid=207769#p207769Firmware for WR703N:
downloads.openwrt.org/attitude_adjustment/12.09-beta2/ar71xx/generic2. Switch the switch next to the LAN / WAN port to WISP
3. Turn off laptop wifi
4. Connect the router via ethernet to the computer and open in the browser
192.168.0.254 (MR3020) or
192.168.1.1 (WR703N)
5. Enter login / password (admin / admin)
6. Go to System Tools> Firmware Upgrade, select OpenWRT firmware.
WR703N Chinese firmware text. For firmware via the web interface, select the last menu on the left, then the third submenu item.
More details .
7. After the upgrade, the system will restart.
8. Go there via telnet
telnet 192.168.1.1
9. Use the passwd command to set a password. This will give access to SSH.
passwd
10. Using vi, edit the network settings. Suppose your main gateway has an address of 192.168.2.1. The OpenWrt address must not be the same, but must be on the same subnet.
vi /etc/config/network
Change the file to this state:
config interface 'loopback' option ifname 'lo' option proto 'static' option ipaddr '127.0.0.1' option netmask '255.0.0.0' config interface 'lan' option ifname 'eth0' option type 'bridge' option proto 'static' option ipaddr '192.168.2.111' option netmask '255.255.255.0' option gateway '192.168.2.1' list dns '192.168.2.1' list dns '8.8.8.8'
11. Disconnect the router from the network.
12. Turn on wifi on laptop
13. Connect the MR3020 (or WR703N) to the gateway router via Ethernet and turn on the configured router in the network. Wait a minute. From a computer connected to LAN, try to log into the router.
ssh root@192.168.2.111
14. Pingan google to check settings
ping google.com
15. Add USB support to OpenWrt (if you did not use the already configured firmware from step 1):
opkg update opkg install kmod-usb-uhci insmod usbcore
USB setup
Format the flash drive into two partitions - the main Ext4 and swap. swap should be between 256 and 512 MB.
Log in to ssh on the router.
Install packages to support Ext4:
root@OpenWrt:~
Insert the flash drive into the router. Check that it is defined.
root@OpenWrt:~
File system setup
Now we will make sda1 the root of the filesystem.
(as described here by
wiki.openwrt.org/doc/howto/extroot#openwrt )
root@OpenWrt:~
Let's check that everything got out of order (should return / dev / sda1 to / mnt / sda1 type ext4):
root@OpenWrt:~
Copy the files from the router to the flash drive so that all the necessary settings are available when we reboot and USB will be the basis of the file system.
root@OpenWrt:~
Add the automatic connection / dev / sda1 to / etc / config / fstab.
root@OpenWrt:~
Use the following settings:
config global automount option from_fstab 1 option anon_mount 1 config global autoswap option from_fstab 1 option anon_swap 0 config mount option target /overlay option device /dev/sda1 option fstype ext4 option options rw,sync option enabled 1 option enabled_fsck 0 config swap option device /dev/sda2 option enabled 0
Reboot the router
root@OpenWrt:~
When all the lights come on again, go to ssh and check that the flash drive is correctly hooked.
root@OpenWrt:~
If you can not log in via ssh, then copying the files went wrong. Remove the flash drive, reboot it via power. When it starts up, you can go there via ssh. Then reinsert the flash drive and repeat the previous steps.
Customize swap
The router has a little memory, long processes can take it all. To test the memory, enter
root@OpenWrt:~
To solve memory problems, you can use the swap partition. First, check that it works:
root@OpenWrt:~
Now connect it to the swap:
root@OpenWrt:~
Run free again to check that it is connected.
root@OpenWrt:~
To make this happen automatically it is best to make a separate script. By the way, at the same time you will learn how to make such scripts.
Script to connect Swap at startup
Let's start by creating a script:
root@OpenWrt:~
Enter the following into the file:
Make it executable:
root@OpenWrt:~
Now you need to make a symlink with /etc/rc.d on it:
root@OpenWrt:~
S109 tells the system the priority of the script. All files in /etc/rc.d begin with S ##. S109 should place it at the very end, after all the rest are launched.
Reboot, log in via ssh and check the swap connection:
root@OpenWrt:~
Customize listening mode
Almost everything is ready. We need to edit the wireless settings:
root@OpenWrt:~
Comment out the wifi ban line:
Use the following settings:
config wifi-iface option device radio0 option network lan option mode monitor option hidden 1
Restart the wifi interface:
root@OpenWrt:~
Error messages such as those presented below should not affect the operation of wifi:
ifconfig: SIOCSIFHWADDR: Invalid argument command failed: Device or resource busy (-16)
Check that wifi is working and is in monitor mode:
root@OpenWrt:~
Package installation
Now we will install all the packages required for the scanner:
root@OpenWrt:~
Scan script check
Copy scripts with git (or you can download them as zip)
root@OpenWrt:~
As responsible hackers, we will not intercept all requests. We will make a white list, which will include only our phones.
root@OpenWrt:/overlay/scripts
Check the script:
root@OpenWrt:/overlay/scripts/wifi-scan
Remove the phone, disconnect from the current network, but do not turn off wifi. In the terminal, you should start to see the requests sent to them. You may notice that not all requests will have an SSID. Non-SSID requests are broadcast and are intended for all access points that are within reach.
Ctrl-C will stop the script
Results
Well, that's it. Now you have a router that tracks smartphones passing by. Of course, our script is not very useful in this form. For example, it can be edited so that it collects more data, writes them to the log, tracks the movement of smartphones between your various devices, etc.