• HTB_Start Point_Tier2——Oopsie


    渗透过程

    信息收集

    拿到目的靶机的IP,先进行端口扫描

    1. ┌──(root㉿kali)-[~/桌面]
    2. └─# nmap -A -sV -sC -Pn 10.129.165.49
    3. Starting Nmap 7.92 ( https://nmap.org ) at 2022-08-22 15:31 CST
    4. Nmap scan report for 10.129.165.49
    5. Host is up (0.51s latency).
    6. Not shown: 998 closed tcp ports (reset)
    7. PORT STATE SERVICE VERSION
    8. 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
    9. | ssh-hostkey:
    10. | 2048 61:e4:3f:d4:1e:e2:b2:f1:0d:3c:ed:36:28:36:67:c7 (RSA)
    11. | 256 24:1d:a4:17:d4:e3:2a:9c:90:5c:30:58:8f:60:77:8d (ECDSA)
    12. |_ 256 78:03:0e:b4:a1:af:e5:c2:f9:8d:29:05:3e:29:c9:f2 (ED25519)
    13. 80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
    14. |_http-title: Welcome
    15. |_http-server-header: Apache/2.4.29 (Ubuntu)
    16. No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
    17. TCP/IP fingerprint:
    18. OS:SCAN(V=7.92%E=4%D=8/22%OT=22%CT=1%CU=30215%PV=Y%DS=2%DC=T%G=Y%TM=6303312
    19. OS:8%P=x86_64-pc-linux-gnu)SEQ(SP=FD%GCD=1%ISR=10E%TI=Z%CI=Z%II=I%TS=A)OPS(
    20. OS:O1=M537ST11NW7%O2=M537ST11NW7%O3=M537NNT11NW7%O4=M537ST11NW7%O5=M537ST11
    21. OS:NW7%O6=M537ST11)WIN(W1=FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)ECN(
    22. OS:R=Y%DF=Y%T=40%W=FAF0%O=M537NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS
    23. OS:%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=
    24. OS:Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=
    25. OS:R%O=%RD=0%Q=)T7(R=N)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%R
    26. OS:UCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)
    27. Network Distance: 2 hops
    28. Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
    29. TRACEROUTE (using port 21/tcp)
    30. HOP RTT ADDRESS
    31. 1 605.11 ms 10.10.16.1
    32. 2 280.22 ms 10.129.165.49
    33. OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
    34. Nmap done: 1 IP address (1 host up) scanned in 87.95 seconds

    开放22 ssh远程登录端口及80 web服务端口 。因为22 端口存在认证,所以从 80端口入手

    访问80端口后,使用小插件获取到 login 的敏感路径。(叫 findsomething ,火狐及Chrome均可在对应插件商店下载)

    访问  http://10.129.165.49/cdn-cgi/login/

     

    发现可使用 guest 账户登录。猜测进去后越权。

     越权

     网站使用 cookie 辨识用户,我们 按下 F12 ,发现了 user 与 role 参数。

     尝试更改role 为admin,再访问 upload 功能,仍无法打开。则应是通过 user 的值判断是否为admin

    那 admin 的值为多少呢? 我第一反应是爆破。后来发现思路不对。正确思路是在 account 模块下发现了

     更改下方 user 的 value 值为 34322 ,访问 upload 模块

     上马

     文件上传点,上传一个php 的反弹shell。

     先对 shell 文件做个修改

    vim /usr/share/webshells/php/php-reverse-shell.php

     修改下方 IP 为本机 IP

     

     上传时,同时开启监听本地 1234端口

     上传成功。一般情况下,上传之后的文件存放在 upload、uploads 目录下。这里我没有爆破目录,直接猜到了。

    访问 http://10.129.165.49/uploads/php-reverse-shell.php,即可收到 shell

     

     /var/www/html 是web服务的目录,即网站的目录。这里的 cdn-cgi目录下发现了 db.php

    里面有连接数据库的账户密码

    1. robert
    2. M3g4C0rpUs3r!

    在 robert 的用户目录,发现他的flag

     提权

    目前拿到的是www-data用户的bash的执行权(执行 whoami 查看即可)、以及一个数据库的账户密码。因为在 home 文件夹下也发现了此账户,猜测此账户的密码与其数据库密码一致。

    配合最开始的ssh端口,想到先远程登录一下。

    ssh robert@10.129.165.49

     如果未开放ssh端口,仍要从 bash 转换为 伪终端,可执行

    python3 -c "import pty; pty.spawn('/bin/bash')"

     再切换到 robert账户。不过这样不稳定,毕竟还是基于反弹shell连接的。

    如何获得 root 权限呢?在上一个靶场中,我们通过查看 powershell 的命令记录获取到 Administrator 的权限,这次使用 SUID提权的方法。

    知识补充

    简谈SUID提权 - FreeBuf网络安全行业门户

    在本靶场中,如果 robert 用户执行的文件从属于 root 用户,就会用root用户的权限执行文件。

    查看 robert 所在用户组、搜索可执行的文件、并查看该文件有没有 s 权限

    1. robert@oopsie:~$ id
    2. uid=1000(robert) gid=1000(robert) groups=1000(robert),1001(bugtracker)
    3. robert@oopsie:~$ find / -group bugtracker 2>/dev/null
    4. /usr/bin/bugtracker
    5. robert@oopsie:~$ ls -al /usr/bin/bugtracker
    6. -rwsr-xr-- 1 root bugtracker 8792 Jan 25 2020 /usr/bin/bugtracker

     发现是有的。那么执行此文件。

    1. robert@oopsie:~$ /usr/bin/bugtracker
    2. ------------------
    3. : EV Bug Tracker :
    4. ------------------
    5. Provide Bug ID: 123
    6. ---------------
    7. cat: /root/reports/123: No such file or directory

     发现此程序的本质是 cat /root/reports/ 

    那么 cat 命令就是用root执行的。

    现在如果我们伪装 "/bin/bash" 为 cat,那么执行 此程序时,就会获得 root权限的shell

    在 tmp 目录下新建了一个 cat 文件,并赋予执行权限。cat 文件的内容是打开命令终端

     将 tmp 目录写入环境变量。那么 cat 命令 就被我们更新成 /bin/bash 了。root执行cat时,会打开终端

    执行 bugtracker 文件

    flag 文件在 /root/root.txt

    此时查看就不要用 cat 了。因为被我们替换了。换 more

    题目答案

    1、With what kind of tool can intercept web traffic?

    proxy

    2、What is the path to the directory on the webserver that returns a login page?

    /cdn-cgi/login

    3、What can be modified in Firefox to get access to the upload page?

    cookie

    4、What is the access ID of the admin user?

    34322

    5、On uploading a file, what directory does that file appear in on the server?

    /uploads

    6、What is the file that contains the password that is shared with the robert user?

    db.php

    7、What executible is run with the option "-group bugtracker" to identify all files owned by the bugtracker group?

    find

    8、Regardless of which user starts running the bugtracker executable, what's user privileges will use to run?

    root

    9、What SUID stands for?

    Set owner User ID

    10、What is the name of the executable being called in an insecure manner?

    cat

    11、Submit user flag

    f2c74ee8db7983851ab2a96a44eb7981

    12、Submit root flag

    af13b0bee69f8a877c3faf667f7beacf

  • 相关阅读:
    gitlab-runner配置与注册
    《JAVA程序设计》教学上机实验报告
    Vue3中props和defineEmit的区别
    ELK+Filebeat经典架构部署
    135. 分发糖果
    最小编辑距离-动态规划
    【rainbowzhou 面试9/101】技术提问--常见的大数据基准测试工具有哪些未命名文章
    QT object元对象
    新手学习PLC
    【汇编 C++】多态底层---虚表、__vfptr指针
  • 原文地址:https://blog.csdn.net/m0_46607055/article/details/126467205