班级作业笔记报告0x05

框架漏洞

作业1:

Apache解析漏洞

影响版本2.4.0~2.4.29

写入代码<?=phpinfo();?>

下方为真实校验的文件名,在文件名后方来个空格

进入十六进制Hex模式,找到文件名后缀的空格,十六进制为0x20即如图

将0x20修改成0x0a,A字符大小写都可以,回车保存

回到Raw模式,如图所示为成功,成功发包即可

访问上传成功的文件,evil1.php文件,但是因为在Hex上改成了evil1.php%0a,所以访问的时候也要加%0a

作业2:

Nginx解析漏洞

本质是Nginx配置错误导致的漏洞

上传文件

修改Content-Type和filename

访问路径,说image error

来个小操作,在文件名后面加个斜杠.php直接解析php,任意的/xxx.php也可以

作业3:

HTTP请求走私漏洞

jsp/tomcat使用getParameter("id")获取到的id参数是第1个id参数,第二个id参数不获取

php/apache2使用$_GET["id"]获取到的id参数是第2个id参数,第一个id参数不获取

因为这个特性,我们在遇到这两个服务时可以尝试利用请求走私漏洞它来绕过WAF的检测

作业4:

Nodejs原型链污染

原题是2020年网鼎杯的青龙组的一道题

参考https://www.anquanke.com/post/id/242645#h2-6

javascript 复制代码
var express = require('express');
var path = require('path');
const undefsafe = require('undefsafe');
const { exec } = require('child_process');

var app = express();
class Notes {
    constructor() {
        this.owner = "whoknows";
        this.num = 0;
        this.note_list = {};
    }

    write_note(author, raw_note) {
        this.note_list[(this.num++).toString()] = {"author": author,"raw_note":raw_note};
    }

    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);
    }

    get_all_notes() {
        return this.note_list;
    }

    remove_note(id) {
        delete this.note_list[id];
    }
}

var notes = new Notes();
notes.write_note("nobody", "this is nobody's first note");

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');

app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));

app.get('/', function(req, res, next) {
  res.render('index', { title: 'Notebook' });
});

app.route('/add_note')
    .get(function(req, res) {
        res.render('mess', {message: 'please use POST to add a note'});
    })
    .post(function(req, res) {
        let author = req.body.author;
        let raw = req.body.raw;
        if (author && raw) {
            notes.write_note(author, raw);
            res.render('mess', {message: "add note sucess"});
        } else {
            res.render('mess', {message: "did not add note"});
        }
    })

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('/delete_note')
    .get(function(req, res) {
        res.render('mess', {message: "please use POST to delete a note"});
    })
    .post(function(req, res) {
        let id = req.body.id;
        if (id) {
            notes.remove_note(id);
            res.render('mess', {message: "delete done"});
        } else {
            res.render('mess', {message: "delete failed"});
        }
    })

app.route('/notes')
    .get(function(req, res) {
        let q = req.query.q;
        let a_note;
        if (typeof(q) === "undefined") {
            a_note = notes.get_all_notes();
        } else {
            a_note = notes.get_note(q);
        }
        res.render('note', {list: a_note});
    })

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();
    })

app.use(function(req, res, next) {
  res.status(404).send('Sorry cant find that!');
});


app.use(function(err, req, res, next) {
  console.error(err.stack);
  res.status(500).send('Something broke!');
});

const port = 8080;
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))

复现需要做的是抓个/status包和/edit_note的POST包

访问/status包的时候会执行命令

访问/edit_note包的时候会添加命令

先访问/edit_note包在访问/status包,/status一次执行一个/edit_note的命令

/edit_note包需要传3个参数,id/author/raw,id传的是原型链__proto__,author传的是命令,raw传的是任意字符

现在的靶机目录下的文件

攻击机来一次/edit_note和/status包

靶机再一下目录文件,多了个123.txt文件,里面执行的命令是whoami的命令

个人评价:

我觉得框架漏洞是信息查,别人打不出来的你能打,而且顺利又神奇,次次bypass和rce都是有原因的,技多不压身,多一技多一力。

相关推荐
DeepModel4 小时前
通俗易懂讲透 Q-Learning:从零学会强化学习核心算法
人工智能·学习·算法·机器学习
云安全助手4 小时前
弹性云服务器+高防IP:让DDoS攻击不再是业务“生死劫”
运维·网络·安全
handler015 小时前
从零实现自动化构建:Linux Makefile 完全指南
linux·c++·笔记·学习·自动化
安小牛6 小时前
Android 开发汉字转带声调的拼音
android·java·学习·android studio
Hello_Embed6 小时前
嵌入式上位机开发入门(二十六):将 MQTT 测试程序加入 APP 任务
网络·笔记·网络协议·tcp/ip·嵌入式
不会编程的懒洋洋7 小时前
C# Task async/await CancellationToken
笔记·c#·线程·面向对象·task·同步异步
仙女修炼史7 小时前
CNN的捷径学习Shortcut Learning in Deep Neural Networks
人工智能·学习·cnn
kang0x07 小时前
easyRSA - Writeup by AI
安全
亚空间仓鼠7 小时前
网络学习实例:网络理论知识
网络·学习·智能路由器
薛定e的猫咪8 小时前
多智能体强化学习求解 FJSP 变体全景:动态调度、AGV 运输、绿色制造与开源代码导航
人工智能·学习·性能优化·制造