首页 > 其他分享 >NKCTF2024

NKCTF2024

时间:2024-03-26 22:12:27浏览次数:30  
标签:code const NKCTF2024 res app let require

my first cms

搜索版本

image-20240325215650662

image-20240325220527845

跳转到登录页面

爆破出用户密码admin Admin123

Extensions > User Defined Tags -> Add User Defined Tag

一句话木马 Run拿到flag

全世界最简单的CTF

拿到源码 格式化

const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const fs = require("fs");
const path = require('path');
const vm = require("vm");
 
app
.use(bodyParser.json())
.set('views', path.join(__dirname, 'views'))
.use(express.static(path.join(__dirname, '/public')))
 
app.get('/', function (req, res){
    res.sendFile(__dirname + '/public/home.html');
})
 
 
function waf(code) {
    let pattern = /(process|\[.*?\]|exec|spawn|Buffer|\\|\+|concat|eval|Function)/g;
    if(code.match(pattern)){
        throw new Error("what can I say? hacker out!!");
    }
}
 
app.post('/', function (req, res){
        let code = req.body.code;
        let sandbox = Object.create(null);
        let context = vm.createContext(sandbox);
        try {
            waf(code)
            let result = vm.runInContext(code, context);
            console.log(result);
        } catch (e){
            console.log(e.message);
            require('./hack');
        }
})
 
app.get('/secret', function (req, res){
    if(process.__filename == null) {
        let content = fs.readFileSync(__filename, "utf-8");
        return res.send(content);
    } else {
        let content = fs.readFileSync(process.__filename, "utf-8");
        return res.send(content);
    }
})
 
 
app.listen(3000, ()=>{
    console.log("listen on 3000");
})

js沙盒逃逸

标签:code,const,NKCTF2024,res,app,let,require
From: https://www.cnblogs.com/ningweiyu/p/18097735

相关文章

  • NKCTF2024-WEB-gxngxngxn
    WEBmyfirstcmscmsmadesimple2.2.19参考:GitHub-capture0x/CMSMadeSimple后台有个rce漏洞访问/admin路由直接爆破弱口令得到admin/Admin123然后访问admin/editusertag.php修改为:<?phpechosystem('cat/_fffff1@g');?>得到flag用过就是熟悉拿到源码进行审......