Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<!DOCTYPE html> <html> <head> <title>I think you're on the right track now!</title> <s..

Decoded Output download

<!DOCTYPE html> 
<html> 
<head> 
<title>I think you're on the right track now!</title> 
<style> 
div.container { 
    width: 100%; 
    border: 1px solid gray; 
} 
 
header, footer { 
    padding: 1em; 
    color: white; 
    background-color: black; 
    clear: left; 
    text-align: center; 
} 
 
nav { 
    float: left; 
    max-width: 160px; 
    margin: 0; 
    padding: 1em; 
} 
 
nav ul { 
    list-style-type: none; 
    padding: 0; 
} 
    
nav ul a { 
    text-decoration: none; 
} 
 
article { 
    margin-left: 170px; 
    border-left: 1px solid gray; 
    padding: 1em; 
    overflow: hidden; 
} 
</style> 
</head> 
<body> 
 
<div class="container"> 
 
<header> 
   <h1>My great web-app!</h1> 
</header> 
   
<nav> 
  <ul> 
    <li><a href="?p=welcome">Welcome</a></li> 
    <li><a href="?p=flag">Flag</a></li> 
    <li><a href="?p=party">Let's Party!</a></li> 
    <li><a href="?p=reader">Feed Reader</a></li> 
  </ul> 
</nav> 
 
<article> 
<?php 
define('VIAINDEX', true); 
 
// Parameter is $_GET['p'] for the page. 
// Use of nullbytes appear to be mitigated in include() in PHP7. This is a good  
// thing. 
// But, fortunately for this CTF challenge, a direct include still works, so.. we'll 
// have to hack around this. 
 
$page = $_GET['p']; 
if(is_array($page)) { 
   die("Yeah? Nah.."); 
} 
 
// Check the local dir with .php appended 
if(file_exists($page . '.php')) { 
    $page = $page . '.php'; 
} 
 
if(strstr($page, 'passwd')) { 
    print "Now now.. We paid mega bucks to a big consultancy to mitigate skiddy tricks like that one! :trollface:"; 
    print "<br /><br /><br /><br />"; 
    print "<br /><br /><br /><br />"; 
} elseif(strstr($page, "access.log") || strstr($page, "nginx.log")) { 
    print ("Nup, we've blocked that one, but it's mitigated in Nginx now anyway"); 
} else { 
    include($page); 
} 
 
?> 
 
</article> 
 
<footer>Hack the Planet!</footer> 
 
</div> 
 
</body> 
</html> 
 

Did this file decode correctly?

Original Code

<!DOCTYPE html>
<html>
<head>
<title>I think you're on the right track now!</title>
<style>
div.container {
    width: 100%;
    border: 1px solid gray;
}

header, footer {
    padding: 1em;
    color: white;
    background-color: black;
    clear: left;
    text-align: center;
}

nav {
    float: left;
    max-width: 160px;
    margin: 0;
    padding: 1em;
}

nav ul {
    list-style-type: none;
    padding: 0;
}
   
nav ul a {
    text-decoration: none;
}

article {
    margin-left: 170px;
    border-left: 1px solid gray;
    padding: 1em;
    overflow: hidden;
}
</style>
</head>
<body>

<div class="container">

<header>
   <h1>My great web-app!</h1>
</header>
  
<nav>
  <ul>
    <li><a href="?p=welcome">Welcome</a></li>
    <li><a href="?p=flag">Flag</a></li>
    <li><a href="?p=party">Let's Party!</a></li>
    <li><a href="?p=reader">Feed Reader</a></li>
  </ul>
</nav>

<article>
<?php
define('VIAINDEX', true);

// Parameter is $_GET['p'] for the page.
// Use of nullbytes appear to be mitigated in include() in PHP7. This is a good 
// thing.
// But, fortunately for this CTF challenge, a direct include still works, so.. we'll
// have to hack around this.

$page = $_GET['p'];
if(is_array($page)) {
   die("Yeah? Nah..");
}

// Check the local dir with .php appended
if(file_exists($page . '.php')) {
    $page = $page . '.php';
}

if(strstr($page, 'passwd')) {
    print "Now now.. We paid mega bucks to a big consultancy to mitigate skiddy tricks like that one! :trollface:";
    print "<br /><br /><br /><br />";
    print "<br /><br /><br /><br />";
} elseif(strstr($page, "access.log") || strstr($page, "nginx.log")) {
    print ("Nup, we've blocked that one, but it's mitigated in Nginx now anyway");
} else {
    include($page);
}

?>

</article>

<footer>Hack the Planet!</footer>

</div>

</body>
</html>

Function Calls

define 1

Variables

None

Stats

MD5 a73c14b113ca0a74d1f362b1e1ca344b
Eval Count 0
Decode Time 157 ms