Lab Manual Format Cyber Security Workshop - BCS453. - DS
Lab Manual Format Cyber Security Workshop - BCS453. - DS
OF
Cyber Security Workshop
(BCS-453)
B.TECH, 2nd Year, Semester -IV
2024-25
Faculty Name:
MANUAL CONTENTS
This manual is intended for the 2nd year students of Computer Science & Engineering in the subject of
Cyber Security Workshop . This manual typically contains practical/lab sessions related Cyber security
covering various aspects related to the subject of enhanced understanding.
Students are advised to thoroughly go through this manual rather than only topics mentioned in the syllabus as
practical aspects are the key to understanding and conceptual visualization of theoretical aspects covered in
the books.
excellence. M2.To develop technocrats with creative skills and leadership qualities, to solve local and
global challenges.
M3. To impart human values and ethics in students, to make them socially and eco-friendly responsible.
Vision of the Department
“To produce globally competent professionals having social values and commitment to serve the global
needs with the ability to work in an interdisciplinary environment."
M2."To create a conducive environment in which students can explore computational problems and
analyze them to identify the optimal solutions."
M3."To strive for continual enhancement of technical knowledge & innovation through industry
interface to accomplish global needs."
Program Educational Objectives(PEOs)
PEO1:Students must be able to apply software engineering principles to analyze complex computing
problems and identify their solutions.
PEO2:Students must be able to analyze, design, and implement the latest technology-driven projects.
PEO3:Students must be able to work in a collaborative environment and understand the ethical , social,
and economic impact of their work.
Program Outcomes(POs)
PO’s An Engineering Graduate of the Department of Computer Science and Engineering Program will be able
to demonstrate:
PO2PROBLEM ANALYSIS: Analyze a problem and identify the computing requirements appropriate to its
solution.
PO5 MODERNTOOLUSAGE: Use appropriate techniques, resources, and modern engineering and IT tools
necessary for computer engineering practice.
PO6 THE ENGINEER AND SOCIETY: Show the understanding of local and global impact of computing
on individuals, organizations and society.
PO7 ENVIRONMENT AND SUSTAINABILITY: Integrate IT-based solutions in environmental contexts,
and demonstrate the knowledge of need for sustainable development.
PO8 ETHICS: Demonstrate the knowledge of professional and ethical responsibilities along with the norms
of the engineering practice.
PO9 INDIVIDUAL AND TEAM WORK: Demonstrate leadership and an ability to work as a member with
responsibility to function on multi-disciplinary teams to accomplish a common goal.
PO10 COMMUNICATION: Demonstrate effectively communicate skills in both oral and written form with
a range of audiences.
PO11 PROJECT MANAGEMENT AND FINANCE: Apply the knowledge and understanding of
engineering and management principles to design, planned budget and propose IT project for an identified
need within a specific scope.
PO12 LIFE-LONG LEARNING: Developed confidence to acquire new knowledge in the computing
discipline and to engage in life-long learning.
Program Specific Outcomes(PSOs)
PSO1: Able to design and implement the data structures and algorithms to deliver quality software products.
PSO2: Able to apply Artificial Intelligence and Machine Learning concepts to solve society-related needs.
Course Evaluation Scheme
Course Objectives:
The teacher will explain:
1. To train the students in packet analysis using wire shark.
2. To train the students in web application security using DVWA.
Pre- requisite:
Course Outcomes (COs)
Bloom's
Course Outcomes: The students should be able to:
Level
CO1 To analyze network traffic using Wireshark, understand key protocols like L4
HTTP, DNS, and SMTP, and detect suspicious activities such as
unauthorized access or malware communication. They will also develop
skills to identify security threats and apply defensive measures to protect
network integrity.
CO2 To analyze malware traffic to identify signs of command-and-control (C2) L4
communication and data infiltration. They will also learn to capture and
analyze plaintext password transmissions using Wireshark, demonstrating
security vulnerabilities and the importance of encryption in protecting
sensitive data.
CO3 To perform and analyze ARP poisoning attacks using tools like Ettercap, L3
understanding how they facilitate Man-in-the-Middle (MITM) attacks.
They will also gain hands-on experience with SQL Injection attacks using
DVWA, learning how attackers exploit input fields to extract, modify, or
delete database information and how to implement preventive security
measures.
CO4 To identify and exploit Cross-Site Scripting (XSS) vulnerabilities in L4
DVWA, demonstrating how malicious scripts can be used for cookie theft
and website defacement. They will also understand Cross-Site Request
Forgery (CSRF) attacks, learning how attackers manipulate authenticated
users into performing unintended actions and implementing security
measures to prevent such threats.
CO5 To identify and exploit File Inclusion vulnerabilities (LFI & RFI) in L4
DVWA, understanding how attackers can execute malicious files and
arbitrary code on a server. They will also gain hands-on experience with
Brute-Force and Dictionary Attacks on login pages, highlighting the risks
of weak passwords and the importance of strong authentication policies.
CO-PO-PSO Mapping
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO PSO
1 2
CO1 3 3 - 2 2 2 - - 3 - - 3 3 3
CO2 3 2 - 2 3 2 - - 3 - - 2 2 2
CO3 2 2 - 3 2 3 - - 3 - - 2 2 2
CO4 3 3 - 2 3 2 - - 3 - - 2 3 3
CO5 2 3 - 2 3 2 - - 3 - - 2 3 3
Avg. 2.6 2.6 - 2.2 2.6 2.2 - - 3 - - 2.2 2.6 2.6
The extent of mapping is as follows: 1 for low, 2 for moderate, 3 for high &”-” for No correlation between
CO & PO.
S.No. List of Programs as per AKTU
1. Basic Packet Inspection: Capture network traffic using Wire shark and analyze basic
protocols like HTTP, DNS, and SMTP to understand how data is transmitted and
received.
2. Detecting Suspicious Activity: Analyze network traffic to identify suspicious patterns,
such as repeated connection attempts or unusual communication between hosts.
3. Malware Traffic Analysis: Analyze captured traffic to identify signs of malware
communication, such as command-and-control traffic or data infiltration.
4. Password Sniffing: Simulate a scenario where a password is transmitted in plaintext.
Use Wireshark to capture and analyze the packets to demonstrate the vulnerability and
the importance of encryption.
5. ARP Poisoning Attack: Set up an ARP poisoning attack using tools like Ettercap.
Analyze the captured packets to understand how the attack can lead to a
Man-in-the-Middle scenario.
1. SQL Injection: Use DVWA to practice SQL injection attacks. Demonstrate how an
attacker can manipulate input fields to extract, modify, or delete database information.
2. Cross-Site Scripting (XSS): Exploit XSS vulnerabilities in DVWA to inject malicious
scripts into web pages. Show the potential impact of XSS attacks, such as stealing
cookies or defacing websites.
3. Cross-Site Request Forgery (CSRF): Set up a CSRF attack in DVWA to demonstrate
how attackers can manipulate authenticated users into performing unintended actions.
4. File Inclusion Vulnerabilities: Explore remote and local file inclusion vulnerabilities
in DVWA. Show how attackers can include malicious files on a server and execute
arbitrary code.
5. Brute-Force and Dictionary Attacks: Use DVWA to simulate login pages and
demonstrate brute-force and dictionary attacks against weak passwords. Emphasize
the importance of strong password policies.
S.No. List of Programs with enhancement of Faculty
1. Basic Packet Inspection: Capture network traffic using Wire shark and analyze basic
protocols like HTTP, DNS, and SMTP to understand how data is transmitted and
received.
2. Detecting Suspicious Activity: Analyze network traffic to identify suspicious patterns,
such as repeated connection attempts or unusual communication between hosts.
3. Malware Traffic Analysis: Analyze captured traffic to identify signs of malware
communication, such as command-and-control traffic or data infiltration.
4. Password Sniffing: Simulate a scenario where a password is transmitted in plaintext.
Use Wireshark to capture and analyze the packets to demonstrate the vulnerability and
the importance of encryption.
5. ARP Poisoning Attack: Set up an ARP poisoning attack using tools like Ettercap.
Analyze the captured packets to understand how the attack can lead to a
Man-in-the-Middle scenario.
6. ICMP Packet Analysis (Ping and Traceroute) Use ping and traceroute commands and
capture ICMP packets. Examine TTL values and round-trip times. Detect network
latency or packet loss issues.
1. SQL Injection: Use DVWA to practice SQL injection attacks. Demonstrate how an
attacker can manipulate input fields to extract, modify, or delete database information.
2. Cross-Site Scripting (XSS): Exploit XSS vulnerabilities in DVWA to inject malicious
scripts into web pages. Show the potential impact of XSS attacks, such as stealing
cookies or defacing websites.
3. Cross-Site Request Forgery (CSRF): Set up a CSRF attack in DVWA to demonstrate
how attackers can manipulate authenticated users into performing unintended actions.
4. File Inclusion Vulnerabilities: Explore remote and local file inclusion vulnerabilities
in DVWA. Show how attackers can include malicious files on a server and execute
arbitrary code.
5. Brute-Force and Dictionary Attacks: Use DVWA to simulate login pages and
demonstrate brute-force and dictionary attacks against weak passwords. Emphasize
the importance of strong password policies.
INDEX
S.
COs BL Date Sign.
No. EXPERIMENT
Aim: Basic Packet Inspection: Capture network traffic using Wire shark and analyze basic
protocols like HTTP, DNS, and SMTP to understand how data is transmitted and received.
Solution
d. During the capture process, Wireshark will show the following screen
e. Once you have captured all the packets needed, use the same buttons or menu options to
Wireshark shows you three different panes for inspecting packet data. The Packet List, the top pane,
lists all the packets in the capture. When you click on a packet, the other two panes change to show
you the details about the selected packet. You can also tell if the packet is part of a conversation.
Here are details about each column in the top pane:
No.: This is the number order of the packet captured. The bracket indicates that this packet is
part of a conversation.
Time: This column shows how long after you started the capture this particular packet was
captured. You can change this value in the Settings menu to display a different option.
Source: This is the address of the system that sent the packet.
Protocol: This is the type of packet. For example: TCP, DNS, DHCPv6, or ARP.
Length: This column shows you the packet’s length, measured in bytes.
Info: This column shows you more information about the packet contents, which will vary
depending on the type of packet.
Packet Details, the middle pane, shows you information about the packet depending on the packet
type. You can right-click and create filters based on the highlighted text in this field.
The bottom pane, Packet Bytes, displays the packet exactly as it was captured in hexadecimal.
When looking at a packet that is part of a conversation, you can right-click the packet and select
Follow to see only the packets that are part of that conversation.
Wireshark filters
Filters allow you to view the capture the way you need to see it to troubleshoot the issues at hand.
Below are several filters.
Capture filters limit the captured packets by the chosen filter. If the packets don’t match the filter,
Wireshark won’t save them. Examples of capture filters include:
a. host IP-address: This filter limits the captured traffic to and from the IP address
b. net 192.168.0.0/24: This filter captures all traffic on the subnet
c. dst host IP-address: Capture packets sent to the specified host
d. port 53: Capture traffic on port 53 only
e. port not 53 and not arp: Capture all traffic except DNS and ARP traffic
Wireshark display filters change the view of the capture during analysis. After you’ve stopped the
packet capture, use display filters to narrow down the packets in the Packet List to troubleshoot
your issue.
a) ip.src==IP-address and ip.dst==IP-address This filter shows packets sent from one
computer (ip.src) to another (ip.dst). You can also use ip.addr to show packets to and from
that IP.
b) tcp.port eq 25: This filter will show you all traffic on port 25, which is usually SMTP traffic
c) icmp: This filter will show you only ICMP traffic in the capture, most likely they are pings
d) ip.addr != IP_address: This filter shows you all traffic except the traffic to or from the
specified computer
Experiment No:2
Aim: Detecting Suspicious Activity: Analyze network traffic to identify suspicious patterns,
such as repeated connection attempts or unusual communication between hosts.
Solution:
The Hypertext Transfer Application Layer Protocol (HTTP) utilizes the internet to establish protocols
whenever the HTTP client/server transmits/receives HTTP requests.
Start a Wireshark capture -> Open a web browser -> Navigate to any HTTPS-based website -> Stop
the Wireshark capture.
Input ' ssl' in the filter box to monitor only HTTPS traffic -> Observe the first TLS packet -> The
destination IP would be the target IP (server).
A standard port scan takes advantage of the TCP three-way handshake. The attacker sends the SYN
packet to the target port. The port is considered open when he gets SYN+ACK as a response, whereas
the arrival of RST shows the port is closed. After receiving SYN+ACK, the hacker would send an
ACK packet to establish a TCP connection.
Analyze TCP SYN traffic
Input ‘tcp.port == 80’ to see only TCP traffic connected to the webserver connection.
Observe the TCP [SYN] packet. Expand Ethernet and observe the destination address that is the
default gateway address; whereas, the source is your own MAC address.
To check the IP details, observe Internet Protocol Version 4; in our case, the destination IP is Googles'
web server IP, and the source IP is the local IP address.
To view TCP details, observe Transmission Control Protocol, like port numbers. Monitor the flag
values. SYN, which is enabled, shows the initial section of the TCP three-way handshake.
Take a look at the TCP [SYN, ACK] packet. Expand Ethernet and observe the destination address
now would be your own MAC address; whereas the source is the default gateway address.
Monitor the acknowledgement code. It's worth noting that the number is one relative ACK number. The
real acknowledgement value is one higher than the previous segment's identifier.
Monitor the flag values. [SYN, ACK], which is enabled, shows the second section of the TCP
three-way handshake.
Analyze SYN flood attack
SYN flood occurs when an attacker delivers a substantial amount of SYN packets to a server using
fake IPs, causing the server to respond with an SYN+ACK and keep its ports partially open,
expecting a response from an invisible client.
By overwhelming a victim with SYN packets, an attacker can effectively overrun the victim's
resources. In this state, the victim fights with traffic, which causes processor and memory usage to
rise, eventually exhausting the victim's resources.
Use the hping3 tool to flood the victim IP. Simultaneously, start capturing the traffic on Wireshark.
Input 'tcp.flags.syn == 1' in the filter box to view SYN packets flood.
Notice a lot of SYN packets with no time lag.
Let’s simulate a Denial of Service (DoS) attack to analyze it via Wireshark. For the demo, I am using
the macof tool, the component of the Dsniff suit toolkit, and flooding a surrounding device's switch
with MAC addresses.
The image below shows IP address is generating requests to another device with the same data size
repeatedly. This sort of traffic shows a standard network DoS attack.
For a DDoS attack, use the macof tool again to generate traffic. Observe the fake source and destination
IP addresses are sending many packets with similar data sizes.
Experiment 3:
Aim: Malware Traffic Analysis: Analyze captured traffic to identify signs of malware
communication, such as command-and-control traffic or data infiltration.
Analyzing captured network traffic for signs of malware communication is a complex task that
requires knowledge of networking protocols, security, and various tools. Below is a general guide
on how you might approach malware traffic analysis:
Prerequisites:
1.Captured Traffic:
● Have a packet capture (PCAP) file containing the network traffic you want to analyze.
Tools:
● Use tools like Wireshark, tcpdump, or other network analysis tools.
2.Filter Traffic:
● Use filters to narrow down your analysis. For example, filter by IP address, protocols, or
time range.
3.Analyze Protocols:
● Look for traffic on non-standard ports. Malware often uses uncommon ports for
communication.
● Malware may use domain names for command-and-control. Look for unusual or suspicious
domain names.
6.HTTP Analysis:
● Analyze HTTP traffic for unusual User-Agent strings, POST requests with large data, or
URLs with encoded data.
● Malware may beacon to a C2 server at regular intervals. Look for patterns in traffic spikes.
● Malware may encrypt its communication. Look for unusual SSL/TLS handshake patterns
or self-signed certificates.
9.Identify Patterns:
● Look for patterns in communication. For example, repetitive or obfuscated data in payload
may indicate encoding or encryption.
● Look for large amounts of data leaving the network. Unusual patterns in outbound traffic
may indicate data exfiltration.
● Understand the normal behavior of the network. Deviations from the baseline may indicate
malware.
● Use threat intelligence feeds to check if any observed IP addresses or domains are
associated with known malicious activities.
● Record your findings, including IP addresses, domains, and any other indicators of
compromise (IoCs).
Caution:
● Avoid Running Untrusted Code: Don't run untrusted code or execute unknown binaries
in a live environment.
Remember that malware is often designed to evade detection, so analysis may require expertise in
both networking and cybersecurity. If you're not confident in your abilities, consider seeking
assistance from a professional cybersecurity expert.
In Wireshark, you can often identify potentially malicious files by analyzing the network traffic
and looking for suspicious patterns or activities. While Wireshark itself doesn't detect or label files
as malicious, it can help you identify files that are being transferred over the network, which may
include malware or other malicious content.
Here are some examples of potentially malicious files that you might encounter in Wireshark:
1. Executable Files (.exe, .dll, .bat): Malware often disguises itself as executable files. Look
for file transfers with extensions like .exe, .dll, .bat, etc.
2. Compressed Archives (.zip, .rar): Malware can be compressed into archive files to evade
detection. Watch out for transfers of compressed files, especially if they're being downloaded from
suspicious or untrusted sources.
3. Documents with Embedded Macros (.doc, .docx, .xls, .xlsx): Malicious documents often
contain macros that can execute code when opened. Pay attention to transfers of documents with
macros enabled, especially if they're from unknown senders.
4. Script Files (.js, .vbs, .ps1): Malware may be distributed in the form of script files that
execute commands on the victim's system. Look for transfers of script files, particularly if they're
being downloaded from suspicious URLs.
5. Trojan Horse Payloads: Trojans often carry malicious payloads disguised as legitimate
files. Watch for unexpected file transfers that match the characteristics of known Trojan payloads.
6. Exploit Payloads: Exploit payloads can be transferred over the network to exploit
vulnerabilities in software. Look for files that match known exploit signatures or are transferred
alongside suspicious network activity.
7. Backdoors and Remote Access Tools (RATs): Malware designed for remote access often
includes files used for controlling compromised systems. Watch for transfers of files associated
with known RATs or backdoors.
8. Malicious Documents with Embedded Objects: Malware can be embedded within
documents as objects (e.g., embedded Flash objects). Look for transfers of documents containing
embedded objects, especially if they're being downloaded from suspicious sources.
It's important to note that the presence of these files in network traffic doesn't necessarily mean
that they are malicious. However, their presence in combination with other suspicious activity
could indicate a security threat. Always exercise caution and use additional security tools and
practices to analyze and mitigate potential risks.
Experiment No:4
Solution:
Password Sniffing:-Password sniffing is a type of network attack in which an attacker intercepts data
packets that include passwords. The attacker then uses a password-cracking program to obtain the
actual passwords from the intercepted data.Password sniffing can be used to obtain passwords for any
type of account, including email, social media, and financial accounts.
Step 1:First of all, open your Wireshark tool in your window or in Linux virtual machine. and start
capturing the network. suppose you are capturing your wireless fidelity.
Step:2 After starting the packet capturing we will go to the website and login the credential on that
website as you can see in the image.
Step-3: Now after completing the login credential we will go and capture the password in
Wireshark. for that we have to use some filter that helps to find the login credential through the
packet capturing.
Step 4: Wireshark has captured some packets but we specifically looking for HTTP packets. so in
the display filter bar we use some command to find all the captured HTTP packets. as you can see
in the below image the green bar where we apply the filter.
Step 5: So there are some HTTP packets are captured but we specifically looking for form data that
the user submitted to the website. for that, we have a separate filter .
As we know that there are main two methods used for submitting form data from web pages like
login forms to the server. the methods are-
● GET
● POST
Step 6: So firstly for knowing the credential we use the first method and apply the filter for the GET
methods as you can see below.
As you can see in the image there are two packets where the login page was requested with a GET
request as well, but there is no form data submitted with a GET request.
Step 7: Now after checking the GET method if we didn’t find the form data, then we will try the
POST method for that we will apply the filter on Wireshark as you can see.
As you can see we have a packet with form data click on the packet with user info and the application
URL encoded. and click on the down-
HTML form URL Encoded where the login credential is found. login credential as it is the same
that we filed on the website in step 2.
Experiment No:5
Aim: ARP Poisoning Attack: Set up an ARP poisoning attack using tools like Ettercap.
Analyze the captured packets to understand how the attack can lead to a Man-in-the-Middle
scenario.
Solution:
When we do that, it opens a new window asking us what interface we want to use and defaults
3. Click "OK", ettercap launches it sniffing and loads its plugins.
4. Click on the "Hosts" tab and you will see a menu that includes "Scan for Hosts". Click on it and ettercap
will begin scanning the network for hosts.
5. Now, using that same "Hosts" tab, click on "Hosts List". This will display all the
hosts that ettercap has discovered on your network as seen in the screenshot below.
6. Now, select one of the hosts that will be the target of this attack in the window by clicking on
it and then click on "Add to Target 1" at the bottom of the window. When you do so, ettercap
will add that host as the first target in our MiTM attack as seen in the screenshot below. Next,
select the second host in this attack and then click "Add to Target 2".
7. Finally, go to the menu above and click on MITM tab and the drop down menu will have a
selection called "ARP Poisoning" as seen in the screenshot below.
8. Select it and it will open a pop window like below. Select "Sniff remote connections".When we
press OK, ettercap will begin ARP poisoning and you will see ettercap respond in its main
windows with the message below.
Now, we have successfully placed ourselves between the two targets systems and all their traffic
must flow through us
Module 2: Web Application Security using DVWA
Experiment 6
Aim: SQL Injection: Use DVWA to practice SQL injection attacks. Demonstrate how an
attacker can manipulate input fields to extract, modify, or delete database information.
DVWA is a deliberately vulnerable web application designed for practicing security testing
techniques. Here's a general outline of how you might conduct a SQL injection attack using
DVWA:
1. Setup DVWA: First, you need to set up DVWA on your local machine or a virtual
server. You can download DVWA from its official GitHub repository and follow the
installation instructions.
2. Access DVWA: Once DVWA is set up, access it through your web browser. By
default, DVWA comes with a login page.
4. Select SQL Injection: In DVWA, there's usually a section dedicated to SQL injection
under the "DVWA Security" tab. Set the security level to low initially, and later you can
increase the security level to test more sophisticated attacks.
5. Identify Input Fields: Look for input fields on the web pages where user input is
processed and sent to the database. Common examples include login forms, search bars, and
registration forms.
6. Perform SQL Injection: In the input fields identified, start by entering basic SQL
injection payloads to see if the application is vulnerable. For example, try entering ' OR 1=1
-- in a login form's username field. If successful, this could log you in without a valid
username and password.
7. Extract Data: Once you've confirmed the vulnerability, you can start extracting data
from the database. Use SQL injection techniques like UNION-based attacks or error- based
attacks to retrieve sensitive information from the database. For example, you might use a
payload like ' UNION SELECT username, password FROM users -- to extract usernames and
passwords from the database.
8. Modify or Delete Data: If the application allows it and you have the necessary
permissions, you can modify or delete data from the database using SQL injection. Craft SQL
queries that perform these actions and inject them into vulnerable input fields.
9. Test Security Levels: Gradually increase the security level in DVWA and see how it
affects your ability to perform successful SQL injection attacks. Higher security levels often
mean better defenses against common SQL injection techniques.
Remember to always practice responsible disclosure and only perform SQL injection attacks on
systems you have permission to test. Unauthorized access to systems can have serious legal
consequences.
Experiment 7
Aim: Cross-Site Scripting (XSS): Exploit XSS vulnerabilities in DVWA to inject malicious
scripts into web pages. Show the potential impact of XSS attacks, such as stealing cookies
or defacing websites.
● Malicious JavaScript has access to all the objects that the rest of the web page has
access to. This includes access to the user’s cookies. Cookies are often used to store
session tokens. If an attacker can obtain a user’s session cookie, they can impersonate
that user, perform actions on behalf of the user, and gain access to the user’s sensitive
data.
● JavaScript can read the browser DOM and make arbitrary modifications to it. Luckily,
this is only possible within the page where JavaScript is running.
● JavaScript can use the XMLHttpRequest object to send HTTP requests with arbitrary
content to arbitrary destinations.
● JavaScript in modern browsers can use HTML5 APIs. For example, it can gain access to
the user’s geolocation, webcam, microphone, and even specific files from the user’s file
system. Most of these APIs require user opt-in, but the attacker
can use social engineering to go around that limitation.
The above, in combination with social engineering, allow criminals to pull off advanced attacks
including cookie theft, planting trojans, keylogging, phishing, and identity theft. XSS
vulnerabilities provide the perfect ground to escalate attacks to more serious ones. Cross-site
Scripting can also be used in conjunction with other types of attacks, for example, Cross-Site
Request Forgery (CSRF).
There are several types of Cross-site Scripting attacks: stored/persistent XSS,
reflected/non-persistent XSS, and DOM-based XSS. You can read more about them in an article
titled Types of XSS.
1. To run malicious JavaScript code in a victim’s browser, an attacker must first find a way
to inject malicious code (payload) into a web page that the victim visits.
2. After that, the victim must visit the web page with the malicious code. If the attack is
directed at particular victims, the attacker can use social engineering and/or phishing to
send a malicious URL to the victim.
For step one to be possible, the vulnerable website needs to directly include user input in its
pages. An attacker can then insert a malicious string that will be used within the web page and
treated as source code by the victim’s browser. There are also variants of XSS attacks where the
attacker lures the user to visit a URL using social engineering and the payload is part of the link
that the user clicks.
The following is a snippet of server-side pseudocode that is used to display the most recent
comment on a web page:
The above script simply takes the latest comment from a database and includes it in an HTML page.
It assumes that the comment printed out consists of only text and contains no HTML tags or other
code. It is vulnerable to XSS, because an attacker could submit a comment that contains a malicious
payload, for example:
The web server provides the following HTML code to users that visit this web page:
When the page loads in the victim’s browser, the attacker’s malicious script executes. Most
often, the victim does not realize it and is unable to prevent such an attack.
To learn more about how XSS attacks are conducted, you can refer to an article titled A
comprehensive tutorial on cross-site scripting.
<script> tag
The <script> tag is the most straightforward XSS payload. A script tag can reference external
JavaScript code or you can embed the code within the script tag itself.
JavaScript events
JavaScript event attributes such as onload and onerror can be used in many different tags. This is a
very popular XSS attack vector.
<body> tag
An XSS payload can be delivered inside the <body> by using event attributes (see above) or
other more obscure attributes such as the background attribute.
<img> tag
Some browsers execute JavaScript found in the <img> attributes.
<iframe> tag
The <iframe> tag lets you embed another HTML page in the current page. An IFrame may
contain JavaScript but JavaScript in the IFrame does not have access to the DOM of the parent
page due to the Content Security Policy (CSP) of the browser. However, IFrames are still very
effective for pulling off phishing attacks.
<input> tag
In some browsers, if the type attribute of the <input> tag is set to image, it can be manipulated to embed a
script.
<link> tag
The <link> tag, which is often used to link to external style sheets, may contain a script.
<table> tag
The background attribute of the <table> and <td> tags can be exploited to refer to a script instead of an
image.
<div> tag
The <div> tag, similar to the <table> and <td> tags, can also specify a background and therefore embed
a script.
<object> tag
The <object> tag can be used to include a script from an external site.
For more details, refer to the following articles: Preventing XSS Attacks and How to Prevent
DOM-based Cross-site Scripting. You can also find useful information in the XSS Prevention
Cheat Sheet maintained by the OWASP organization.
Step 1: Train and maintain awareness
To keep your web application safe, everyone involved in building the
web application must be aware of the risks associated with XSS
vulnerabilities. You should provide suitable security training to all your
developers, QA staff, DevOps, and SysAdmins. You can start by
referring them to this page.
CSRF attacks exploit the trust that a web application has in a user's browser. An attacker tricks
an authenticated user into unknowingly executing malicious actions on a web application they
are logged into. This can be achieved by crafting a malicious web page or email containing code
that automatically submits requests to the target web application on behalf of the user.
However, it's crucial to understand the importance of protecting against CSRF attacks and to
implement appropriate security measures in web applications, such as:
1. CSRF tokens: Use unique tokens in forms that are submitted to the server with each
request. The server verifies these tokens to ensure that the request originated from the
legitimate user and not from an attacker's site.
2. SameSite cookies: Set the SameSite attribute on cookies to restrict their usage to
first-party context, preventing them from being sent in cross-origin requests.
3. HTTP Referer header: Check the Referer header on the server-side to verify that requests
originated from the expected source.
4. Use of security headers: Implement security headers like Content-Security-Policy (CSP)
and X-Frame-Options to mitigate the risk of CSRF attacks.
5. Session management: Implement robust session management practices, such as session
expiration, session invalidation on logout, and session rotation.
If you're interested in learning more about web security and how to defend against CSRF attacks,
I recommend studying reputable resources and participating in ethical hacking courses or
workshops conducted by recognized cybersecurity organizations. Remember to always use your
skills responsibly and ethically to contribute positively to cybersecurity efforts.
Experiment 9:
Aim: File Inclusion Vulnerabilities: Explore remote and local file inclusion vulnerabilities
in DVWA. Show how attackers can include malicious files on a server and execute
arbitrary code.
File Inclusion Vulnerabilities, both remote and local, occur when a web application allows a user
to include files on the server that should not be accessible to them. This could enable attackers to
include malicious files, such as scripts or configuration files, and execute arbitrary code on the
server.
However, understanding the basics of File Inclusion Vulnerabilities and how to defend against
them is important for improving web application security. Here are some general guidelines for
mitigating File Inclusion Vulnerabilities:
1. Input Validation: Always validate and sanitize user input, especially when including
files or paths. Ensure that only allowed and expected inputs are accepted.
2. File Whitelisting: Maintain a whitelist of allowed files or directories that can be included
by the application. Reject requests that attempt to include files outside the whitelist.
3. Path Hardening: Avoid using user-controlled input directly in file paths. Use absolute
paths or relative paths with strict limitations to prevent directory traversal attacks.
5. File Permissions: Set appropriate file permissions to restrict access to sensitive files and
directories. Ensure that files containing sensitive information or executable code are not
accessible to unauthorized users.
6. Regular Security Audits: Conduct regular security audits and penetration testing to
identify and address vulnerabilities in the application code.
If you're interested in learning more about web security and how to defend against file inclusion
vulnerabilities, I recommend studying reputable resources and participating in ethical hacking
courses or workshops conducted by recognized cybersecurity organizations. Remember to
always use your skills responsibly and ethically to contribute positively to cybersecurity efforts.
Experiment 10
Aim: Brute-Force and Dictionary Attacks: Use DVWA to simulate login pages and
demonstrate brute-force and dictionary attacks against weak passwords. Emphasize the
importance of strong password policies.
1.Setting up DVWA:
● Ensure it's configured with a database backend (e.g., MySQL) and properly secured.
● In DVWA, there are security levels ranging from low to high. Set it to low for
demonstration purposes.
● This makes DVWA vulnerable to simple attacks, allowing us to demonstrate the concepts
without causing harm.
4.Brute-Force Attack:
● Specify the target URL (DVWA login page), the username (usually "admin"), and set a
password list.
● Execute the attack and observe how the tool systematically tries different passwords until
it finds the correct one.
● This demonstrates the danger of weak passwords and the effectiveness of brute- force
attacks.
5.Dictionary Attack:
● After demonstrating the attacks, emphasize the importance of strong password policies.
● Encourage the use of long, complex passwords that include a mix of uppercase and
lowercase letters, numbers, and special characters.
● Advocate for the use of passphrases, which are longer and easier to remember than
traditional passwords.
● Recommend enabling multi-factor authentication (MFA) wherever possible to add an
extra layer of security.
● Finally, educate users about the risks of weak passwords and the importance of practicing
good password hygiene.
● Encourage regular password changes and discourage password reuse across multiple
accounts.
● Provide guidance on how to create and manage strong passwords securely.
By simulating these attacks in a controlled environment like DVWA and
emphasizing the importance of strong password policies, you can effectively
demonstrate the risks associated with weak passwords and educate users on best
practices for password security. Remember to conduct such demonstrations
responsibly and ethically, with the intention of improving awareness and
promoting better cybersecurity practices.
Experiment 11
Aim: Analyze ICMP (Internet Control Message Protocol) packets using Wireshark while
executing the ping and traceroute commands. By capturing packets in Wireshark, we can
examine TTL (Time-To-Live) values, round-trip times (RTT), and detect network latency or
packet loss issues.
Tools Required
ping 8.8.8.8
1. Stop the Wireshark capture after executing ping and traceroute.
2. Use the filter icmp in Wireshark’s filter bar to display only ICMP packets.
3. Examine:
o ICMP Echo Requests and Replies (for ping).
o ICMP Time Exceeded messages (for traceroute).
o TTL values: Each router decreases the TTL by 1 until it reaches 0, triggering an ICMP Time
Exceeded response.
o Round-trip time (RTT): The delay between request and reply packets.
o Packet loss: If Echo Requests are sent but no replies are received, it may indicate network
issues.
● Ping Results:
o A normal response shows consistent RTT values.
o High RTT values indicate latency.
o Packet loss suggests network congestion or faulty links.
● Traceroute Results:
o Each router (hop) along the path is identified.
o Sudden increases in RTT may indicate congestion or routing issues.
o Missing hops may suggest firewalls blocking ICMP packets.
Conclusion
Wireshark provides a visual representation of ICMP packet exchanges during ping and traceroute. By
analyzing TTL values, RTT, and packet loss, we can diagnose network performance issues, detect bottlenecks,
and troubleshoot connectivity problems.
Assessment Criteria:
Record 3 Marks
Execution 4 Marks
Viva 3 Marks
SQL Injection
26. What is SQL Injection, and how does it work?
27. How can an attacker extract data using SQL Injection?
28. What are the different types of SQL Injection attacks?
29. How can developers prevent SQL Injection vulnerabilities?
30. What is parameterized querying, and why is it important?
Cross-Site Scripting (XSS)
31. What is Cross-Site Scripting (XSS), and how does it work?
32. What are the different types of XSS attacks?
33. How can an attacker use XSS to steal cookies?
34. What security measures can prevent XSS attacks?
35. How does Content Security Policy (CSP) help mitigate XSS?
Cross-Site Request Forgery (CSRF)
36. What is CSRF, and how does it exploit authenticated users?
37. How does CSRF differ from XSS?
38. What is the role of anti-CSRF tokens in preventing attacks?
39. How can SameSite cookies help mitigate CSRF attacks?
40. What are some real-world examples of CSRF attacks?
File Inclusion Vulnerabilities
41. What is Local File Inclusion (LFI) and Remote File Inclusion (RFI)?
42. How can attackers exploit file inclusion vulnerabilities?
43. What are some common consequences of file inclusion attacks?
44. How can developers secure applications against LFI and RFI?
45. What are some real-world examples of file inclusion attacks?
Brute-Force and Dictionary Attacks
46. What is a brute-force attack, and how does it work?
47. How does a dictionary attack differ from a brute-force attack?
48. What tools can be used to perform brute-force attacks?
49. How can account lockout policies prevent brute-force attacks?
50. What is the importance of strong passwords in mitigating brute-force attacks?