03-18-2023, 10:03 AM
(This post was last modified: 03-27-2023, 02:02 PM by HackMaster.)
Wifi_Db - Script To Parse Aircrack-ng Captures To A SQLite Database
![[Image: AVvXsEhO52gZbQmL_OEzbU412aIPg_SeOmZWvXlq...=w640-h594]](https://blogger.googleusercontent.com/img/a/AVvXsEhO52gZbQmL_OEzbU412aIPg_SeOmZWvXlqsbl-pDKOLdVB84rwbBJ4eh-P2m_hQBg0a_o8vk4Upb-hMQ_N06B4E3eA_c3uG1BdNCzWIVO3u8zvSBdoKFf7IaK5_6n4s-2EQ_7sfLQa3bBtuHoE8e_QNAYW9CosUxgbqtqAukbgqa3vbW-i_SwmvXOlmw=w640-h594)
Script to parse Aircrack-ng captures into a SQLite database and extract useful information like handshakes (in 22000 hashcat format), MGT identities, interesting relations between APs, clients and it's Probes, WPS information and a global view of all the APs seen.
Features
Manual installation
Debian based systems (Ubuntu, Kali, Parrot, etc.)
Dependencies:
Installation
Arch
Dependencies:
Installation
Usage
Scan with airodump-ng
Run airodump-ng saving the output with -w:
Create the SQLite database using Docker
To save de output in current folder db.SQLITE file
To share the folder with the captures with the docker
![[Image: AVvXsEhO52gZbQmL_OEzbU412aIPg_SeOmZWvXlq...=w640-h594]](https://blogger.googleusercontent.com/img/a/AVvXsEhO52gZbQmL_OEzbU412aIPg_SeOmZWvXlqsbl-pDKOLdVB84rwbBJ4eh-P2m_hQBg0a_o8vk4Upb-hMQ_N06B4E3eA_c3uG1BdNCzWIVO3u8zvSBdoKFf7IaK5_6n4s-2EQ_7sfLQa3bBtuHoE8e_QNAYW9CosUxgbqtqAukbgqa3vbW-i_SwmvXOlmw=w640-h594)
Create the SQLite database using manual installation
Once the capture is created, we can create the database by importing the capture. To do this, put the name of the capture without format.
In the event that we have multiple captures we can load the folder in which they are directly. And with -d we can rename the output database.
![[Image: AVvXsEhL-Vaq3y0psRaN7c_eyMvqHukYkNPKRfZP...=w640-h478]](https://blogger.googleusercontent.com/img/a/AVvXsEhL-Vaq3y0psRaN7c_eyMvqHukYkNPKRfZPPWwljNybjzlT0zsbeKvXP2lM0fVTZ0dVQIukcYs-57pqIjat843tbV0yWdO1nAwO43J-hnbzsqcqKvo-JQQAPhqvSujFSrzB_BZc14hCY7nZ7QFF31Bo95pbRYY400wDbO1Oi_AgNXHI_D9U0g9aRqSODQ=w640-h478)
Open database
The database can be open with:
![[Image: AVvXsEjPwrhKSOK5BnQ2JmXfkWW4dyotmo1eWC7X...=w640-h420]](https://blogger.googleusercontent.com/img/a/AVvXsEjPwrhKSOK5BnQ2JmXfkWW4dyotmo1eWC7XUhozQSJgl_j-1xQ6TiH2PSYyY4dFArbcEvS3Sy1otlzgxvh0ZLGSTaE69kf0bH_eihHko90e0D8PSxuiHNZyN7wreG_zOzu4lbduORFc0zrq2uh3qYPpzPVHM2keY-2wS_IeH0pDh_rjF-FbBwlsZ4-K_A=w640-h420)
Below is an example of a ProbeClientsConnected table.
![[Image: AVvXsEgqPKxTR_l4MiEOdb6KlLy7AKeBmK5cYc3q...=w640-h190]](https://blogger.googleusercontent.com/img/a/AVvXsEgqPKxTR_l4MiEOdb6KlLy7AKeBmK5cYc3qPiLzGp3QsoShCax5pETY8-ESnCH2saQsmfsnJ4DY5dIyGTFvKHZPHY0W36xxYgpQVs6m1KSJ6wXRHc2x-P3IM1HnU2bKL_WCnhyb5N4008yQL9skZhaRGeVDb6uZRnfvPW_bxQbwsCN6n89uEJ9rSxBOOA=w640-h190)
Arguments
usage: wifi_db.py [-h] [-v] [--debug] [-o] [-t LAT] [-n LON] [--source [{aircrack-ng,kismet,wigle}]] [-d DATABASE] capture [capture ...]
positional arguments:
capture capture folder or file with extensions .csv, .kismet.csv, .kismet.netxml, or .log.csv. If no extension is provided, all types will
be added. This option supports the use of wildcards (*) to select multiple files or folders.
options:
-h, --help show this help message and exit
-v, --verbose increase output verbosity
--debug increase output verbosity to debug
-o, --obfuscated Obfuscate MAC and BSSID with AA:BB:CC:XX:XX:XX-defghi (WARNING: replace all database)
-t LAT, --lat LAT insert a fake lat in the new elements
-n LON, --lon LON insert a fake lon i n the new elements
--source [{aircrack-ng,kismet,wigle}]
source from capture data (default: aircrack-ng)
-d DATABASE, --database DATABASE
output database, if exist append to the given database (default name: db.SQLITE)
Database
wifi_db contains several tables to store information related to wireless network traffic captured by airodump-ng. The tables are as follows:
This table stores information about the wireless clients that are connected to an access point, including the MAC address of the access point
This table stores information about the handshakes captured during the captures, including the MAC address of the access point
Script to parse Aircrack-ng captures into a SQLite database and extract useful information like handshakes (in 22000 hashcat format), MGT identities, interesting relations between APs, clients and it's Probes, WPS information and a global view of all the APs seen.
Features
- Displays if a network is cloaked (hidden) even if you have the ESSID.
- Shows a detailed table of connected clients and their respective APs.
- Identifies client probes connected to APs, providing insight into potential security risks usin Rogue APs.
- Extracts handshakes for use with hashcat, facilitating password cracking.
- Displays identity information from enterprise networks, including the EAP method used for authentication.
- Generates a summary of each AP group by ESSID and encryption, giving an overview of the security status of nearby networks.
- Provides a WPS info table for each AP, detailing information about the Wi-Fi Protected Setup configuration of the network.
- Logs all instances when a client or AP has been seen with the GPS data and timestamp, enabling location-based analysis.
- Upload files with capture folder or file. This option supports the use of wildcards (*) to select multiple files or folders.
- Docker version in Docker Hub to avoid dependencies.
- Obfuscated mode for demonstrations and conferences.
- Possibility to add static GPS data.
Code:
docker pull r4ulcl/wifi_dbManual installation
Debian based systems (Ubuntu, Kali, Parrot, etc.)
Dependencies:
- python3
- python3-pip
- tshark
- hcxtools
Code:
sudo apt install tshark
sudo apt install python3 python3-pip
git clone https://github.com/ZerBea/hcxtools.git
cd hcxtools
make
sudo make install
cd ..Installation
Code:
git clone https://github.com/r4ulcl/wifi_db
cd wifi_db
pip3 install -r requirements.txtArch
Dependencies:
- python3
- python3-pip
- tshark
- hcxtools
Code:
sudo pacman -S wireshark-qt
sudo pacman -S python-pip python
git clone https://github.com/ZerBea/hcxtools.git
cd hcxtools
make
sudo make install
cd ..Installation
Code:
git clone https://github.com/r4ulcl/wifi_db
cd wifi_db
pip3 install -r requirements.txtUsage
Scan with airodump-ng
Run airodump-ng saving the output with -w:
Code:
sudo airodump-ng wlan0mon -w scan --manufacturer --wps --gpsdCreate the SQLite database using Docker
Code:
#Folder with captures
CAPTURESFOLDER=/home/user/wifi
# Output database
touch db.SQLITE
docker run -t -v $PWD/db.SQLITE:/db.SQLITE -v $CAPTURESFOLDER:/captures/ r4ulcl/wifi_dbTo save de output in current folder db.SQLITE file
Code:
-v $PWD/db.SQLITE:/db.SQLITETo share the folder with the captures with the docker
Code:
-v $CAPTURESFOLDER:/captures/Create the SQLite database using manual installation
Once the capture is created, we can create the database by importing the capture. To do this, put the name of the capture without format.
Code:
python3 wifi_db.py scan-01In the event that we have multiple captures we can load the folder in which they are directly. And with -d we can rename the output database.
Code:
python3 wifi_db.py -d database.sqlite scan-folderOpen database
The database can be open with:
- sqlitebrowser
Below is an example of a ProbeClientsConnected table.
Arguments
usage: wifi_db.py [-h] [-v] [--debug] [-o] [-t LAT] [-n LON] [--source [{aircrack-ng,kismet,wigle}]] [-d DATABASE] capture [capture ...]
positional arguments:
capture capture folder or file with extensions .csv, .kismet.csv, .kismet.netxml, or .log.csv. If no extension is provided, all types will
be added. This option supports the use of wildcards (*) to select multiple files or folders.
options:
-h, --help show this help message and exit
-v, --verbose increase output verbosity
--debug increase output verbosity to debug
-o, --obfuscated Obfuscate MAC and BSSID with AA:BB:CC:XX:XX:XX-defghi (WARNING: replace all database)
-t LAT, --lat LAT insert a fake lat in the new elements
-n LON, --lon LON insert a fake lon i n the new elements
--source [{aircrack-ng,kismet,wigle}]
source from capture data (default: aircrack-ng)
-d DATABASE, --database DATABASE
output database, if exist append to the given database (default name: db.SQLITE)
Database
wifi_db contains several tables to store information related to wireless network traffic captured by airodump-ng. The tables are as follows:
- : This table stores information about the access points (APs) detected during the captures, including their MAC addressCode:
AP
-
Network name bssidssidWhether the network is cloakedcloakedManufacturer manuf Channel channel Frequency frequency Carrier carrier Encryption typeencryption and total packets received from this AP packetsTotalThe table uses the MAC address as a primary key
- Code:
Client
This table stores information about the wireless clients detected during the captures, including their MAC address
Code:mac
Network name
Code:ssid
Manufacturer
Code:manuf
- Code:
type
and total packets received from this client
The table uses the MAC address as a primary key.Code:packetsTotal
- Code:
SeenClient
This table stores information about the clients seen during the captures, including their MAC address
Code:mac
Time of detection
Code:time
Tool used to capture the data
Code:tool
Signal strength
Code:signal_rssi
Latitude
Code:lat
Longitude
Code:lon
Altitude
Code:alt
The table uses the combination of MAC address and detection time as a primary key, and has a foreign key relationship with the table
Code:Client
This table stores information about the wireless clients that are connected to an access point, including the MAC address of the access point
- Code:
Connected
Code:bssid
and the client
Code:mac
The table uses a combination of access point and client MAC addresses as a primary key, and has foreign key relationships with both the
andCode:AP
Code:Client
Tables
- Code:
WPS
This table stores information about access points that have Wi-Fi Protected Setup (WPS) enabled, including their MAC address
Code:bssid
Network name
Code:wlan_ssid
WPS version
Code:wps_version
Device name
Code:wps_device_name
Model name
Code:wps_model_name
Model number
Code:wps_model_number
Configuration methods
Code:wps_config_methods
Keypad configuration methods
Code:wps_config_methods_keypad
The table uses the MAC address as a primary key, and has a foreign key relationship with the table
.Code:AP
- Code:
SeenAp
This table stores information about the access points seen during the captures, including their MAC address
Code:bssid
Time of detection
Code:time
Tool used to capture the data
Code:tool
Signal strength
Code:signal_rssi
Latitude
Code:lat
Longitude
Code:lon
Altitude
Code:alt
and timestamp
Code:bsstimestamp
The table uses the combination of access point MAC address and detection time as a primary key, and has a foreign key relationship with the table
.Code:AP
- Code:
Probe
This table stores information about the probes sent by clients, including the client MAC address
Code:mac
Network name
Code:ssid
and time of probe
Code:time
The table uses a combination of client MAC address and network name as a primary key, and has a foreign key relationship with the table
.Code:Client
This table stores information about the handshakes captured during the captures, including the MAC address of the access point
- Code:
Handshake
Code:bssid
The client
Code:mac
File name
Code:file
The hashcat format
The table uses a combination of access point and client MAC addresses, and file name as a primary key, and has foreign key relationships with both theCode:hashcat
andCode:AP
tables.Code:Client
- : This table represents EAP (Extensible Authentication Protocol) identities and methods used in wireless authentication. TheCode:
Identity
andCode:bssid
fields are foreign keys that reference theCode:mac
andCode:AP
tables, respectively. Other fields include the identity and method used in the authentication process.Code:Client
Views
- : This view selects the MAC address of the probe, the manufacturer and type of the client device, the total number of packets transmitted by the client, and the SSID of the probe. It joins theCode:
ProbeClients
andCode:Probe
tables on the MAC address and orders the results by SSID.Code:Client
- : This view selects the BSSID of the connected access point, the SSID of the access point, the MAC address of the connected client device, and the manufacturer of the client device. It joins theCode:
ConnectedAP
,Code:Connected
, andCode:AP
tables on the BSSID and MAC address, respectively, and orders the results by BSSID.Code:Client
- : This view selects the BSSID and SSID of the connected access point, the MAC address of the probe, the manufacturer and type of the client device, the total number of packets transmitted by the client, and the SSID of the probe. It joins theCode:
ProbeClientsConnected
,Code:Probe
, andCode:Client
tables on the MAC address of the probe, and filters the results to exclude probes that are connected to the same SSID that they are probing. The results are ordered by the SSID of the probe.Code:ConnectedAP
- : This view selects the BSSID of the access point, the SSID of the access point, the MAC address of the client device that performed the handshake, the manufacturer of the client device, the file containing the handshake, and the hashcat output. It joins theCode:
HandshakeAP
,Code:Handshake
, andCode:AP
tables on the BSSID and MAC address, respectively, and orders the results by BSSID.Code:Client
- : This view selects the BSSID of the access point, the SSID of the access point, the MAC address of the client device that performed the handshake, the manufacturer of the client device, the file containing the handshake, and the hashcat output. It joins theCode:
HandshakeAPUnique
,Code:Handshake
, andCode:AP
tables on the BSSID and MAC address, respectively, and filters the results to exclude handshakes that were not cracked by hashcat. The results are grouped by SSID and ordered by BSSID.Code:Client
- : This view selects the BSSID of the access point, the SSID of the access point, the MAC address of the client device that performed the identity request, the manufacturer of the client device, the identity string, and the method used for the identity request. It joins theCode:
IdentityAP
,Code:Identity
, andCode:AP
tables on the BSSID and MAC address, respectively, and orders the results by BSSID.Code:Client
- : This view selects the SSID, the count of access points broadcasting the SSID, the encryption type, the manufacturer of the access point, and whether the SSID is cloaked. It groups the results by SSID and orders them by the count of access points in descending order.Code:
SummaryAP
![[Image: hmr1.png]](https://hackmyride.com/images/virtualblue/hmr1.png)
