班级作业笔记报告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都是有原因的,技多不压身,多一技多一力。

相关推荐
栩栩云生11 分钟前
AI 写代码犯的错,早被写进了错题集
linux·安全·ai编程
AOwhisky23 分钟前
Python 学习笔记(第十三期)——运维自动化(下·前篇):远程命令执行——paramiko基础篇
运维·python·学习·云原生·自动化·运维开发·paramiko
前端世界34 分钟前
MySQL 基础入门(学习第4天)——约束与 DML 操作详解
数据库·学习·mysql
dear_bi_MyOnly37 分钟前
【SpringBoot配置文件】
java·spring boot·后端·学习·spring·java-ee·学习方法
AOwhisky1 小时前
Python 学习笔记(第十四期)——运维自动化(下·中篇):远程文件传输——paramiko进阶篇
运维·python·学习·云原生·自动化·文件传输·paramiko
huijingjituan1 小时前
新一代IM聊天软件|构建企业专属智能通讯生态
安全·实时互动·即时通讯·极光鸟·灰鲸
math_hongfan1 小时前
鸿蒙Flutter setState机制深入理解
学习·flutter·华为·harmonyos·鸿蒙
其实防守也摸鱼1 小时前
补天SRC新手入门指南:从0到1的漏洞挖掘之路
网络·python·学习·安全·web安全·数据挖掘·挖洞
●VON2 小时前
鸿蒙 PC Markdown 编辑器内部隐私与安全评审
安全·华为·编辑器·harmonyos·鸿蒙
星恒随风2 小时前
C++ STL 栈详解:stack 的使用、经典题目与简单模拟实现
开发语言·数据结构·c++·笔记·学习