{"id":1395,"date":"2015-09-29T00:15:44","date_gmt":"2015-09-28T22:15:44","guid":{"rendered":"https:\/\/0x90r00t.com\/fr\/?p=1395"},"modified":"2015-09-29T18:59:54","modified_gmt":"2015-09-29T16:59:54","slug":"trend-micro-2015-progamming-100-write-up","status":"publish","type":"post","link":"https:\/\/0x90r00t.com\/fr\/2015\/09\/29\/trend-micro-2015-progamming-100-write-up\/","title":{"rendered":"[Trend Micro 2015] [Progamming 100] Write-Up"},"content":{"rendered":"<h2>Description<\/h2>\n<blockquote><p>Click on the different color.<\/p><\/blockquote>\n<p><!--more--><\/p>\n<h2>Resolution<\/h2>\n<p>Comme la description l&rsquo;indiquait, il fallait cliquer sur le carr\u00e9 qui avait une couleur diff\u00e9rente des autres.<\/p>\n<p>Ca a commenc\u00e9 doucement avec 2&#215;2 blocs, r\u00e9solvable humainement.<\/p>\n<p>Et \u00e0 chaque clic, la grille s&rsquo;agrandissait et les couleurs devenaient de moins en moins distinguables.<\/p>\n<p><a href=\"https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/Capture-25.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1396\" src=\"https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/Capture-25.png\" alt=\"blocs 5\" width=\"418\" height=\"419\" srcset=\"https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/Capture-25.png 418w, https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/Capture-25-150x150.png 150w, https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/Capture-25-300x300.png 300w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/a> Puis (\u00e7a commence \u00e0 \u00eatre tendu) :<\/p>\n<p><a href=\"https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/2300558bbe9f8e4393f7e84009afec60bb4625b5c810.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1397\" src=\"https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/2300558bbe9f8e4393f7e84009afec60bb4625b5c810.png\" alt=\"blocs 12\" width=\"399\" height=\"399\" srcset=\"https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/2300558bbe9f8e4393f7e84009afec60bb4625b5c810.png 399w, https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/2300558bbe9f8e4393f7e84009afec60bb4625b5c810-150x150.png 150w, https:\/\/0x90r00t.com\/wp-content\/uploads\/2015\/09\/2300558bbe9f8e4393f7e84009afec60bb4625b5c810-300x300.png 300w\" sizes=\"auto, (max-width: 399px) 100vw, 399px\" \/><\/a><\/p>\n<p>Voyant le nombre de possibilit\u00e9s s&rsquo;accroitre, nous avons alors cod\u00e9 un outil pour r\u00e9soudre ce challenge :<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n $page = 'http:\/\/ctfquest.trendmicro.co.jp:43210\/click_on_the_different_color';\r\n $border = 3;\r\n \r\n while (true) {\r\n  $data = file_get_contents($page);\r\n  if (preg_match('#ocation\\.href=\\'\/(.+?)\\?#', $data, $regs)) {\r\n   $dest = $regs&#x5B;1];\r\n   if (preg_match('#&lt;img src=&quot;(.+?)&quot;#', $data, $regs)) {\r\n    $img = imagecreatefrompng('http:\/\/ctfquest.trendmicro.co.jp:43210'.$regs&#x5B;1]);\r\n    if ($img) {\r\n     $bordercolor = imagecolorat($img, 0, 0); \/\/ Couleur de la bordure\r\n     $colorref = imagecolorat($img, $border+1, $border+1); \/\/ Couleur du bloc apr\u00e8s la bordure\r\n\r\n     for ($i = 1; true; ++$i) { \/\/ Check de la taille du bloc\r\n      if (($color = imagecolorat($img, $border+$i, $border+1)) == $bordercolor) { \/\/ Si la couleur n'est pas celle de la bordure\r\n       $blocksize = $i; \/\/ Taille d'un bloc\r\n       $blocs = (imagesx($img)-$border)\/($blocksize+$border); \/\/ Nombre de blocs\r\n       echo &quot;Size: $i\\nRef: $colorref\\nColor: $color\\nBorder: $bordercolor\\nBlocs: $blocs\\n&quot;; \/\/ Debug\r\n       for ($x = 0; $x &lt; $blocs; ++$x) { \/\/ Recherche du bloc diff\u00e9rent\r\n        for ($y = 0; $y &lt; $blocs; ++$y) {\r\n         $rx = ($blocksize+$border)*$x+$border+1;\r\n         $ry = ($blocksize+$border)*$y+$border+1;\r\n         \r\n         $test = imagecolorat($img, $rx, $ry); \/\/ Couleur du bloc \u00e0 tester\r\n         \r\n         if ($test != $colorref) { \/\/ Si couleur diff\u00e9rente de la r\u00e9f\u00e9rence, bingo ?\r\n          echo &quot;$rx \/ $ry : $test : $colorref\\n&quot;; \/\/ Debug\r\n          $page = 'http:\/\/ctfquest.trendmicro.co.jp:43210\/'.$dest.'?x='.$rx.'&amp;y='.$ry;\r\n          continue 4;\r\n         }\r\n        }\r\n       }\r\n       \r\n       break;\r\n      }\r\n     }\r\n    } else {\r\n     break;\r\n    }\r\n   }\r\n  } else {\r\n   echo $data;\r\n   break;\r\n  }\r\n }\r\n<\/pre>\n<p>Au bout de quelques secondes, jusqu&rsquo;\u00e0 arriver \u00e0 80&#215;80 blocs \u00e0 analyser, nous obtenons le flag !<\/p>\n<p><code>Le flag est : TMCTF{U must have R0807 3Y3s!}<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description Click on the different color.<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,35,95],"tags":[98,97,96,54],"class_list":["post-1395","post","type-post","status-publish","format-standard","hentry","category-2015-fr","category-ctf-fr","category-trend-micro-2015-fr","tag-couleurs","tag-gd","tag-programmation","tag-php"],"_links":{"self":[{"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/posts\/1395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/comments?post=1395"}],"version-history":[{"count":4,"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/posts\/1395\/revisions"}],"predecessor-version":[{"id":1434,"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/posts\/1395\/revisions\/1434"}],"wp:attachment":[{"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/media?parent=1395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/categories?post=1395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/0x90r00t.com\/fr\/wp-json\/wp\/v2\/tags?post=1395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}