Ethical Hacking 简明教程
Ethical Hacking - Overview
Hacking has been a part of computing for almost five decades and it is a very broad discipline, which covers a wide range of topics. The first known event of hacking had taken place in 1960 at MIT and at the same time, the term "Hacker" was originated.
Hacking is the act of finding the possible entry points that exist in a computer system or a computer network and finally entering into them. Hacking is usually done to gain unauthorized access to a computer system or a computer network, either to harm the systems or to steal sensitive information available on the computer.
Hacking is usually legal as long as it is being done to find weaknesses in a computer or network system for testing purpose. This sort of hacking is what we call Ethical Hacking.
A computer expert who does the act of hacking is called a "Hacker". Hackers are those who seek knowledge, to understand how systems operate, how they are designed, and then attempt to play with these systems.
Types of Hacking
We can segregate hacking into different categories, based on what is being hacked. Here is a set of examples −
-
Website Hacking − Hacking a website means taking unauthorized control over a web server and its associated software such as databases and other interfaces.
-
Network Hacking − Hacking a network means gathering information about a network by using tools like Telnet, NS lookup, Ping, Tracert, Netstat, etc. with the intent to harm the network system and hamper its operation.
-
Email Hacking − It includes getting unauthorized access on an Email account and using it without taking the consent of its owner.
-
Ethical Hacking − Ethical hacking involves finding weaknesses in a computer or network system for testing purpose and finally getting them fixed.
-
Password Hacking − This is the process of recovering secret passwords from data that has been stored in or transmitted by a computer system.
-
Computer Hacking − This is the process of stealing computer ID and password by applying hacking methods and getting unauthorized access to a computer system.
Advantages of Hacking
Hacking is quite useful in the following scenarios −
-
To recover lost information, especially in case you lost your password.
-
To perform penetration testing to strengthen computer and network security.
-
To put adequate preventative measures in place to prevent security breaches.
-
To have a computer system that prevents malicious hackers from gaining access.
Disadvantages of Hacking
Hacking is quite dangerous if it is done with harmful intent. It can cause −
-
Massive security breach.
-
Unauthorized system access on private information.
-
Privacy violation.
-
Hampering system operation.
-
Denial of service attacks.
-
Malicious attack on the system.
Purpose of Hacking
There could be various positive and negative intentions behind performing hacking activities. Here is a list of some probable reasons why people indulge in hacking activities −
-
Just for fun
-
Show-off
-
Steal important information
-
Damaging the system
-
Hampering privacy
-
Money extortion
-
System security testing
-
To break policy compliance
Ethical Hacking - Hacker Types
Hackers can be classified into different categories such as white hat, black hat, and grey hat, based on their intent of hacking a system. These different terms come from old Spaghetti Westerns, where the bad guy wears a black cowboy hat and the good guy wears a white hat.
White Hat Hackers
白帽黑客又称 Ethical Hackers 。他们永远不会打算伤害一个系统,而是尝试找出计算机或网络系统中的软肋,作为渗透测试和安全漏洞评估的一部分。
道德黑客并不违法,并且是 IT 行业中可获得的极具挑战性的一份工作。有许多公司聘用道德黑客进行渗透测试和安全漏洞评估。
Black Hat Hackers
黑帽黑客又称 crackers ,他们通过入侵来获取对系统的未授权访问权限,然后妨碍系统运营或窃取敏感信息。
黑帽黑客总是是非法的,因为其恶意目的包括窃取公司数据、侵犯隐私、破坏系统、阻断网络通信等。
Grey Hat Hackers
灰帽黑客是黑帽和白帽黑客的混合体。他们会采取行动,但并非出于恶意目的。出于自己兴趣的目的,他们会在未经所有人许可或不知情的情况下利用计算机系统或网络中的安全漏洞。
他们的目的是引起所有人的注意,并从所有人那里得到赞赏或少量奖励金。
Ethical Hacking - Famous Hackers
在本章中,我们将简要了解一些著名的黑客以及他们如何成名的内容。
Jonathan James
乔纳森·詹姆斯是一位美国黑客,因成为美国历史上第一个因网络犯罪被判入狱的未成年人而臭名昭著。2008 年,他因自伤枪伤而自杀。
1999 年,年仅 16 岁的他就通过破解属于美国宇航局的服务器的密码来访问多台计算机,窃取了国际空间站的源代码以及其他敏感信息。
Ian Murphy
伊恩·墨菲,也称为 Captain Zap,曾一度让高中生为他盗取计算机设备。伊恩自称是“第一个因犯罪而被定罪的黑客”。
1986 年,伊恩与其失业的妻子决定组建某种类型的企业后,他作为顶级黑客的职业生涯就被捏造了。
他有着悠久的计算机和互联网诈骗历史。他的一个最喜欢的游戏是伪造电子邮件头信息并发送第三方威胁信。
Kevin Mitnick
凯文·米特尼克是一位计算机安全顾问兼作者,他潜入其客户的公司来揭示他们的安全优势、劣势和潜在漏洞。
他是第一个将他的脸永生在联邦调查局“最想通缉”海报上的黑客。他曾是美国历史上最受通缉的计算机罪犯。
从 20 世纪 70 年代直到 1995 年被最后一次逮捕,他熟练地绕过了公司安全保障,并且进入了一些戒备最森严的系统,例如 Sun Microsystems、Digital Equipment Corporation、Motorola、Netcom 和 Nokia。
Mark Abene
马克·阿贝以其化名 Phiber Optik 闻名于世,是一位信息安全专家兼企业家。他在 20 世纪 80 年代和 90 年代初期是一位备受瞩目的黑客。他是最早公开争论并捍卫道德黑客作为对行业有益的工具的积极优点的黑客之一。
他的专业知识领域包括渗透研究、现场安全评估、安全代码审查、安全策略审查和生成、系统和网络架构、系统管理和网络管理等诸多方面。他的客户包括美国运通、瑞银集团、富国银行、安永、毕马威等。
Johan Helsinguis
尤汉·赫尔辛吉厄斯,更为人所知的名字是 Julf,他于 20 世纪 80 年代进入公众视野,当时他开始运营世界上最受欢迎的匿名 remailer penet.fi。
尤汉还负责第一个泛欧互联网服务提供商 Eunet International 的产品开发。
目前,他是阿姆斯特丹黑客空间协会 Technologia Incognita 的董事会成员,并用他的网络知识为全球通信公司提供支持。
Linus Torvalds
林纳斯·托瓦兹被认为是有史以来最优秀的黑客之一。他通过创建广受欢迎的类 Unix 操作系统 Linux 而声名鹊起。Linux 是开源的,成千上万的开发人员都为其内核做出了贡献。但是,托瓦兹仍然是决定哪些新代码并入 Linux 标准内核的最终权威。截至 2006 年,大约有 2% 的 Linux 内核是由托瓦兹本人编写的。
他只是渴望简单的生活和开发出世界上最好的操作系统来获得乐趣。托瓦兹获得过斯德哥尔摩大学和赫尔辛基大学的荣誉博士学位。
Robert Morris
罗伯特·莫里斯,即 Morris 蠕虫的创建者,Morris 蠕虫是第一个在互联网上释放的蠕虫。该蠕虫具有使计算机速度变慢并使其无法继续使用的能力。因此,他被判处缓刑三年、400 小时的社区服务并且还必须支付 10500 美元的罚款。
莫里斯目前在麻省理工学院计算机科学与人工智能实验室担任终身教授。
Ethical Hacking - Terminologies
Following is a list of important terms used in the field of hacking.
-
Adware − Adware is software designed to force pre-chosen ads to display on your system.
-
Attack − An attack is an action that is done on a system to get its access and extract sensitive data.
-
Back door − A back door, or trap door, is a hidden entry to a computing device or software that bypasses security measures, such as logins and password protections.
-
Bot − A bot is a program that automates an action so that it can be done repeatedly at a much higher rate for a more sustained period than a human operator could do it. For example, sending HTTP, FTP or Telnet at a higher rate or calling script to create objects at a higher rate.
-
Botnet − A botnet, also known as zombie army, is a group of computers controlled without their owners’ knowledge. Botnets are used to send spam or make denial of service attacks.
-
Brute force attack − A brute force attack is an automated and the simplest kind of method to gain access to a system or website. It tries different combination of usernames and passwords, over and over again, until it gets in.
-
Buffer Overflow − Buffer Overflow is a flaw that occurs when more data is written to a block of memory, or buffer, than the buffer is allocated to hold.
-
Clone phishing − Clone phishing is the modification of an existing, legitimate email with a false link to trick the recipient into providing personal information.
-
Cracker − A cracker is one who modifies the software to access the features which are considered undesirable by the person cracking the software, especially copy protection features.
-
Denial of service attack (DoS) − A denial of service (DoS) attack is a malicious attempt to make a server or a network resource unavailable to users, usually by temporarily interrupting or suspending the services of a host connected to the Internet.
-
DDoS − Distributed denial of service attack.
-
Exploit Kit − An exploit kit is software system designed to run on web servers, with the purpose of identifying software vulnerabilities in client machines communicating with it and exploiting discovered vulnerabilities to upload and execute malicious code on the client.
-
Exploit − Exploit is a piece of software, a chunk of data, or a sequence of commands that takes advantage of a bug or vulnerability to compromise the security of a computer or network system.
-
Firewall − A firewall is a filter designed to keep unwanted intruders outside a computer system or network while allowing safe communication between systems and users on the inside of the firewall.
-
Keystroke logging − Keystroke logging is the process of tracking the keys which are pressed on a computer (and which touchscreen points are used). It is simply the map of a computer/human interface. It is used by gray and black hat hackers to record login IDs and passwords. Keyloggers are usually secreted onto a device using a Trojan delivered by a phishing email.
-
Logic bomb − A virus secreted into a system that triggers a malicious action when certain conditions are met. The most common version is the time bomb.
-
Malware − Malware is an umbrella term used to refer to a variety of forms of hostile or intrusive software, including computer viruses, worms, Trojan horses, ransomware, spyware, adware, scareware, and other malicious programs.
-
Master Program − A master program is the program a black hat hacker uses to remotely transmit commands to infected zombie drones, normally to carry out Denial of Service attacks or spam attacks.
-
Phishing − Phishing is an e-mail fraud method in which the perpetrator sends out legitimate-looking emails, in an attempt to gather personal and financial information from recipients.
-
Phreaker − Phreakers are considered the original computer hackers and they are those who break into the telephone network illegally, typically to make free longdistance phone calls or to tap phone lines.
-
Rootkit − Rootkit is a stealthy type of software, typically malicious, designed to hide the existence of certain processes or programs from normal methods of detection and enable continued privileged access to a computer.
-
Shrink Wrap code − A Shrink Wrap code attack is an act of exploiting holes in unpatched or poorly configured software.
-
Social engineering − Social engineering implies deceiving someone with the purpose of acquiring sensitive and personal information, like credit card details or user names and passwords.
-
Spam − A Spam is simply an unsolicited email, also known as junk email, sent to a large number of recipients without their consent.
-
Spoofing − Spoofing is a technique used to gain unauthorized access to computers, whereby the intruder sends messages to a computer with an IP address indicating that the message is coming from a trusted host.
-
Spyware − Spyware is software that aims to gather information about a person or organization without their knowledge and that may send such information to another entity without the consumer’s consent, or that asserts control over a computer without the consumer’s knowledge.
-
SQL Injection − SQL injection is an SQL code injection technique, used to attack data-driven applications, in which malicious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker).
-
Threat − A threat is a possible danger that can exploit an existing bug or vulnerability to compromise the security of a computer or network system.
-
Trojan − A Trojan, or Trojan Horse, is a malicious program disguised to look like a valid program, making it difficult to distinguish from programs that are supposed to be there designed with an intention to destroy files, alter information, steal passwords or other information.
-
Virus − A virus is a malicious program or a piece of code which is capable of copying itself and typically has a detrimental effect, such as corrupting the system or destroying data.
-
Vulnerability − A vulnerability is a weakness which allows a hacker to compromise the security of a computer or network system.
-
Worms − A worm is a self-replicating virus that does not alter files but resides in active memory and duplicates itself.
-
Cross-site Scripting - 跨站点脚本 (XSS) 是一种通常在网络应用程序中发现的计算机安全漏洞类型。XSS 使攻击者能够将客户端脚本注入到其他用户查看的网页中。
-
Zombie Drone - Zombie Droine 被定义为被匿名用作恶意活动(例如散布不受欢迎的垃圾邮件)的士兵或“无人机”的劫持计算机。
Ethical Hacking - Tools
在本章中,我们将简单探讨一些广泛用于防止黑客攻击和未经授权访问计算机或网络系统的著名工具。
NMAP
Nmap 代表网络映射器。它是一款开源工具,广泛用于网络发现和安全审核。Nmap 最初设计用于扫描大型网络,但它也可以同样很好地扫描单个主机。网络管理员还发现它对诸如网络清单、管理服务升级计划和监控主机或服务正常运行时间之类的任务很有用。
Nmap uses raw IP packets to determine −
-
what hosts are available on the network,
-
what services those hosts are offering,
-
what operating systems they are running on,
-
what type of firewalls are in use, and other such characteristics.
Nmap runs on all major computer operating systems such as Windows, Mac OS X, and Linux.
Metasploit
Metasploit is one of the most powerful exploit tools. It’s a product of Rapid7 and most of its resources can be found at: www.metasploit.com. It comes in two versions − commercial and free edition. Matasploit can be used with command prompt or with Web UI.
With Metasploit, you can perform the following operations −
-
Conduct basic penetration tests on small networks
-
Run spot checks on the exploitability of vulnerabilities
-
Discover the network or import scan data
-
Browse exploit modules and run individual exploits on hosts
Burp Suit
Burp Suite is a popular platform that is widely used for performing security testing of web applications. It has various tools that work in collaboration to support the entire testing process, from initial mapping and analysis of an application’s attack surface, through to finding and exploiting security vulnerabilities.
Burp is easy to use and provides the administrators full control to combine advanced manual techniques with automation for efficient testing. Burp can be easily configured and it contains features to assist even the most experienced testers with their work.
Angry IP Scanner
Angry IP scanner is a lightweight, cross-platform IP address and port scanner. It can scan IP addresses in any range. It can be freely copied and used anywhere. In order to increase the scanning speed, it uses multithreaded approach, wherein a separate scanning thread is created for each scanned IP address.
Angry IP Scanner simply pings each IP address to check if it’s alive, and then, it resolves its hostname, determines the MAC address, scans ports, etc. The amount of gathered data about each host can be saved to TXT, XML, CSV, or IP-Port list files. With help of plugins, Angry IP Scanner can gather any information about scanned IPs.
Cain & Abel
Cain & Abel is a password recovery tool for Microsoft Operating Systems. It helps in easy recovery of various kinds of passwords by employing any of the following methods −
-
sniffing the network,
-
cracking encrypted passwords using Dictionary, Brute-Force and Cryptanalysis attacks,
-
recording VoIP conversations,
-
decoding scrambled passwords,
-
recovering wireless network keys,
-
revealing password boxes,
-
uncovering cached passwords and analyzing routing protocols.
Cain & Abel 是一款非常实用的工具,适用于以下人群:安全顾问、专业渗透测试人员及打算出于道德原因使用该工具的人士。
Ettercap
Ettercap 的全称是 Ethernet Capture,它是一款用于针对中间人攻击的网络安全工具。它的功能包括嗅探活动连接、实时内容过滤以及其他许多有趣的小技巧。Ettercap 内置了网络和主机分析功能。它支持以主动和被动方式解析许多协议。
你可以在所有流行的操作系统(例如 Windows、Linux 及 Mac OS X)上运行 Ettercap。
EtherPeek
EtherPeek 是一款非常棒的工具,它可以在多协议异构网络环境中简化网络分析。EtherPeek 是一款体积小巧(不足 2 MB)的工具,可以轻松地在数分钟内完成安装。
EtherPeek 会主动嗅探网络上的流量数据包。在默认情况下,EtherPeek 支持以下协议:AppleTalk、IP、IP 地址解析协议 (ARP)、NetWare、TCP、UDP、NetBEUI 及 NBT 数据包。
SuperScan
SuperScan 是一款非常强大的工具,网络管理员可以利用它来扫描 TCP 端口并解析主机名。它具有一个用户友好界面,可以用来:
-
使用任何 IP 范围执行 ping 扫描和端口扫描。
-
从内置列表或任何给定范围中扫描任何端口范围。
-
查看已连接主机的响应。
-
使用内置编辑器修改端口列表和端口说明。
-
合并端口列表以构建新列表。
-
连接至任何已发现的开放端口。
-
将自定义帮助程序应用程序分配给任何端口。
QualysGuard
QualysGuard 包含了一套工具,可简化安全操作并降低合规成本。它可以按需提供重要的安全情报,并针对 IT 系统和 Web 应用程序自动执行审计、合规性和保护的全方位服务。
QualysGuard 包含了一组可监控、检测和保护你的全球网络的工具。
WebInspect
WebInspect 是一款 Web 应用程序安全评估工具,它用于识别 Web 应用程序层中已知和未知的漏洞。
它还可以帮助检查 Web 服务器是否配置正确,并尝试进行常见的 Web 攻击,例如参数注入、跨站点脚本编写、目录遍历等。
LC4
LC4 之前称为 L0phtCrack 。它是一款密码审核与恢复应用程序。它用于测试密码强度和恢复丢失的 Microsoft Windows 密码(有时会使用字典、暴力破解和混合攻击)。
LC4 会恢复 Windows 用户帐户密码,以簡化将用户迁移到另一个身份验证系统或访问密码丢失的帐户。
LANguard Network Security Scanner
LANguard Network Scanner monitors a network by scanning connected machines and providing information about each node. You can obtain information about each individual operating system.
It can also detect registry issues and have a report set up in HTML format. For each computer, you can list the netbios name table, current logged-on user, and Mac address.
Network Stumbler
Network stumbler is a WiFi scanner and monitoring tool for Windows. It allows network professionals to detect WLANs. It is widely used by networking enthusiasts and hackers because it helps you find non-broadcasting wireless networks.
Network Stumbler can be used to verify if a network is well configured, its signal strength or coverage, and detect interference between one or more wireless networks. It can also be used to non-authorized connections.
ToneLoc
ToneLoc stands for Tone Locator. It was a popular war dialling computer program written for MS-DOS in the early 90’s. War dialling is a technique of using a modem to automatically scan a list of telephone numbers, usually dialling every number in a local area code.
Malicious hackers use the resulting lists in breaching computer security - for guessing user accounts, or locating modems that might provide an entry-point into computer or other electronic systems.
It can be used by security personnel to detect unauthorized devices on a company’s telephone network.
Ethical Hacking - Skills
作为一名道德黑客,你需要了解各种黑客技术,例如 −
-
Password guessing and cracking
-
Session hijacking
-
Session spoofing
-
Network traffic sniffing
-
Denial of Service attacks
-
Exploiting buffer overflow vulnerabilities
-
SQL injection
在本章中,我们将讨论你成为道德黑客专家所需的某些技能。
Basic Skills
计算机黑客既是一门科学,也是一门艺术。与任何其他专业知识一样,你需要付出大量努力才能获得知识并成为一名专家黑客。一旦你步入正轨,你需要付出更多努力来跟上最新技术、新漏洞和利用技术。
-
一个道德黑客必须是一位计算机系统专家,并且需要有非常强的编程和计算机网络技能。
-
一名道德黑客需要有大量的耐心、恒心和毅力,以便一次又一次地尝试并等待所需的结果。
此外,道德黑客应该足够聪明来理解形势和其他用户的思维方式,以便运用社会工程漏洞。一名优秀的道德黑客也具备出色的问题解决能力。
Courses & Certifications
本教程提供了成为一名成功的道德黑客的基本准则。如果你想在这个领域脱颖而出,那么你可以选择参加以下课程和认证 −
-
获得计算机科学学士学位或 A+ 证书以了解最常见的硬件和软件技术。
-
进入编程员角色几年,然后转到技术支持职位。
-
继续获得 Network+ 或 CCNA 等网络认证,然后获得 Security+、CISSP 或 TICSA 等安全认证。
-
建议您获得一些网络工程师和系统管理员的工作经验,以彻底了解网络和系统。
-
继续阅读各种书籍、教程和论文以了解各种计算机安全方面,并将其作为挑战,作为网络安全工程师保护您的网络和计算机系统。
-
学习涵盖创建特洛伊木马、后门、病毒和蠕虫、拒绝服务 (DoS) 攻击、SQL 注入、缓冲区溢出、会话劫持和系统黑客的课程。
-
掌握渗透测试、信息收集和侦察以及社会工程的艺术。
-
最后获得认证道德黑客 (CEH) 认证。
GIAC(全球信息保证认证)和 Offensive Security Certified Professional (OSCP) 是额外的 IT 安全认证,它们将为您的个人资料增加很多价值。
Ethical Hacking - Process
Ethical Hacking - Reconnaissance
信息收集和了解目标系统是道德黑客攻击中的第一个过程。侦查是一组用来秘密发现和收集有关目标系统信息的流程和技术(足迹、扫描和枚举)。
在侦查期间,道德黑客试图收集尽可能多的有关目标系统的信息,按照下面列出的七个步骤执行 −
-
Gather initial information
-
Determine the network range
-
Identify active machines
-
发现开放端口和接入点
-
Fingerprint the operating system
-
Uncover services on ports
-
Map the network
我们将在本教程的后续章节中详细讨论所有这些步骤。侦查分为两部分 − Active Reconnaissance 和 Passive Reconnaissance 。
Ethical Hacking - Footprinting
足迹收集是一个侦察过程中的部分内容,用于收集目标计算机系统或网络的可能信息。足迹收集可以是 passive ,也可以是 active 。查看公司的网站是一个被动足迹收集的示例,而尝试通过社交工程学获取敏感信息是一个主动信息收集的示例。
足迹收集基本上是黑客尽可能收集尽可能多的信息以找到入侵目标系统的方法或至少决定哪种类型的攻击更适合该目标的第一步。
在此阶段,黑客可以收集以下信息:
-
Domain name
-
IP Addresses
-
Namespaces
-
Employee information
-
Phone numbers
-
E-mails
-
Job Information
在以下部分,我们将讨论如何提取有关连接到互联网的任何计算机系统或网络的基本且易于获取的信息。
Domain Name Information
您可以使用 http://www.whois.com/whois 网站获取有关域名信息的详细信息,包括其所有者、其注册商、注册日期、到期时间、名称服务器、所有者的联系信息等。
以下是从 WHOIS 查询中提取的 www.tutorialspoint.com 的示例记录:
Finding IP Address
您可以在提示符处使用 ping 命令。此命令在 Windows 及 Linux 操作系统中均可用。以下是查找 tutorialspoint.com 的 IP 地址的示例:
$ping tutorialspoint.com
它将产生以下结果 −
PING tutorialspoint.com (66.135.33.172) 56(84) bytes of data.
64 bytes from 66.135.33.172: icmp_seq = 1 ttl = 64 time = 0.028 ms
64 bytes from 66.135.33.172: icmp_seq = 2 ttl = 64 time = 0.021 ms
64 bytes from 66.135.33.172: icmp_seq = 3 ttl = 64 time = 0.021 ms
64 bytes from 66.135.33.172: icmp_seq = 4 ttl = 64 time = 0.021 ms
Finding Hosting Company
获得网站地址后,您可以使用 [role="bare"] [role="bare"]https://www.ip2location.com/ip2location.com 网站来获取更多详细信息。以下是查找 IP 地址详细信息的示例:
此处,ISP 行会向您提供有关托管公司的详细信息,因为 IP 地址通常仅由托管公司提供。
IP Address Ranges
小型站点可能与其关联单个 IP 地址,但较大的网站通常具有多个用于提供不同域名和子域名的 IP 地址。
You can obtain a range of IP addresses assigned to a particular company using American Registry for Internet Numbers (ARIN).
You can enter company name in the highlighted search box to find out a list of all the assigned IP addresses to that company.
History of the Website
It is very easy to get a complete history of any website using www.archive.org.
You can enter a domain name in the search box to find out how the website was looking at a given point of time and what were the pages available on the website on different dates.
Ethical Hacking - Fingerprinting
道德黑客中的术语 OS 指纹识别是指用来确定远程计算机上运行什么操作系统的任何方法。这可能是−
-
Active Fingerprinting − 活动指纹识别是通过向目标机器发送特制的包来完成的,然后记下其响应并分析收集到的信息来确定目标 OS。在以下部分中,我们给出了一个示例来说明如何使用 NMAP 工具检测目标域的 OS。
-
Passive Fingerprinting − 被动指纹识别基于远程系统的信息收集器痕迹。基于包的收集器痕迹(例如 Wireshark),您可以确定远程主机的操作系统。
我们有以下四个重要元素,我们将在其中查看这些元素以确定操作系统−
-
TTL − 操作系统在出站包上设置 Time-To-Live 。
-
Window Size − 操作系统设置窗口大小。
-
DF − 操作系统是否设置 Don’t Fragment 位。
-
TOS − 操作系统是否设置 Type of Service ,如果是,则设置什么。
通过分析数据包的这些因素,你能确定远程操作系统。此系统并非 100% 准确,且适用于某些操作系统,而不适用于其他操作系统。
Basic Steps
在攻击系统之前,你必须知道是哪些操作系统承载网站。一旦知道了目标操作系统,就很容易确定可能存在哪些漏洞以利用目标系统。
下面是一个简单的 nmap 命令,可以用来识别用于承载网站的操作系统,以及与域名相关的所有已打开端口,即 IP 地址。
$nmap -O -v tutorialspoint.com
它将向你展示有关给定域名或 IP 地址的以下敏感信息:
Starting Nmap 5.51 ( http://nmap.org ) at 2015-10-04 09:57 CDT
Initiating Parallel DNS resolution of 1 host. at 09:57
Completed Parallel DNS resolution of 1 host. at 09:57, 0.00s elapsed
Initiating SYN Stealth Scan at 09:57
Scanning tutorialspoint.com (66.135.33.172) [1000 ports]
Discovered open port 22/tcp on 66.135.33.172
Discovered open port 3306/tcp on 66.135.33.172
Discovered open port 80/tcp on 66.135.33.172
Discovered open port 443/tcp on 66.135.33.172
Completed SYN Stealth Scan at 09:57, 0.04s elapsed (1000 total ports)
Initiating OS detection (try #1) against tutorialspoint.com (66.135.33.172)
Retrying OS detection (try #2) against tutorialspoint.com (66.135.33.172)
Retrying OS detection (try #3) against tutorialspoint.com (66.135.33.172)
Retrying OS detection (try #4) against tutorialspoint.com (66.135.33.172)
Retrying OS detection (try #5) against tutorialspoint.com (66.135.33.172)
Nmap scan report for tutorialspoint.com (66.135.33.172)
Host is up (0.000038s latency).
Not shown: 996 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
3306/tcp open mysql
TCP/IP fingerprint:
OS:SCAN(V=5.51%D=10/4%OT=22%CT=1%CU=40379%PV=N%DS=0%DC=L%G=Y%TM=56113E6D%P=
OS:x86_64-redhat-linux-gnu)SEQ(SP=106%GCD=1%ISR=109%TI=Z%CI=Z%II=I%TS=A)OPS
OS:(O1=MFFD7ST11NW7%O2=MFFD7ST11NW7%O3=MFFD7NNT11NW7%O4=MFFD7ST11NW7%O5=MFF
OS:D7ST11NW7%O6=MFFD7ST11)WIN(W1=FFCB%W2=FFCB%W3=FFCB%W4=FFCB%W5=FFCB%W6=FF
OS:CB)ECN(R=Y%DF=Y%T=40%W=FFD7%O=MFFD7NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A
OS:=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%
OS:Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=
OS:A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=
OS:Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%
OS:T=40%CD=S)
如果你没有在 Linux 系统上安装 nmap 命令,那么你可以使用以下 yum 命令安装它:
$yum install nmap
你可以仔细查看 nmap 命令来检查和了解与系统相关并保护其免遭恶意攻击的不同功能。
Port Scanning
我们刚刚看到 nmap 命令给出的信息。此命令会列出给定服务器上所有打开的端口。
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
3306/tcp open mysql
你还可以使用以下命令检查是否打开了特定的端口:
$nmap -sT -p 443 tutorialspoint.com
它将产生以下结果 −
Starting Nmap 5.51 ( http://nmap.org ) at 2015-10-04 10:19 CDT
Nmap scan report for tutorialspoint.com (66.135.33.172)
Host is up (0.000067s latency).
PORT STATE SERVICE
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds
一旦黑客知道打开的端口,那么他就可以通过打开的端口计划不同的攻击技术。
Ping Sweep
Ping 扫描是一种网络扫描技术,你可以使用它来确定 IP 地址范围内的哪些 IP 地址映射到活动主机。Ping 扫描也称为 ICMP sweep 。
你可以对 Ping 扫描使用 fping 命令。此命令是一个类似 ping 的程序,它使用因特网控制消息协议 (ICMP) 回声请求来确定主机是否已启动。
fping 不同于 ping ,因为你可以在命令行上指定任意数量的主机,或指定包含要 ping 的主机列表的文件。如果主机在某个时间限制和/或重试限制内没有响应,它将被认为不可达。
DNS Enumeration
域名服务器 (DNS) 像地图或地址簿。事实上,它就像一个分布式数据库,用于将 IP 地址 192.111.1.120 转换为名称 www.example.com, 反之亦然。
DNS 枚举是查找所有 DNS 服务器及其对应记录的过程。其目的是在发起攻击之前尽可能收集有关目标的有趣详细信息。
你可以在 Linux 上使用 nslookup 命令来获取 DNS 和主机相关信息。此外,你可以使用以下 DNSenum 脚本来获取有关域名的详细信息:
DNSenum 脚本可以执行以下重要操作 −
-
Get the host’s addresses
-
Get the nameservers
-
Get the MX record
-
对名称服务器执行 axfr 查询
-
通过 Google scraping 获取额外名称和子域名
-
从文件进行蛮力破解子域还可以对有 NS 记录的子域执行递归
-
计算 C 类域网络范围并在其上执行 whois 查询
-
在 reverse lookups 上执行 netranges
Ethical Hacking - Sniffing
嗅探是使用嗅探工具监控和捕获通过给定网络的所有数据包的过程。这是一种“窃听电话线”并了解对话的形式。它也被称为 wiretapping 应用于计算机网络。
如果一组企业交换机端口已打开,就有很大的可能性,他们的一名员工可以嗅探网络的全部流量。任何在相同物理位置的人都可以使用以太网电缆连接到网络,或以无线方式连接到该网络并嗅探全部流量。
换句话说,嗅探使您可以查看各种流量,包括受保护和不受保护的流量。在条件合适且实施了正确的协议时,攻击方有可能收集可用于进一步攻击或给网络或系统所有者造成其他问题的信息。
What can be sniffed?
人们可以从网络中嗅探以下敏感信息——
-
Email traffic
-
FTP passwords
-
Web traffics
-
Telnet passwords
-
Router configuration
-
Chat sessions
-
DNS traffic
How it works
嗅探器通常将系统的 NIC 转到 promiscuous mode ,以便它监听在其网段上传输的所有数据。
混杂模式是指以太网硬件(特别是网络接口卡 (NIC))的独特方式,它允许 NIC 接收网络上的所有流量,即使该流量不是针对此 NIC 的。默认情况下,NIC 会忽略所有未发送给它的流量,这是通过将以太网数据包的目标地址与设备的硬件地址(也称为 MAC)进行比较来完成的。虽然这对于网络来说很有意义,但是非混杂模式使得难以使用网络监视和分析软件来诊断连接问题或流量利用率。
嗅探器可以通过解码数据包中封装的信息,持续监视通过网卡传输到计算机的所有流量。
Types of Sniffing
嗅探本质上可分为主动或被动。
Passive Sniffing
在被动嗅探中,流量被锁定,但不会以任何方式被改变。被动嗅探只允许监听。它适用于集线器设备。在集线器设备上,流量会被发送到所有端口。在一个使用集线器连接系统的网络中,网络上的所有主机都可以看到流量。因此,攻击者可以轻松捕获流量。
好消息是,如今集线器几乎已经过时了。大多数现代网络使用交换机。因此,被动嗅探不再有效。
Active Sniffing
在主动嗅探中,流量不仅被锁定和监控,而且可能会根据攻击者的决定以某种方式被改变。主动嗅探用于嗅探基于交换机的网络。它涉及向目标网络注入 address resolution packets (ARP),以在交换机 content addressable memory (CAM)表中泛洪。CAM 会跟踪每个主机连接到哪个端口。
以下是主动嗅探技术——
-
MAC Flooding
-
DHCP Attacks
-
DNS Poisoning
-
Spoofing Attacks
-
ARP Poisoning
Protocols which are affected
诸如久经考验的 TCP/IP 等协议在设计时从未考虑安全性,因此对潜在攻击者几乎没有抵抗力。几条规则很容易被嗅探 −
-
HTTP − 它用于明文发送信息,没有任何加密,因此是一个真正的目标。
-
SMTP (简单邮件传输协议) − SMTP 基本用于电子邮件传输。此协议效率很高,但它没有包含针对嗅探的任何保护措施。
-
NNTP (网络新闻传输协议)− 它用于各种通信,但它主要缺点是数据甚至密码都通过网络以明文发送。
-
POP (邮局协议) − POP 仅用于从服务器接收电子邮件。此协议不包含针对嗅探的保护,因为它可能会被诱捕。
-
FTP (文件传输协议) − FTP 用于发送和接收文件,但它不提供任何安全功能。所有数据都作为明文发送,很容易被嗅探。
-
IMAP (互联网消息访问协议) − IMAP 在其功能上与 SMTP 相同,但它极易受到嗅探。
-
Telnet − Telnet 会通过网络以明文形式发送所有内容(用户名、密码、击键),因此它很容易被嗅探。
嗅探器并不是只能让你查看实时流量的简单工具。如果你真的想要对每个数据包进行分析,请保存捕获内容并在时间允许时对其进行查看。
Hardware Protocol Analyzers
在我们进一步了解嗅探器之前,讨论 hardware protocol analyzers 很重要。这些设备会在硬件级别插入网络,并且可以监视流量而不会对其进行操纵。
-
硬件协议分析器用于监视和识别系统中安装的黑客软件生成的可疑网络流量。
-
它们会捕获数据包,对其进行解码,并根据特定规则分析其内容。
-
硬件协议分析器可以让攻击者看到通过电缆的每个数据包的各个数据字节。
由于在许多情况下成本非常高,因此大多数道德黑客无法轻易获得这些硬件设备。
Lawful Interception
合法截取(LI)被定义为合法获取通信网络数据(如电话呼叫或电子邮件)的途径。LI 始终必须为了分析或证据的目的而追求合法权限。因此,法律截取是一种安全流程,其中网络运营商或服务供应商允许执法人员访问个人或组织的私人通信。
几乎所有国家都起草并颁布了法规来规范合法截取程序;标准化组织正在制定 LI 技术规范。通常,LI 活动是为了基础设施保护和网络安全的目的而进行。然而,除非另有禁止,私人网络基础设施的运营商可以在其自己的网络内保留 LI 功能,作为固有权利。
LI was formerly known as wiretapping and has existed since the inception of electronic communications.
Ethical Hacking - Sniffing Tools
在网络上进行嗅探有很多可用的工具,它们都具有自己的特性来帮助黑客分析流量并获取信息。嗅探工具是非常常见的应用程序。我们在此列出了一些有趣的工具:
-
BetterCAP - BetterCAP 是一款功能强大、灵活、可移植的工具,用于对网络执行各种类型的 MITM 攻击,实时操作 HTTP、HTTPS 和 TCP 流量,嗅探凭据等等。
-
Ettercap - Ettercap 是一款用于中间人攻击的综合套件。它具有实时监听连接、即时内容过滤和许多其他有趣技能的特点。它支持许多协议的主动和被动解析,并且包含许多用于网络和主机分析的功能。
-
Wireshark - 它是最广为人知和使用最广泛的数据包嗅探器之一。它提供了大量功能,协助流量的解析和分析。
-
Tcpdump - 它是一个著名的命令行数据包分析器。它提供了在网络上传输过程中拦截和观察 TCP/IP 及其他数据包的能力。可以在 www.tcpdump.org 获得。
-
WinDump - tcpdump 是流行的 Linux 数据包嗅探器的一个 Windows 端口,它是一款命令行工具,非常适合显示头信息。
-
OmniPeek - OmniPeek 是 WildPackets 制造的一款商业产品,是 EtherPeek 产品的升级版。
-
Dsniff - 一套工具,旨在对不同的协议执行嗅探,以拦截和揭示密码。Dsniff 设计用于 Unix 和 Linux 平台,在 Windows 平台上没有完全等效的工具。
-
EtherApe - 这是一个 Linux/Unix 工具,旨在直观地显示系统传入和传出的连接。
-
MSN Sniffer - 它是一个专门为嗅探 MSN Messenger 应用程序生成流量而设计的嗅探实用工具。
-
NetWitness NextGen - 它包含一个基于硬件的嗅探器以及其他功能,旨在监视和分析网络上的所有流量。此工具由 FBI 及其他执法机构使用。
潜在的黑客可以使用这些嗅探工具中的任何一个来分析网络流量并获取信息。
Ethical Hacking - ARP Poisoning
地址解析协议 (ARP) 是一种无状态协议,用于将 IP 地址解析为计算机的 MAC 地址。网络上需要进行通信的所有网络设备都会在系统中广播 ARP 查询,以找出其他计算机的 MAC 地址。ARP 欺骗也称为 ARP Spoofing 。
以下是 ARP 的工作原理:
-
当一台计算机需要与另一台计算机进行通信时,它会查询其 ARP 表。
-
如果表中找不到 MAC 地址,则 ARP_request 会在网络上广播。
-
网络上的所有计算机都会将此 IP 地址与 MAC 地址进行比较。
-
如果网络中的其中一台计算机识别出此地址,则它会使用自己的 IP 地址和 MAC 地址响应 ARP_request 。
-
请求计算机将在其 ARP 表中存储地址对,然后进行通信。
What is ARP Spoofing?
可以伪造 ARP 数据包以将数据发送到攻击者的计算机。
-
ARP 欺骗会构造大量伪造的 ARP 请求和响应数据包来重载交换机。
-
交换机被设置为 forwarding mode ,并且在 ARP table 充斥着欺骗的 ARP 响应之后,攻击者就可以嗅探到所有网络数据包。
攻击者用伪造的条目随机填充目标计算机的 ARP 缓存,这也称为 poisoning 。ARP 欺骗使用中间人访问来污染网络。
What is MITM?
中间人攻击(缩写为 MITM、MitM、MIM、MiM、MITMA)暗示一种主动攻击,其中 adversaries 冒充用户,通过在受害者之间创建连接并发送他们之间的消息来进行攻击。在这种情况下,受害者认为他们在彼此通信,但实际上,恶意行为者控制着通信。
存在第三人来控制和监视两方之间的通信流量。诸如 SSL 等一些协议有助于阻止这种类型的攻击。
ARP Poisoning − Exercise
In this exercise, we have used BetterCAP to perform ARP poisoning in LAN environment using VMware workstation in which we have installed Kali Linux and Ettercap tool to sniff the local traffic in LAN.
For this exercise, you would need the following tools −
-
VMware workstation
-
Kali Linux or Linux Operating system
-
Ettercap Tool
-
LAN connection
Note − This attack is possible in wired and wireless networks. You can perform this attack in local LAN.
Step 1 − Install the VMware workstation and install the Kali Linux operating system.
Step 2 − Login into the Kali Linux using username pass “root, toor”.
Step 3 − Make sure you are connected to local LAN and check the IP address by typing the command ifconfig in the terminal.
Step 4 − Open up the terminal and type “Ettercap –G” to start the graphical version of Ettercap.
Step 5 − Now click the tab “sniff” in the menu bar and select “unified sniffing” and click OK to select the interface. We are going to use “eth0” which means Ethernet connection.
Step 6 − Now click the “hosts” tab in the menu bar and click “scan for hosts”. It will start scanning the whole network for the alive hosts.
Step 7 − Next, click the “hosts” tab and select “hosts list” to see the number of hosts available in the network. This list also includes the default gateway address. We have to be careful when we select the targets.
Step 8 − Now we have to choose the targets. In MITM, our target is the host machine, and the route will be the router address to forward the traffic. In an MITM attack, the attacker intercepts the network and sniffs the packets. So, we will add the victim as “target 1” and the router address as “target 2.”
In VMware environment, the default gateway will always end with “2” because “1” is assigned to the physical machine.
Step 9 − In this scenario, our target is “192.168.121.129” and the router is “192.168.121.2”. So we will add target 1 as victim IP and target 2 as router IP.
Step 10 − Now click on “MITM” and click “ARP poisoning”. Thereafter, check the option “Sniff remote connections” and click OK.
Step 11 − Click “start” and select “start sniffing”. This will start ARP poisoning in the network which means we have enabled our network card in “promiscuous mode” and now the local traffic can be sniffed.
Note − We have allowed only HTTP sniffing with Ettercap, so don’t expect HTTPS packets to be sniffed with this process.
Step 12 − Now it’s time to see the results; if our victim logged into some websites. You can see the results in the toolbar of Ettercap.
以下是嗅探是如何运作的。您一定已经明白了,只需启用 ARP 欺骗就可以轻松获得 HTTP 凭据。
ARP 欺骗有可能会给公司环境造成巨大损失。这就是任命道德黑客来保护网络的地方。
与 ARP 欺骗类似,还有其他攻击,例如 MAC 泛洪、MAC 欺骗、DNS 欺骗和 ICMP 欺骗,它们都可能给网络造成重大损失。
在下一章,我们将会讨论另一种称为 DNS poisoning 的攻击类型。
Ethical Hacking - DNS Poisoning
DNS 欺骗是一种欺骗 DNS 服务器,使其确信它已收到真实信息的技术,而实际上它并未收到。这将导致在 DNS 级别替换错误的 IP 地址,在那里 Web 地址被转换为数字 IP 地址。它允许攻击者用服务器控件的 IP 地址替换给定 DNS 服务器上目标网站的 IP 地址条目。攻击者可以创建可能包含恶意内容的服务器假 DNS 条目,名称与该服务器相同。
例如,用户键入 www.google.com,但用户会被发送到另一个欺诈网站,而不是被定向到 Google 服务器。正如我们所理解的,DNS 欺骗用于将用户重定向到由攻击者管理的虚假页面。
DNS Poisoning − Exercise
让我们使用相同的工具 Ettercap 对 DNS 欺骗进行练习。
DNS 欺骗非常类似于 ARP 欺骗。要启动 DNS 欺骗,您必须从我们在上一章中已经讨论过的 ARP 欺骗开始。我们将使用 Ettercap 中已经存在的 DNS spoof 插件。
Step 1 − 打开终端并键入“nano etter.dns”。此文件包含由 Ettercap 用于解析域名地址的所有 DNS 地址的条目。在此文件中,我们将添加 Facebook 的一个假条目。如果有人想要打开 Facebook,他将被重定向到另一个网站。
Step 2 − 现在在“重定向到 www.linux.org” 字样下插入条目。请参见以下示例 −
Step 3 - 现在保存此文件并保存文件退出。使用“ctrl+x”保存文件。
Step 4 - 此后,整个过程都相同,开始 ARP 中毒。启动 ARP 中毒后,单击菜单栏中的“插件”并选择“dns_spoof”插件。
Step 5 - 激活 DNS_spoof 后,您将在结果中看到,每当有人在其浏览器中键入 facebook.com 时,它将开始向 Google IP 进行欺骗。
这意味着用户在其浏览器中获取 Google 页面,而不是 facebook.com。
在本练习中,我们了解了如何通过不同的工具和方法来嗅探网络流量。这里一家公司需要一位道德黑客为其提供网络安全,以阻止所有这些攻击。让我们了解一下一位道德黑客可以做些什么来防止 DNS 中毒。
Defenses against DNS Poisoning
作为一名道德黑客,您的工作很大可能将您置于预防而不是笔试的位置。您作为攻击者所知道的事情可以帮助您防止从外部采用的技术。
以下是笔试人员的角度对我们刚刚涵盖的攻击进行的防御措施:
-
对网络中最敏感的部分使用硬件交换网络,以将流量分离到一个独立的分段或冲突域。
-
在交换机上实现 IP DHCP 侦听,以防止 ARP 中毒和欺骗攻击。
-
实施策略以防止网络适配器使用混杂模式。
-
部署无线接入点时要小心,因为无线网络上的所有流量都可能被嗅探。
-
使用 SSH 或 IPsec 等加密协议加密敏感流量。
-
端口安全由交换机使用,这些交换机能够编程以仅允许特定的 MAC 地址在每个端口上发送和接收数据。
-
IPv6 具有 IPv4 所没有的安全优势和选项。
-
用 SSH 替换 FTP 和 Telnet 等协议是防止嗅探的有效防御措施。如果 SSH 不是可行的解决方案,请考虑使用 IPsec 保护旧的传统协议。
-
虚拟专用网络 (VPN) 由于其加密方面,可以提供有效的防御嗅探措施。
-
SSL 是与 IPsec 一起强大的防御措施。
Ethical Hacking - Exploitation
Exploit 是一种程序化软件或脚本,它可以让黑客通过利用漏洞来控制某个系统。黑客一般使用漏洞扫描程序(例如 Nessus、Nexpose、OpenVAS 等)来查找这些漏洞。
Metasploit 是一个强有力的工具,可以找到系统中的漏洞。
根据这些漏洞,我们来查找利用。我们将在此讨论一些可以用来查找漏洞的最好的搜索引擎。
Ethical Hacking - Enumeration
枚举属于道德黑客的第一阶段,即“信息收集”。这是一项攻击者与受害者建立主动连接并尝试发现尽可能多的攻击向量的过程,可用于进一步利用这些系统。
枚举可用于获取信息,例如 −
-
Network shares
-
SNMP 数据,如果它们未被正确保护
-
IP tables
-
Usernames of different systems
-
Passwords policies lists
枚举取决于系统提供的服务。它们可以是 −
-
DNS enumeration
-
NTP enumeration
-
SNMP enumeration
-
Linux/Windows enumeration
-
SMB enumeration
让我们现在讨论一些广泛用于枚举的工具。
NTP Suite
NTP 套件用于 NTP 枚举。这很重要,因为在网络环境中,您可以找到其他主服务器,帮助主机更新它们的时间,并且您可以在不验证系统的情况下完成此操作。
Take a look at the following example.
ntpdate 192.168.1.100 01 Sept 12:50:49 ntpdate[627]:
adjust time server 192.168.1.100 offset 0.005030 sec
or
ntpdc [-ilnps] [-c command] [hostname/IP_address]
root@test]# ntpdc -c sysinfo 192.168.1.100
***Warning changing to older implementation
***Warning changing the request packet size from 160 to 48
system peer: 192.168.1.101
system peer mode: client
leap indicator: 00
stratum: 5
precision: -15
root distance: 0.00107 s
root dispersion: 0.02306 s
reference ID: [192.168.1.101]
reference time: f66s4f45.f633e130, Sept 01 2016 22:06:23.458
system flags: monitor ntp stats calibrate
jitter: 0.000000 s
stability: 4.256 ppm
broadcastdelay: 0.003875 s
authdelay: 0.000107 s
enum4linux
enum4linux is used to enumerate Linux systems. Take a look at the following screenshot and observe how we have found the usernames present in a target host.
Ethical Hacking - Metasploit
Metasploit is one of the most powerful exploit tools. Most of its resources can be found at: https://www.metasploit.com. It comes in two versions − commercial and free edition. There are no major differences in the two versions, so in this tutorial, we will be mostly using the Community version (free) of Metasploit.
As an Ethical Hacker, you will be using “Kali Distribution” which has the Metasploit community version embedded in it along with other ethical hacking tools. But if you want to install Metasploit as a separate tool, you can easily do so on systems that run on Linux, Windows, or Mac OS X.
The hardware requirements to install Metasploit are −
-
2 GHz+ processor
-
1 GB RAM available
-
1 GB+ available disk space
Matasploit can be used either with command prompt or with Web UI.
To open in Kali, go to Applications → Exploitation Tools → metasploit.
After Metasploit starts, you will see the following screen. Highlighted in red underline is the version of Metasploit.
Exploits of Metasploit
From Vulnerability Scanner, we found that the Linux machine that we have for test is vulnerable to FTP service. Now, we will use the exploit that can work for us. The command is −
use “exploit path”
The screen will appear as follows −
Then type mfs> show options in order to see what parameters you have to set in order to make it functional. As shown in the following screenshot, we have to set RHOST as the “target IP”.
We type msf> set RHOST 192.168.1.101 and msf>set RPORT 21
Then, type mfs>run. If the exploit is successful, then it will open one session that you can interact with, as shown in the following screenshot.
Metasploit Payloads
Payload, in simple terms, are simple scripts that the hackers utilize to interact with a hacked system. Using payloads, they can transfer data to a victim system.
Metasploit payloads can be of three types −
-
Singles − Singles are very small and designed to create some kind of communication, then move to the next stage. For example, just creating a user.
-
Staged − It is a payload that an attacker can use to upload a bigger file onto a victim system.
-
Stages − Stages are payload components that are downloaded by Stagers modules. The various payload stages provide advanced features with no size limits such as Meterpreter and VNC Injection.
Payload Usage − Example
We use the command show payloads. With this exploit, we can see the payloads that we can use, and it will also show the payloads that will help us upload /execute files onto a victim system.
To set the payload that we want, we will use the following command −
set PAYLOAD payload/path
Set the listen host and listen port (LHOST, LPORT) which are the attacker IP and port. Then set remote host and port (RPORT, LHOST) which are the victim IP and port.
Type “exploit”. It will create a session as shown below −
Now we can play with the system according to the settings that this payload offers.
Ethical Hacking - Trojan Attacks
Trojans are non-replication programs; they don’t reproduce their own codes by attaching themselves to other executable codes. They operate without the permissions or knowledge of the computer users.
Trojans hide themselves in healthy processes. However we should underline that Trojans infect outside machines only with the assistance of a computer user, like clicking a file that comes attached with email from an unknown person, plugging USB without scanning, opening unsafe URLs.
Trojans have several malicious functions −
-
They create backdoors to a system. Hackers can use these backdoors to access a victim system and its files. A hacker can use Trojans to edit and delete the files present on a victim system, or to observe the activities of the victim.
-
Trojans can steal all your financial data like bank accounts, transaction details, PayPal related information, etc. These are called Trojan-Banker.
-
Trojans can use the victim computer to attack other systems using Denial of Services.
-
Trojans can encrypt all your files and the hacker may thereafter demand money to decrypt them. These are Ransomware Trojans.
-
They can use your phones to send SMS to third parties. These are called SMS Trojans.
Trojan Information
If you have found a virus and want to investigate further regarding its function, then we will recommend that you have a look at the following virus databases, which are offered generally by antivirus vendors.
-
Kaspersky Virus database − https://www.kaspersky.com
-
F-secure − https://www.f-secure.com
-
Symantec – Virus Encyclopedia − https://www.symantec.com
Ethical Hacking - TCP/IP Hijacking
TCP/IP Hijacking is when an authorized user gains access to a genuine network connection of another user. It is done in order to bypass the password authentication which is normally the start of a session.
In theory, a TCP/IP connection is established as shown below −
To hijack this connection, there are two possibilities −
-
Find the seq which is a number that increases by 1, but there is no chance to predict it.
-
The second possibility is to use the Man-in-the-Middle attack which, in simple words, is a type of network sniffing. For sniffing, we use tools like Wireshark or Ethercap.
Example
An attacker monitors the data transmission over a network and discovers the IP’s of two devices that participate in a connection.
When the hacker discovers the IP of one of the users, he can put down the connection of the other user by DoS attack and then resume communication by spoofing the IP of the disconnected user.
Shijack
In practice, one of the best TCP/IP hijack tools is Shijack. It is developed using Python language and you can download it from the following link − https://packetstormsecurity.com/sniffers/shijack.tgz
Here is an example of a Shijack command −
root:/home/root/hijack# ./shijack eth0 192.168.0.100 53517 192.168.0.200 23
Here, we are trying to hijack a Telnet connection between the two hosts.
Hunt
Hunt is another popular tool that you can use to hijack a TCP/IP connection. It can be downloaded from − https://packetstormsecurity.com/sniffers/hunt/
Ethical Hacking - Email Hijacking
Email Hijacking, or email hacking, is a widespread menace nowadays. It works by using the following three techniques which are email spoofing, social engineering tools, or inserting viruses in a user computer.
Email Spoofing
In email spoofing, the spammer sends emails from a known domain, so the receiver thinks that he knows this person and opens the mail. Such mails normally contain suspicious links, doubtful content, requests to transfer money, etc.
Social Engineering
Spammers send promotional mails to different users, offering huge discount and tricking them to fill their personal data. You have tools available in Kali that can drive you to hijack an email.
Email hacking can also be done by phishing techniques. See the following screenshot.
The links in the email may install malware on the user’s system or redirect the user to a malicious website and trick them into divulging personal and financial information, such as passwords, account IDs or credit card details.
Phishing attacks are widely used by cybercriminals, as it is far easier to trick someone into clicking a malicious links in the email than trying to break through a computer’s defenses.
Inserting Viruses in a User System
The third technique by which a hacker can hijack your email account is by infecting your system with a virus or any other kind of malware. With the help of a virus, a hacker can take all your passwords.
How to detect if your email has been hijacked?
-
The recipients of spam emails include a bunch of people you know.
-
You try to access your account and the password no longer works.
-
You try to access the “Forgot Password” link and it does not go to the expected email.
-
Your Sent Items folder contains a bunch of spams you are not aware of sending.
Ethical Hacking - Password Hacking
我们有用于电子邮件、数据库、计算机系统、服务器、银行账户和我们想要保护的几乎所有内容的密码。密码通常是进入系统或帐户的密钥。
通常情况下,人们倾向于设置易于记住的密码,例如他们的出生日期、家人的名字、手机号码等。这正是导致密码薄弱且容易被黑客攻击的原因。
人们应该始终注意使用强密码来保护他们的帐户免受潜在黑客的攻击。强密码具有以下属性:−
-
至少包含 8 个字符。
-
字母、数字和特殊字符混合使用。
-
小写字母和大写字母相结合。
Dictionary Attack
在字典攻击中,黑客使用词典中预定义的单词列表来尝试猜测密码。如果设置的密码较弱,则字典攻击可以非常快速地对其进行解码。
Hydra 是一个流行的工具,被广泛用于字典攻击。请看以下屏幕截图,了解我们如何使用 Hydra 来找出 FTP 服务的密码。
Hybrid Dictionary Attack
混合字典攻击使用字典单词集与扩展名组合。例如,我们有单词“admin”,并将其与数字扩展名(例如“admin123”、“admin147”等)组合在一起。
Crunch 是一个单词列表生成器,您可以在其中指定标准字符集或字符集。 Crunch 可以生成所有可能的组合和排列。此工具与 Linux 的 Kali 发行版捆绑在一起。
Brute-Force Attack
在暴力攻击中,黑客使用字母、数字、特殊字符、小写字母和大写字母的所有可能组合来破解密码。这种类型的攻击成功的可能性很高,但需要大量的时间来处理所有组合。暴力攻击速度很慢,黑客可能需要一个具有高处理能力的系统来更快地执行所有这些排列和组合。
John the Ripper 或 Johnny 是设置暴力攻击的强大工具之一,它与 Linux 的 Kali 发行版捆绑在一起。
Rainbow Tables
彩虹表包含一组预定义且已散列的密码。它是一个查找表,尤其用于从密码文本中恢复明文密码。在密码恢复过程中,它只需查看预先计算的散列表即可破解密码。这些表可从 http://project-rainbowcrack.com/table.htm 下载
RainbowCrack 1.6.1 是使用彩虹表的工具。它可在 Kali 发行版中再次使用。
Ethical Hacking - Wireless Hacking
无线网络是一组两个或多个通过无线电波连接的设备,在有限的空间范围内彼此连接。无线网络中的设备可以自由移动,但可以连接网络并在网络中与其他设备共享数据。它们如此普遍的一个最关键点是,其安装成本非常低,并且比有线网络快。
无线网络得到了广泛使用,并且很容易设置。它们使用 IEEE 802.11 标准。 wireless router 是将用户连接到互联网的无线网络中最重要的设备。
在无线网络中,我们有 Access Points ,它们是作为逻辑交换机工作的无线范围扩展。
尽管无线网络提供了极大的灵活性,但它们有其安全问题。黑客无需出现在网络所在的大楼里即可嗅探网络数据包。由于无线网络通过无线电波通信,黑客可以轻松地从附近位置嗅探网络。
大多数攻击者使用网络嗅探来查找 SSID 并黑客入侵无线网络。当我们的无线卡转换为嗅探模式时,它们被称为 monitor mode 。
Kismet
Kismet is a powerful tool for wireless sniffing that is found in Kali distribution. It can also be downloaded from its official webpage − https://www.kismetwireless.net
让我们看看它是如何工作的。首先,打开一个终端并键入 kismet 。启动 Kismet 服务器,然后单击“是”,如下面的屏幕截图所示。
如这里所示,单击“开始”按钮。
现在,Kismet 将开始捕获数据。以下屏幕截图显示了它将如何显示 −
NetStumbler
NetStumbler 是另一种无线黑客工具,主要用于 Windows 系统。它可以从 http://www.stumbler.net/ 下载
在系统上使用 NetStumbler 非常容易。你只需单击“扫描”按钮并等待结果,如下面的屏幕截图所示。
它应显示如下屏幕截图 −
需要注意的是你的卡应支持监视模式,否则你将无法监视。
Wired Equivalent Privacy
有线等效保密(WEP)是一种安全协议,旨在保护无线网络并保持其私密性。它利用数据链路层的加密来禁止对网络的未经授权访问。
在传输开始之前,使用该密钥加密分组。完整性检查机制 检查分组在传输后未被更改。
请注意,WEP 并非完全不受安全问题影响。它会遇到以下几个问题:
-
CRC32 无法确保分组的完全加密完整性。
-
它易受字典攻击。
-
WEP 也易受到拒绝服务攻击。
Wireless DoS Attacks
在无线环境中,攻击者可以远距离攻击网络,因此有时难以收集针对攻击者的证据。
DoS 的第一种类型是 Physical Attack 。这种类型的攻击非常基础,其基础是无线电干扰,这种干扰甚至可以用 2.4 GHz 范围内运行的无绳电话来创造。
另一种类型是 Network DoS Attack 。由于无线接入点创造了一种共享介质,因此它提供了使此介质洪水般涌向接入点(AP)的可能性,从而会降低其对尝试连接的各个客户端的处理速度。此类攻击仅由 ping flood DoS attack 即可创建。
Pyloris 是一种流行的 DoS 工具,您可以从以下位置下载: https://sourceforge.net/projects/pyloris/
低轨道离子加农炮 (LOIC) 是一种其他流行的 DoS 攻击工具。
Ethical Hacking - Social Engineering
让我们通过一些示例来了解社会工程攻击的概念。
Example 1
你一定注意到过公司将旧文件当作垃圾丢弃在垃圾桶中。这些文件可能包含一些敏感信息,例如姓名、电话号码、帐号、社保号码、地址等。许多公司的传真机仍使用复写纸,一旦卷纸用完,其复写纸就会被丢弃在垃圾桶中,可能会包含敏感数据的痕迹。虽然听起来不太可能,但攻击者可以轻易地从公司的垃圾箱中获取信息,方法是翻找垃圾。
Example 2
一个攻击者可能会和一个公司职员交朋友,并在一段时间内与其建立良好的关系。这种关系可以通过社交网络、聊天室在线建立,也可以在咖啡馆、操场上或通过任何其他方式进行线下建立。攻击者会取得公司职员的信任,并最终在不留任何线索的情况下获取所需的敏感信息。
Ethical Hacking - DDOS Attacks
分布式拒绝服务 (DDoS) 攻击是一种通过从多个源生成大量流量来使在线服务或网站不可用的尝试。
与拒绝服务 (DoS) 攻击不同,在拒绝服务 (DoS) 攻击中,使用一台计算机和一个 Internet 连接向目标资源发送大量数据包,分布式拒绝服务 (DDoS) 攻击使用多台计算机和多个 Internet 连接,通常在全球范围内分布,称为 botnet 。
大规模体积 DDoS 攻击可以产生每秒以十千兆比特(甚至数百千兆比特)衡量的流量。我们确信您的普通网络将无法处理此类流量。
What are Botnets?
攻击者构建一个黑客机器网络,这些机器被称为 botnets ,通过电子邮件、网站和社交媒体传播恶意代码段。一旦这些计算机受到感染,就可以在没有其所有者知情的情况下进行远程控制,并像一支军队一样用来对任何目标发动攻击。
DDoS 洪流可以通过多种方式生成。例如 −
-
Botnets can be used for sending more number of connection requests than a server can handle at a time.
-
Attackers can have computers send a victim resource huge amounts of random data to use up the target’s bandwidth.
Due to the distributed nature of these machines, they can be used to generate distributed high traffic which may be difficult to handle. It finally results in a complete blockage of a service.
Types of DDoS Attacks
DDoS attacks can be broadly categorized into three categories −
-
Volume-based Attacks
-
Protocol Attacks
-
Application Layer Attacks
Volume-Based Attacks
Volume-based attacks include TCP floods, UDP floods, ICMP floods, and other spoofedpacket floods. These are also called Layer 3 & 4 Attacks. Here, an attacker tries to saturate the bandwidth of the target site. The attack magnitude is measured in Bits per Second (bps).
-
UDP Flood − A UDP flood is used to flood random ports on a remote host with numerous UDP packets, more specifically port number 53. Specialized firewalls can be used to filter out or block malicious UDP packets.
-
ICMP Flood − This is similar to UDP flood and used to flood a remote host with numerous ICMP Echo Requests. This type of attack can consume both outgoing and incoming bandwidth and a high volume of ping requests will result in overall system slowdown.
-
HTTP Flood − The attacker sends HTTP GET and POST requests to a targeted web server in a large volume which cannot be handled by the server and leads to denial of additional connections from legitimate clients.
-
Amplification Attack − The attacker makes a request that generates a large response which includes DNS requests for large TXT records and HTTP GET requests for large files like images, PDFs, or any other data files.
Protocol Attacks
Protocol attacks include SYN floods, Ping of Death, fragmented packet attacks, Smurf DDoS, etc. This type of attack consumes actual server resources and other resources like firewalls and load balancers. The attack magnitude is measured in Packets per Second.
-
DNS Flood − DNS floods are used for attacking both the infrastructure and a DNS application to overwhelm a target system and consume all its available network bandwidth.
-
SYN Flood − The attacker sends TCP connection requests faster than the targeted machine can process them, causing network saturation. Administrators can tweak TCP stacks to mitigate the effect of SYN floods. To reduce the effect of SYN floods, you can reduce the timeout until a stack frees memory allocated to a connection, or selectively dropping incoming connections using a firewall or iptables.
-
Ping of Death − The attacker sends malformed or oversized packets using a simple ping command. IP allows sending 65,535 bytes packets but sending a ping packet larger than 65,535 bytes violates the Internet Protocol and could cause memory overflow on the target system and finally crash the system. To avoid Ping of Death attacks and its variants, many sites block ICMP ping messages altogether at their firewalls.
Application Layer Attacks
应用程序层攻击包括 Slowloris、零日 DDoS 攻击、针对 Apache、Windows 或 OpenBSD 漏洞的 DDoS 攻击等。这里的目标是使 Web 服务器崩溃。攻击强度以 Requests per Second 为单位。
-
Application Attack − 也称为 Layer 7 Attack ,攻击者通过过度的登录、数据库查询或搜索请求来使应用程序超载。检测第 7 层攻击非常困难,因为这些攻击类似于合法的网站流量。
-
Slowloris − 攻击者向目标 Web 服务器发送大量 HTTP 头,但从不完成请求。目标服务器会保持这些虚假连接的打开状态,最后溢出最大并发连接池,导致无法向合法客户端提供进一步的连接。
-
NTP Amplification − 攻击者利用可公开访问的网络时间协议 (NTP) 服务器,用用户数据报协议 (UDP) 流量淹没目标服务器。
-
Zero-day DDoS Attacks − 零日漏洞是一种系统或应用程序缺陷,供应商先前不知道,并且尚未修补或打过补丁。这些是每天出现的新型攻击,例如,利用尚未发布补丁的漏洞。
How to Fix a DDoS Attack
您可以应用的 DDoS 保护选项有很多,这取决于 DDoS 攻击的类型。
您的 DDoS 保护从识别和关闭系统中所有可能的 OS 和应用程序级别漏洞开始,关闭所有可能的端口,从系统中删除不必要的访问权限,并在代理或 CDN 系统后面隐藏您的服务器。
如果您发现 DDoS 攻击的强度较低,那么您可以找到许多基于防火墙的解决方案,这些解决方案可以帮助您过滤掉基于 DDoS 的流量。但如果您遭受大流量 DDoS 攻击(如千兆位或更多),那么您应该寻求 DDoS 保护服务提供商的帮助,该服务提供商提供更全面、主动和真实的方法。
在选择和选择 DDoS 保护服务提供商时,您必须小心。有许多服务提供商想要利用您的处境。如果您告诉他们您正在受到 DDoS 攻击,那么他们将开始以不合理的高成本向您提供各种服务。
我们可以向您建议一个简单有效的解决方案,它从寻找一个出色的 DNS 解决方案提供商开始,该提供商足够灵活,可以为您的网站配置 A 和 CNAME 记录。其次,您将需要一个出色的 CDN 提供商,它可以处理大量的 DDoS 流量,并作为其 CDN 软件包的一部分为您提供 DDoS 保护服务。
假设您的服务器 IP 地址为 AAA.BBB.CCC.DDD。然后,您应该执行以下 DNS 配置 −
-
在 DNS 区域文件中创建一个 A Record ,如下所示,并使用 DNS 标识符(例如, ARECORDID ),并对其对外保密。
-
现在要求您的 CDN 提供商将创建的 DNS 标识符与一个 URL 链接起来,类似于 cdn.someotherid.domain.com 。
-
你将使用 CDN URL cdn.someotherid.domain.com 创建两条 CNAME 记录,第一条指向 www ,第二条指向 @,如下所示。
你可以向系统管理员寻求帮助,以便理解这些要点并适当地配置 DNS 和 CDN。最后,你将在 DNS 中获得如下配置。
现在,让 CDN 提供商处理所有类型的 DDoS 攻击,你的系统将保持安全。但前提是你不得向任何人透露系统的 IP 地址或 A 记录标识符,否则直接攻击将重新开始。
Ethical Hacking - Cross-Site Scripting
Cross-site scripting (XSS) is a code injection attack that allows an attacker to execute malicious JavaScript in another user’s browser.
The attacker does not directly target his victim. Instead, he exploits a vulnerability in a website that the victim visits, in order to get the website to deliver the malicious JavaScript for him. To the victim’s browser, the malicious JavaScript appears to be a legitimate part of the website, and the website has thus acted as an unintentional accomplice to the attacker. These attacks can be carried out using HTML, JavaScript, VBScript, ActiveX, Flash, but the most used XSS is malicious JavaScript.
These attacks also can gather data from account hijacking, changing of user settings, cookie theft/poisoning, or false advertising and create DoS attacks.
Example
Let’s take an example to understand how it works. We have a vulnerable webpage that we got by the metasploitable machine. Now we will test the field that is highlighted in red arrow for XSS.
First of all, we make a simple alert script
<script>
alert(‘I am Vulnerable’)
</script>
它将生成如下输出:
Types of XSS Attacks
XSS attacks are often divided into three types −
-
Persistent XSS, where the malicious string originates from the website’s database.
-
Reflected XSS, where the malicious string originates from the victim’s request.
-
DOM-based XSS, where the vulnerability is in the client-side code rather than the server-side code.
Generally, cross-site scripting is found by vulnerability scanners so that you don’t have to do all the manual job by putting a JavaScript on it like
<script>
alert('XSS')
</script>
Burp Suite and acunetix are considered as the best vulnerability scanners.
Ethical Hacking - SQL Injection
SQL injection is a set of SQL commands that are placed in a URL string or in data structures in order to retrieve a response that we want from the databases that are connected with the web applications. This type of attacks generally takes place on webpages developed using PHP or ASP.NET.
SQL 注入攻击可用于以下目的 −
-
To dump the whole database of a system,
-
To modify the content of the databases, or
-
To perform different queries that are not allowed by the application.
This type of attack works when the applications don’t validate the inputs properly, before passing them to an SQL statement. Injections are normally placed put in address bars, search fields, or data fields.
The easiest way to detect if a web application is vulnerable to an SQL injection attack is to use the " ‘ " character in a string and see if you get any error.
Example 1
Let’s try to understand this concept using a few examples. As shown in the following screenshot, we have used a " ‘ " character in the Name field.
Now, click the Login button. It should produce the following response −
It means that the “Name” field is vulnerable to SQL injection.
Example 2
We have this URL − http://10.10.10.101/mutillidae/index.php?page=site-footer-xssdiscussion.php
And we want to test the variable “page” but observe how we have injected a " ‘ " character in the string URL.
When we press Enter, it will produce the following result which is with errors.
SQLMAP
SQLMAP is one of the best tools available to detect SQL injections. It can be downloaded from http://sqlmap.org/
It comes pre-compiled in the Kali distribution. You can locate it at − Applications → Database Assessment → Sqlmap.
After opening SQLMAP, we go to the page that we have the SQL injection and then get the header request. From the header, we run the following command in SQL −
./sqlmap.py --headers="User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:25.0)
Gecko/20100101 Firefox/25.0" --cookie="security=low;
PHPSESSID=oikbs8qcic2omf5gnd09kihsm7" -u '
http://localhost/dvwa/vulnerabilities/sqli_blind/?id=1&Submit=Submit#' -
level=5 risk=3 -p id --suffix="-BR" -v3
The SQLMAP will test all the variables and the result will show that the parameter “id” is vulnerable, as shown in the following screenshot.
Quick Tips
To prevent your web application from SQL injection attacks, you should keep the following points in mind −
-
Unchecked user-input to database should not be allowed to pass through the application GUI.
-
Every variable that passes into the application should be sanitized and validated.
-
The user input which is passed into the database should be quoted.
Ethical Hacking - Pen Testing
渗透测试是许多公司用来最大程度减少其安全漏洞的方法。这是一种受控方式,由专业人员试图入侵您的系统并向您展示您应该修复的漏洞。
在执行渗透测试之前,必须达成一项协议,该协议将明确提及以下参数 -
-
渗透测试的时间是什么时候,
-
攻击的 IP 来源将会是什么地方,以及
-
系统的渗透域是什么。
渗透测试是由专业道德黑客执行的,他们主要使用商业的、开源工具、自动化工具和手动检查。没有限制;此处最重要的目标是尽可能发现更多安全漏洞。
Types of Penetration Testing
我们有五种渗透测试 -
-
Black Box - 在这里,道德黑客没有任何有关他要尝试渗透的组织的基础设施或网络的信息。在黑盒渗透测试中,黑客尝试通过自己的方式查找信息。
-
Grey Box - 它是一种渗透测试类型,其中道德黑客对基础设施有部分了解,例如其域名服务器。
-
White Box - 在白盒渗透测试中,道德黑客会获得有关他要渗透的组织的基础设施和网络的所有必要信息。
-
External Penetration Testing - 这种类型的渗透测试主要关注网络基础设施或服务器及其在基础设施下运行的软件。在这种情况下,道德黑客尝试通过互联网使用公共网络进行攻击。黑客尝试通过攻击他们的网页、网络服务器、公共 DNS 服务器等来入侵公司基础设施。
-
Internal Penetration Testing - 在这种类型的渗透测试中,道德黑客位于公司的网络中并由此处执行其测试。
渗透测试还可能导致问题,例如系统故障、系统崩溃或数据丢失。因此,公司在进行渗透测试之前应权衡利弊。风险计算如下,并且是管理风险。
RISK = Threat × Vulnerability
Example
您有一个处于生产中的在线电子商务网站。您想在使其上线之前进行渗透测试。在这里,您必须首先权衡利弊。如果您继续进行渗透测试,可能会导致服务中断。相反,如果您不想执行渗透测试,那么您就有可能面临未修补的漏洞的风险,并且该漏洞将始终构成威胁。
在进行渗透测试之前,建议您书面记录该项目的范围。您应该明确要测试的内容。例如 -
-
您的公司有 VPN 或任何其他远程访问技术,并且您想测试该特定点。
-
Your application has webservers with databases, so you might want to get it tested for SQL injection attacks which is one of the most crucial tests on a webserver. In addition, you can check if your webserver is immune to DoS attacks.
Quick Tips
Before going ahead with a penetration test, you should keep the following points in mind −
-
First understand your requirements and evaluate all the risks.
-
Hire a certified person to conduct penetration test because they are trained to apply all the possible methods and techniques to uncover possible loopholes in a network or web application.
-
Always sign an agreement before doing a penetration test.