攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. ·...

21
第一部分 攻击者杀链 1走进Kali Linux 2确定目标——被动侦察 3主动侦察和漏洞扫描 4漏洞利用 5后期利用——行动的目的 6后期利用——持久性 Part 1

Upload: others

Post on 25-Nov-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第一部分

攻击者杀链

■ 第1章 走进Kali Linux■ 第2章 确定目标——被动侦察■ 第3章 主动侦察和漏洞扫描■ 第4章 漏洞利用■ 第5章 后期利用——行动的目的■ 第6章 后期利用——持久性

Part 1

Page 2: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第 1 章

走进 Kali Linux

Kali Linux(Kali)是 BackTrack 渗透测试平台的后继产品,BackTrack 通常被认为是标

准工具包,该工具包使安全数据和语音网络的渗透测试更加方便。本章介绍 Kali,并着重

讲解如何定制 Kali 以支持高级渗透测试。本章主要的知识点如下:

� Kali 简介

� 网络服务和安全通信配置

� Kali 更新

� Kali 定制

� 用第三方应用程序扩展 Kali 的功能

� 渗透测试集的有效管理

1.1 Kali Linux

BackTrack(BT)(www.offensive-security.com)是一种可扩展、多样化的渗透测试和防

御工具,旨在帮助安全审计员和网络管理员正确评估网络安全。授权和未经授权的渗透测

试人员(黑客)都在使用这一工具。

2012 年 8 月,BackTrack 发布了最新版本 BT 5r3。BT 5r3 版本基于 Ubuntu Linux 操作

系统,并且已经被安全团体普遍采用和支持。但由于该版本的文件体系结构,导致对工具

列表及其关联性的管理变得困难。

在 BackTrack 中,所有渗透测试工具均放置在 / pentest 目录下,而子目录 /web 或 /database 帮助定义本地工具。然而,在这样的文件系统层次结构中,要寻找和执行任意工具

并非易事。例如,对于 sqlninja,将其译成 SQL 注入还是网络漏洞评估工具,或者是网络

Chapter 1

Page 3: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   3

攻击工具还是数据库开发工具?

2013 年 3 月,基于 Debian GNU/Linux 操作系统的渗透测试新工具 Kali Linux 取代了

BackTrack,它使用一种新的平台体系结构。

Debian 遵守文件系统层次结构标准(Filesystem Hierarchy Standard,FHS),对于

BackTrack,这是 Debian 的一个显著优点。不需要浏览 / 渗透测试树导航,可以从系统的任

何地方调用一个工具,因为应用都包含在系统路径中。

Kali 包含的其他特征如下:

� 支持多种桌面环境,例如 Gnome、KDE、LXDE 以及 XFCE,也支持多种语言。

� 兼容 Debian 的工具一天至少和 Debian 资源库同步四次,使更新封装包和支持安全

修复更容易。

� 支持 ISO 自定义,也就是允许用户建立他们自己的 Kali 版本。引导程序功能也执行

企业级网络的安装,可以用先前的种子文件进行自动化安装。

� ARMEL 和 ARMHF 支持,允许 Kali 安装在 Raspberry Pi、ODROID-U2/-X2,以及

Samsung Chromebook 这些硬件上。

� 包含超过 300 个渗透测试、数据取证和防御工具。它们由内核补丁程序提供无线支

持,允许一些数据包注入无线攻击。

� Kali 保留了一个免费的开源项目。最重要的是,它得到了活跃的在线社区的支持。

在本书中,我们使用 64 位 Kali 环境下的 VMware 虚拟机(具体安装步骤请参考本书

附录)。

使用 VM,是因为在其他操作系统中很容易快速地执行某些应用,例如微软的

Windows 系统。另外,VM 可以和渗透测试结果一起归档,通过评估档案,来决定一个特

定的漏洞是否被测试工具集检

测到。

Kali 安装完成后,用户可

以看到系统默认的 GUI 的顶部

菜单栏和一些简单的图标。通

过 选 择 菜 单 项 Applications,然后选择 Kali Linux,用户可

以访问菜单系统,菜单系统包

含前 10 个安全工具(Top 10 Security Tools)以及一系列文

件夹,这些工具由渗透测试期

间遵循的一般顺序来排列,如

图 1.1 所示。

Chapter 4

[ 135 ]

Optical flow is the process of matching selected points from one image to another, assuming both images are part of a sequence and relatively close to one another. Most optical flow methods compare a small region, known as the search window or patch, around each point from image A to the same area in image B. Following a very common rule in computer vision, called the brightness constancy constraint (and other names), the small patches of the image will not change drastically from one image to the other, and therefore the magnitude of their subtraction should be close to zero. In addition to matching patches, newer methods of optical flow use a number of additional methods to get better results. One is using image pyramids, which are smaller and smaller resized versions of the image, which allow for working "from-coarse-to-fine"—a very well-used trick in computer vision. Another method is to define global constraints on the flow field, assuming that the points close to each other "move together" in the same direction. A more in-depth review of optical flow methods in OpenCV can be found in Chapter Developing Fluid Wall Using the Microsoft Kinect which is available on the Packt website..

Using optical flow in OpenCV is fairly easy by invoking the calcOpticalFlowPyrLK function. However, we would like to keep the result matching from OF similar to that using rich features, as in the future we would like the two approaches to be interchangeable. To that end, we must install a special matching method—one that is interchangeable with the previous feature-based method, which we are about to see in the code section that follows:

Vector<KeyPoint>left_keypoints,right_keypoints;

// Detect keypoints in the left and right imagesFastFeatureDetectorffd;ffd.detect(img1, left_keypoints);ffd.detect(img2, right_keypoints);

vector<Point2f>left_points;KeyPointsToPoints(left_keypoints,left_points);

vector<Point2f>right_points(left_points.size());

// making sure images are grayscaleMat prevgray,gray;if (img1.channels() == 3) { cvtColor(img1,prevgray,CV_RGB2GRAY); cvtColor(img2,gray,CV_RGB2GRAY);} else { prevgray = img1;

BT 5r3 用户应熟悉这个菜单。然而,也存在一些改变,包括简化了的网络服务

