-
Notifications
You must be signed in to change notification settings - Fork 4
/
dump_sqlite.sh
executable file
·36 lines (30 loc) · 1.24 KB
/
dump_sqlite.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# libcrack.so
# Wed jul 30 17:31:16 CEST 2014
#
# Explore the filesystem for sqlite
# databases and dump the contents
if [ -z "$1" ]; then
printf "\n\t\e[0;31mUsage:\e[0m $0 <directory> <bool show content>\n\n"
exit 1
fi
targetdir="$1"
showcontent="$2"
dbfiles="dbfiles.$$"
printf "[*] Discovering sqlite databases at \e[1;33m$targetdir\e[0m ...\n"
find "$targetdir" -exec file {} \; | grep -i sqlite | cut -f1 -d: > "$dbfiles"
while read dbfile; do
printf "[*] Analysing database $dbfile \e[0;93m=========================================\e[0m\n\n"
printf "[*] Database schema $dbfile \e[0;92m-----------------------------------------------------\e[0m\n\n"
echo .schema | sqlite3 "$dbfile"
printf "\e[1m[*] ----------------------------------------------------------------------\e[0m\n\n"
if [ "$showcontent" == "true" ]; then
tables=$(echo .schema | sqlite3 "$dbfile" | grep TABLE | awk '{print $3}' | cut -f1 -d \()
for t in $tables; do
printf "[*] Table $dbfile:$t \e[1;32m-----------------------------------------\e[0m\n\n"
echo ".headers ON\n.mode columns\nselect * from $t;" | sqlite3 "$dbfile"
echo;echo
done
fi
done < "$dbfiles"
rm "$dbfiles"