41 lines
1.1 KiB
Python
Executable File
41 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import base64
|
|
|
|
# public String urlEncode(byte[] input) {
|
|
# StringBuffer buf = new StringBuffer();
|
|
# for (int i=0; i<input.length; i++) {
|
|
# buf.append(String.format("%%%2x", input[i]));
|
|
# }
|
|
# return buf.toString();
|
|
# }
|
|
|
|
# public boolean checkPassword(String password) {
|
|
# String urlEncoded = urlEncode(password.getBytes());
|
|
# String base64Encoded = base64Encode(urlEncoded.getBytes());
|
|
# String expected = "JTYzJTMwJTZlJTc2JTMzJTcyJTc0JTMxJTZlJTY3JTVm"
|
|
# + "JTY2JTcyJTMwJTZkJTVmJTYyJTYxJTM1JTY1JTVmJTM2"
|
|
# + "JTM0JTVmJTY0JTMxJTM5JTM0JTM4JTY0JTM0JTY1";
|
|
# return base64Encoded.equals(expected);
|
|
# }
|
|
|
|
def url_decode(input: str) -> str:
|
|
return ''.join(chr(int(x, 16)) for x in input.split('%')[1:])
|
|
|
|
def main():
|
|
expected = (
|
|
"JTYzJTMwJTZlJTc2JTMzJTcyJTc0JTMxJTZlJTY3JTVm"
|
|
"JTY2JTcyJTMwJTZkJTVmJTYyJTYxJTM1JTY1JTVmJTM2"
|
|
"JTM0JTVmJTY0JTMxJTM5JTM0JTM4JTY0JTM0JTY1"
|
|
)
|
|
|
|
url_encoded = base64.b64decode(expected).decode()
|
|
|
|
result = url_decode(url_encoded)
|
|
|
|
print(f"picoCTF{{{result}}}")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|