VulnHub靶场----Earth

免责声明

       文章为作者学习记录,请勿利用文章相关技术从事非法活动,

      如因此产生任何的不良后果与文章作者无关,本文仅供学习参考。

靶机:The Planets: Earth ~ VulnHub

攻击机:VM kali-linux

 1.信息收集

nmap:收集端口服务信息

1、nmap -p- 192.168.56.102

发现靶机开放了22,80,443端口

2、nmap -sC -sV -p 22,80,443 192.168.56.102 -oN nmap.log

发现443下绑定了两个域名:earth.local,terratest.earth.local

2.WEB渗透

访问WEB

80端口返回一个错误页面

 443端口返回一个正常页面,经过检查没什么用

绑定刚才扫描出的两个域名进行访问

vim /etc/hosts

访问earth.local,页面给出两个输入框,应该是把Message也对应key做加解密运算

目录扫描

扫描earth.local发现admin目录,访问发现是一个登录页面,试试常见弱口令与万能密码发现无用
 

gobuster dir -u https://earth.local -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -x .php,.txt,.zip -k

访问terratest.earth.local没啥用,并进行目录扫描,发现robots.txt文件(一般网站都会有)

gobuster dir -u https://terratest.earth.local -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -x .php,.txt,.zip -k

查看robots.txt:发现一个文件不知道后缀,利用后缀字典写个py脚本自动测试即可,这里因就一个文件于是手动尝试,发现后缀为.txt

 访问testing notes.txt:提示说使用XOR(异或)算法加密,并提示testdata.txt文件里面是加密密码,用户名为:terra

 访问testdata.txt:发现一段介绍地球的字符串,应该是密文

用earth.local首页下面的字符串(上面的图片没有截出来,也不想改了)与testdata.txt数据进行异或解码(最后解码是earthclimatechangebad4humansearthclimatechangebad4humans...;即earthclimatechangebad4humans的重复字符串)

推测密码为:earthclimatechangebad4humans

回到登录页面,使用terra账号,earthclimatechangebad4humans密码登录

登录成功

 反弹Shell

发现禁止远程连接,那就找找敏感文件呗

 最后在 /var/earth_web下找到第一个flag(user_flag.txt),在/var/earth_web/secure_message下找到forms.py文件,产看源码发现对数字ip进行了过滤,用带字母的16进制ip绕过

import re from ipaddress
import ip_address from django
import forms from django.forms
import ModelForm from django.core.exceptions
import ValidationError from .models 
import EncryptedMessage 
class MessageForm(ModelForm): 
    message_key = forms.CharField(max_length=50) 
class Meta:
     model = EncryptedMessage fields = ['message'] 
class CLICommandField(forms.CharField): 
    def validate(self, value): 
        super().validate(value) 
        for potential_ip in re.findall(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', value): 
            try: 
                ip_address(potential_ip) 
            except: 
                pass 
            else: 
                raise ValidationError('Remote connections are forbidden.') 
class CLIForm(forms.Form): 
    cli_command = CLICommandField(label='CLI command', max_length=100)

用带字母的16进制ip绕过(将ip换成16进制即可),进行反弹shell,成功反弹

 获得交互式shell

python -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
Ctrl + z

stty -a
stty raw -echo;fg
                reset
stty rows xxx columns yyy (xxx,yyy是stty -a命令输出的值)

3.提权

find查找有suid权限的文件

find / -perm -u=s -type f 2>/dev/null

发现reset_root文件,根据文件名判断应该跟root有关,用它来提权

执行reset_root,提示说缺少一些触发器,这里下载(用nc或http服务)到本地调试,用strace调试,缺少以下文件

 """复盘的时候,到这里靶机出现一些问题,应该是把靶机给玩坏了,然后一些操作就执行不了了,所以一些截图就没有了"""

在相应路径下创建好以上文件后,执行reset_root,发现root的密码被重置为Earth

"""我这里因为之前的操作,进程一直被占用,就不展示了"""

切换用户,拿到root权限,拿到第二个flag,Game Over!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值