For challenge Hack into Skynet
, there exists at least two possible ways.
- the first is to bypass the black box detection engine
Skynet
, which involves some levels of gussing how the internal logic works and find some method to bypass it. - the second method is to abuse flask, to make flask
get_data()
return something highly obfuscated to make skynet engine no way to work.
That is why the challenge description said which way do you prefer?
Here I would illustrate how to abuse flask.
First step first, you need to get a login session. Review the given code snippet,you can find there is a logical bug in there, which may let you obtain a session-id with empty username and arbitrary password.
Second step, leak data using the obvious sqli there. But sadly it's protected by skynet.
when http client post form data, application/x-www-form-urlencoded
is the most commonly used content type. But we could also use multipart/form-data
which is also a acceptable Content-Type
.
And soon you will find that str(get_data())
return the whole body to the detection engine, which make it harder for detection engine to work.
Further, reading into flask source code, we could notice that internally it use https://github.com/pallets/werkzeug/ as CGI wrapper. And when multipart form data has a Content-Type
header, werkzeug
would decode using python's internal bytes.decode
method https://github.com/pallets/werkzeug/blob/9efe8c00dcb2b6fc086961ba304729db01912652/src/werkzeug/formparser.py#L434
Thus, we could encode payload using some encoding like utf-16
to make payload obfuscated further. At this step, you could run any SQL injection statement as you like without worring about banned by the Skynet detection engine.