├── 01 extract变量覆盖.php
├── 02 绕过过滤的空白字符.php
├── 03 多重加密.php
├── 04 SQL注入_WITH ROLLUP绕过.php
├── 05 ereg正则%00截断.php
├── 06 strcmp比较字符串.php
├── 07 sha()函数比较绕过.php
├── 08 SESSION验证绕过.php
├── 09 密码md5比较绕过.php
├── 10 urldecode二次编码绕过.php
├── 11 sql闭合绕过.php
├── 12 X-Forwarded-For绕过指定IP地址.php
├── 13 md5加密相等绕过.php
├── 14 intval函数四舍五入.php
├── 15 strpos数组绕过NULL与ereg正则%00截断.php
├── 16 SQL注入or绕过.php
├── 17 密码md5比较绕过.php
├── 18 md5()函数===使用数组绕过.php
├── 19 ereg()函数strpos() 函数用数组返回NULL绕过.php
├── 20 十六进制与数字比较.php
├── 21 数字验证正则绕过.php
├── 22 弱类型整数大小比较绕过.php
├── 23 md5函数验证绕过.php
├── 24 md5函数true绕过注入.php
├── 25 switch没有break 字符与0比较绕过.php
├── 26 unserialize()序列化.php
├── 27.php
├── 28.php
├── 29.php
├── README.md
└── img
└── 24_1.png
/01 extract变量覆盖.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/02 绕过过滤的空白字符.php:
--------------------------------------------------------------------------------
1 | $value) {
19 | $value = trim($value); //trim — 去除字符串首尾处的空白字符(或者其他字符)
20 | is_string($value) && $req[$key] = addslashes($value); // is_string — 检测变量是否是字符串,addslashes — 使用反斜线引用字符串
21 | }
22 | }
23 |
24 |
25 | function is_palindrome_number($number) {
26 | $number = strval($number); //strval — 获取变量的字符串值
27 | $i = 0;
28 | $j = strlen($number) - 1; //strlen — 获取字符串长度
29 | while($i < $j) {
30 | if($number[$i] !== $number[$j]) {
31 | return false;
32 | }
33 | $i++;
34 | $j--;
35 | }
36 | return true;
37 | }
38 |
39 |
40 | if(is_numeric($_REQUEST['number'])) //is_numeric — 检测变量是否为数字或数字字符串
41 | {
42 |
43 | $info="sorry, you cann't input a number!";
44 |
45 | }
46 | elseif($req['number']!=strval(intval($req['number']))) //intval — 获取变量的整数值
47 | {
48 |
49 | $info = "number must be equal to it's integer!! ";
50 |
51 | }
52 | else
53 | {
54 |
55 | $value1 = intval($req["number"]);
56 | $value2 = intval(strrev($req["number"]));
57 |
58 | if($value1!=$value2){
59 | $info="no, this is not a palindrome number!";
60 | }
61 | else
62 | {
63 |
64 | if(is_palindrome_number($req["number"])){
65 | $info = "nice! {$value1} is a palindrome number!";
66 | }
67 | else
68 | {
69 | $info=$flag;
70 | }
71 | }
72 |
73 | }
74 |
75 | echo $info;
--------------------------------------------------------------------------------
/03 多重加密.php:
--------------------------------------------------------------------------------
1 | where))
11 | {
12 | $this->select($this->where);
13 | }
14 | }
15 | function select($where)
16 | {
17 | $sql = mysql_query('select * from user where '.$where);
18 | //函数执行一条 MySQL 查询。
19 | return @mysql_fetch_array($sql);
20 | //从结果集中取得一行作为关联数组,或数字数组,或二者兼有返回根据从结果集取得的行生成的数组,如果没有更多行则返回 false
21 | }
22 | }
23 |
24 | if(isset($requset['token']))
25 | //测试变量是否已经配置。若变量已存在则返回 true 值。其它情形返回 false 值。
26 | {
27 | $login = unserialize(gzuncompress(base64_decode($requset['token'])));
28 | //gzuncompress:进行字符串压缩
29 | //unserialize: 将已序列化的字符串还原回 PHP 的值
30 |
31 | $db = new db();
32 | $row = $db->select('user=\''.mysql_real_escape_string($login['user']).'\'');
33 | //mysql_real_escape_string() 函数转义 SQL 语句中使用的字符串中的特殊字符。
34 |
35 | if($login['user'] === 'ichunqiu')
36 | {
37 | echo $flag;
38 | }else if($row['pass'] !== $login['pass']){
39 | echo 'unserialize injection!!';
40 | }else{
41 | echo "(╯‵□′)╯︵┴─┴ ";
42 | }
43 | }else{
44 | header('Location: index.php?error=1');
45 | }
46 |
47 | ?>
--------------------------------------------------------------------------------
/04 SQL注入_WITH ROLLUP绕过.php:
--------------------------------------------------------------------------------
1 | '."
";
6 | echo ''."
";
7 | echo ''."
";
8 | echo ''."
";
9 | echo ''."
";
10 | echo ''."
";
11 | die;
12 | }
13 |
14 | function AttackFilter($StrKey,$StrValue,$ArrReq){
15 | if (is_array($StrValue)){
16 |
17 | //检测变量是否是数组
18 |
19 | $StrValue=implode($StrValue);
20 |
21 | //返回由数组元素组合成的字符串
22 |
23 | }
24 | if (preg_match("/".$ArrReq."/is",$StrValue)==1){
25 |
26 | //匹配成功一次后就会停止匹配
27 |
28 | print "水可载舟,亦可赛艇!";
29 | exit();
30 | }
31 | }
32 |
33 | $filter = "and|select|from|where|union|join|sleep|benchmark|,|\(|\)";
34 | foreach($_POST as $key=>$value){
35 |
36 | //遍历数组
37 |
38 | AttackFilter($key,$value,$filter);
39 | }
40 |
41 | $con = mysql_connect("XXXXXX","XXXXXX","XXXXXX");
42 | if (!$con){
43 | die('Could not connect: ' . mysql_error());
44 | }
45 | $db="XXXXXX";
46 | mysql_select_db($db, $con);
47 |
48 | //设置活动的 MySQL 数据库
49 |
50 | $sql="SELECT * FROM interest WHERE uname = '{$_POST['uname']}'";
51 | $query = mysql_query($sql);
52 |
53 | //执行一条 MySQL 查询
54 |
55 | if (mysql_num_rows($query) == 1) {
56 |
57 | //返回结果集中行的数目
58 |
59 | $key = mysql_fetch_array($query);
60 |
61 | //返回根据从结果集取得的行生成的数组,如果没有更多行则返回 false
62 |
63 | if($key['pwd'] == $_POST['pwd']) {
64 | print "CTF{XXXXXX}";
65 | }else{
66 | print "亦可赛艇!";
67 | }
68 | }else{
69 | print "一颗赛艇!";
70 | }
71 | mysql_close($con);
72 | ?>
--------------------------------------------------------------------------------
/05 ereg正则%00截断.php:
--------------------------------------------------------------------------------
1 | You password must be alphanumeric
*-* have not been found
'); 20 | } 21 | } 22 | else 23 | { 24 | echo 'Invalid password
'; 25 | } 26 | } 27 | ?> -------------------------------------------------------------------------------- /06 strcmp比较字符串.php: -------------------------------------------------------------------------------- 1 | 0;如果两者相等,返回 0。 5 | 6 | //比较两个字符串(区分大小写) 7 | die('Flag: '.$flag); 8 | else 9 | print 'No'; 10 | } 11 | 12 | ?> -------------------------------------------------------------------------------- /07 sha()函数比较绕过.php: -------------------------------------------------------------------------------- 1 | Your password can not be your name!'; 9 | else if (sha1($_GET['name']) === sha1($_GET['password'])) 10 | die('Flag: '.$flag); 11 | else 12 | echo 'Invalid password.
'; 13 | } 14 | else 15 | echo 'Login first!
'; 16 | ?> -------------------------------------------------------------------------------- /08 SESSION验证绕过.php: -------------------------------------------------------------------------------- 1 | Wrong guess.'; 11 | } 12 | mt_srand((microtime() ^ rand(1, 10000)) % rand(1, 10000) + rand(1, 10000)); 13 | ?> -------------------------------------------------------------------------------- /09 密码md5比较绕过.php: -------------------------------------------------------------------------------- 1 | connect_error) { 8 | die("Connection failed: " . mysql_error($conn)); 9 | } 10 | 11 | //赋值 12 | 13 | $user = $_POST[user]; 14 | $pass = md5($_POST[pass]); 15 | 16 | //sql语句 17 | 18 | // select pw from php where user='' union select 'e10adc3949ba59abbe56e057f20f883e' # 19 | 20 | // ?user=' union select 'e10adc3949ba59abbe56e057f20f883e' #&pass=123456 21 | 22 | $sql = "select pw from php where user='$user'"; 23 | $query = mysql_query($sql); 24 | if (!$query) { 25 | printf("Error: %s\n", mysql_error($conn)); 26 | exit(); 27 | } 28 | $row = mysql_fetch_array($query, MYSQL_ASSOC); 29 | //echo $row["pw"]; 30 | 31 | if (($row[pw]) && (!strcasecmp($pass, $row[pw]))) { 32 | 33 | //如果 str1 小于 str2 返回 < 0; 如果 str1 大于 str2 返回 > 0;如果两者相等,返回 0。 34 | 35 | 36 | echo "Logged in! Key:**************
"; 37 | } 38 | else { 39 | echo("Log in failure!
"); 40 | 41 | } 42 | } 43 | ?> -------------------------------------------------------------------------------- /10 urldecode二次编码绕过.php: -------------------------------------------------------------------------------- 1 | not allowed!"); 4 | exit(); 5 | } 6 | 7 | $_GET[id] = urldecode($_GET[id]); 8 | if($_GET[id] == "hackerDJ") 9 | { 10 | echo "Access granted!
"; 11 | echo "flag: *****************}
"; 12 | } 13 | ?> -------------------------------------------------------------------------------- /11 sql闭合绕过.php: -------------------------------------------------------------------------------- 1 | connect_error) { 8 | die("Connection failed: " . mysql_error($conn)); 9 | } 10 | $user = $_POST[user]; 11 | $pass = md5($_POST[pass]); 12 | 13 | //select user from php where (user='admin')# 14 | 15 | //exp:admin')# 16 | 17 | $sql = "select user from php where (user='$user') and (pw='$pass')"; 18 | $query = mysql_query($sql); 19 | if (!$query) { 20 | printf("Error: %s\n", mysql_error($conn)); 21 | exit(); 22 | } 23 | $row = mysql_fetch_array($query, MYSQL_ASSOC); 24 | //echo $row["pw"]; 25 | if($row['user']=="admin") { 26 | echo "Logged in! Key: ***********
"; 27 | } 28 | 29 | if($row['user'] != "admin") { 30 | echo("You are not admin!
"); 31 | } 32 | } 33 | 34 | ?> 35 | -------------------------------------------------------------------------------- /12 X-Forwarded-For绕过指定IP地址.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /13 md5加密相等绕过.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /14 intval函数四舍五入.php: -------------------------------------------------------------------------------- 1 | no! try again"; 10 | } 11 | else{ 12 | echo($query[content]); 13 | } 14 | } 15 | 16 | ?> -------------------------------------------------------------------------------- /15 strpos数组绕过NULL与ereg正则%00截断.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /16 SQL注入or绕过.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /17 密码md5比较绕过.php: -------------------------------------------------------------------------------- 1 | Logged in! Key: ntcf{**************} "; 14 | } 15 | else { 16 | echo("Log in failure!
"); 17 | } 18 | } 19 | 20 | ?> -------------------------------------------------------------------------------- /18 md5()函数===使用数组绕过.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /19 ereg()函数strpos() 函数用数组返回NULL绕过.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /20 十六进制与数字比较.php: -------------------------------------------------------------------------------- 1 | = $one) && ($digit <= $nine) ) 16 | { 17 | // Aha, digit not allowed! 18 | return "flase"; 19 | } 20 | } 21 | if($number == $temp) 22 | return $flag; 23 | } 24 | $temp = $_GET['password']; 25 | echo noother_says_correct($temp); 26 | 27 | ?> -------------------------------------------------------------------------------- /21 数字验证正则绕过.php: -------------------------------------------------------------------------------- 1 | = preg_match('/^[[:graph:]]{12,}$/', $password)) //preg_match — 执行一个正则表达式匹配 9 | { 10 | echo 'Wrong Format'; 11 | exit; 12 | } 13 | while (TRUE) 14 | { 15 | $reg = '/([[:punct:]]+|[[:digit:]]+|[[:upper:]]+|[[:lower:]]+)/'; 16 | if (6 > preg_match_all($reg, $password, $arr)) 17 | break; 18 | $c = 0; 19 | $ps = array('punct', 'digit', 'upper', 'lower'); //[[:punct:]] 任何标点符号 [[:digit:]] 任何数字 [[:upper:]] 任何大写字母 [[:lower:]] 任何小写字母 20 | foreach ($ps as $pt) 21 | { 22 | if (preg_match("/[[:$pt:]]+/", $password)) 23 | $c += 1; 24 | } 25 | if ($c < 3) break; 26 | //>=3,必须包含四种类型三种与三种以上 27 | if ("42" == $password) echo $flag; 28 | else echo 'Wrong password'; 29 | exit; 30 | } 31 | } 32 | 33 | ?> -------------------------------------------------------------------------------- /22 弱类型整数大小比较绕过.php: -------------------------------------------------------------------------------- 1 | 1336){ 9 | echo $flag; 10 | } 11 | 12 | ?> -------------------------------------------------------------------------------- /23 md5函数验证绕过.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /24 md5函数true绕过注入.php: -------------------------------------------------------------------------------- 1 | ' . mysql_error() . '' ); 19 | $row1 = mysql_fetch_row($result); 20 | var_dump($row1); 21 | mysql_close($link); 22 | ?> -------------------------------------------------------------------------------- /25 switch没有break 字符与0比较绕过.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /26 unserialize()序列化.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | readfile(); 12 | ?> 13 |