Ethical Hacking VMS
Ethical Hacking VMS
When combining ethics with hacking, you arrive at the practice of ethical
hacking, where the use of hacking skills aligns with moral principles and
professional standards to ensure security and protect systems.
Ethical hacking, also known as penetration testing or white-hat hacking,
is the authorized and legal practice of testing an organization's security
measures to identify vulnerabilities and weaknesses
Ethical hackers are skilled professionals who use the same techniques and
tools as malicious hackers, but their intent is to improve security rather than
exploit it.
Terminology
2. Virus
3. UI Redress (Clickjacking)
4. Cookie Theft
6. DNS Spoofing
7. Social Engineering
9. Malware-Injection Devices
Definition: Physical devices (e.g., USB drives) used to inject malware into a
system.
How it works:
o Attackers plant infected devices in accessible areas (e.g., parking
lots).
o Victims plug in the device, unknowingly executing malware.
Example: A USB stick containing ransomware.
Prevention:
o Avoid using unknown devices.
o Disable auto run features.
Hacktivism :
Hacktivism is when people use hacking to promote causes they care about, such as
social or political issues. It combines hacking skills with activism, usually targeting
governments, companies, or other organizations they believe are doing something
wrong or unjust.
Break into websites and replace them with messages supporting their cause.
Overload websites to shut them down temporarily (called a DDoS attack).
Leak sensitive information to expose wrongdoing.
It's a way to use technology to raise awareness and make a point about issues like
freedom, human rights, or government actions.
Motivation:
Methods:
Anonymous:
RedHack:
Process contains:
1. Understanding Competitors
2. Market Analysis
3. Strategic Positioning
Assessing competitive positioning using tools like SWOT
(Strengths, Weaknesses, Opportunities, Threats) analysis.
Developing strategies to outperform competitors or enter untapped
markets.
6. Applications of CI
DNS Enumeration
1. DNS Basics
1. WHOIS Lookup
2. Zone Transfers
Query specific DNS records using tools like dig, nslookup, or host.
Example: Query for MX records
dig example.com MX
4. Reverse DNS Lookup
5. Subdomain Enumeration
6. Brute Forcing
Use platforms like VirusTotal, Shodan(IoT and internet search engine), and
Censys to gather DNS information passively.
1. dig
2. nslookup
3. Fierce
4. DNSRecon
5. Amass
6. Sublist3r
ARIN Lookup
Definition:
ARIN (American Registry for Internet Numbers) is a Regional Internet Registry
(RIR) responsible for managing IP address allocations and Autonomous System
Numbers (ASNs) in North America. An ARIN Lookup queries ARIN's database
to retrieve details about an IP address or ASN.
Purpose:
Information Provided:
1. IP Address Details:
2. ASN Details:
3. Network Information:
Key Differences :
Traceroute in Footprinting
a diagnostic tool that tracks and records the path taken by packets across an IP
network. It shows the sequence of routers (hops) the packet traverses to reach its
destination. This provides insight into the network's structure and the connectivity
between systems.
Traceroute provides insight into the network topology, including the devices and
routers that form the route between the attacker’s machine and the target. This tool
helps identify potential vulnerabilities, map out the target’s network, and gather
crucial information that can assist in subsequent stages of the penetration testing or
hacking process.
1.investigate
2.Hook
3.Play
4.Exit
2. Spear Phishing
3. Whailing
6. Baiting
7. Pop-Up Attacks
8.Website phishing
Clone original website
1. Pretexting
2. Tailgating (Piggybacking)
3. Dumpster Diving
5. Shoulder Surfing
6. Impersonation
1.Port scan
A widely used tool to scan and identify open ports and services.
1. TCP Scan: A full connection is made with each open port on the target system,
verifying if the port is open.
SYN Packet Sent: The scanner sends a SYN (synchronize) packet to the
target port. This is the first step of a TCP handshake.
SYN-ACK Response: If the target port is open, the target responds with a
SYN-ACK packet, indicating that it is willing to establish a connection.
ACK Sent: The scanner then sends an ACK packet to complete the
handshake and establish a connection.
Connection Established: Once the connection is established, the scanner
can then report that the port is open. It may also immediately close the
connection, depending on the tool or process used.
Port Closed: If the port is closed, the target will respond with a RST (reset)
packet, indicating the port is not open or accepting connections.
2.SYN Scan: This is a more stealthy scan that sends a SYN (synchronize) packet,
like the start of a TCP handshake, to determine if the port is open or closed. SYN
Scan is a more stealthy and faster way to scan for open ports compared to a TCP
Connect Scan. It works by only initiating the first part of the TCP handshake and
never completing the connection, which helps to avoid being find out.
SYN Packet Sent: The scanner sends a SYN (synchronize) packet to the
target port. This is the first part of the TCP three-way handshake. The SYN
packet is used to request a connection.
SYN-ACK Response (Port Open): If the target port is open and accepting
connections, the target responds with a SYN-ACK packet. This indicates
that the target is willing to establish a connection.
RST Response (Port Closed): If the port is closed, the target will respond
with a RST (reset) packet to indicate that it refuses the connection attempt.
Scanner Does Not Complete the Handshake: The scanner does not
respond to the SYN-ACK packet with an ACK (which would complete the
handshake), and instead just moves on to the next port. This behavior means
the target never fully establishes a connection.
3.UDP Scan: Scans for open UDP ports, which don't rely on the connection
process like TCP does. These can identify DNS and other UDP-based services.
Send UDP Packet: The scanner sends a UDP packet (often a "dummy"
packet or an application-specific request) to the target port on the remote
system.
No Response (Port Open): If the target port is open, it will typically not
respond at all. This is because, with UDP, there is no inherent
acknowledgment or handshake process. An open port may just silently
accept the incoming packet.
ICMP Port Unreachable (Port Closed): If the target port is closed, the
target system will typically respond with an ICMP (Internet Control
Message Protocol) "Port Unreachable" message. This indicates that the
UDP packet could not be delivered because the port is closed.
Additional Responses (Optional): Depending on the application or service
running on the open port, some responses may be received, especially for
certain services that expect specific UDP packets. For example, a DNS
server may reply with a DNS response if a UDP request for DNS resolution
is sent to it.
4.FIN Scan: Sends a TCP FIN packet to see if it receives a response, indicating the
port is open. This is used to bypass firewalls that are not configured to properly
handle such packets.
The scanner sends a FIN packet to the target port. A FIN packet in TCP is
used to indicate that the sender wants to close the connection. Typically, this
would be used by the two parties in a connection to gracefully shut down
communication.
If the port is closed, the target system will respond with a RST (Reset)
packet. This is because, according to the TCP protocol, when a closed port
receives a FIN packet, the system must reset the connection, as it cannot
respond to the termination request.
If the port is open, the system will generally not respond at all (because
there is no active connection to terminate), or it may ignore the FIN packet.
According to TCP standards, sending a FIN to an open port is not a valid
action in an existing connection, so the system typically does not send a
reset (RST) packet.
Stealth: The FIN scan is considered stealthier than a standard TCP Connect
Scan because it doesn't complete the handshake (SYN-ACK-ACK) and
instead sends a FIN packet, which should not be expected unless there's an
active connection. As a result, many firewalls and intrusion detection
systems may not detect a FIN scan as easily as a full connection scan.
No Connection Establishment: Since the FIN scan does not establish a
connection (it doesn't go through the full TCP handshake), it is more "quiet"
compared to other types of scans.
Can Be Detected by Some Firewalls or IDS: While FIN scans are
stealthier than standard scans, they are not foolproof. Some modern
firewalls or intrusion detection/prevention systems (IDS/IPS) can recognize
unusual FIN packets or patterns that indicate scanning behavior.
Additionally, some systems may be configured to send a reset (RST) even
for FIN packets, which could give away the scan.
Different systems react to these packets in different ways, so these scans can reveal
details of the target system and whether it is protected by a firewall.
5.Xmas Scan: Sends packets with unusual flags to check for open ports. The
scanner sends a TCP packet with FIN, PSH, and URG flags set to a target port.
The Xmas Scan is another type of port scan that uses TCP flags in an
unconventional way to probe whether ports are open or closed. It is often
considered a stealthy scan, similar to the FIN scan, but with a different approach.
Let's dive into how it works.
What is a Xmas Scan?
In TCP, different flags are used to control the state of a connection. A Xmas Scan
sends a packet with a combination of flags that is rarely used in normal
communication, specifically with the FIN, URG, and PSH flags set. These flags
are not typically sent together in regular TCP traffic, which is why this scan can
sometimes be stealthier and harder to detect by security systems.
Send an Xmas packet: The scanner sends a packet to the target port with
the FIN, URG, and PSH flags set in the TCP header. This is an unusual
combination of flags that doesn't normally occur in regular network
communication.
What happens when the port is open:
1. If the port is open, the target system typically does not respond to the
Xmas packet. It does not send a reset (RST) packet or any other
response because the Xmas packet doesn't correspond to any valid
request for connection initiation or termination.
What happens when the port is closed:
1. If the port is closed, the target system will respond with an RST
(Reset) packet. This is because the packet, with those unusual flags, is
effectively interpreted as an erroneous or invalid packet, and the target
system will reset the connection, indicating that the port is closed.
Let’s break down how Stealth Scans work, their different types, and why they are
often used.
The idea is that many systems only log or respond to fully established
connections (i.e., when the handshake is complete). By only sending the initial
packets of the handshake or sending unusual packets that don't fit normal behavior,
a Stealth Scan attempts to avoid triggering the system's defenses.
6. Null Scan
How it works: A Null Scan sends a TCP packet with no flags set (all flags
are turned off). Since the packet does not contain any flag, the target system
is unsure about what the packet is for.
Instead of ICMP, it sends TCP ACK packets to specific ports (e.g., 80,
443).
If a RST (Reset) is received, the host is alive.
Eg. nmap -sn -PA 192.168.1.0/24
Firewalls often block ICMP but allow TCP packets.
Bypasses ICMP restrictions.
More stealthy than SYN scans because it doesn’t try to establish a
connection.
Sends TCP SYN packets (instead of ICMP) to common ports like 80, 443.
If the host responds with SYN-ACK, it is alive.
Eg. nmap -sn -PS80,443 192.168.1.0/24
Useful when ICMP and ACK scans are blocked.
Often bypasses firewalls
IDLE scan
The Idle Scan (also called a Zombie Scan) is an advanced TCP port scanning
technique that allows an attacker to perform stealthy network reconnaissance
without revealing their own IP address.
This method exploits the behaviour of an idle machine (called a "zombie") to infer
information about a target system.
Eg. The attacker first sends a probe packet (SYN/ACK or SYN) to the
zombie and records the IP ID value.Let’s assume the zombie's current IP
ID is 1000.
The attacker forges a SYN packet (pretending to be from the zombie) and
sends it to the target system.
The target responds based on the port status:
SNMP Enumeration
System Hacking :
1. Password-Cracking Techniques
1. Non-Electronic Attacks:
These attacks don’t involve any digital tools or software. Instead, they rely
on human interaction or observation.
Brute Force Attack: Trying all possible combinations until the correct one
is found. It’s time-consuming but effective.
Dictionary Attack: Using a predefined list of common words or passwords.
Credential Stuffing: Using stolen username and password pairs from one
breach to access other accounts.
Phishing: Trick users into providing passwords via fake emails or websites.
Many devices (e.g., routers, IoT devices) come with default credentials that
users often don’t change.
Attackers look up these default credentials online and use them to gain
unauthorized access.
5. Offline Attacks:
These involve obtaining the encrypted password file and cracking the
passwords without interacting with the live system.
2. Types of Passwords
Static Passwords:
Dynamic Passwords:
Passphrases:
Graphical Passwords:
Biometric Passwords:
Keyloggers:
Types of Keyloggers:
1. Hardware Keyloggers:
2. Software Keyloggers:
How it works ?
The attacker gains higher privileges than their current level (e.g., from a
normal user to an administrator).
Example: Exploiting a vulnerability in system software to gain root or
admin access.
The attacker accesses another user’s account with the same privilege level.
Example: Logging into another user’s email account without increasing
access rights.
2. Misconfigured Permissions:
3. Credential Dumping:
5. Rootkits :
Rootkit- means a set of tools that allow someone to gain and maintain root-level
access to a system without detection.
Types of Rootkits:
1. Volume-based Attacks:
2. Protocol Attacks:
BOTs/BOTNETs:
“Smurf” Attack:
“SYN” Flooding:
SYN Flooding is a protocol attack that exploits the TCP handshake process.
During a normal TCP handshake:
1. Client sends a SYN packet.
2. Server responds with a SYN-ACK packet.
3. Client completes the handshake with an ACK packet.
In SYN Flooding:
The attacker sends multiple SYN packets but never responds to SYN-
ACKs.
The server holds open connections, waiting for ACKs, exhausting
connection resources.
This prevents legitimate users from establishing connections.
DoS/DDoS Countermeasures:
1. Network-Level Defenses:
2. Application-Level Defenses:
3. Architectural Measures:
Sniffers
Sniffers are tools or software used to capture and analyze network traffic. They can
be used for legitimate purposes like network monitoring or troubleshooting, but
they can also be misused by attackers to capture sensitive data like usernames,
passwords, and other confidential information.
Passive Sniffing:
Active Sniffing:
ARP Poisoning
Description:
Impact:
MAC Flooding
Description:
Impact:
Description:
An attacker corrupts the DNS cache to redirect users to malicious
websites.
Methods include:
Sniffing Countermeasures
1. Encryption:
Use secure protocols like HTTPS, SFTP, SSH, and TLS for data
transmission.
Implement VPNs for secure communication over public networks.
2. Network Segmentation:
3. Switch Security:
Use port security and static ARP entries to prevent MAC flooding and
ARP poisoning.
Enable DHCP snooping and dynamic ARP inspection (DAI).
6. User Education:
Session Hijacking
Session hijacking is an attack where an attacker takes over a valid session between
a user and a web server. This is done to gain unauthorized access to information or
services by stealing or manipulating session tokens.
4. Session Fixation:
The attacker sets a known session ID and tricks the user into
authenticating with it.
After authentication, the attacker uses the known session ID to access
the account.
5. Session Sidejacking:
Sequence Prediction
Description:
Impact:
1. Session Sniffing:
2. Session Prediction:
3. Session Fixation:
The attacker sets a session ID and forces the victim to use it.
After authentication, the attacker uses the same session ID for
unauthorized access.
4. Session Stealing:
Prevention techniqes :
1. Encryption:
4. Token Security:
Web servers are crucial components of web applications but are often targeted due
to various vulnerabilities. Common weaknesses include:
Patches in a Web Server are software updates released by vendors to fix security
vulnerabilities, bugs, and performance issues.
Basically patch management is the process that helps to acquire,test and install
multiple patches(code change)on existing application and software tools
SQL Injection:
This technique exploits the UNION SQL operator to combine results from
multiple SELECT queries.
Attackers use UNION SELECT to retrieve additional data from other
tables.
4. Escalating Privileges
If attackers gain admin access, they can modify database contents or create
new accounts.
Authentication Types :
3. Token-Based Authentication
4 .Biometric Authentication
Attackers use various methods to crack passwords and gain unauthorized access:
The attacker tries every possible combination of characters until the correct
password is found.
Slow but effective if passwords are weak
2 .Dictionary Attack
3. Credential Stuffing
5. Phishing Attack
Attackers trick users into revealing passwords via fake login pages or
emails.
Example: A fake PayPal login page asking users to enter their credentials.
6. Keylogging
8. Password Spraying
1.Hashcat
3 .Hydra
4. Burp Suite
Web security testing tool that can be used for brute force attacks on web-
based login forms.
5.SQLmap
Used for SQL Injection attacks to extract login credentials from vulnerable
databases.
Countermeasures :
1. Enforce Strong Password Policies
Lock user accounts after multiple failed login attempts (e.g., 5-10 attempts).
Web applications are prime targets for attackers due to their exposure to the
internet. Hackers exploit vulnerabilities to steal data, gain unauthorized access, or
disrupt services
1. Injection Attacks
Web applications are prone to injection attacks like SQL injection. By
exploiting these vulnerabilities, malicious actors can gain unauthorized
access to your databases. However, vigilant coding practices and input
validation can fortify your defense.
4. Security Misconfigurations
A security misconfiguration happens when a web application or server has
weak settings, default credentials, or unnecessary features enabled, making it
vulnerable to attacks. Unpatched software exposes known vulnerabilities.
6. Broken Authentication
Google Hacking is a technique used to find sensitive data and vulnerabilities using
Google search queries (also called Google Dorks).
It is a technique used to find sensitive information using advanced search queries
on Google. Hackers and security researchers use it to discover:
Exposed login pages
Sensitive files (passwords, databases, etc.)
Vulnerable web applications
Open directories & webcams
Google Dorking is a powerful tool—used by ethical hackers to find
vulnerabilities and attackers to exploit weak websites.
If your site is misconfigured, hackers can find & exploit it easily.
Secure your web apps by blocking indexing, restricting access, and fixing
misconfigurations prevents from Google dorking.
Buffer Overflows:
Buffer overflows are exploits that hackers use against an operating system or
application; like SQL injection attacks, they’re usually targeted at user input
fields.
A buffer overflow exploit causes a system to fail by overloading memory or
executing a command shell or arbitrary code on the target system.
buffer-overflow vulnerability is caused by a lack of bounds checking or a
lack of input-validation sanitization in a variable field (such as on a web
form).
If the application doesn’t check or validate the size or format of a variable
before sending it to be stored in memory, an overflow vulnerability exits.
The two types of buffer overflows are stack-based and heap-based. The
stack and the heap are storage locations for user-supplied variables are
stored in the stack or heap until the program needs them.
To detect program buffer overflow vulnerabilities that result from poorly
written source code, a hacker sends large amounts of data to the application
via a form field and sees what the program does as a result.
If the program does not handle the excess data, it overwrites memory,
causing the application to crash.
The hacker can overwrite the return address of a function to point to
malicious code (shellcode).
A stack-based buffer overflow happens when a program writes more data than
allowed into a buffer (a temporary storage area in memory). This overwrites other
data in memory, including the function return address, which can allow an
attacker to execute malicious code.
If the program doesn't check input size, entering more than 10 bytes causes
an overflow, overwriting nearby memory.
The extra data spills into the return address, which normally tells the
program where to go next.
Hackers replace it with the address of their own malicious code.
When the function returns, it jumps to the hacker’s code instead of the
correct program instructions.
Mutation techniques :
Functions like strcpy(), strcat(), and streadd() do not check buffer sizes,
making them prone to buffer overflows.
Safer alternatives: Use strncpy(), strncat(), fgets(), or bounded memory
functions.
Java manages memory automatically and does not allow direct buffer
manipulations like C/C++.
Java programs cannot suffer from buffer overflow attacks, making it a safer
alternative for secure applications.
Wireless Hacking:
WEP (Wired Equivalent Privacy)
WEP was the first security protocol for wireless networks, introduced in 1997 as part of
the IEEE 802.11 standard. It was designed to provide confidentiality similar to a wired
network but was later found to be highly vulnerable.
It basically provides 64 bits of data at a time to encrypt and/or decrypt your data. The
algorithm used to encrypt and decrypt data is RC4, which is a stream cipher that uses an
initialization vector (IV). Employs a 24-bit Initialization Vector (IV) added to the
encryption key.
The IV is transmitted in plaintext, making it susceptible to attacks.
WEP has two modes of operation – text mode and hexadecimal mode. In-text mode,
the encryption key is a plain text string, while in hexadecimal mode, it is represented as
six 8-bit integers
Attackers can break WEP encryption using the following methods:
1. Passive Attack: Capturing enough IVs and analyzing patterns.
2. Active Attack: Injecting packets to accelerate IV collection.
3. ARP Injection: Trick the network into generating more packets.
WEP was deprecated in 2004 due to its weak encryption and ease of cracking.
Modern Wi-Fi networks should use WPA2 or WPA3 for better security.
1. Passive Attacks
A passive attack involves listening to wireless traffic without interfering with the network. The
attacker captures packets and analyzes them to extract encryption keys.
How it Works:
Limitation:
2.Active Attacks
An active attack interferes with the network by injecting packets, causing increased traffic to
speed up the attack.
1.Packet Injection
How it Works:
ARP injection forces a Wi-Fi access point to generate traffic by tricking it into responding to
ARP requests.
How it Works:
Advantage:
Limitation:
Although WPA3 is more secure, attackers use downgrade and side-channel attacks:
Downgrade Attacks
Forces the network to fall back to WPA2, making it vulnerable to known attacks.
Side-Channel Attacks
WPA3 uses Simultaneous Authentication of Equals (SAE), also known as the Dragonfly
Handshake.
Attackers analyze timing leaks or power consumption patterns to extract cryptographic
keys.
Wireless Sniffers :
A wireless sniffer is a tool used to monitor, capture, and analyze network traffic over a Wi-Fi connection.
These tools can be used for network troubleshooting, security auditing, and penetration testing. However,
they can also be misused for eavesdropping and hacking.
Example: Wireshark
2 Active Sniffers
Eg. Ettercap
A Rogue Access Point (AP) is an unauthorized wireless access point installed within a network.
It can be either malicious (set up by attackers) or accidental (set up by employees without IT
approval). These rogue APs pose serious security threats to organizations and individuals.
1. Malicious Rogue AP
2. Unauthorized Employee AP
3. Compromised AP
An attacker creates a fake Wi-Fi network with the same SSID as a trusted network.
Users unknowingly connect, allowing attackers to intercept sensitive information.
4. WEP/WPA Cracking
Cracking weak encryption protocols (e.g., WEP) using tools like Aircrack-ng.
WPA/WPA2 attacks use dictionary or brute-force methods to crack passwords.
5. Deauthentication Attack
Forces devices to disconnect from the Wi-Fi network, making them reconnect to an
attacker-controlled network.
Tools like MDK3 and Aireplay-ng are commonly used.
6. Bluetooth Hacking
Adjust router settings to limit the signal range, preventing outsiders from accessing
the network.
Use network monitoring tools to detect and respond to unauthorized access attempts.
It is also known as ethical hacking because it follows legal and authorized procedures to test
security defenses.
The tester has no prior knowledge of the system's internal structure, architecture, or
source code.
Simulates an external attack by a real hacker who does not have insider access.
Finding security loopholes through reconnaissance
Testing firewalls, intrusion detection systems (IDS), and external-facing applications
Identifying vulnerabilities in publicly available resources
Time-consuming due to lack of information
The tester has full knowledge of the system, including network diagrams, source code,
architecture, and internal security controls.
Simulates an insider attack where the attacker has complete access, such as a developer
or an employee with malicious intent.
Conducted Code review for security flaws (e.g., SQL injection, buffer overflow)
Conducted Testing authentication mechanisms
Checking for misconfigurations and insecure APIs
Saves time compared to black-box testing
Requires skilled testers with programming knowledge
3. Gray Box Testing
The tester has partial knowledge of the system, such as login credentials or limited
network details.
Simulates an attack from a semi-privileged insider, such as a contractor or a user with
limited access.
Testing privilege escalation possibilities
Evaluating how much damage a compromised user account can cause
Identifying security flaws in authentication and session management
Might miss vulnerabilities that only a deep source-code analysis (white box) can uncover
It provides a structured methodology for conducting security assessments, penetration testing, and
vulnerability analysis in IT systems.
Defines planning, discovery, attack, and reporting phases
Often used in government and regulated industries
4) Exploitation
5) Post-Exploitation
Pen-Test Deliverables
After completing penetration testing, a comprehensive report is provided. The key deliverables
include: