Ethical Hacking UNIT-4
Ethical Hacking UNIT-4
UNIT IV
Sniffing, Packet Analysis & Session Hijacking: Sniffing, Packet Analysis, Types of Sniffing,
Active and Passive Sniffing Techniques, Session Hijacking, Social Engineering: Social
Engineering, Process, Identity Theft, Human and Computer Based Social Engineering
Techniques, Phishing Process, Types of Phishing Attacks, Social Engineering Toolkit (SET).
SNIFFING
Sniffing is the process of intercepting the exchange of information between two hosts. In
sniffing, attacker intercepts the information which is exchanged in the form of packets from the
communication between HOST A and HOST B or simply client and server.
Sniffing is one of the important techniques and plays a major role in the penetration testing.
Sniffing is simply refers to stealing the sensitive information or data over a network. The data
may be passwords, login details, texts, files, etc. In the sniffing, attacker setups man in the
middle attack or packet sniffers to intercept the packets which are used to transfer the
information between client and server.
Now, attacker analyse the packets to gain sensitive information. An attacker can manipulate
and modify the packets to hack into the network. Also sniffing gives attacker an advantage to
change the information of the original packet and send the fake packet to the receiver.
In the process of penetration testing, sniffing is one of the major techniques which profes sional
uses. Sometimes, an attacker can sniff passwords or credentials over the wireless networks
Ethical hackers use network sniffing tools to capture and examine data packets as they travel
across a network. By analyzing these packets, they can uncover potential security issues such
as unencrypted sensitive information, unauthorized access attempts, and potential
vulnerabilities in network protocols or configurations.
1. Hardware Sniffers :
Like hardware keyloggers, hardware sniffers are the physical tools which are used to intercept
the packets. A hardware tool is installs between the server and target. That hardware works on
• Hardware sniffer is basically installed when the wired connection is present between
two hosts.
The Fluke Networks OptiView XG is an example of a hardware sniffer. It's a portable network
analysis tool designed for diagnosing and troubleshooting complex network issues. It's a self-
contained device with its own interface and display.
➢ Software sniffers are known as packet analysers and are widely used for the sniffing
traffic and packet analysis.
➢ Packet analysis is one of the important technique in which all the incoming and
outgoing packets are analysed. From the packet analysis information is gained
➢ On the big levels, traffic monitoring is done regularly to avoid the threats coming to the
network. Sometime, malwares or viruses can be packed into the packet and transferred
by the attacker, so using the packet analysis, exploitation can be avoided.
➢ Wireshark is one of the most powerful packet analyser tools. Wireshark comes pre-
installed in kali linux whereas it is available for download on its website.
➢ Along with wireshark, TcpDump and tShark are also used. tShark is command line
based wireshark tool used for packet analysis.
Wireshark is a popular open-source software sniffer that allows you to capture and analyze
network traffic. It can be installed on your computer and used to intercept data packets on the
local network interface. While Wireshark itself is a software application, it's a great example of
a software sniffer in action.
PACKET ANALYSIS:
Traffic monitoring and packet analysis is widely adopted by corporates to stay away from
security threats. Sometimes, packets transferred are infected or contains malicious information.
In this case monitoring each and every incoming and outgoing packet is necessary.
1. Capture: Packet capture involves intercepting data packets as they travel through a
network. This can be done using hardware or software tools, such as network analyzers,
packet sniffers, or intrusion detection systems. These tools can be set up to capture
packets on specific network interfaces or segments.
2. Inspection: Once captured, the individual packets are inspected to gather information
about their contents. This includes details such as source and destination IP addresses,
source and destination port numbers, protocol used (e.g., TCP, UDP), payload data, and
more.
3. Analysis: The captured packet data is analyzed to gain insights into network activity,
performance, and potential issues. Network administrators, security analysts, and
researchers use packet analysis to identify patterns, anomalies, and potential threats.
They can also use it to troubleshoot network problems, optimize network performance,
and ensure compliance with network policies.
4. Diagnosis and Troubleshooting: Packet analysis can help diagnose network issues such
as latency, packet loss, and connection problems. By examining the sequence of
packets exchanged between devices, analysts can pinpoint the source of problems and
take corrective actions.
TYPES OF SNIFFING
Sniffing refers to the practice of intercepting and inspecting data as it travels across a network.
Sniffing the traffic and packet analysis can be done in following two ways:
1. Active Sniffing :
In the active sniffing, sniffing is done through switch. An attacker tries to poison the switch
using fake or spoofed mac address. The ultimate aim is to poison the switch and intercept
every packets passing through it. In this, switch acts as intermediate. Now the switch looks
each and every mac address and sends the information on the connected ports.
2. Detection Risk
4. Security Analysis
5. Malicious Use
6. Promiscuous Mode
Though sniffing took place using switch it is difficult to sniff the packets and there are great
chances of being caught. Active sniffing may get detected easily and hence it is not efficient
way of sniffing.
2. Passive Sniffing :
In the passive sniffing, sniffing is done through HUB. An attacker directly gets connected to
the hub and starts sniffing. This type of sniffing is often used for network analysis,
troubleshooting, and monitoring purposes. As the attacker is directly connected to the hub, it is
difficult to detect the sniffing and there are less chances of being caught. Passive sniffing is
quite easy as compared to the active sniffing.
In the passive sniffing, hub acts as an intermediate. The packets are intercepted easily and
analysis process became smooth.
Passive sniffers do not actively inject any packets into the network; instead, they passively
listen to the traffic that is already present on the network.
Network administrators commonly use passive sniffing tools, also known as network analyzers
or protocol analyzers, to troubleshoot network issues. By analyzing the existing traffic, they
can identify problems such as bottlenecks, errors, or abnormal patterns.
Security Monitoring:
Passive sniffing can be used for security monitoring to detect and analyze network anomalies.
Security professionals may use passive sniffers to identify potential security threats or
unauthorized activities on the network.
1. MAC Flooding :
Mac flooding is technique used for flooding the SWITCH by sending huge amount of requests.
The switch gets flooded by huge number of mac requests.
A switch contains limited memory to map the mac address on the physical ports. By sending
the numerous amount of request the limited gets over. In the process, the switch is bombed
with fake mac addresses resulting into the flooding of switch.
Once the switch is get flooded, now it acts as hub because of the flooding switch messed up.
Now, due to behaviour shown by switch is like a hub, packets are transferred to all the devices
on the network and hence the attacker can easily perform the sniffing.
A. Macof
Macof is one of the powerful tools used for MAC Flooding. Macof is pre-installed with kali
linux. It simply floods the local random mac address resulting into failure of the switch to open
in repeating mode and hence enables sniffing with ease.
Using Macof :
2. Type “macof /?“ to open the help screen of the macof tool.
macof [-i interface] [-s source] [-d destination] [-e tha] [-x sport] [-y dport] [-n times].
2. ARP Spoofing :
ARP is the Address Resolution Protocol which is used to convert ip address into mac address.
Arp packets are intercepted to send the data to attacker’s machine. Working of ARP is
discussed in the previous chapters. An attacker can exploit arp poisoning in order to intercept
or perform sniffing attack in a network. When the switch is flooded using mac flooding the arp
tables can be spoofed, due to flooding the switch is in forward mode so that sniffing can be
performed easily.
In the arp poisoning, the attacker steals the arp information and spoofs the mac address of the
target to itself. Now, switch sends all the information to the spoofed mac address i.e. to the
attacker.
1. User A sends Arp request to the switch asking about the ip address. The query of ip address
is processed by switch. For ex ip address is 42.45.56.45.
2. Now User B having the same ip address will reply to the switch with its mac address. For
ex, mac address is x:y:z:a:b . now here is role of attacker.
3. Attacker will eavesdrop on the arp request and will spoof the mac address of target and
sends its mac address to the User A which is a:b:x:y:z .
4. Now all the information or the queries of the ip address 42.45.56.45 will be sent to the
attacker’s machine.
Generally Cain and Abel, ettercap, etc. are used for arp poisoning. In this book, cain and abel
is discussed.
Cain and able is powerful password recovery tool which is also used for sniffing and various
purposes. It allows password recovery using brute force, sniffing, dictionary attacks and by
Using Wireshark :
SESSION HIJACKING
An attacker tries to access the remote session of a target by stealing the session id of the target.
If the attacker is able to get the valid session id of target system, he can easily access the active
remote session of target. Using a session id, an attacker can get access into the target system
and take over the data.
➢ Session hijacking can be done from various types. When the attacker is able to steal the
tcp sessions between two hosts, this is known as TCP Session Hijacking.
1. Active :
In active session hijacking, an attacker is able to manage stealing active and valid session id of
the target user. Attacker disconnects the target from the active session and takes over that
active session.
Generally the attacker needs to intercept the packets and analysis them in order to get valid
cookies or session id information. Before that takeover of an active session are quite complex
and difficult.
Session Token or Cookie- When a user logs into a system or a website, they are often
assigned a session token or cookie.
Use of Stolen Token- Once the attacker has the session token, they use it to impersonate the
legitimate user.
2. Passive :
➢ In the passive session hijacking, an attacker sits between two communicating host and
analyse their communication packets traffic.
➢ Passive session hijacking, also known as session eavesdropping, is an attack in which
an unauthorized party monitors and intercepts communication between two entities
without actively manipulating the data during transmission.
➢ After getting the session id or valid cookie, attacker hijacks the session but doesn’t
perform any exploit.
Attacker simply analyse all the packet communication which are going in forward request and
tries to communicate using the fake identity in order to get highly sensitive information from
the other side.
1. Monitoring Communication:
The attacker secretly monitors the communication between a user and a system, such as
a website or an application.
2. Capturing Session Data:
The attacker captures data exchanged during the session, including session tokens,
cookies, or other authentication credentials.
3. Analyzing Captured Data:
Once the data is captured, the attacker analyzes it to extract sensitive information, such
as session identifiers or authentication tokens.
4. Unauthorized Access:
With the information obtained through passive session hijacking, the attacker may gain
unauthorized access to the user's account or system.
In the network side session hijacking, an attacker sits between two communicating hosts and
tries to intercept all the communication packets to get the valid cookies and session IDs.
Generally it is done when the communication between two hosts is TCP or UDP based.
In application side session hijacking, an attacker tries to get the valid session ids of the target
user in-order to get access of the active session and sometimes due to presence of critical
vulnerability attacker can even create an unauthorised new session.
Session Ids might be present in the URL of web application which is reflected result of HTTP
GET request. Also user tries to intercept the valid session cookies of the target user and tries to
hijack the session. Generally, Brute Force is used in guessing for the session ids. An attacker
uses the brute force to get the session id of the target user.
Hamster :
SOCIAL ENGINEERING
Social engineering is an art of human exploitation. Exploiting the human itself to gets sensitive
information. Social engineering play very big role in the hacking and penetration testing. A
good needs to be a good social engineering.
If a hacker is good at social engineering, hacking a thing is not a big deal for him. An attacker
manipulates the user in order to get sensitive information using social engineering. Social
engineering may be human based or tool based.
Both kind of social engineering plays an important role. If an attacker is able to manipulate the
customer services or receptionist of a company, he can get some sort of sensitive information
from there. Hence social engineering is a vast field, by which simply manipulate a target, an
attacker can compromise and gain much of sensitive information to perform further hack.
For ex, an attacker calls the target and says hello, I am from XYZ Company, you have won
50000 rupees in our lottery and many other manipulating things. They ask for your personal
information in order to avail this money. Now, at last sometimes they give you a number to
call and avail you lottery amount.
During this they already have performed social engineering attack and gained your personal
information. Many times people get emails and messages as well. There are many scammers
who try to thug a person to get benefited.
UNIT-4 [19] Dr.R.Satheeskumar, Professor
A human is the weakest part of any company. Exploiting the human by manipulating can give
tons of sensitive information and sometimes even access to the network of company.
There is no solution to fix the level of human manipulation. Hence a human is always
vulnerable to social engineering and hence the whole corporate network is vulnerable. Simply
manipulating a person can provide huge information disclosure, the person may be directly or
indirectly related to the company, may be the peon or clerk or maybe an officer at higher post.
There is no such role of post in the social engineering. Social engineering totally depends upon
the manipulating skills of an attacker, if he is good at manipulating or convincing a person, he
can compromise into the whole network, without actually performing Hack.
1. Analysis : Analysis is one of important factor at any stage of life as well as in penetration
testing. If an attacker wants to perform social engineering attack at any corporate structure,
first requirement is to analyse the human behaviour of employees and officers. Once the
attacker successfully analyse and finds a vulnerable target, attacker can successfully perform
the attack. Hence before targeting any random human, an attacker needs to analyse the whole
target structure.
2. Selection :
After careful assessment, now attacker selects the most vulnerable human with which he can
perform social engineering and can get some sensitive information. While selecting sometimes
attacker choose medium or least vulnerable person if the position of that person is higher.
Hence for successful attack, an attacker needs to choose the target person very carefully.
4. Attack :
This is the ultimate phase, in this phase an attacker performs attack which may be in-person or
live attack. Attacker tries to gain sensitive information from the target by the sake of faith and
trust. If the attacker is able to maintain good relationship, he can easily exploit and gain access
to the sensitive information.
These are the simple process which is followed by an attacker while performing. A hacker
never go off the track, he follow the process because if something got missed, there are
chances of being caught.
Identity Theft :
➢ Identity theft is referred as making a fake identity of the same person in order to get
benefit. If an attacker steals name and information of the target, this thing is known as
identity theft.
➢ Identity theft is generally done when attacker is engaged in cases of fraud. Fake identities
are generally used by the fraudsters to commit fraud.
➢ How an attacker steals the identity is quite interesting thing. Generally people throws off
bills or other documents from which an attacker can gain information of the target.
Sometimes an attacker stole your purse which contains your important documents.
- for ex : if an attacker gets your identity card, now if he wants to use it to get fake passport,
simply he will apply for a new passport stating the bills and saying that you have moved to
new address.
Now this is the major threat where the fraudsters can do big scams and ultimately the target is
victimised. Once the new identity cards are made, an attacker can also ask you bank to issue
new cheque books or credit and debit cards by showing the fake identity and ultimately target
is now also exploited financially. From the fake identity of the target, an attacker can do
anything. He can issue new sim cards, bank accounts and much more fake scams on the name
of the target. If the activities get caught, ultimately the target is victimised in first sight.
1. Phone Call:
A phone call is used for social engineering, an attacker owns a fake identity and tries to get
information from the target. An attacker behaves like or sounds in such a manner to gain trust
of the target over phone call. Now once the attacker succeeds in manipulating the target,
gaining information is not a big deal.
For Ex : Person A receive a phone call stating I am from XYZ University and this is to inform
you that your documents are missing or misplaced by the staff. Please provide your following
information to keep you admission secure.
Generally in this case, due to fear of losing the admission or having the faith that call is from
university, A will provide the information asked. Now, actually the caller was owned a fake
identity of university employee and manipulated A to give off the information. Hence before
giving the information, ensure that the cause is genuine.
2. Message
Fake messages are sent to users to gain their personal and sensitive information. Those
messages seem very real and trust worthy but actually there is a hand of attacker behind them.
For Ex:
Person A receive a message, stating thank you for being the customer of XYZ, you are our
today’s lucky customer and have won a prize. Please provide your information to confirm your
prize. Now the person A thinks that the message is from company and there is now harm in
providing the information and hence replies back with the asked information. In this case target
3. Dumpster Diving
Looking for sensitive information in garbage or dumps is known as dumpster diving.
Sometimes, attacker may find a piece of paper or some important important documents from
which sensitive information can be retrieved. When penetration testing or hacking is performed
each and every possible aspect of gathering information is taken into consideration.
4. Shoulder Surfing :
Looking at shoulder or guessing the password by viewing a person typing or indirectly seeking
into his hand movement to get password. Sometimes it provides quite sensitive information.
5. Eavesdropping :
An attacker can look for the information without the permission and knowledge of the target.
Eavesdropping might be happened when someone is doing sort of transitions or at any possible
area where the information can be obtained by simply looking secretly. Attacker sometime
hears the verbal conversation of its target to gain some information.
1. E-Mail :
E-mails are widely used for the information exchange. Hence it is a major way by which social
engineering can be done. An attacker can send malicious files like Trojans or viruses and
which can exploit the target.
Generally spammers send infected emails or email containing infected files to the target. Once
the target open the mail or attachment, virus or Trojan associated with it gets executed into the
system of target and remotely spying the target system. Hence the attacker can gain the
information of target from target’s system.
For Ex : A receives an email with an attachment, now the email seems to be from a reputed
company and hence A opens the mail. Now there is an attachment which is named x.docs or
maybe of any type. A download and opens the attachment for viewing. In the background, a
malicious application gets executed and now tracks every activity of A’s system. Sometimes
product sell emails are also sent to the users stating that get a particular product in 80% off or
some other sort advertisement. User generally opens those links and register with their details.
They won’t get any product but their information has been disclosed and there are chances of
identity theft.
While downloading or visiting a website, sometimes popup window occurs showing some
interesting things which attract the user to follow the pop-up and ultimately they end up with
giving their information to the attacker. More or less, again there is a huge chance of identity
theft. Data collected is generally sold out at higher prices and this data is misused.
3. Phishing :
Phishing is one of the oldest but working techniques of social engineering. In the phishing
generally an attacker creates a fake webpage or fake login page which looks exactly same as
the original page. Now, once the page is made the attacker targets a user and manipulates him
to login on that. Once user logins, his credentials are recorded into the attacker’s database.
Now-a-days, phishing has been extended. Phishing can be done by making fake pages, by fake
e-mail or fake applications which resembles to the original one. Phishing can be easily
identified by checking the URL. The phishing link will contain the url which will not resemble
to the original URL.
For Ex :
A person receives an email that XYZ Company (reputed one) is launching an Application.
Apply for the beta-tester of the application and there is a link present to login and download
the application. User generally gets happy by seeing that he got a chance to test the application
for everyone.
Now, once he opens the link and register successfully, the page shows some message like “
ooppss.. !! You missed the chance, We have already closed beta-tester application”. Generally
user ignores and takes it as consequence but actually he is victimised of phishing and social
engineering.
PHISHING PROCESS:
1. First an attacker creates the replica of original website and check whether there is anything
which can be easily detected. After the successful creation, sometimes for the surety attacker
runs the phishing site on local host using the software like “xampp”.
2. Once the phishing site runs with zero error on the local host, attacker register for a fake
domain and fake hosting provided fake information. Attacker tries to keep the domain look
similar to the original one.
3. Once the phishing site is live, now attacker targets the users and send phishing link via mail
or over the chats in such a way that user get manipulated and opens the link. Once user login to
the link, his credentials are recorded.
In MITM, Attacker sits between the source and destination. Attacker monitors and sniffs the
activities of the target and tries to get the credentials. MITM can be performed over http as
well as https. Generally the user is redirected to a proxy server and real proxy is not used
which makes this attack more successful. The proxy may be of any type but attacker avoids the
user to use real proxy.
XSS attack is generally performed by injecting code injection in the url parameters or input
data field. Generally xss is carried out by url formatting. Xss may be persistence or DOM
based. XSS is counted in top 10 vulnerability list according to owasp top 10 2013.
3. URL Redirection :
Attacker shares a link to the target user which on opening redirects to the phishing page.
Attacker tries to keep the link as similar as the original so that there are less chances of being
caught. This is one of the traditional methods of performing the phishing attack. Generally user
shares such links over personal chats or emails.
4. Site cloning :
Site cloning is generally performed directly by the Social Engineering Toolkit (SET) which
comes pre-installed in kali linux. It creates the clone of site on the local ip of the attacker.
When the target & attacker both share the same network, site cloning is useful.
Attacker can inject malware into the target system by the means of e-mail or any method or
installs the keylogger which tracks every activity of the target and anonymous sends the data
record to the attacker when target system goes online.
Client-Side Attack:
A client-side attack targets vulnerabilities on the user's device or application rather than the
server or network. This could involve exploiting weaknesses in web browsers, plugins, or other
client-side software.
Social engineering toolkit is one of the powerful packages which contain tons of social
engineering tools. SET comes pre-installed in kali linux. Set can be downloaded into other
operating systems too. SET is an open source framework which is freely available.
Social Engineering toolkit have ability to perform various attacks like tabnapping, site cloning,
mass mailing, arduino based attacks and much more. Website attack vectors are generally used to
perform phishing type attacks.
11. It will ask for IP Address on which the Site will be cloned, Open a terminal and type
“ifconfig” to check the ip address. Provide the ip address of kali machine.
12. Now, it will ask for the URL of the website to clone. Input the desired website.
13. This will take a little time and starts cloning. If the apache service is not on, it will ask for
turning it on. Input with ‘y ‘ to turn on the apache service.
14. Now send the ”ip address” on which the site has been cloned. Remember, target and attacker
needs to be on same network.
15. Passwords will stored in directory named “VAR/WWW “ in the log file.
7. To mass attack single email, select (1) option, else select (2) option.
8. Select (1) for bombing via own gmail account, else select (2) for creating own server or open
relay.
12. Set the priority. For high priority select ‘yes’ else ‘no’.
13. Enter the email subject. Select the type of mail. For html input with ‘h’ and for plain input
with ‘p’.
14. Input the body of message and once the body is completed, end with using “END”.
Social engineering inside the corporate is performed successfully due to lack of training of
employees, inter-personal controversies or by the ex-employee. Social engineering can be
prevented to a great extent if the proper training is given to the employees.
2. Proper training.
3. Ensure about the received phone call or text message before giving information.
6. Don’t visit the links which are detected by the browser as harmful.