Dbdump

From WebOS Internals

Jump to: navigation, search

This is just a simple script that will find all .db3 or .db files and dump them to the /media/internal/dbdump directory as HTML, so you can easily poke around to see if there is anything interesting.


#!/bin/ash
SQLITE3=/usr/bin/sqlite3
FOLDER=/media/internal/dbdump
INDEX=$FOLDER/index.html
DB=1

getTables() {
        $SQLITE3 $1 .tables
}

dumpTable() {
        db=$1
        tableName=$2
        fileName=$3
        $SQLITE3 $db <<EOF >> $fileName
.mode html
.header ON
.nullvalue --NULL--
select * from $tableName;
.exit
EOF
}

if [ -d $FOLDER ]
then
        rm -rf $FOLDER.bak
        mv $FOLDER $FOLDER.bak
fi

mkdir $FOLDER

files=`find / -name '*.db' -o -name '*.db3'`

cat <<EOF > $INDEX
<HTML><HEAD><TITLE>dbdump</TITLE></HEAD><BODY>
EOF

for db in $files
do
        echo "DB:$db"
        echo "<HR/>$db<UL>" >> $INDEX
        dbFolder=$FOLDER/db$DB
        dbIndex=$dbFolder/index.html
        mkdir $dbFolder
        echo "<HTML><HEAD><TITLE>dbdump - $db</TITLE></HEAD><BODY>Tables<UL>" > $dbIndex
        tables=`getTables $db`
        for table in $tables
        do
                echo "  - $table"
                echo "<LI/><A href='db$DB/$table.html'>$table</A>" >> $INDEX
                echo "<LI/><A href='$table.html'>$table</A>" >> $dbIndex
                tablePage=$dbFolder/$table.html
                echo "<HTML><HEAD><TITLE>dbdump - $db/$table</TITLE></HEAD><BODY><TABLE border=1>" > $tablePage
                dumpTable $db $table $tablePage
                echo "</TABLE></BODY></HTML>" >> $tablePage
        done
        echo "</UL>" >> $INDEX
        echo "</UL>" >> $dbIndex
        echo "Generated: `date`" >> $dbIndex
        echo "</BODY></HTML>" >> $dbIndex
        DB=$(($DB+1))
done

echo "Generated: `date`" >> $INDEX
echo "</BODY></HTML>" >> $INDEX


Personal tools
Google AdSense