ctf-writeups

Writeups for CTFs solved by DarkKnight

View on GitHub

OverTheWire Wargames

Natas Level 10 –> Level 11

Username: natas11

Password: U82q5TCMMQ9xuFoI3dYX61s7OZD9JKoK

URL: http://natas11.natas.labs.overthewire.org

Solution

$defaultencrypt = “ClVLIh4ASCsCBE8lAxMacFMZV2hdVVotEhhUJQNVAmhSRwh6QUcIaAw%3D”; $defaultencrypt = base64_decode($defaultencrypt);

function xor_encrypt($in, $key) { $text = $in; $outText = ‘’;

// Iterate through each character
for($i=0;$i<strlen($text);$i++) {
$outText .= $text[$i] ^ $key[$i % strlen($key)];
}

return $outText; }

$key = xor_encrypt($default, $defaultencrypt); echo $key ?>

* It will return "qw8Jqw8Jqw8Jqw8Jqw8Jqw8J" so we can say that key = "qw8J", now with the same function as source code lets encrypt our cookies
```php
<?php

function xor_encrypt($in) {
    $key = 'qw8J';
    $text = $in;
    $outText = '';

    // Iterate through each character
    for($i=0;$i<strlen($text);$i++) {
    $outText .= $text[$i] ^ $key[$i % strlen($key)];
    }

    return $outText;
}

$data = array( "showpassword"=>"yes", "bgcolor"=>"#ffffff");

$cookies =  base64_encode(xor_encrypt(json_encode($data)));

echo $cookies;
?>

Natas12 Password

EDXp0pS26wLKHZy1rDBPUZk0RKfLGIR3