Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.
<HTML>
<HEAD><TITLE>Login Page</TITLE></HEAD>
<BODY>
<CENTER>
<FORM method="POST" action="http://yourserver/cgi-bin/login.py">
<paragraph> Enter your login name: <input type="text" name="login">
<paragraph> Enter your password: <input type=password name="password">
<paragraph> <input type="submit" value="Connect">
</FORM>
</CENTER>
<HR>

</form>
</BODY>
</HTML>

login.py:

#!/usr/local/bin/python
import cgi

def header(title):
   print "Content-type: text/html\n"
   print "<HTML>\n<HEAD>\n<TITLE>%s</TITLE>\n</HEAD>\n<BODY>\n" % (title)

def footer():
   print "</BODY></HTML>"

form = cgi.FieldStorage()
password = "python"

if not form:
   header("Login Response")
elif form.has_key("login") and form["login"].value != "" and form.has_key("password")       and form["password"].value == password:
header("Connected ..." )
   print "<center><hr><H3>Welcome back," , form["login"].value, ".</H3><hr></center>"
   print r"""<form><input type="hidden" name="session" value="%s"></form>""" % (form["login"].value)
   print "<H3><a href=browse.html>Click here to start browsing</a></H3>"

else:
   header("No success!")
   print "<H3>Please go back and enter a valid login.</H3>"

footer()

I would like to make this login form vulnerable to RCE (remote code execution), is this possible with the function eval() or exec().

I am looking for functions that introduce a vulnerability within the login form. Are there whole classes/modules that contain dangerous functionally? Also would it be possible to make this login form vulnerable to remote code execution?

share|improve this question
1  
Are you going to use this knowledge for good or for evil? –  Winston Ewert Feb 27 '12 at 15:39
    
This is for a hacking challenge i am creating :) so its for good :D (whitehat) –  xerxzz Feb 27 '12 at 16:01
add comment

1 Answer 1

I would like to make this login form vulnerable to RCE ( remote code execution), is this possible with the function eval() or exec()?

Yes. If you pass unchecked user input to either of those functions then you are allowing remote code execution.

I am looking for functions that introduce a vulnerability within the login form.I am particularly interested in Remote Code Execution vulnerabilities. Are there whole classes/modules that contain dangerous functionally?

Yes. Python can open files/delete files/connect to databases/etc. So yes there is plenty of bad things that could happen if you can execute arbitrary code.

Also would it be possible to make this login form vulnerable to remote code execution?

Yes. See above.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.