*Leggi questo in un altro linguaggio: Italiano.
Sugar is a script that automates the creation of DBs and tables, and the modification and export of the records contained in the csv files generated by Wigle
The Script is written entirely in bash and mysql, for the Database part mariaDB is used. The latter was designed and tested using CSV files produced by Wigle via mobile phone. After performing a wardriving session and exporting the networks found in csv format, it is possible to automatically create a Database containing two tables, one for Wifi networks, the other for Bluetooth networks.
Using the appropriate option, the script generates two files from the csv, one containing the Wifi networks and the other the Bluetooth networks, subsequently the two files are automatically transformed into insert sql queries, and can be inserted in the Database, in this way duplicate records are eliminated.
The MACAddress of the networks is used as Primary Key and the insert queries use the "INSERT IGNORE" option in this way only the records actually found can be exported, without any duplicate networks.
In addition to the export of the entire tables, ready to be uploaded to Wigle, it is possible to carry out searches based on the keys used by the networks (WPA2,WPA,WEP ...) or on the SSIDs of the Wifi and Bluetooth networks.
The generated exports, always in csv, are generally saved in the /var/lib/mysql/ directory.
The current version has been tested on Linux Mint 21.
Let's start with the installation of mariaDB, running the following commands:
sudo apt update
sudo apt install libmariadb3 libmariadb-dev mariadb-server
sudo systemctl start mariadb.service
Now let's add our local user among the users in the DB.
We get the name of our user with the following command:
whoami
and run mariaDB :
sudo mariadb
Now we run the following query:
# Insert your user name in place of user
CREATE USER 'user'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost';
FLUSH PRIVILEGES;
Now our local user will be able to access the database and modify it.
Let's verify that the utils-linux package is already installed :
dpkg -l|grep utils-linux
Otherwise, install it with the command:
sudo apt install utils-linux -y
After downloading Sugar with the command :
git clone https://github.com/Psycho-naut/Sugar.git
we run the following commands:
# Let's enter the Sugar directory and create the missing directories:
cd Sugar
mkdir -p {input,log,output}
mkdir -p output/sql
mkdir -p conf/tmp
# Assign execute permissions to the script
sudo chmod +x Sugar.sh
Sugar.sh --generate
o
Sugar.sh -g
To create a database renamed Wigle, in which two tables will be created, one for wifi networks and the other for bluetooth networks.
Sugar.sh --count <csv|db|all>
o
Sugar.sh -c <csv|db|all>
To count the networks in the csv file exported from Wigle, first copy it into the Sugar/input/ directory. To count the networks in the database, first create it with the -g option and then populate it with the -i option.
Sugar.sh --split
o
Sugar.sh -s
The --split option splits the bluetooth networks from the wifi ones and modifies the files making them executable queries on the DB.
Sugar.sh --insert
o
Sugar.sh -i
The --insert option launches the query inside the db in such a way as to insert the records, if an error inherent to the syntax is recorded during the execution it is recommended to check the two files inside the Sugar/output/ directory sql/, after opening them with any editor make sure there are no dirty characters.
Sugar.sh --export
o
Sugar.sh -e
"Opzioni"
Sugar.sh --export b
o
Sugar.sh --export w
o
Sugar.sh --export wb
with the --export option we can select and export all the records present in the tables, these will generally be saved in the /var/lib/mysql directory
the option --export b exports the contents of the bluetooth table, --export w exports the contents of the wifi table, --export wb exports both in two separate .csv files.
The above options produce no output.
Sugar.sh --export w+
o
Sugar.sh --export n
The --export w+ option allows you to search for records based on the key (WPA2,WPA,WEP,ESS), the result of the select is sent back in output, later it is possible to save the result of the query.
The --export n option allows you to search on one of the two tables of your choice for the records starting from the network name (SSID).
Author: Psychonaut
I assume no responsibility for the use of the script, created for the sole purpose of studying the manipulation of csv files and their storage. The script can be downloaded and modified at will.