和通信访问。

图 1.1 Kali Linux 启动菜单

Page 4: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

4   第一部分 攻击者杀链

1.2 配置网络服务和安全通信

使用 Kali 的第一步是确保其连接到有线网络或者无线网络,用来支持更新和用户自定义。

你或许需要通过动态主机配置协议(Dynamic Host Configuration Protocol,DHCP)得

到 IP 地址,或者静态分配。

首先,在终端窗口中,用命

令 ifconfig 来确认你的 IP 地

址,如图 1.2 所示。

在 这 个 特 殊 情 况 下,

VM 被 分 配 到 IP 地 址 192. 168.204.132。 如 果 没 有 获

得 IP 地址,可以通过命令

dhclient eth0(或者其他可用

的、依靠系统特定配置的端口)使用 DHCP 来分配地址。

如果一个静态 IP 地址被使用了,那么就需要添加信息。例如,通过如下代码可以分配

一个静态的 IP 地址 192.168.204.128:

Starting with Kali Linux

[ 18 ]

Configuring network services and secure communicationsThe first step in being able to use Kali is to ensure that it has connectivity to either a wired or wireless network to support updates and customization.

You may need to obtain an IP address by DHCP (Dynamic Host Configuration Protocol), or assign one statically. First, confirm your IP address using the ifconfig command from a terminal window, as shown in the following screenshot:

In this particular case, the VM has been assigned an IP address of 192.168.204.132. If an IP address was not obtained, an address can be assigned by DHCP using the command dhclient eth0 (or other available interfaces, which will depend on the specific configuration of the system being used).

If a static IP address is used, additional information may be required. For example, you can assign a static IP of 192.168.204.128 as follows:

host IP address: 192.168.204.128

subnet mask: 255.255.255.0

default gateway: 192.168.204.1

DNS server: 192.168.204.10

打开终端窗口并输入以下命令:

Chapter 1

[ 19 ]

Enter a terminal window and enter the following command:

root@kali:~# ifonconfig eth0 192.168.204.128/24

root@kali:~# route add default gw 192.168.204.1

root@kali:~# echo nameserver 192.168.204.10 > /etc/resolv.conf

Changes made to IP settings are nonpersistent, and will be lost when Kali is rebooted. To make the changes permanent, you will need to edit the /etc/network/interfaces file, as shown in the following screenshot:

By default, Kali does not start with the DHCP service enabled. Doing so announces the new IP address on the network, and this may alert administrators about the presence of the tester. For some test cases, this may not be an issue, and it may be advantageous to have certain services start automatically during boot up. This can be achieved by entering the following commands:

root@kali~# update-rc.d networking defaults

root@kali~# /etc/init.d/networking restart

Kali installs with network services that can be started or stopped as required, including DHCP, HTTP, SSH, TFTP, and the VNC server. These services are usually invoked from the command line, however, some are accessible from the Kali menu.

这时的 IP 设置是非持续的,当 Kali 重新启动时,设置的 IP 会恢复原有状态。为了使

配置永久保持,需要编辑 /etc/network/interfaces 文件,如图 1.3 所示。

图 1.3 编辑 IP 地址

图 1.2 使用 ifconfi g 命令确认 IP 地址

Page 5: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   5

默认情况下,Kali 启动时没有激活 DHCP 服务。先声明新的网络 IP 地址,这样可能警

告管理员:存在测试人员。对一些测试实例,这不仅仅不是问题,而且还有利于在启动期

间自动开启一些服务。可以通过输入以下命令来实现:

Chapter 1

[ 19 ]

Enter a terminal window and enter the following command:

root@kali:~# ifonconfig eth0 192.168.204.128/24

root@kali:~# route add default gw 192.168.204.1

root@kali:~# echo nameserver 192.168.204.10 > /etc/resolv.conf

Changes made to IP settings are nonpersistent, and will be lost when Kali is rebooted. To make the changes permanent, you will need to edit the /etc/network/interfaces file, as shown in the following screenshot:

By default, Kali does not start with the DHCP service enabled. Doing so announces the new IP address on the network, and this may alert administrators about the presence of the tester. For some test cases, this may not be an issue, and it may be advantageous to have certain services start automatically during boot up. This can be achieved by entering the following commands:

root@kali~# update-rc.d networking defaults

root@kali~# /etc/init.d/networking restart

Kali installs with network services that can be started or stopped as required, including DHCP, HTTP, SSH, TFTP, and the VNC server. These services are usually invoked from the command line, however, some are accessible from the Kali menu.

Kali 安装时就包含了网络服务,且它可以在需要时开启或关闭,包括 DHCP、HTTP、SSH、 TFTP 以及 VNC 服务器。这些服务通常由命令行来调用,但其中一些也可以通过 Kali菜单项来访问。

1.2.1 调整网络代理设置

用户分为经过验证的,或者未经过验证的。连接时必须更改 bash.bashrc 和 apt.conf。这两个文件都在 /root/etc 目录中。

1. 编辑 bash.bashrc 文件,如图 1.4 所示,用文本编辑器打开文件,并添加以下内容到

bash.bashrc 文件底部:

Starting with Kali Linux

[ 20 ]

Adjusting network proxy settingsUsers located behind an authenticated or unauthenticated proxy connection must modify bash.bashrc and apt.conf. Both files are located in the /root/etc directory.

1. Edit the bash.bashrc file, as shown in the following screenshot, use a text editor to add the following lines to the bottom of the bash.bashrc file:export ftp_proxy="ftp://user:password@proxyIP:port"

export http_proxy="http://user:password@proxyIP:port"

export https_proxy="https://user:password@proxyIP:port"

export socks_proxy="https://user:password@proxyIP:port"

2. Replace proxyIP and port with your proxy IP address and port number respectively, and replace the username and password with your authentication username and password. If there's no need to authenticate, write only the part following the @ symbol.

3. In the same directory, create the apt.conf file and enter the following command lines, as shown in the following screenshot:

图 1.4 编辑 bash.bashrc 文件

Page 6: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

6   第一部分 攻击者杀链

2. 分别用你的代理 IP 地址和端口号代替 proxyIP 和 port,然后用你的验证用户名和密

