EthicalHacking
EthicalHacking
www.skcet.ac.in
Module – 2
INTRODUCTION TO AUDITING FRAMEWORKS
www.skcet.ac.in
Introduction to Reconnaissance
The term reconnaissance comes from the military and means to actively seek
an enemy’s intentions by collecting and gathering information about an
enemy’s composition and capabilities via direct observation, usually by scouts
or military intelligence personnel trained in surveillance.
Reducing Detection
Planning & Preparation
Risks
Improving Defense
Maximising Impact
Posture
Role of Reconnaissance
#1 Identification of Vulnerabilities
Reconnaissance helps identify weaknesses and vulnerabilities in
target systems or networks.
By gathering information about the target's infrastructure,
software versions, and configurations, attackers can pinpoint
potential entry points for exploitation.
Role of Reconnaissance
#2 Understanding the Target Environment
Reconnaissance provides insight into the target's network
architecture, security measures, and defenses.
This understanding allows attackers to tailor their attack
strategies to bypass security controls effectively.
Role of Reconnaissance
#3 Planning and Preparation
Reconnaissance allows attackers to plan and prepare their
attacks more effectively.
By gathering intelligence about the target, attackers can develop
detailed attack strategies, select appropriate tools and techniques,
and anticipate potential obstacles.
Role of Reconnaissance
#4 Reducing Detection Risks
Effective reconnaissance helps attackers minimize the risk of
detection.
By gathering information passively or using stealthy scanning
techniques, attackers can gather intelligence without alerting
defenders to their presence.
Role of Reconnaissance
#5 Maximizing Impact
Reconnaissance helps attackers maximize the impact of their
attacks by identifying high-value targets and assets within the
target environment.
By focusing their efforts on critical systems and data, attackers
can inflict greater damage and achieve their objectives more
effectively.
Role of Reconnaissance
#6 Improving Defense Posture
Understanding the techniques and tools used in reconnaissance can
help organizations improve their defense posture.
By monitoring for reconnaissance activities and implementing
appropriate security controls, organizations can detect and mitigate
potential threats before they escalate into full-blown cyber attacks.
Types of Reconnaissance
Two types of Reconnaissance: Active and Passive
Active Reconnaissance
With active reconnaissance, hackers interact directly with the computer system and
attempt to obtain information through techniques like automated scanning or manual
testing and tools like ping and netcat. Active recon is generally faster and more
accurate, but riskier because it creates more noise within a system and has a higher
chance of being detected.
Passive Reconnaissance
Passive reconnaissance gathers information without directly interacting with
systems, using tools such as Wireshark and Shodan and methods such as OS
fingerprinting to gain information.
Information Gathering Techniques
Social Engineering
Footprinting
Network Scanning
Vulnerability Scanning
War Dialling
Physical Observation
Dumpster Diving
❑ To get this information, a hacker might use various methods with variant tools. This
information is the first road for the hacker to crack a system.
❑ Network scanning can be done using a variety of tools, such as ping sweeps and
port scanners.
Information Gathering Techniques
#4 Vulnerability Scanning
❑ Vulnerability scanning is a crucial process within any comprehensive
cybersecurity program.
❑ This technique involves using specialized tools to scan a target's assets for known
vulnerabilities.
Information Gathering Techniques
#5 War Dialing
❑ War dialing is a technique used in reconnaissance in cybersecurity that involves automatically
dialing a range of phone numbers to identify active modems.
❑ It is an active reconnaissance method that is used to identify potential targets for a future attack.
❑ War dialing is typically done by using specialized software tools, which can dial a large
number of phone numbers in a short period.
❑ Once a modem is identified, the war dialer will attempt to connect to the modem and determine
if it is accessible and what type of device it is.
❑ Modern war dialing tools have evolved to use Voice over IP (VOIP) connections,
significantly increasing the speed and efficiency of the dialing process. This advancement
allows the software to make a higher volume of calls in a shorter period, enhancing the
ability to scan extensive lists of phone numbers quickly.
Information Gathering Techniques
#6 Reconnaissance with Physical Observation
❑ "Reconnaissance with physical observation" refers to the act of gathering
information about a target by directly observing it in person, using visual cues
and physical presence to collect details about a location, individuals, or
infrastructure, often done discreetly to avoid detection; essentially, "spying" by
physically being present at a site to gather intelligence.
❑ Dumpster driving can be used to find information that has been discarded,
such as old documents, memos, and hardware.
Information Gathering Techniques
#8 Open Source Intelligence
❑ Open-Source Intelligence (OSINT) refers to the process of collecting, analyzing,
and disseminating publicly available information.
❑ The information can be found on various sources such as the internet, social
media, newspapers, publications, government reports, etc.
❑ OSINT is used to gather information about a wide range of topics, including
political, economic, military, and security-related issues.
❑ The goal of OSINT is to gather the information that is not classified but could
be valuable for decision-making, threat intelligence, investigations, and
research purposes.
Analysis of Information
❑ Once the information is collected through reconnaissance, it needs to be analyzed to
extract valuable insights and make sense of the data.
❑ The process of analyzing the information can involve several different techniques and
methods, depending on the specific context and the information being analyzed.
Nmap was designed to rapidly scan large networks, but works fine
against single hosts.
Nmap runs on all major computer operating systems, and official
binary packages are available for Linux, Windows, and Mac OS X.
In addition to the classic command-line Nmap executable, the
Nmap suite includes an advanced GUI and results viewer
(Zenmap), a flexible data transfer, redirection, and debugging tool
(Ncat), a utility for comparing scan results (Ndiff), and a packet
generation and response analysis tool (Nping).
Nmap
If Nmap can’t see the target, it won’t scan the target unless the -Pn (do not
ping) option is used.
This option was invoked using the -P0 and -PN option in previous Nmap
releases.
Using the -Pn option can create problems because Nmap will try to scan
each of the target’s ports, even if the target isn’t up, which can waste time.
To strike a good balance, consider using the -P option to select another
type of ping behavior.
For example, the -PP option will use ICMP timestamp requests and the
–PM option will use ICMP netmask requests.
Nmap: output options
When you specify your targets for scanning, Nmap will accept
specific IP addresses, address ranges in both CIDR format such as
/8, /16, and /24, as well as ranges using 192.168.1.100e200-style
notation.
If you have a hosts file, which may have been generated from your
ping sweep earlier (hint, hint), you can specify it as well, using the
-iL flag.
Nmap: speed options
Nmap allows the user to specify the “speed” of the scan, or the
amount of time from probe sent to reply received, and therefore,
how fast packets are sent.
On a fast local area network (LAN), you can optimize your scanning
by setting the -T option to 4, or Aggressive, usually without
dropping any packets during the send.
If you find that a normal scan is taking a very long time due to
ingress filtering, or a firewall device, you may want to enable
Aggressive scanning.
Nmap Timing Templates
Nmap: port-scanning options
The state of the port as determined by an Nmap scan can be open, filtered,
or unfiltered.
Open means that the target machine accepts incoming request on that
port.
Filtered means a firewall or network filter is screening the port and
preventing Nmap from discovering whether it’s open.
Unfiltered mean the port is determined to be closed, and no firewall or
filter is interfering with the Nmap requests.
Nmap has numerous command switches to perform different types of
scans.
Nmap Scans
XMAS scans send a packet with the FIN, URG, and PSH flags set.
If the port is open, there is no response; but if the post is closed, the
target responds with a RST/ACK packet.
XMAS scans work only on target systems that follow the RFC 793
implementation of TCP/IP and don’t work against any version of
Windows.
FIN, NULL, IDLE Scans
FIN: A FIN scan is similar to an XMAS scan but sends a packet with just
the FIN flag set.
FIN scans receive the same response and have the same limitations as
XMAS scans.
NULL: A NULL scan is also similar to XMAS and FIN in its limitations
and response, but it just sends a packet with no flags set.
IDLE: An IDLE scan uses a spoofed IP address to send a SYN packet to
a target. Depending on the response, the port can be determined to be
open or closed.
IDLE scans determine port scan response by monitoring IP header
sequence numbers.
TCP Communication Flag Types
www.skcet.ac.in
Surveying the attack surface
The attack surface refers to all the points, assets, and avenues
through which an attacker can potentially exploit or compromise a
system, network, or organization.
Asset Inventory:
❖ Create an inventory of all assets within the target environment.
❖ This includes hardware devices, servers, endpoints, network
infrastructure, and software applications.
❖ Identify all web applications and services associated with the target.
❖ This includes public-facing websites, internal web applications, and
web services.
Steps involved in Surveying the attack surface
Cloud Services and Assets:
❖ If the target organization uses cloud services, identify and enumerate
assets within cloud environments.
❖ This includes resources on platforms like AWS, Azure, or Google Cloud.
Wireless Networks:
❖ Identify and assess wireless networks within the target environment.
❖ This includes Wi-Fi networks and associated security
configurations.
Employee Information:
❖ Collect information about employees, especially those who may have
access to sensitive systems or information.
❖ This includes email addresses, job titles, and roles.
Physical Infrastructure:
❖ If possible, assess the physical infrastructure, including data centers, server
rooms, and other facilities.
❖ Physical security measures are critical aspects of the overall attack surface.
Domain name
Network blocks
Network services and applications
System architecture
Intrusion detection system
Authentication mechanisms
Specific IP addresses
Access control mechanisms
Phone numbers
Contact addresses
Scanning and Enumeration
Scanning and enumeration are the next steps in the hacking process
after the information gathering phase has been completed.
Scanning and enumeration tools are most often active
information-gathering tools and therefore allow the hacker to be
detected.
For this reason, many tools and techniques exist to minimize the
opportunity for detection and reduce the chance of the hacker being
identified.
Scanning and Enumeration
There are different tools that are being used for Active Stack and
Passive Stack Fingerprinting.
Active Fingerprinting Tools: Nmap.
Passive Fingerprinting Tools: Network Miner, P0f, Satori
Active Fingerprinting Tools
NetworkMiner:
❑ It is a Network Forensic Analysis Tool for Windows.
❑ It is used to detect operating systems, sessions, hostnames, open
ports, etc.
❑ The main purpose of NetworkMiner is to collect data that can be
used as forensic evidence about hosts on the network rather than to
collect data regarding the traffic on the network.
Passive Fingerprinting Tools
P0f:
❑ It is a versatile passive OS fingerprinting tool that is used to
identify the remote system, how far it is located, and its uptime.
❑ It also detects certain types of packet filters and the name of the
ISP, while remaining Passive as it does not generate any network
traffic.
Satori:
❑ Satori is one of the most frequently used passive fingerprinting
programs that uses multiple protocols for OS identification.
❑ It is available in both Windows and Linux platforms.
Prevention of Fingerprinting
The hacker first makes a connection to the proxy server and then
requests a connection to the target computer via the existing
connection to the proxy.
Essentially, the proxy requests access to the target computer not the
hacker’s computer.
This lets a hacker surf the web anonymously or otherwise hide
their attack.
Prepare Proxies
The NetBIOS null session use specific port numbers on the target
machine.
Null sessions require access to TCP ports 135, 137,139, and/or 445.
One countermeasure is to close these ports on the target system.
This can be accomplished by disabling SMB services on individual
hosts by unbinding the TCP/IP WINS client from the interface in the
network connection’s properties.
SNMP Enumeration
SNMP has two passwords you can use to access and configure the SNMP
agent from the management station. The first is called a read community
string.
This password lets you view the configuration of the device or system.
The second is called the read/write community string; it’s for changing or
editing the configuration on the device.
Generally, the default read community string is public and the default
read/write community string is private.
A common security loophole occurs when the community strings are left
at the default settings: A hacker can use these default passwords to view
or change the device configuration.
SNMP Enumeration
Hacking Tools
SNMPUtil and IP Network Browser are SNMP enumeration tools.
SNMPUtil gathers Windows user account information via SNMP in
Windows systems.
Some information such as routing tables, ARP tables, IP addresses,
MAC addresses, TCP and UDP open ports, user accounts, and
shares can be read from a Windows system that has SNMP enabled
using the SNMPUtil tools.
IP Network Browser from the SolarWinds toolset also uses SNMP
to gather more information about a device that has an SNMP agent.
SNMP Enumeration Countermeasures
www.skcet.ac.in
Introduction to Active Hosts
www.skcet.ac.in
Nmap Scripting Engine (NSE)
The Nmap Scripting Engine (NSE) is one of Nmap's most powerful and
flexible features. It allows users to write (and share) simple scripts (using
the Lua programming language ) to automate a wide variety of
networking tasks.
Those scripts are executed in parallel with the speed and efficiency you
expect from Nmap. Users can rely on the growing and diverse set of
scripts distributed with Nmap, or write their own to meet custom needs.
Tasks we had in mind when creating the system include network
discovery, more sophisticated version detection, vulnerability detection.
NSE can even be used for vulnerability exploitation.
Nmap Scripting
One of the more advanced features recently added to Nmap is the ability to create scripts
enabling automation.
These scripts can be used to automate a wide variety of functions including enumeration,
vulnerability scans, and even exploitation.
For the purposes of enumeration, these Nmap scripts can help automate some of your work
and speed up your penetration testing process.
More scripts are being developed constantly, but most security toolsets such as BackTrack
include a number of basic scripts.
Tasks performed by NSE
Network discovery
This is Nmap's bread and butter. Examples include
looking up whois data based on the target domain,
querying ARIN, RIPE, or APNIC for the target IP to
determine ownership, performing identd lookups on open
ports, SNMP queries, and listing available NFS/SMB/RPC
shares and services.
Tasks performed by NSE
Vulnerability detection
When a new vulnerability is discovered, you often want to scan your
networks quickly to identify vulnerable systems before the bad guys do.
While Nmap isn't a comprehensive vulnerability scanner, NSE is
powerful enough to handle even demanding vulnerability checks.
When the Heartbleed bug affected hundreds of thousands of systems
worldwide, Nmap's developers responded with the ssl-heartbleed
detection script within 2 days. Many vulnerability detection scripts are
already available and we plan to distribute more as they are written.
Tasks performed by NSE
Backdoor detection
Many attackers and some automated worms leave backdoors to
enable later reentry. Some of these can be detected by Nmap's
regular expression based version detection, but more complex
worms and backdoors require NSE's advanced capabilities to
reliably detect.
NSE has been used to detect the Double Pulsar NSA backdoor in
SMB and backdoored versions of UnrealIRCd, vsftpd, and
ProFTPd.
Tasks performed by NSE
Vulnerability exploitation
As a general scripting language, NSE can even be used to exploit
vulnerabilities rather than just find them. The capability to add
custom exploit scripts may be valuable for some people (particularly
penetration testers), though we aren't planning to turn Nmap into an
exploitation framework such as Metasploit.
Script Categories
Nmap scripts are stored in a scripts subdirectory of the Nmap data directory by default. For
efficiency, scripts are indexed in a database stored in scripts/script.db, which lists the category or
categories in which each script belongs.
When referring to scripts from script.db by name, you can use a shell-style ‘*’ wildcard.
nmap --script "http-*"
Loads all scripts whose name starts with http-, such as http-auth and http-open-proxy. The
argument to --script had to be in quotes to protect the wildcard from the shell.
More complicated script selection can be done using the and, or, and not operators to build
Boolean expressions. The operators have the same precedence as in Lua: not is the highest,
followed by and and then or. You can alter precedence by using parentheses. Because expressions
contain space characters it is necessary to quote them.
NSE Scripts
NSE supports four types of scripts, which are distinguished by the kind of targets
they take and the scanning phase in which they are run. Individual scripts may support
multiple types of operation.
Prerule scripts
These scripts run before any of Nmap's scan phases, so Nmap has not collected any
information about its targets yet. They can be useful for tasks which don't depend on
specific scan targets, such as performing network broadcast requests to query DHCP and
DNS SD servers. Some of these scripts can generate new targets for Nmap to scan (only if
you specify the newtargets NSE argument). For example, dns-zone-transfer can obtain a
list of IPs in a domain using a zone transfer request and then automatically add them to
Nmap's scan target list. Prerule scripts can be identified by containing a prerule function
(see the section called “Rules”).
Script Types and Phases
Host scripts
Scripts in this phase run during Nmap's normal scanning process
after Nmap has performed host discovery, port scanning, version
detection, and OS detection against the target host.
This type of script is invoked once against each target host which
matches its hostrule function. Examples are whois-ip, which looks
up ownership information for a target IP, and path-mtu which tries
to determine the maximum IP packet size which can reach the target
without requiring fragmentation.
Script Types and Phases
Service scripts
These scripts run against specific services listening on a target host.
For example, Nmap includes more than 15 http service scripts to run
against web servers. If a host has web servers running on multiple
ports, those scripts may run multiple times (one for each port).
These are the most commong Nmap script type, and they are
distinguished by containing a portrule function for deciding which
detected services a script should run against.
Script Types and Phases
Postrule scripts
These scripts run after Nmap has scanned all of its targets. They can be
useful for formatting and presenting Nmap output. For example,
ssh-hostkey is best known for its service (portrule) script which connects
to SSH servers, discovers their public keys, and prints them. But it also
includes a postrule which checks for duplicate keys amongst all of the
hosts scanned, then prints any that are found.
Another potential use for a postrule script is printing a reverse-index of
the Nmap output—showing which hosts run a particular service rather
than just listing the services on each host. Postrule scripts are identified by
containing a postrule function.
References
https://nmap.org/book/man-nse.html