get_note(id) { var r = {} undefsafe(r, id, undefsafe(this.note_list, id)); return r; }
edit_note(id, author, raw) { undefsafe(this.note_list, id + '.author', author); undefsafe(this.note_list, id + '.raw_note', raw); }
}
var notes = new Notes();
app.route('/edit_note') .get(function(req, res) { res.render('mess', {message: "please use POST to edit a note"}); }) .post(function(req, res) { let id = req.body.id; let author = req.body.author; let enote = req.body.raw; if (id && author && enote) { notes.edit_note(id, author, enote); res.render('mess', {message: "edit note sucess"}); } else { res.render('mess', {message: "edit note failed"}); } })
app.route('/status') .get(function(req, res) { let commands = { "script-1": "uptime", "script-2": "free -m" }; for (let index in commands) { exec(commands[index], {shell:'/bin/bash'}, (err, stdout, stderr) => { if (err) { return; } console.log(`stdout: ${stdout}`); }); } res.send('OK'); res.end(); })
const port = 8080; app.listen(port, () =>console.log(`Example app listening at http://localhost:${port}`))
攻击过程解析: POST /edit_note路由传入id=__proto__.aaa&author={command}&raw=111 函数就会访问note_list字典的属性__proto__.aaa.author。因为aaa是不存在的属性,所以最后函数会将author参数的值赋给__proto__.author从而在字典原型中添加了一个author属性。每个实例使用for...in...都会遍历到这个属性。 exp:
#!/usr/bin/env python # -*- coding: utf-8 -*- from Crypto.Util.number import * import random
n = 2 ** 512 m = random.randint(2, n-1) | 1 c = pow(m, bytes_to_long(flag), n) print'm = ' + str(m) print'c = ' + str(c)
# m = 391190709124527428959489662565274039318305952172936859403855079581402770986890308469084735451207885386318986881041563704825943945069343345307381099559075 # c = 6665851394203214245856789450723658632520816791621796775909766895233000234023642878786025644953797995373211308485605397024123180085924117610802485972584499
n = 2**512 m = 391190709124527428959489662565274039318305952172936859403855079581402770986890308469084735451207885386318986881041563704825943945069343345307381099559075 c = 6665851394203214245856789450723658632520816791621796775909766895233000234023642878786025644953797995373211308485605397024123180085924117610802485972584499 print(discrete_log(n,c,m))