码代替用户名和密码。如果不需要验证,那么只需要写 @ 符号后面的部分。

3. 在同一个目录中,创建 apt.conf 文件,输入下面的命令行,如图 1.5 所示。

图 1.5 编辑 apt.conf 文件

4. 保存并关闭文件。注销后重新登录以激活新的配置。

1.2.2 使用安全 Shell 保护通信安全

在测试过程中,为了最小化被目标网络检测到的可能,Kali 不用任何外部监听网络服

务。一些服务已经安装,例如安全 Shell(SSH,Secure Shell)。自然,必须优先使用它们。

Kali 用默认的 SSH 密钥进行预配置。在开启 SSH 服务前,禁用默认密钥,并生成一个

唯一的密钥集以供使用。

将默认的 SSH 密钥移动到备份文件夹,然后通过下列命令生成一个新的 SSH 密钥集:

Chapter 1

[ 21 ]

4. Save and close the file. Log out and then log in to activate the new settings.

Securing communications with Secure ShellTo minimize detection by a target network during testing, Kali does not enable any externally-listening network services. Some services, such as Secure Shell (SSH), are already installed. However, they must be enabled prior to use.

Kali comes preconfigured with default SSH keys. Before starting the SSH service, it's a good idea to disable the default keys and generate a unique keyset for use.

Move the default SSH keys to a backup folder, and then generate a new SSH keyset using the following command:

dpkg-reconfigure openssh-server

The process of moving the original keys and generating the new keyset is shown in the following screenshot.移动原始密钥和生成新密钥集的过程是公开的,如图 1.6 所示。

图 1.6 移动密钥

为了验证新生成的密钥是唯一的,计算它们的哈希值 md5sum,然后和原始密钥进行比

较,如图 1.7 所示。

要用菜单项来开启 SSH 服务,依次选择 Applications | Kali Linux |System Services | SSHD | SSHD Start。

Page 7: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   7

用命令行启动 SSH 服务,如图 1.8 所示。

 

图 1.7 计算 md5sum 与原始密钥进行比较 图 1.8 用命令行启动 SSH 服务

为了验证 SSH 正在运行,执行一个 netstat 查询,如图 1.9 所示。

图 1.9 运行 netstat 检查 SSH 运行状态

在先前的例子中,SSH 的守护进程正在监听 22 号端口。使用如下命令行终止 SSH:

Starting with Kali Linux

[ 22 ]

To verify that the newly generated keys are unique, calculate their md5sum hash values, and compare with the original keys as shown in the following screenshot.

To start the SSH service using the menu, select Applications | Kali Linux | System Services | SSHD | SSHD Start.

To start SSH from the command line, use the command line shown in the following screenshot:

To verify that SSH is running, perform a netstat query, as shown in the following screenshot:

The SSH daemon is listening on port 22 in the previous example. To stop SSH, use the following command:

/etc/init.d/ssh stop

1.3 更新 Kali Linux

Kali 必须定期打补丁,确保基本的操作系统和应用是最新的,同时更新了安全补丁。

Debian 软件包管理系统

Debian 的软件包管理系统是一个独立绑定的应用,叫作软件包(packages)。在自定义

环境中,用户可以安装或者移除软件包,软件包也支持一些任务,例如渗透测试。它们也

可以扩展 Kali 的一些功能,支持一些任务,例如通信(Skype、即时消息、安全邮件等)或

者编辑文档(在 Wine 环境下运行的 OpenOffice 和 Microsoft Office)。

软件包存储在资源库中,用户下载到自己的系统中,以此确保软件包是完整的。

软件包和资源库默认情况下,Kali 只使用官方的 Kali 资源库。不完整的安装进程可能不能把资源库添

加到正确的 source.list 文件,或者当有新的应用添加时,你可能希望扩展可用的资源库。

