CTF Sharing 19 Nov 2018
P.W.N. University - CTF 2018
https://uni.hctf.fun/
Thinking out of the box
No advanced programming technique is required to solve the following CTF problem
1) Java Script
var http = require('http'); const crypto = require('crypto'); var url = require('url'); var fs = require('fs'); var _0x86d1=["\x68\x65\x78","\x72\x61\x6E\x64\x6F\x6D\x42\x79\x74\x65\x73"]; function generatePart1() { return { x: crypto[_0x86d1[1]](8) }[x].toString(_0x86d1[0]); } function generatePart2() { return [+!+[]]+[!+[]+!+[]+!+[]]+[!+[]+!+[]+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]; } http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); passwd = generatePart1() + generatePart2(); var url_content = url.parse(req.url, true); if (passwd == url_content.query.passwd) { res.write(fs.readFileSync('flag.txt', 'utf8')); } else { res.write('<html><body><form method="get"><input type="text" name="passwd" value="password"><input type="submit" value="login" /></form></body></html>'); } res.end(); }).listen(8888);
Source: https://drive.google.com/open?id=1h0xoqLcmBqPolviSZFcl8kmQAV6uZKdN
Tips
2) PHP
<?php include("flag.php"); if (isset($_GET['passwd'])) { if (hash("md5", $_GET['passwd']) == '0e514198428367523082236389979035') { echo $flag; } } else { echo '<html><body><form method="get"><input type="text" name="passwd" value="password"><input type="submit" value="login" /></form></body></html>'; } ?>
Source: https://drive.google.com/file/d/1Q3Zb444wWUAwLuOe3bQBDObPoDAhuycp/view
Tips
3) Python
from flask import Flask, request, send_from_directory app = Flask(__name__) passwd = open("/opt/passwd.txt").read() flag = open("/opt/flag.txt").read() @app.route('/') def index(): userpw = request.args.get("passwd", "") if userpw == passwd: return flag, 200, {"Content-Type": "text/plain"} else: return '<html><body><form method="get"><input type="text" name="passwd" value="password"><input type="submit" value="login" /></form></body></html>' if __name__ == '__main__': assert(len(passwd) == 3) assert(passwd.isdigit()) app.run()
Source: https://drive.google.com/file/d/1HEYoj6ScY3KexZW6eU9SzNue8YFvSIbk/view
Tips
No comments:
Post a Comment