代码区项目交易流程

Intended solutions for 35c3ctf 2018 web "php"


Last year (we're in 2019 now), I had the great pleasure (thanks to tsuro ) to write a challenge for the 35c3ctf , called php". 86% of the teams in the top100 solved it, with a total of 209 solves on 636 playing teams, so maybe it should have been used for the 35c3 junior ctf instead.

But on the other hand, I only got positive feedback about it, so maybe it was ok after all. Anyway, here is the code:

<?php $line = trim(fgets(STDIN)); $flag = file_get_contents('/flag'); class B { function __destruct() { global $flag; echo $flag; } } $a = @unserialize($line); throw new Exception('Well that was unexpected…'); echo $a;

There are several possible solutions.

The intended one was to borrow the fast destruct trick from phpcgg : setting our object as a value somewhere in an array, then overwriting the index with something else, triggering the garbage collection. The payload could look like this: a:2:{i:7;O:1:"B":0:{};i:7;i:0} .

An other route could be to feed invalid data to unserialize, because of the presence of the @ : - a non-existent object present in an array with a B instance: a:2:{i:0;O:1:"B":0:{}i:1;O:1:"LOL";} . - an invalid object property count, O:1:"B":1337:{} or O:1:"B":0:{"1337":0} .

本文开发(php)相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师

点击收藏

LAST Avast Highlights the Threat Landscape for 2019 Real-time Unique Input Validation with VueJS and Laravel NEXT