VAPT Unit 4
VAPT Unit 4
TY BVoc CSF
Unit 4
1) Explain the Network and System penetration testing with Network ports and
Services.
Network and System Penetration Testing is a security testing process used to identify,
exploit, and validate vulnerabilities in network infrastructure and operating systems. It
focuses on network ports, running services, configurations, and system-level weaknesses
to assess how an attacker can gain unauthorized access.
23 Telnet No encryption
Step 4: Exploitation
Exploit vulnerabilities using tools like Metasploit.
Example:
Exploiting SMB service to gain system shell.
Conclusion
Network and System Penetration Testing is essential to secure organizational infrastructure.
By analyzing network ports and services, testers can identify vulnerable entry points and
prevent real-world cyber attacks through timely remediation.
Comparison: Network vs System pentesting
1. Port Knocking
Definition
Port Knocking is a security technique in which network ports remain closed until a client
sends a predefined sequence of connection attempts (knocks) to specific ports. After the
correct sequence, the required port is opened temporarily.
Working
All ports are closed by firewall
Client sends a specific knock sequence
Firewall recognizes the sequence
Service port is opened for that client
Example
Knock sequence:
7000 → 8000 → 9000
After this sequence, SSH (port 22) opens for a short time.
Used to hide services from port scanners.
2. Service Fingerprinting
Definition
Service Fingerprinting is the process of identifying the service type and version running on an
open port. This helps in determining whether the service has known vulnerabilities.
Working
Scan open ports
Analyze banners and responses
Match with known service signatures
Example
Using Nmap:
nmap -sV [Link]
Output:
80/tcp open http Apache httpd 2.4.49
Shows web server type and version.
3. OS Fingerprinting
Definition
OS Fingerprinting is the technique of identifying the operating system running on a target
machine by analyzing network behavior.
Types
Passive OS Fingerprinting – Observes traffic silently
Active OS Fingerprinting – Sends crafted packets
Example
Using Nmap:
nmap -O [Link]
Output:
OS: Linux 5.x (Ubuntu)
Helps attackers and defenders understand OS-level vulnerabilities.
5. Security Importance
Port knocking hides critical services
Service fingerprinting helps detect vulnerable services
OS fingerprinting helps apply correct patches
Conclusion
Port knocking improves security by hiding open ports, while service and OS fingerprinting
help identify running services and operating systems. These techniques are crucial in both
penetration testing and network defense, allowing organizations to understand and secure
their network infrastructure effectively.
3) Elaborate on working with various types of network service scans with Examples.
Network service scanning is a crucial phase of network security assessment and
penetration testing. It involves identifying open ports, running services, service
versions, and configurations on a target system. These scans help security
professionals understand the attack surface and detect vulnerable services.
3. UDP Scan
Working
Scans UDP ports.
Slower due to lack of response from closed ports.
Example
nmap -sU [Link]
Use: Identify services like DNS (53), SNMP (161), TFTP (69).
5. OS Detection Scan
Working
Sends crafted packets.
Analyzes responses to identify OS.
Example
nmap -O [Link]
6. Aggressive Scan
Working
Combines OS detection, version scan, scripts, and traceroute.
Example
nmap -A [Link]
Use: Quick but noisy scan.
Conclusion
Different types of network service scans provide varying levels of detail and stealth.
Using a combination of TCP, UDP, service version, and OS scans helps security
professionals fully understand network exposure and secure critical services
effectively.
1. Firewall Implementation
Explanation:
Firewalls monitor and control incoming and outgoing network traffic based on
predefined security rules.
Example:
Blocking unused ports like 23 (Telnet) and allowing only 22 (SSH) for remote access.
Conclusion
Effective countermeasures for network attacks combine preventive, detective, and
corrective controls. Implementing firewalls, encryption, IDS/IPS, authentication, and
regular updates significantly strengthens network security and reduces cyber risk.
1. Identifying Vulnerabilities
Explanation:
Vulnerability identification is the process of discovering weaknesses in systems, applications,
or services that may be exploited.
Techniques Used:
OS and service version detection
Configuration review
Known CVE mapping
Misconfiguration analysis
Example:
A web server running Apache 2.4.49 is identified, which is known to have a path traversal
vulnerability (CVE-2021-41773).
2. Scanning Services
Explanation:
Service scanning identifies open ports, running services, and service versions on a target
system.
Purpose:
Identify attack surface
Detect vulnerable services
Map network exposure
Example:
A scan reveals:
Port 21 → FTP
Port 80 → HTTP
Port 3306 → MySQL
An outdated FTP service may allow anonymous login.
3. Exploiting Services
Explanation:
Exploitation involves using a vulnerability to gain unauthorized access or perform unintended
actions.
Conditions for Exploitation:
Vulnerable service version
Weak credentials
Missing patches
Example:
Exploiting an FTP service that allows anonymous access to upload malicious files or read
sensitive data.
4. Verification of Vulnerabilities
Explanation:
Verification ensures the vulnerability is real, exploitable, and impactful, avoiding false
positives.
Verification Methods:
Proof of Concept (PoC)
Controlled exploitation
Manual testing
Example:
After detecting SQL Injection, entering ' OR '1'='1 confirms unauthorized database access.
6. Querying Exploits
Explanation:
Exploit querying involves searching exploit repositories using software names, versions, or
CVE IDs.
Example:
Searching:
“Apache 2.4.49 exploit”
“CVE-2021-41773”
Results show a directory traversal exploit enabling file access.
7. Mapping Vulnerability to Risk
Explanation:
After exploitation and verification, the vulnerability is rated based on impact and likelihood.
Example:
Vulnerability: RCE in web service
Impact: Full system compromise
Risk Level: Critical
Conclusion
Identifying vulnerabilities, scanning services, exploiting weaknesses, and verifying results
using open exploit sources form the core of penetration testing. This structured approach
helps organizations understand real-world risks and implement effective security controls
before attackers exploit them.
6) Explain the Metasploit with for exploitation, password cracking techniques and
counter measures with Examples.
Definition
Metasploit Framework is an open-source penetration testing platform used by
ethical hackers to identify, exploit, and validate vulnerabilities in systems and
networks. It provides ready-made exploits, payloads, auxiliary modules, and post-
exploitation tools.
b) Credential Harvesting
Extracts stored or cached passwords after access
Targets browsers, memory, or system files
Example:
Dumping password hashes after gaining system access.
3. Post-Exploitation in Metasploit
After successful exploitation, Metasploit enables:
Privilege escalation
Credential dumping
Lateral movement
Example:
Upgrading a user-level shell to administrator access.
Conclusion
Metasploit is a powerful ethical hacking framework used for exploitation, password
attacks, and post-exploitation analysis. While it helps security professionals assess
system weaknesses, strong countermeasures such as patching, password security,
and monitoring are essential to defend against real-world attacks.
7) Explain Man-in-middle attack, ARP poisoning, Session Hijacking DNS spoofing and
its countermeasures with Example.
Network attacks often aim to intercept, manipulate, or redirect communication
between users and servers. Attacks like MITM, ARP poisoning, session hijacking, and
DNS spoofing compromise confidentiality, integrity, and authenticity of data.
3. Session Hijacking
Definition
Session hijacking involves stealing a valid session ID to impersonate a legitimate user
after authentication.
Types
Cookie hijacking
TCP session hijacking
Example
Attacker captures a session cookie from an unsecured HTTP website and gains access
to the victim’s account without logging in.
Countermeasures
Use HTTPS
Regenerate session IDs after login
Set HttpOnly & Secure cookie flags
Implement session timeout
Conclusion
MITM, ARP poisoning, session hijacking, and DNS spoofing are serious network
attacks that exploit trust and weak configurations. Implementing encryption,
authentication, secure DNS, and network monitoring significantly reduces the risk
of such attacks.
8) Explain the payloads with their types and Example.
Definition
A payload is the malicious or controlled code executed on a target system after
successful exploitation of a vulnerability. In ethical hacking, payloads are used to
validate security weaknesses, gain access, maintain control, or extract information.
Exploit = Delivery mechanism
Payload = Actual action performed
Purpose of Payloads
Gain remote access (shell)
Extract sensitive information
Maintain persistence
Escalate privileges
Test system defenses
Types of Payloads
1. Single Payloads
Explanation:
These payloads execute a single specific task and then terminate.
Characteristics:
Lightweight
No persistent connection
Example:
Opening a calculator application
Creating a user account
2. Staged Payloads
Explanation:
Staged payloads are delivered in multiple parts. A small initial payload loads a larger
payload later.
Advantages:
Evades detection
Reduces initial payload size
Example:
A small loader connects back to the attacker and downloads a full control module.
3. Non-Staged Payloads
Explanation:
Entire payload is delivered in one step.
Advantages:
Faster execution
No dependency on network
Example:
A complete reverse shell sent in a single execution.
4. Reverse Payloads
Explanation:
The target system initiates a connection back to the attacker.
Why used:
Bypasses firewalls
Works behind NAT
Example:
Victim machine connects back to attacker’s system for remote control.
5. Bind Payloads
Explanation:
The payload opens a listening port on the victim system, waiting for attacker
connection.
Limitations:
Blocked by firewalls
Requires open inbound ports
Example:
Opening a listening shell on port 4444.
6. Meterpreter Payload
Explanation:
An advanced, memory-resident payload that provides full control without writing
files to disk.
Capabilities:
Credential dumping
Screenshot capture
Keylogging
Privilege escalation
Example:
Dumping password hashes from memory after system access.
Conclusion
Payloads are the core execution component of an attack, determining the final
impact after exploitation. Understanding payload types helps security professionals
detect, prevent, and mitigate cyber attacks effectively.
2. Reverse Shell
Definition
A reverse shell is a shell where the target system initiates a connection back to the
attacker, providing remote command execution.
Unlike a bind shell, the connection is initiated from inside the target network.
8. Example Scenario
A vulnerable PHP application allows command execution. An attacker injects a
reverse shell payload, enabling remote access to the web server through an
outbound connection.
9. Security Countermeasures
Restrict outbound traffic
Monitor network connections
Use application whitelisting
Patch web vulnerabilities
Deploy IDS/IPS systems
Conclusion
A shell provides direct control over a system, while a reverse shell enables stealthy
remote access by bypassing network restrictions. Understanding their operation
helps organizations detect misuse and strengthen defenses.
10) Explain the Bind Shell-applications, advantages and limitations with Examples.
Bind Shell – Applications, Advantages, Limitations & Examples
1. Definition of Bind Shell
A bind shell is a type of remote shell where the target (victim) system opens and
binds a listening port, waiting for the attacker to connect. Once the connection is
established, the attacker gains command-line access to the target system.
Bind shell = Victim listens, attacker connects
7. Example Scenario
A vulnerable Linux server allows command execution. The attacker opens a bind shell
on port 4444. The attacker connects to that port and executes system commands
remotely.
8. Security Countermeasures
Close unused ports
Implement firewall rules
Monitor open ports
Use intrusion detection systems
Apply least-privilege access
Conclusion
A bind shell provides direct remote access by opening a listening port on the target
system. While easy to implement, it is less stealthy and more detectable than reverse
shells, making it suitable mainly for controlled environments.
1. Post-Exploitation Modules
Definition
Post-exploitation modules are tools or techniques used after exploitation to maintain
access, gather data, escalate privileges, and analyze system weaknesses.
Objectives
Gain higher privileges
Identify misconfigurations
Discover system vulnerabilities
Establish persistence
Example:
After obtaining a user-level shell on a Linux server, post-exploitation modules are
used to check for sudo permissions and kernel vulnerabilities.
2. Privilege Escalation
Definition
Privilege escalation is the process of gaining higher access rights (e.g., from normal
user to administrator/root).
Types
Vertical Privilege Escalation – User → Admin
Horizontal Privilege Escalation – Access another user’s data
Techniques
Exploiting vulnerable services
Abusing weak file permissions
Exploiting kernel vulnerabilities
Example
A user account is allowed to run certain commands with sudo without a password,
enabling root access.
3. Identifying Misconfigurations
Definition
Misconfigurations are incorrect or insecure system settings that attackers can
exploit.
Common Misconfigurations
Weak file permissions
Default credentials
Unrestricted services
Improper sudo rules
Example
A configuration file containing database credentials is readable by all users, allowing
unauthorized access.
7. Countermeasures
Apply least-privilege principle
Regular patch management
Secure configuration auditing
Monitor privilege usage
Disable unnecessary services
Conclusion
Post-exploitation is a critical phase of penetration testing that exposes how a minor
breach can escalate into full system compromise. Identifying privilege escalation
paths, misconfigurations, and system vulnerabilities helps organizations strengthen
internal defenses and prevent advanced attacks.
1. Keyloggers
Definition
A keylogger records keystrokes entered by a user to capture sensitive data such as
usernames and passwords.
Example
An attacker captures login credentials typed into a web browser on a compromised
system.
Countermeasures
Use endpoint security (EDR/AV)
Enable multi-factor authentication (MFA)
Restrict administrative privileges
Monitor unusual process behavior
4. Custom Modules
Definition
Custom modules are tailor-made attack components designed for specific targets or
environments.
Purpose
Avoid detection
Perform targeted attacks
Bypass default security rules
Example
A custom module designed to exploit a proprietary internal application.
Countermeasures
Secure custom applications
Perform regular security audits
Use behavior-based detection systems
Conclusion
Keyloggers, surveillance modules, custom payloads, and AV evasion techniques
represent advanced post-exploitation threats. Understanding them helps
organizations deploy strong endpoint security, access controls, and monitoring
mechanisms to prevent severe cyber incidents.
13) Explain tools of Trade-Data exfiltration techniques-file hiding using steganography
with Example.
Introduction
After gaining access to a system, attackers often use data exfiltration techniques to
secretly transfer sensitive data and file hiding techniques like steganography to avoid
detection. Ethical hackers study these methods to identify risks and strengthen
security controls.
1. Data Exfiltration
Definition
Data exfiltration is the unauthorized transfer of sensitive data from a compromised
system to an external location controlled by the attacker.
b) Email-Based Exfiltration
Explanation:
Data is sent as email attachments or embedded within messages.
Example:
Confidential documents sent using a personal email account.
4. Steganography Techniques
a) Image Steganography
Data hidden in pixel values
Least Significant Bit (LSB) modification
Example:
Confidential text hidden inside a JPG image.
b) Audio Steganography
Data embedded in sound waves
Example:
Sensitive data hidden inside an MP3 file.
c) Video Steganography
Data distributed across video frames
Example:
Secret data embedded in a short video clip.
6. Real-World Example
In a corporate breach, attackers hid financial records inside image files using
steganography and exfiltrated them through HTTPS traffic, bypassing traditional
security monitoring.
7. Countermeasures
Monitor outbound network traffic
Use Data Loss Prevention (DLP) tools
Restrict USB and removable media
Inspect image and file metadata
Implement strict access controls
Use behavior-based detection systems
Conclusion
Data exfiltration and steganography are advanced techniques used to steal
information stealthily. Understanding these methods enables organizations to deploy
strong monitoring, DLP solutions, and access control policies to prevent data
leakage.
1. Achieving Persistence
Definition
Persistence refers to techniques used to maintain access to a compromised system
even after reboots, logouts, or temporary disruptions.
Common Persistence Techniques
Startup or boot-time execution
Scheduled tasks or services
Registry or configuration modifications
Backdoor user accounts
Example
An attacker configures a malicious service to start automatically when the system
boots, allowing continued access even after a restart.
2. Importance of Persistence
Enables long-term monitoring
Allows repeated access without re-exploitation
Helps attackers move laterally within networks
3. Covering Tracks (Anti-Forensics)
Definition
Anti-forensics involves methods used to hide evidence of intrusion, making
detection and investigation difficult.
Objectives
Avoid detection
Delay incident response
Bypass forensic analysis
b) Timestamp Modification
Explanation:
Changing file timestamps to hide modification history.
Example:
A malicious file shows the same creation date as system files.
c) File Hiding
Explanation:
Hiding files using hidden attributes or obscure directories.
Example:
A malicious file stored in a hidden system folder.
d) Process Masquerading
Explanation:
Running malicious processes under legitimate-looking names.
Example:
Malware named similar to a system service to avoid suspicion.
6. Real-World Scenario Example
In a corporate breach, attackers created a hidden startup task to regain access after
reboots and deleted login logs to delay detection, resulting in prolonged data
exposure.
7. Countermeasures
Enable centralized logging and SIEM
Monitor startup items and scheduled tasks
Implement file integrity monitoring
Apply least-privilege principle
Conduct regular forensic audits
Use EDR and behavior-based detection
Conclusion
Persistence and anti-forensics techniques allow attackers to remain undetected and
prolong control over systems. Understanding these methods helps organizations
deploy effective monitoring, logging, and incident response strategies to quickly
detect and eliminate threats.
1. Network Hardening
Definition
Network hardening involves securing network infrastructure (routers, switches,
firewalls, servers) by configuring them securely and restricting unauthorized access.
b) Network Segmentation
Divide network into secure zones (VLANs)
Limit lateral movement
Example:
Separating user network from database servers.
c) Secure Protocols
Replace insecure protocols with secure ones
Example:
Use SSH instead of Telnet, HTTPS instead of HTTP.
d) IDS/IPS Deployment
Detect and prevent suspicious network activity
Example:
IDS alerts when port scanning or brute-force attempts occur.
e) Access Control
Restrict network access using ACLs and authentication
Example:
Only authorized IP addresses can access internal servers.
2. System Hardening
Definition
System hardening focuses on securing operating systems and applications by
removing unnecessary components, enforcing security policies, and applying
patches.
d) Strong Authentication
Enforce strong passwords and MFA
Example:
Password + OTP for system login.
v
4. Real-World Example
An organization hardens its infrastructure by:
Blocking unused ports
Updating OS regularly
Enforcing MFA
Segmenting internal networks
Result: Reduced risk of malware, ransomware, and insider attacks.
5. Benefits of Hardening
Reduces attack surface
Prevents unauthorized access
Improves compliance
Enhances system stability
Conclusion
Network and system hardening are essential cybersecurity practices that protect
systems from attacks by strengthening configurations, enforcing policies, and
continuously monitoring activity. Proper hardening significantly lowers the chances
of successful cyber attacks.