攻防世界系列 :warmup

1.打开题目,一个贱贱的滑稽表情

F12看到注释内容source.php

2.访问source.php

 <?php
highlight_file(__FILE__);
class emmm
{
public static function checkFile(&$page)
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
} if (in_array($page, $whitelist)) {
return true;
} $_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
} $_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
}
} if (! empty($_REQUEST['file'])
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
) {
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>

看到代码中白名单里还有hint.php文件

3.代码审计

if (! empty($_REQUEST['file'])
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
) {
include $_REQUEST['file'];
exit;
}

需要我们post方法传入一个file变量

满足

(1)file不为空

(2)file值是一个字符串

(3)通过checkFile()函数检查

其中checkFile()包括三次白名单检测,两次字符串截取,一次URL解码

几个重要的php函数

is_string()

//判断变量是否为字符串,是返回true否返回false

isset()

//判断变量是否被赋值,是返回true否返回false

in_array(a,b)

//从数组b中搜索值a

mb_strpos(a,b)

//返回要查找的字符串b在另一个字符串a中首次出现的位置

mb_substr(a,b,c)

//返回字符串a中从b开始长度为c(c参数可有可无,默认到结尾)的部分

4.构造payload

根据代码要求,file中要包含"hint.php"或"source.php",要有"?"可以把关键字"hint.php"或"source.php"截取出来。

所以payload为

file=hint.php?../../../../../../../ffffllllaaaagggg

file=source.php?../../../../../../../ffffllllaaaagggg



收工 !

攻防世界(十一)warmup的更多相关文章

  1. 攻防世界 WEB 高手进阶区 HCTF 2018 warmup Writeup

    攻防世界 WEB 高手进阶区 HCTF 2018 warmup Writeup 题目介绍 题目考点 PHP代码审计 Writeup 打开 http://220.249.52.134:37877 常规操 ...

  2. 攻防世界web新手区做题记录

    学校信安协会第一次培训结束后的作业,要求把攻防世界的web新手区题目做一遍并写题解. 第一题 view_source 查看源代码右键不能用,但是F12能用,于是找到源代码 输入到flag框即可 后来在 ...

  3. 攻防世界web新手区

    攻防世界web新手区 第一题view_source 第二题get_post 第三题robots 第四题Backup 第五题cookie 第六题disabled_button 第七题simple_js ...

  4. 攻防世界 WriteUp

    附:|>>>攻防世界-WEB-新手练习区<<<| WriteUp目录 01.|>>>baby_web<<<| 02.|>& ...

  5. 攻防世界-MISC:base64stego

    这是攻防世界新手练习区的第十一题,题目如下: 点击下载附件一,发现是一个压缩包,点击解压,发现是需要密码才能解密 先用010editor打开这个压缩包,这里需要知道zip压缩包的组成部分,包括压缩源文 ...

  6. CTF--web 攻防世界web题 robots backup

    攻防世界web题 robots https://adworld.xctf.org.cn/task/answer?type=web&number=3&grade=0&id=506 ...

  7. CTF--web 攻防世界web题 get_post

    攻防世界web题 get_post https://adworld.xctf.org.cn/task/answer?type=web&number=3&grade=0&id=5 ...

  8. 攻防世界 web进阶练习 NewsCenter

    攻防世界 web进阶练习 NewsCenter   题目是NewsCenter,没有提示信息.打开题目,有一处搜索框,搜索新闻.考虑xss或sql注入,随便输入一个abc,没有任何搜索结果,页面也没有 ...

  9. 【攻防世界】高手进阶 pwn200 WP

    题目链接 PWN200 题目和JarvisOJ level4很像 检查保护 利用checksec --file pwn200可以看到开启了NX防护 静态反编译结构 Main函数反编译结果如下 int ...

随机推荐

  1. JavaWeb 补充(Servlet)

    Servlet: server applet 概念: 运行在服务器端的小程序     * Servlet就是一个接口,定义了Java类被浏览器访问到(tomcat识别)的规则.     * 将来我们自 ...

  2. Cobalt Strike使用教程一

    Cobalt Strike使用教程一     0x00 简介 Cobalt Strike是一款基于java的渗透测试神器,常被业界人称为CS神器.自3.0以后已经不在使用Metasploit框架而作为 ...

  3. SpringBoot-如何设计优秀的后端接口?

    1 概述 本篇文章以Spring Boot为基础,从以下三个方向讲述了如何设计一个优秀的后端接口体系: 参数校验:涉及Hibernate Validator的各种注解,快速失败模式,分组,组序列以及自 ...

  4. Salesforce学习之路(五)role hierarchy & sharing

    1. Role Hierarchy 在私有或者混合模型中,如果在organization-wide defaults设置某个对象为Private,那么对象的记录只有拥有者可以查看.但是,role hi ...

  5. Tree UVA - 548

      You are to determine the value of the leaf node in a given binary tree that is the terminal node o ...

  6. JDBC_13_封装JDBC工具类

    封装JDBC工具类 代码: import java.sql.*; /** * JDBC工具类,简化JDBC编程 */ public class DBUtil { //工具类中的构造方法都是私有的,因为 ...

  7. 【pytest官方文档】解读fixtures - 10. fixture有效性、跨文件共享fixtures

    一.fixture有效性 fixture有效性,说白了就是fixture函数只有在它定义的使用范围内,才可以被请求到.比如,在类里面定义了一个fixture, 那么就只能是这个类中的测试函数才可以请求 ...

  8. 869. Reordered Power of 2

    Starting with a positive integer N, we reorder the digits in any order (including the original order ...

  9. jmeter响应时间与postman响应时间为什么不一样?

    postman响应时间 是一个线程或者一个用户再者说是发送一次请求的响应时间,一般都是200ms一下: 而jmeter属于并行,就是多个用户去访问这个功能点或者接口,多个用户同时访问,就会造成压力,自 ...

  10. 关于Number、parseInt、isNaN转化参数

    1.首先,关于NaN的相等判断 alert(NaN==NaN) //返回的是false: 2.isNaN 确定这个参数是否是数值或者是否可以被转化为数值:NaN是not a number 的缩写,所以 ...