用命令行来更新 source.list 文件(echo deb http://http.kali.org/kiali kali main contrib non-free >> /etc/apt/sources.list),或者用一个文本编辑器来更新。

Page 8: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

8   第一部分 攻击者杀链

默认程序包资源库在目录 /etc/apt/sources.list 中,如下所示;如果不存在,编辑

sources.list 文件,增加它们。

Chapter 1

[ 23 ]

Updating Kali LinuxKali must be patched regularly to ensure that the base operating system and applications are up-to-date and that security patches have been applied.

The Debian package management systemDebian's package management system relies on discrete bundled applications called packages. Packages can be installed or removed by the user to customize the environment, and support tasks such as penetration testing. They can also extend the functionality of Kali, supporting tasks, such as communications (Skype, instant messaging, and secure e-mails) or documentation (OpenOffice and Microsoft Office running under Wine).Packages are stored in repositories and are downloaded to the system user to ensure the integrity of the package.

Packages and repositoriesBy default, Kali uses only the official Kali repositories. It is possible that an incomplete installation process may not add the repositories to the correct sources.list file, or that you may wish to extend the available repositories when new applications are added.Updating the source.list file can be done from the command line (echo deb http://http.kali.org/kiali kali main contrib non-free >> /etc/apt/sources.list), or by using a text editor.

The default package repositories that should be present in /etc/apt/sources.list are listed as follows; if not present, edit the sources.list file to include them:

## Kali deb http://http.kali.org/kali kali main contrib non-free ## Kali-dev deb http://http.kali.org/kali kali-dev main contrib non-free ## Kali Security updates deb http://security.kali.org/kali-security kali/updates main contrib non-free

Not every Kali tool is presently maintained in the official tool repositories. If you choose to update a tool manually, it is possible that you will overwrite existing packaged files and break dependencies. Therefore, some tools that have not been officially moved to Debian repositories, such as the aircrack-ng, dnsrecon, sqlmap, beef-xss, and Social Engineering Toolkit (se-toolkit), are maintained in the Bleeding Edge repository. This repository may also be added to sources.list using the following command line:

## Bleeding Edge repository deb http://repo.kali.org/kali kali kali-bleeding-edge main

官方工具资源库中并不包含所有的 Kali 工具。如果你选择手动更新一个工具,那么你

有可能重写现有的软件包文件,并破坏依赖性。因此,存在一些没正式地移入 Debian 资源

库中的工具,例如 aircrack-ng、 dnsrecon、 sqlmap、beef-xss 等,以及社交工程工具包(Social Engineering Toolkit),这些工具由 Bleeding Edge 资源库维护。用下面的命令行将资源库添

加到 sources.list 中:

Chapter 1

[ 23 ]

Updating Kali LinuxKali must be patched regularly to ensure that the base operating system and applications are up-to-date and that security patches have been applied.

The Debian package management systemDebian's package management system relies on discrete bundled applications called packages. Packages can be installed or removed by the user to customize the environment, and support tasks such as penetration testing. They can also extend the functionality of Kali, supporting tasks, such as communications (Skype, instant messaging, and secure e-mails) or documentation (OpenOffice and Microsoft Office running under Wine).Packages are stored in repositories and are downloaded to the system user to ensure the integrity of the package.

Packages and repositoriesBy default, Kali uses only the official Kali repositories. It is possible that an incomplete installation process may not add the repositories to the correct sources.list file, or that you may wish to extend the available repositories when new applications are added.Updating the source.list file can be done from the command line (echo deb http://http.kali.org/kiali kali main contrib non-free >> /etc/apt/sources.list), or by using a text editor.

The default package repositories that should be present in /etc/apt/sources.list are listed as follows; if not present, edit the sources.list file to include them:

## Kali deb http://http.kali.org/kali kali main contrib non-free ## Kali-dev deb http://http.kali.org/kali kali-dev main contrib non-free ## Kali Security updates deb http://security.kali.org/kali-security kali/updates main contrib non-free

Not every Kali tool is presently maintained in the official tool repositories. If you choose to update a tool manually, it is possible that you will overwrite existing packaged files and break dependencies. Therefore, some tools that have not been officially moved to Debian repositories, such as the aircrack-ng, dnsrecon, sqlmap, beef-xss, and Social Engineering Toolkit (se-toolkit), are maintained in the Bleeding Edge repository. This repository may also be added to sources.list using the following command line:

## Bleeding Edge repository deb http://repo.kali.org/kali kali kali-bleeding-edge main

dpkgdpkg 是 Debian 的软件包管理系统。这里使用命令行来安装、移除和查询软件包。一般

来说,dpkg 在独立的软件包上执行功能。

在 Kali 系统中,dpkg 在编译安装的应用列表时特别有用,命令是 dpkg -l > list.txt。如果你想知道一个特定工具是否已安装,可输入命令 dpkg -l | grep <tool name>。

图 1.10 表明,当调用 dpkg-1 时,引用了返回数据,并提供了安装在 Kali 版本上的应

用列表;这对于识别应用特别有用,应用只能用命令行来直接访问。

图 1.10 使用 dpkg-1 命令

使用高级软件包工具高级软件包工具(Advanced Packaging Tool,APT),通过搜索资源库、安装或者升

级的软件包,以及所有需要的依赖性,来扩展 dkpg 的功能。APT 也可以用来升级完整的

版本。

最常用的 apt 命令如下:

Page 9: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   9

� apt-get update :该命令用来重新同步本地软件包索引文件和它们定义在 /etc/apt/sources.list 目录下的资源。在执行一个 upgrade 或者 dist-upgrade 命令前,始终应该

首先使用 update 命令。

� apt-get upgrade :用来安装软件包的最新版本,这些软件包使用 /etc/apt/sources.list安装在系统上。升级安装在 Kali 上的有最新版本的软件包。升级命令不会改变或者

删除没有升级的软件包,也不会安装已有的软件包。

� apt-get dist-upgrade :该命令升级现所有安装在系统和相关位置的软件包。命令也可

从系统上移除淘汰的软件包。

命令 apt-get 可以全面描述一个软件包,并标识包的依赖性(apt-cache show <package name>)或者移除一个软件包(apt-get remove <package name>)。

Chapter 4

[ 135 ]

Optical flow is the process of matching selected points from one image to another, assuming both images are part of a sequence and relatively close to one another. Most optical flow methods compare a small region, known as the search window or patch, around each point from image A to the same area in image B. Following a very common rule in computer vision, called the brightness constancy constraint (and other names), the small patches of the image will not change drastically from one image to the other, and therefore the magnitude of their subtraction should be close to zero. In addition to matching patches, newer methods of optical flow use a number of additional methods to get better results. One is using image pyramids, which are smaller and smaller resized versions of the image, which allow for working "from-coarse-to-fine"—a very well-used trick in computer vision. Another method is to define global constraints on the flow field, assuming that the points close to each other "move together" in the same direction. A more in-depth review of optical flow methods in OpenCV can be found in Chapter Developing Fluid Wall Using the Microsoft Kinect which is available on the Packt website..

Using optical flow in OpenCV is fairly easy by invoking the calcOpticalFlowPyrLK function. However, we would like to keep the result matching from OF similar to that using rich features, as in the future we would like the two approaches to be interchangeable. To that end, we must install a special matching method—one that is interchangeable with the previous feature-based method, which we are about to see in the code section that follows:

Vector<KeyPoint>left_keypoints,right_keypoints;

// Detect keypoints in the left and right imagesFastFeatureDetectorffd;ffd.detect(img1, left_keypoints);ffd.detect(img2, right_keypoints);

vector<Point2f>left_points;KeyPointsToPoints(left_keypoints,left_points);

vector<Point2f>right_points(left_points.size());

// making sure images are grayscaleMat prevgray,gray;if (img1.channels() == 3) { cvtColor(img1,prevgray,CV_RGB2GRAY); cvtColor(img2,gray,CV_RGB2GRAY);} else { prevgray = img1;

在启动阶段,通过执行 apt-get update 命令和 upgrade 命令来确保你的会话正在

使用最新的工具。完成任务最简单的方法是创建一个 update.sh 脚本,这个脚本

包含以下命令行: apt-get update && apt-get upgrade –y && apt-get distupgrade –y

一些应用不通过 apt-get 命令来升级。例如,exploit-db 存档文件的本地副本必须手动升

级。创建一个 update.sh 脚本,并添加下列命令行,使其自动执行升级:

Chapter 1

[ 25 ]

• apt-get dist-upgrade: This upgrades all packages currently installed on the system and their dependencies. It also removes obsolete packages from the system.The apt-get command can also be used to show a full description of a package and identify its dependencies (apt-cache show <package name>) or remove a package (apt-get remove <package name>).

Run the apt-get update command and the upgrade command at start-up to ensure your session is using the most up-to-date tools. The easiest way to do this is to create an update.sh script that includes the following command line:apt-get update && apt-get upgrade –y && apt-get dist-upgrade –y

Some applications are not upgraded by the apt-get command. For example, the local copy of the exploit-db archive must be manually upgraded. Create a script named update.sh and add the following commands to it, to automate the update process:

cd /usr/share/exploitdb

wget http://www.exploit-db.com/archive.tar.bz2

tar –xvjf archive.tar.bz2

rm archive.tar.bz2

Configuring and customizing Kali LinuxKali is a framework that is used to complete a penetration test. However, the tester should never feel tied to the tools that have been installed by default, or by the look and feel of the Kali desktop. By customizing BackTrack, a tester can increase the security of client data that is being collected, and make it easier to do a penetration test.

Common customizations made to Kali include:

• Resetting the root password• Adding a non-root user• Speeding up Kali operations• Sharing folders with MS Windows• Creating encrypted folders

1.4 配置和自定义 Kali Linux

Kali 是一个用来完成渗透测试的框架。然而,测试人员不会感觉到相关联的默认安装

的测试工具,或者是使用 Kali 桌面安装的工具。通过自定义 BackTrack,测试人员可以提

高收集到的客户数据的安全性,使渗透测试更简单。

Kali 的常见自定义包括:

� 重置超级用户密码

� 添加普通用户

� 加速 Kali 运行

� 与 Microsoft Windows 共享文件夹

� 创建加密文件夹

1.4.1 重置超级用户密码

使用以下命令修改用户密码:

Page 10: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

10   第一部分 攻击者杀链

Starting with Kali Linux

[ 26 ]

Resetting the root passwordTo change a user password, use the following command:

passwd root

You will then be prompted to enter a new password, as shown in the following screenshot:

Adding a non-root userMany of the applications provided in Kali must run with root-level privileges in order to function. Root-level privileges do possess a certain amount of risk, for example, miskeying a command or using the wrong command can cause applications to fail or even damage the system being tested. In some cases, it is preferable to test with user-level privileges. In fact, some applications force the use of lower-privilege accounts.

To create a non-root user, you can simply use the command adduser from the terminal and follow the instructions that appear, as shown in the following screenshot:

Speeding up Kali operationsSeveral tools can be used to optimize and speed up Kali operations:

• When using a virtual machine, install the VM's software drive package: Guest Additions (VirtualBox) or VMware Tools (VMware).

然后会提示你输入一个新的密码,如图 1.11 所示。

1.4.2 添加普通用户

为了执行其功能,Kali 提供的许多应用必须用超级

用户的权限(Root-level privileges)运行。超级用户权限有一定的风险,例如,输错一个命

令或者使用了一个错误的命令,将会导致应用终止,甚至损害被测试的系统。在一些例子

中,使用普通用户级权限来测试是更可取的。事实上,一些应用促进了低权限账户的使用。

为了创建一个普通用户,可以简单地在终端上使用命令 adduser,接着会出现指令,如

图 1.12 所示。

图 1.12 创建普通用户

1.4.3 加速 Kali 运行

以下几个工具可以用来优化和加速 Kali 运行:

� 在使用虚拟机时,安装 VM 软件驱动包 Guest Additions(VirtualBox)或者 VMware Tools(VMware)。

� 在创建虚拟机时,选择一个固定大小的磁盘,而不是动态分配的磁盘。固定大小的

磁盘可以更快地添加文件,并且碎片更少。

� 预先加载的应用(apt-get install preload)能识别一个用户最常用的程序,也能把二进

制文件和依赖性预先加载到内存,以提供更快速的访问。随着安装后的第一次重启,

它会自动运行。

� BleachBit(apt-get install bleachbit)释放磁盘空间,通过释放缓存、删除 cookie、清

除上网记录、粉碎临时文件、删除日志,以及丢弃其他一些非必需的文件来提高隐

私性。使用高级技术,包括粉碎文件来防止恢复,擦除空闲磁盘空间来隐藏没有完

全删除的文件的踪迹。

图 1.11 修改用户密码

Page 11: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   11

� 在默认情况下,Kali 不会显示所有出现在开始菜单里的应用。每个在启动阶段安装

的应用降低了系统数据,并且可能会影响内存使用和系统性能。用启动管理器 BUM(Boot Up Manager)来禁止启动时非必要的服务和应用(apt-get install bum),如图

1.13 所示。

图 1.13 启用 BUM

� 直接从键盘添加 gnome-do(apt-get install gnome-do)启动应用。从应用 | 附件

(Applications | Accessories )菜单中选择 gnome-do 配置它。一旦启动后,选择首选

项(Preferences)菜单,激活静启动(Quiet Launch)功能,并选择一个启动命令(例

如,Ctrl + Shift)。选好启动密钥后,清除现有的命令,然后输入需要执行的命令行。

如果不从键盘直接启动,那么可能会写入一些能启动复杂操作的特定脚本语句。

1.4.4 与 Microsoft Windows 共享文件夹

Kali 工具集能灵活地与驻留在不同操作系统上的应用共享成果,特别是 Microsoft Windows。最有效的数据共享方式是创建从主机操作系统以及 Kali Linux VM 客户机能访问

的一个文件夹。

当将主机或 VM 中的数据放置在共享文件夹中时,所有能访问共享文件夹的系统都能

立刻访问数据。

Page 12: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

12   第一部分 攻击者杀链

创建共享文件夹的步骤如下:

1. 在主机操作系统上建立一个文件夹。在这个例子中,我们将其命名为 Kali_Share 。2. 右击文件夹,选择共享(Sharing)选项卡,并从中选择 Share。3. 确保文件是与每个人(Everyone)共享的,允许级别(Permission Level)设置为读 /

写(Read / Write)。

4. 如果你没有这样操作,那么在 BackTrack 上安装适当的工具。例如,在使用 VMware时,安装 VMware 工具(具体安装步骤可参考本书附录)。

5. 在完成安装之后,在 VMware 菜单里选择虚拟机设置(Virtual Machine Setting)。找

到共享文件夹(Shared Folders)菜单,并选择保持打开(Always Enabled)选项。创建主机

操作系统中已存在的共享文件夹的路径,如图 1.14 所示。

图 1.14 虚拟机设置界面

Chapter 4

[ 135 ]

Optical flow is the process of matching selected points from one image to another, assuming both images are part of a sequence and relatively close to one another. Most optical flow methods compare a small region, known as the search window or patch, around each point from image A to the same area in image B. Following a very common rule in computer vision, called the brightness constancy constraint (and other names), the small patches of the image will not change drastically from one image to the other, and therefore the magnitude of their subtraction should be close to zero. In addition to matching patches, newer methods of optical flow use a number of additional methods to get better results. One is using image pyramids, which are smaller and smaller resized versions of the image, which allow for working "from-coarse-to-fine"—a very well-used trick in computer vision. Another method is to define global constraints on the flow field, assuming that the points close to each other "move together" in the same direction. A more in-depth review of optical flow methods in OpenCV can be found in Chapter Developing Fluid Wall Using the Microsoft Kinect which is available on the Packt website..

Using optical flow in OpenCV is fairly easy by invoking the calcOpticalFlowPyrLK function. However, we would like to keep the result matching from OF similar to that using rich features, as in the future we would like the two approaches to be interchangeable. To that end, we must install a special matching method—one that is interchangeable with the previous feature-based method, which we are about to see in the code section that follows:

Vector<KeyPoint>left_keypoints,right_keypoints;

// Detect keypoints in the left and right imagesFastFeatureDetectorffd;ffd.detect(img1, left_keypoints);ffd.detect(img2, right_keypoints);

vector<Point2f>left_points;KeyPointsToPoints(left_keypoints,left_points);

vector<Point2f>right_points(left_points.size());

// making sure images are grayscaleMat prevgray,gray;if (img1.channels() == 3) { cvtColor(img1,prevgray,CV_RGB2GRAY); cvtColor(img2,gray,CV_RGB2GRAY);} else { prevgray = img1;

虽然 VirtualBox 使用不同的菜单名,但过程是一样的。

Page 13: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   13

6. 打开 Kali 桌面上的文件浏览器。可以在 mnt 文件夹中找到共享文件夹(也有可能在

子文件夹 hgfs 中找到)。

7. 将文件夹拖到 Kali 桌面上,这样就创建了一个到真实文件夹的链接。

8. 在主机操作系统中,具有相同名字的文件夹中的所有内容都可以被访问,反之亦然。

共享文件中,将包含一次渗透测试中的敏感数据,所以需要通过加密来保护用户网络,

在数据丢失时,减轻测试人员的责任。

1.4.5 用 TrueCrypt 创建加密文件夹

在进行一次渗透测试时,你将会访问到敏感客户信息,包括可利用的漏洞,你也会得

到一些毁坏数据的副本。确保这些信息的安全是测试人员的法律责任和道德责任。承担这

些责任的最好方法是在存储和传输过程中,确保加密所有的客户信息。

根据以下步骤,在 BackTrack 上安装 TrueCrypt:1. 在应用(Applications)菜单中,选择 Accessories | TrueCrypt 选项。

2. 打开上述应用创建加密文件夹。你可以看到主菜单,如图 1.15 所示。

图 1.15 TrueCrypt 主菜单

3. 在主菜单中,选择创建卷(Create Volume)按钮。这可以启动 TrueCrypt Volume 创建向导(TrueCrypt Volume Creation Wizard),如图 1.16 所示。

Page 14: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

14   第一部分 攻击者杀链

图 1.16 TrueCrypt Volume 创建向导

4. 选择 Create an encrypted file container 选项,然后点击下一步(Next)按钮。

5. 下一个界面会提示卷类型(Volume Type)选项,然后选择 Standard TrueCrypt volume,并点击 Next 按钮。

6. 在 Volume Location 界 面, 选 择 Select File。 你 需 要 在 Specify a New TrueCrypt Volume 中输入名称(Name),并保存在指定的文件夹中,如图 1.17 所示。

图 1.17 在 Specify a New TrueCrypt Volume 中输入名称

7. 选择一个文件名。不能选择与测试客户相关的文件名,或者能指明敏感资料存在于

目录中的文件名。用数字或者编码来表示客户,用一般的名字表示结果。把文件保存在桌

面上,然后点击 Next 按钮。

8. 图 1.18 提 供 了 加 密 选 项(Encryption Options)。 从 下 拉 菜 单 里 选 择 加 密 算 法

Page 15: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   15

(Encryption Algorithm)。菜单包含了几个加密算法,对于常规目的来说,AES(默认密钥

长度为 256 位)已经足够了。你也会选择一个哈希算法(Hash Algorithm),默认情况下,

RIPEMD-160 也足够了。在完成选择后,点击下一步(Next)按钮。

图 1.18 加密选项界面

9. 然后提示你选择卷容量(Volume Size)。你应该选择一个最小的,大概 500MB,但

是,可以依照测试方法进行改变,之后点击 Next 按钮。

10. 根据提供的强密码规则来选择卷口令(Volume Password)。选择并确认密码,然后

点击 Next 按钮,如图 1.19 所示。

图 1.19 设置卷口令

Page 16: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

16   第一部分 攻击者杀链

11. 进入格式选项(Format Options)界面。设置文件系统选项(Filesystem Options),从

下拉菜单中选择 FAT,之后点击 Next 按钮。

12. 之后进入卷格式化 (Volume Format)界面,为加密的文件系统创建一个随机密钥。

密钥是根据鼠标移动生成的,根据提示,在一个窗口上移动鼠标一段时间,这样能确保加

密密钥的随机性(密码长度)。密钥生成之后,点击 Format 创建 TrueCrypt 卷。

13. 最后,卷创建成功。它在桌面上以图标的形式出现。卷是被加密的,可以被复制到

一个外部存储硬件上,或者移动到主机系统,在这些过程中,卷仍是被加密的。

要使用加密的卷,必须先在 TrueCrypt 主菜单中选择 Slot 来管理加密的文件夹。选择

完后,用 Select File 按钮来选择加密文件的文件名。在这个例子中,我们使用桌面上预先

建好的文件 pentest,如图 1.20 所示。

图 1.20 TrueCrypt 加密卷管理

点击 Mount 按钮。此时,界面会提示请你输入密码,如图 1.21 所示。

图 1.21 输入密码

Page 17: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   17

输入正确的密码后,可以在桌面上看到 Slot 1 的详细变化,其反映出加密文件夹的属

性,桌面上出现一个叫作 truerypt1 的新图标,如图 1.22 所示。

图 1.22 输入正确密码后的界面

如果你双击 truecrypt1 图标,你可以看到一个文件浏览器(File Browser)视图。

此时,它充当一个常规的目录,你可以用该文件夹存储所有与测试相关的信息。当你

使用完文件夹中的内容,希望确保所有数据均加密时,在主菜单上选择 Dismount,文件夹

恢复到加密状态。

1.5 第三方应用程序的管理

虽然 Kali 预装了数百个应用程序,但是为了有效地测试特定的环境(如工业系统),你

仍需要安装额外的应用程序,添加新的尖端工具,或者确保已经安装了自己喜欢的工具。

Kali 可以很容易地找到、安装和管理这些工具。

1.5.1 安装第三方应用程序

安装第三方应用程序的有很多种方法:使用 apt-get 命令、访问 GitHub 资源库、直接

安装应用程序。

所有工具都可以从 Kali Linux 资源库中使用 apt-get 安装(install) 命令进行安装。 安装

(install)命令可以在命令行中的一个终端窗口中执行,或者用户可以选择一个图形化的软件

包管理工具。

推荐的第三方应用程序包括:

� apt-file :这是一个命令行工具,用来搜索 APT 包系统。该命令允许你列出没有安装

或获取的包的内容。

Page 18: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

18   第一部分 攻击者杀链

� gnome-tweak-tool:该应用允许用户更改主题和快速配置桌面选项。

� instanbul:这是一个桌面屏幕记录器,可以用它来制作一部关于桌面活动的电影。

� openoffice:这是一个开放源码的办公套件(帮助文档)。

� scrub :这是一个安全删除(反取证)工具,安全地删除数据,使用各种覆盖模式,

以符合严格的政府标准。

� shutter:这是一个截图工具,捕捉桌面的图像、打开的窗口,或某个选择。

� team viewer :支持远程访问和远程管理。它还允许测试人员在目标网络上预先配置

计算机,并且对目标网络进行远程测试。

� terminator :这是一个 Linux 终端窗口的替换,允许横向滚动——没有更多的包装

文本!

不存在于 Debian 库且使用 apt-get install 可访问的工具仍然安装在 Kali 上。但是,用

户必须接受手动安装,它们与资源库不协调,可能会破坏依赖性导致应用程序运行失败。

一些工具对于软件开发项目使用 GitHub 的在线资源库。由于修订 Git 系统的灵活性以

及社交媒体等方面的原因,许多开发人员喜欢这种开放的资源库。我们将使用工具 recon-ng,一个网络侦察框架。

从 GitHub 的资源库克隆 recon-ng 的当前版本,请使用以下命令行:

Starting with Kali Linux

[ 36 ]

Recommended third-party applications include:

• apt-file: This is a command-line tool to search within packages of the APT packaging system. It allows you to list contents of a package without installing or fetching it.

• gnome-tweak-tool: This allows users to change themes and rapidly configure desktop options.

• instanbul: This is a desktop screen recorder that allows you to make a movie of desktop activities.

• openoffice: This is an open source office productivity suite that assists in documentation.

• scrub: This is a secure deletion (anti-forensic) tool that securely deletes data to comply with stringent government standards using various overwrite patterns.

• shutter: This is a screenshot tool that captures images of a desktop, open window, or a selection.

• team viewer: This supports remote access and remote administration. It also allows testers to place a pre-configured computer (a dropbox) on the target network and control testing from a remote location.

• terminator: This is a replacement for the Linux terminal window that allows horizontal scrolling—no more wrapped text!

Tools that are not present in a Debian repository and are accessible using apt-get install can still be installed on Kali. However, the user must accept that manual installs are not coordinated with repositories, and they may break dependencies causing applications to fail.

Some tools use the GitHub online repository for software development projects. Many developers favor this open repository due to the flexibility of the Git revision system as well as the social-media aspects of the software sites. One tool that we will be using is recon-ng, a web reconnaissance framework.

To clone the current version of recon-ng from the GitHub repository, use the following command line:

cd /opt; git clone https://[email protected]/LaNMaSteR53/recon-ng.git

cd opt/recon-ng

./recon-ng.py

最后,一些应用必须手动安装。例如,要恢复异步端口扫描器 Unicornscan, 可以回到

Kali,并且必须:

� 确保依赖关系是首先存在的:apt-get install flex。 � 下载 Unicornscan 的最新版本(下载网址:www.unicornscan.org,当前版本是

unicornscan-0.4.7-2)。

� 以一个新的目录提取文件的内容:tar jxf unicornscan-0.4.7-2.tar.bz2。 � 更改目录为 Unicornscan:cd unicornscan-0.4.7/。 � 编译源代码:./configure CFLAGS=-D_GNU_SOURCE && make && make install。

因为每个应用程序的确切依赖关系和安装过程都会发生变化,所以你需要参考开发商

的自述文件(README),以确保正确安装和配置这些应用程序。

1.5.2 作为普通用户运行第三方应用程序

Kali Linux 的目的是为了支持渗透测试。大多数工具需要超级访问权限,这也就是访问

工具集和数据会借助密码和加密保护的原因。

然而,一些第三方工具是注定不会有超级运行权限的。例如,Web 浏览器可能会被攻

Page 19: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   19

破,并给予攻击者超级访问权限,这对安全有重要的影响。

如果超级访问权限不是必需的,工具应遵循最小特权原则,作为一个普通用户运行。

要运行应用程序,并且作为普通用户运行该应用程序,使用超级账户登录到 Kali,Kali应配置一个普通账户。在这个例子中,我们将预先用 adduser 命令创建名为 noroot 的账户。

执行以下步骤以普通用户身份运行浏览器 Iceweasel。1. 创建一个普通用户账户。在这个例子中,我们将使用 noroot。2. 我们将使用 sux,这是从一个特权用户传递一个包装应用给普通用户的凭据。使用

apt-get install 命令下载并安装 sux。3. 启动 Web 浏览器,然后将其最小化。

4. 输入命令行:ps aux |grep iceweasel。正如你所看到的,Iceweasel 正在以超级权限运行。

5. 关闭 Iceweasel,使用命令 sux - noroot iceweasel 重新启动,如图 1.23 所示。

图 1.23 使用命令 sux - noroot iceweasel 重启 Iceweasel

如果你检查 Iceweasel 标题栏,你会看到它作为 noroot 用户调用,一个没有管理员权限

的账户,如图 1.24 所示。

图 1.24 显示 noroot 用户

你也可以通过检查开放进程来确认 Iceweasel 是以 noroot 账户下运行的,如图 1.25 所示。

图 1.25 使用开放进程确认 Iceweasel 以 noroot 用户运行

1.6 渗透测试的有效管理

渗透测试中最困难的方面之一,是在测试完成后,记住测试的网络或目标系统的所有

Page 20: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

20   第一部分 攻击者杀链

有关部分,或试图记住实际上测试的目标。

BT 5r3 强调 Draedis 和 MagicTree 等管理工具的使用。这些工具为测试数据提供了一个

中央存储库,方便数据测试。此外,它们通常会提供一些框架,让测试人员知道他们使用

的测试方法,以及哪些测试工作仍有待完成。这种性质的工具在漏洞评估或渗透测试中具

有极好的协调性。

这些工具仍位于 Applications |Kali Linux| Reporting Tools | Evidence Management 菜单中。

但是,对于复杂的渗透测试,其中涉及的方法,可能是因为它更好地适应了目标网络?

一些测试人员使用键盘记录器或者 Wireshark,记录测试过程中产生的击键和数据包流

量。这些数据是有用的,如果在测试中导致网络或应用中断,重放和分析发送数据包,能

够识别是哪些工具包影响了网络。

Kali Linux 包括几个更适合做快速笔记的工具,以及用于迅速增加剪切和粘贴数据的资

源库的工具,包括 KeepNote 和 Zim desktop wiki。测试人员不仅需要进行测试,并收集数据,他们还要将研究结果反馈给客户。这是非

常困难的,因为有些结果很短暂,在一个时间点上有一个测试说明文档,但是,某时在目

标系统上的数据会改变,未来的测试不能证明过去文档描述的安全漏洞,即使它可能重新

出现。

对于好结果的另一个挑战是,它们需要形成客户可理解的文档。

黄金法则是要随时抓取正面的、潜在的结果的屏幕截图。使用一种工具(如 Shutter)捕捉桌面上的图像。

在默认情况下,Kali 配置了一个跨平台的命令行工具——CutyCapt,来捕捉网页并创

建多种类型的图像,包括 PDF、PS、PNG、JPEG、TIFF、GIF 和 BMP。例如,要创建谷歌搜索页面中一张特定大小的图像,应输入如下命令行提示符:

Starting with Kali Linux

[ 40 ]

For example, to create an image of a specific size from the Google search page, enter the following from a command-line prompt:

..cutycapt --url=http://www.google.com --out=google.png --min-width=300 --min-heightheight=250.

On execution, an image of the size specified in the previous command is displayed, as shown in the following screenshot:

CutyCapt is especially useful when demonstrating the presence of web-based vulnerabilities such as cross-site scripting.

Static images can be very useful, however, a video of an exploit that compromises a target network and shows the actions of an attacker as they compromise sensitive data is a very compelling tool. The instanbul screen recorder creates a video of an "exploit in progress," which allows the exploit to be replayed for training purposes, or to demonstrate the vulnerability to the client.

SummaryIn this chapter, we examined Kali, a collection of tools widely used by legitimate penetration testers and hackers to assess the security of data systems and networks. We emphasized Kali as a virtual machine, allowing both the host operating system and the VM guest to support testing.

在执行时,会显示在前面的命令中指定过大小的图像,如图 1.26 所示。

图 1.26 使用 CutyCapt 抓取的屏幕截图

Page 21: 攻击者杀链images.china-pub.com/ebook4945001-4950000/4949997/ch01.pdf · 2016. 7. 13. · 第2章 确定目标——被动 ... In this particular case, the VM has been assigned

第1章 走进Kali Linux   21

当演示基于 Web 的网络漏洞时,CutyCapt 是特别有用的,如运行跨站点脚本。

静态图像是非常有用的,但是,一个攻击视频会包括如何破坏目标网络,以及攻击者

获取敏感数据的行为,所以视频也是一个非常引人注目的工具。instanbul 屏幕录像机创建

关于正在进行的漏洞攻击的视频,出于训练目的,允许它重复播放,或者向客户证明漏洞

存在。

1.7 总结

本章讨论了 Kali,这个工具集合,它被测试人员广泛应用,通过渗透来评估数据系统

和网络的安全性。我们强调 Kali 作为一个虚拟机,同时允许主机操作系统和虚拟机用户进

行测试。

Kali 是一个工具库,在使用它的过程中,保证工具的实时性是一项巨大挑战。这里,

我们回顾了 Debian 包管理系统以及如何从命令行和 GUI 应用程序初始化更新。更重要的

是,学习了如何定制化 Kali 来增强工具和收集的数据的安全性。我们致力于实现利用工具

来支持过程的目标,而不是过程支持工具。

下一章,我们将学习如何有效利用开源情报(OSINT)来识别目标的脆弱性攻击表面和

创建特定的用户密码表,这会使社会工程学攻击和其他攻击变得更容易。