AWDP

什么是awdp?
AWDP是一种综合考核参赛团队攻击、防御技术能力、即时策略的攻防兼备比赛模式。每个参赛队互为攻击方和防守方,充分体现比赛的实战性、实时性和对抗性,对参赛队的渗透能力和防护能力进行综合全面的考量。

说白了awdp其实就是ctf+漏洞修复罢了。

修复其实就是加waf,预处理,让主办方的payload无法打通修复后的web系统

正常修会比打简单,而且因为awdp是按轮数吃分的,修的越早能吃的分越多,所以一般都先修后打。

常见FIX手段

SQL注入:加waf,过滤引号等,php就使用预处理,java若为mybatis就将${}改为#{}

rce :找到rce的点对命令执行的函数人eval,system引号反引号等进行过滤,也可以尝试对这个rce的点进行删除

php反序列化:找到链尾对其进行过滤,在反序列化前进行过滤。在链首部如__wakeup来判断其每个属性是否为类的实例,如果是就exit()

ssrf:一般ssrf都是有伴随着一个强制本地ip的命令执行路由或者文件读取路由,或者就是使用file://这种协议来文件读取,所以在写waf时需要限制协议过滤file|gopher|dict|sftp|ldap,

SSTI:看框架如flask可以对{进行过滤,如果其他框架如bottle对{%进行过滤,建议在写waf时顺便多加一点如system,popen,flag等

文件上传:强制后缀判定,文件内容判断

原型链污染:直接注释即可

java反序列化:修改输入流类

sql注入

sql注入最常规的修复方法就是加waf

php的直接使用addslashes来处理即可

目前再ctf中java中出现sql注入一般有两种1.利用自带的jdbc编写导致的sql注入,利用mybatis来编写时造成的sql注入

将直接拼接的sql语句改为预处理语句即可

mybatis的sql注入相对会好修一些就是漏洞点会比较难找

SSTI

文件上传

java反序列化

修复java反序列化的时候可以先尝试上通防,如果通防没防住就需要找一下出题人有没有重写或者自己写了恶意类

192.168.255.224

原型链污染

常用waf

php

全局waf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$str1 ="";
foreach ($_POST as $key => $value) {
$str1.=$key;
$str1.=$value;
}
$str2 ="";
foreach ($_GET as $key => $value) {
$str2.=$key;
$str2.=$value;
}
if (preg_match("/system|tail|flag|\'|\"|\<|\{|\}|exec|base64|phpinfo|<\?|\"/i", $str1)||preg_match("/system|tail|flag|\'|\"|\<|\{|\}|exec|base64|phpinfo|<\?|\"/i", $str2)) {
die('no!');
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//RCE
function wafrce($str){
return !preg_match("/openlog|syslog|readlink|symlink|popepassthru|stream_socket_server|scandir|assert|pcntl_exec|fwrite|curl|system|eval|assert|flag|passthru|exec|chroot|chgrp|chown|shell_exec|proc_open|proc_get_status|popen|ini_alter|ini_restore/i", $str);
}


//SQL
function wafsqli($str){
return !preg_match("/select|and|\*|\x09|\x0a|\x0b|\x0c|\x0d|\xa0|\x00|\x26|\x7c|or|into|from|where|join|sleexml|extractvalue|+|regex|copy|read|file|create|grand|dir|insert|link|server|drop|=|>|<|;|\"|\'|\^|\|/i", $str);
}


if (preg_match("/select|flag|union|\\\\$|\'|\"|--|#|\\0|into|alert|img|prompt|set|/\*|\x09|\x0a|\x0b|\x0c|\0x0d|\xa0|\%|\<|\>|\^|\x00|\#|\x23|[0-9]|file|\=|or|\x7c|select|and|flag|into|where|\x26|\'|\"|union|\`|sleep|benchmark|regexp|from|count|procedure|and|ascii|substr|substring|left|right|union|if|case|pow|exp|order|sleep|benchmark|into|load|outfile|dumpfile|load_file|join|show|select|update|set|concat|delete|alter|insert|create|union|or|drop|not|for|join|is|between|group_concat|like|where|user|ascii|greatest|mid|substr|left|right|char|hex|ord|case|limit|conv|table|mysql_history|flag|count|rpad|\&|\*|\.|/is",$s)||strlen($s)>50){
header("Location: /");
die();
}


//XSS
function wafxss($str){
return !preg_match("/\'|http|\"|\`|cookie|<|>|script/i", $str);
}