Created
August 31, 2016 20:32
-
-
Save ITAYC0HEN/5df90c37fcdd78196778475e67011f7a to your computer and use it in GitHub Desktop.
[CTF(x) 2016 : WEB] Harambehub – 100 pts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
import static spark.Spark.*; | |
/** | |
* Created by aashish on 8/26/16. | |
*/ | |
public class HarambeHub { | |
public static void main(String[] args) { | |
post("/users", (req, res) -> { | |
String username = req.queryParams("username"); | |
String password = req.queryParams("password"); | |
String realName = req.queryParams("real_name"); | |
if(username == null || password == null) { | |
return "FAILED"; | |
} | |
for(User user : User.users) { | |
if(user.getUsername().matches(username)) { | |
return "FAILED: User with that name already exists!"; | |
} | |
} | |
new User("[Member] " + username, password, realName); | |
return "OK: Your username is \"" + "[Member] " + username + "\""; | |
}); | |
get("/name", (req, res) -> { | |
String username = req.queryParams("username"); | |
String password = req.queryParams("password"); | |
if(username == null || password == null) { | |
return "FAILED"; | |
} | |
for(User user : User.users) { | |
if(user.verify(username, password)) { | |
return user.getRealName(); | |
} | |
} | |
return "FAILED"; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment