Unit 3 Notes
Unit 3 Notes
Introduction to Enumeration – DNS Zone Transfers – NetBIOS Enumeration Tools- Windows and
Linux Operating System Vulnerabilities – Metasploit framework- System Hacking – Malware
Creation – Evading IDS, Firewall and Honeypot - Maintaining Access and Clearing Tracks
1. Introduction to Enumeration
Enumeration is the process of extracting valuable information from a target system or
network. Different enumeration techniques are used depending on the type of system and the
required information. Let’s explore the main types of enumeration with real-world examples.
i. NetBIOS Enumeration
What is NetBIOS Enumeration?
NetBIOS (Network Basic Input/Output System) allows computers to communicate and share files
over a local network. NetBIOS enumeration is used to gather information about shared resources,
machine names, and services on a Windows network.
Scenario:
A company has a file-sharing system on its internal Windows network. An ethical hacker or
administrator wants to check what network shares and devices are available.
nbtstat -A 192.168.1.10
Expected Output:
Result: The attacker or administrator discovers that "SHARED_DOCS" is an available file share,
which could be accessed for further testing or security auditing.
ii. SNMP Enumeration
What is SNMP Enumeration?
Simple Network Management Protocol (SNMP) is used for monitoring and managing network
devices (e.g., routers, switches, printers). If misconfigured, attackers can extract system details,
running processes, or even modify configurations.
Scenario:
A network administrator wants to check device information on a corporate router. However, an
attacker could also exploit weak SNMP settings to retrieve sensitive details.
Expected Output:
Result: The attacker now knows the router model, admin contact, and location, which could be
used in social engineering or further attacks.
Prevention: Change default SNMP community strings and restrict SNMP access.
Scenario:
An attacker targets a company using Microsoft Active Directory to extract a list of employees.
Expected Output:
Result: The attacker now has employee names, emails, and job roles, which can be used for
phishing or brute-force attacks.
Scenario:
An attacker looks for misconfigured NTP servers that respond to the "monlist" command, which
provides a list of recent clients. This data can be used to launch NTP amplification attacks.
Expected Output:
Result: The attacker now knows which devices are syncing with the NTP server and can exploit
them for further attacks.
� What is Netstat?
Netstat is a command-line tool used to view network connections, active ports, and NetBIOS
statistics. It helps in diagnosing network issues, monitoring TCP/IP activity, and resolving
NetBIOS name conflicts.
Let’s assume you suspect an unknown system is accessing shared files on your network. You want
to check NetBIOS connections to see active file-sharing sessions.
Expected Output:
Explanation:
Port 139 (NetBIOS Session Service) → Indicates a shared file access session.
Port 445 (SMB - Server Message Block) → Windows file sharing over the network.
The foreign IPs (192.168.1.10, 192.168.1.12) represent systems accessing shared files.
Output Example:
Active Connections
Proto Local Address Foreign Address State
TCP 192.168.1.5:139 192.168.1.20:1234 ESTABLISHED
nbtstat -A 192.168.1.20
� This will reveal the NetBIOS name and shared resources of the remote device.
ii. Hyena (GUI-Based Windows Management & Enumeration)
What is Hyena?
Hyena is a Windows system management tool that provides a graphical interface for managing
Active Directory, shared resources, users, groups, and network sessions.
Imagine you’re an IT administrator and want to check who is accessing shared files on your
Windows server.
Example Output:
User: JohnDoe
Group: IT Admins
Nested Group: Domain Users
What is PsExec?
PsExec is a command-line tool that allows you to run commands on remote Windows
computers without physically accessing them.
Assume you are an administrator and need to check the IP configuration of a remote system
(192.168.1.20).
Output:
Output Example:
I. Windows OS Vulnerabilities
Windows, being one of the most commonly used operating systems, is frequently targeted by
attackers. Some of the key vulnerabilities include:
i. Buffer Overflows
What is it?
A buffer overflow occurs when a program writes more data to a memory buffer than it can
hold, causing data corruption or code execution. This allows attackers to inject malicious code
and take control of the system.
Microsoft’s Server Message Block (SMB) service had a buffer overflow vulnerability in Windows
XP, Windows Server 2003.
Attackers exploited this bug to remotely execute malware on unpatched systems.
The Conficker worm used this vulnerability to spread across millions of computers.
use exploit/windows/smb/ms08_067_netapi
Effect: If the system is vulnerable, the attacker gains a remote shell, allowing them to execute
commands.
Prevention:
Keep Windows updated with security patches.
Disable SMBv1 (Older versions of SMB are vulnerable).
ii. Remote Code Execution (RCE)
What is it?
RCE vulnerabilities allow attackers to execute commands remotely on a Windows system. This
is often exploited in unpatched software, web applications, or network services.
use exploit/windows/smb/ms17_010_eternalblue
Effect: Attackers gain full control of the system and can install malware.
Prevention:
Always update Windows and apply patches.
Disable unnecessary services like SMB.
Use a firewall to block untrusted connections.
What is it?
Privilege escalation occurs when an attacker gains higher-level permissions (Administrator or
SYSTEM access) by exploiting OS vulnerabilities.
The Windows Print Spooler service had a flaw that allowed attackers to gain SYSTEM privileges.
Attackers could install programs, modify data, and create new accounts with full rights.
This was widely exploited in corporate networks.
powershell
CopyEdit
powershell -ExecutionPolicy Bypass -File exploit.ps1
Prevention:
Disable Print Spooler if not needed:
What is it?
Zero-day vulnerabilities are security flaws discovered by hackers before the vendor releases a
patch. These are highly dangerous because there is no immediate fix.
A privilege escalation flaw in the Win32k driver allowed attackers to execute arbitrary code.
Used by ransomware groups to take control of Windows machines.
Microsoft released a patch, but many unpatched systems remained vulnerable.
Prevention:
Enable automatic updates.
Use an intrusion detection system (IDS).
Implement application whitelisting to prevent unknown executables.
II. Linux OS Vulnerabilities
Linux is widely used in servers, cloud computing, and enterprise environments due to its
stability and security. However, Linux is not invulnerable—hackers can exploit vulnerabilities
to gain unauthorized access, execute malicious code, or disrupt services.
Below are the key Linux OS vulnerabilities, each explained separately with real-time examples.
i. Kernel Vulnerabilities
What is it?
The Linux kernel is the core of the operating system. A kernel vulnerability can allow attackers
to gain root access or execute arbitrary code at the highest privilege level.
Scenario:
A vulnerability in the Linux kernel’s copy-on-write (COW) mechanism allowed any user to gain
root access.
Attackers could modify read-only files and overwrite system binaries.
This was exploited in the wild, affecting servers and cloud systems.
Exploitation Demonstration
uname -r
The attacker gains root privileges and can execute any command.
Prevention:
Privilege escalation occurs when a low-privileged user exploits vulnerabilities to gain root
access.
Scenario:
Exploitation Demonstration
sudoedit -s /
If an error like "malloc(): corrupted top size" appears, the system is vulnerable.
./sudo_exploit
Prevention:
An RCE vulnerability allows attackers to run malicious code remotely on a Linux system. This
can happen due to weak SSH, vulnerable services, or exposed APIs.
Scenario:
Exploitation Demonstration
Prevention:
Many Linux servers host web applications (Apache, Nginx, PHP). Web applications can be
vulnerable to:
Scenario:
Exploitation Demonstration
Prevention:
v. Package Vulnerabilities
What is it?
Linux systems rely on third-party software (Apache, OpenSSH, Python). If these packages
contain security flaws, attackers can exploit them.
Scenario:
A flaw in OpenSSL’s Heartbeat extension leaked sensitive memory data (including passwords &
encryption keys).
Attackers stole SSL certificates from major websites.
Exploitation Demonstration
openssl version -a
Prevention:
Weak security settings make Linux systems vulnerable. Common misconfigurations include:
Scenario:
Exploitation Demonstration
Prevention:
A zero-day exploit is an unknown vulnerability that has no fix. Attackers use these flaws to
target Linux systems before patches are released.
Scenario:
Introduction
Metasploit is a penetration testing framework used for developing and executing exploit
code against remote target machines. It is widely used in cybersecurity for vulnerability
assessment, ethical hacking, and security testing. The framework provides a vast library of
exploits, payloads, auxiliary tools, and post-exploitation modules, making it an essential tool for
both offensive and defensive security professionals.
1. Exploits
2. Payloads
A payload is the code that gets executed on the target system after a successful exploit.
Types of payloads:
o Reverse Shell – The compromised machine connects back to the attacker’s machine.
o Bind Shell – The attacker connects to a shell on the compromised machine.
o Meterpreter – An advanced, interactive payload that provides deep system access.
Example: windows/meterpreter/reverse_tcp
3. Auxiliary Modules
Non-exploit modules used for scanning, enumeration, fuzzing, and brute-force attacks.
Used to gather information about a target before launching an attack.
Example: scanner/ftp/ftp_login for brute-forcing FTP credentials.
4. Encoders
5. Post-Exploitation Modules
Used after a successful exploitation to perform advanced attacks such as privilege escalation,
data extraction, and maintaining persistence.
Example: windows/gather/enum_logged_on_users – Retrieves a list of logged-in users.
Used to prevent Intrusion Detection Systems (IDS) from detecting malicious payloads.
Helps in buffer overflow attacks by adding non-operational instructions.
1. Msfconsole
msfconsole
search smb
use exploit/windows/smb/ms17_010_eternalblue
2. Msfvenom
3. Armitage
1. Exploit Modules – The actual attack code that targets a system vulnerability. Exploits are used to
gain access to a system by targeting security vulnerabilities. Once the exploit is executed
successfully, attackers try to escalate privileges to gain superuser (root) access.
Types of Exploits
Remote
Works over a network and exploits vulnerabilities without prior access to the system.
Exploit
Requires prior access to the system and is used to escalate privileges (e.g., from user
Local Exploit
to root).
1. Open Metasploit:
msfconsole
use exploit/windows/smb/ms08_067_netapi
exploit
Types of Payloads
Payload
Description
Type
Self-contained payloads that perform a single task (e.g., adding a user, running
Singles
an executable).
Stagers Small programs that download and execute the main payload in memory.
The final payload that executes malicious activities after being delivered by a
Stages
stager.
This creates an executable payload that, when run on the target system, opens a Meterpreter
session for remote control.
3 Auxiliary Modules
Auxiliary modules do not exploit vulnerabilities but are used for scanning, enumeration, and
other security-related tasks.
This scans the network for SMB services and lists their versions.
4 Encoders in Metasploit
Encoders modify payloads to help them bypass antivirus and intrusion detection systems
(IDS).
Features of Encoders
The "shikata_ga_nai" encoder modifies the payload to make it harder for antivirus software to
detect.
5️ Post-Exploitation Modules
Post-exploitation modules help maintain access, gather system information, and perform
additional attacks after a system is compromised.
Dumping passwords
Capturing keystrokes
Extracting user credentials
Escalating privileges
Features of NOPs
Operating System (OS) hardening is the process of securing a system by reducing its
vulnerabilities. It involves modifying default configurations, removing unnecessary programs or
services, applying updates, and implementing security features to ensure that the system is less
prone to attacks. This process plays a vital role in protecting both Windows and Linux systems
from various threats including malware, unauthorized access, and system exploitation.
In Windows OS, hardening begins with keeping the system up to date. Applying regular
Windows updates and installing security patches helps fix known vulnerabilities. Enabling
Windows Defender provides real-time protection against viruses, spyware, and other malware.
Along with this, Windows Firewall should be configured to restrict unauthorized access by
defining inbound and outbound rules based on specific needs.
Another critical aspect of Windows hardening is managing user privileges. Enforcing User
Account Control (UAC) ensures that administrative privileges are granted only when necessary.
The use of strong and complex passwords, account lockout policies after multiple failed login
attempts, and disabling default administrative accounts add extra layers of security. Group Policy
Editor (gpedit.msc) can be used to enforce system-wide security policies, such as password
expiration, USB access control, and software restriction.
System services and features that are not in use should be disabled using services.msc to
minimize attack surfaces. Audit policies and security logs should be enabled through the Event
Viewer to monitor suspicious activities. Moreover, enabling BitLocker ensures that sensitive data
on the hard drive is encrypted, preventing unauthorized access if the device is stolen or
compromised.
In Linux OS, hardening starts with regular updates and upgrades. The use of package
managers like apt or yum ensures the installation of the latest security patches. Unnecessary
services should be disabled using system management tools like systemctl. For example, disabling
services such as Bluetooth, Telnet, or FTP, if they are not required, helps reduce potential entry
points for attackers.
Secure SSH configuration is another important step in Linux hardening. This includes
changing the default SSH port, disabling root login via SSH, and restricting access to specific
users. Configuration files like /etc/ssh/sshd_config can be edited to apply these settings. Setting
correct file permissions using commands like chmod, chown, and defining appropriate umask
values ensures that users cannot access or modify files they don’t own.
Linux systems should also employ firewall rules using tools such as UFW (Uncomplicated
Firewall) or iptables. These firewalls help control incoming and outgoing network traffic.
Additionally, security tools like Fail2Ban help monitor login attempts and block IPs that show
malicious behavior, while ClamAV can be used for antivirus scanning.
User management is also critical in Linux. Unused users and groups should be deleted, and
the principle of least privilege must be followed. Logs located in /var/log/ directories should be
monitored regularly to detect anomalies. Tools such as auditd, chkrootkit, and logwatch can help
in monitoring and intrusion detection.
In conclusion, both Windows and Linux OS hardening aim to protect systems from
unauthorized access, data breaches, and malware attacks. The key practices include applying
updates, managing users and permissions, configuring firewalls, disabling unused services, and
monitoring system activities. Regularly reviewing security settings and adapting to new threats is
essential in maintaining a secure and robust operating environment.