Question: The server uses the following Python code, which escapes the username and applies the MD 5 hash function to the password. Warning: This target is

The server uses the following Python code, which escapes the username and applies the MD5 hash function to the password.
Warning: This target is significantly more difficult than the previous two SQL injection targets. We strongly urge you to start early.
```
from hashlib import md5
from flask import request
@app.route("/sqlinject/2", methods=["POST"])
def login():
username = request.form["username"]
escaped_username = mysql_real_escape_string(username)
password_bytes = request.form["password"].encode("latin-1")
password_digest = md5(password_bytes).digest().decode("latin-1")
query = "SELECT * FROM users WHERE username='"+ escaped_username +"' AND passwc
selected_users = mysql.execute(query).fetchall()
if len(selected_users)>0:
return "Login successful!"
else:
return "Incorrect username or password."
```
This is more difficult than the previous two defenses. You will need to write a program to produce a working exploit. You can use any language you like, but we recommend Python 3.
Please put all source files for your program into the sql_2-src directory in the starter files. At submission, please archive this directory, making a ZIP file named sql_2-src.zip.
Hint: If your script is taking a really long time to run, it may be worth designing an SQL injection that it will have an easier time finding. Consider looking at the W3 Schools SQL Operators page for some inspiration.
The server uses the following Python code, which

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!