一、代码审计打开靶场,获得以下代码:// php版本:5.4.44 header("Content-type: text/html; charset=utf-8"); highlight_file(__FILE__); class evil{ public $hint; public function __construct($hint){ $this->hint = $hint; } public function __destruct(){ if($this->hint==="hint.php") @$this->hint = base64_encode(file_get_contents($this->hint)); var_dump($this->hint); } function __wakeup() { if ($this->hint != "
一、RCE简介RCE漏洞,全称远程命令/代码执行漏洞,可以让攻击者直接向后台服务器远程注入操作系统命令或者代码,从而控制后台系统。RCE分为:远程命令执行Remote Command Execute远程代码执行Remote Code Execute二、远程命令执行漏洞原理一般出现这种漏洞,是因为应用系统从设计上需要给用户提供指定的远程命令操作的接口。比如我们常见的路由器、防火墙、入侵检测等设备的web管理界面上。一般会给用户提供一个ping操作的web界面,用户从web界面输入目标IP,提交后,后台会对该IP地址进行一次ping测试,并返回测试结果。 如果,设计者在完成该功能时,没有做严格的安全控制,则可能会导致攻击者通过该接口提交“意想不到”的命令,从而让后台进行执行,从而控制整个后台服务器。这种漏洞形成的条件有两个:有执行系统命令的函数。函数中存在外部可操作的变量。相关函数system() :执行外部程序,并且显示输出exec()/shell_exec(): 通过 shell 环境执行命令,并且将完整的输出以字符串的方式返回pcntl_exec() :在当前进程空间执行指定程序pa
index.phpinclude 'tm.php'; // Next step in tm.php if (preg_match('/tm\.php\/*$/i', $_SERVER['PHP_SELF'])) { exit("no way!"); } if (isset($_GET['source'])) { $path = basename($_SERVER['PHP_SELF']); if (!preg_match('/tm.php$/', $path) && !preg_match('/index.php$/', $path)) { exit("nonono!"); } highlight_file($path); exit(); }basename函数漏洞:在使用默认语言环境设置时,basename() 会删除文件名开头的非 ASCII 字符。例如:$path1="/www/%ffindex.php"; echo basename
道格安全CTF-EZSSRF1. 代码审计进入靶场,我们发现一页PHP代码。<?php highlight_file(__FILE__); //find something in flag1.php <-- 提示1 $d = $_GET['d']; $file = $_GET['ctf']; if (filter_var($d, FILTER_VALIDATE_URL)) { $r = parse_url($d); if (isset($file)) { if (strpos($file, "lai") !== false && strpos($file, "ya") !== false) { @include($file . '.php');//解题点一 } else { die("Sorry, you can not pass"); } if (preg_matc
一、代码审计include("flag.php"); highlight_file(__FILE__); class FileHandler { protected $op; protected $filename; protected $content; function __construct() { $op = "1"; $filename = "/tmp/tmpfile"; $content = "Hello World!"; $this->process(); } public function process() { if($this->op == "1") { $this->write(); } else if($this->op == "2") {
Equinox
一个乐于分享的网安人