CSE Cyber Security LAB Manual
CSE Cyber Security LAB Manual
LAB MANUAL
LIST OF EXPERIMENTS
Experiment 1
Aim: Capture network traffic using Wireshark and analyze basic protocols like HTTP, DNS and SMTP to
understand how data is transmitted and received.
Software Used: Wireshark
Procedure:
1. https://www.wireshark.org/
Download wireshark app and install it.
2. Select a network on which data is being transmitted and received like wi-fi n/w or ethernet.
3. To start or stop the traffic on the network, press ctrl+E.
4. In data packet capturing on top frame, what you will see:
Number | Time | Source | Destination | Protocol | Length | Info
Middle frame example:
Frame
Linux cooked capture
Internet protocol version, Source, Destination,
Transmission control protocol, src port, dst port, seq. length
WIRESHARK FILTERS
There are two ways to filter:
Build the filter via the fancy GUI (Expression button)
Type of filter into the “Apply a display filter” entry field (below the toolbar)
https://wiki.wireshark.org/DisplayFilters
MOST COMMON WIRESHARK FILTERS
ip.src==192.168.246.154
ip.dst==192.168.246.154
tcp.srcport==443
tcp.port eq=80
Filter for http and https traffic:
Tcp.port==443 or tcp.port==80
ssl or http
tcp.port in {80 443 8080}
tcp.port==80 || tcp.port==443 || tcp.port==8080
MOST COMMON WIRESHARK FILTERS
Filter for protocol:
tcp
udp
dns
IP address:
ip.addr==192.168.1.1
! (ip.addr==192.168.1.1)
Bottom frame:
Data
MOST COMMON WIRESHARK FILTERS
Example for web traffic:
http.request.uri==”website name”
https://demo.testfire.net
http.response.code==200
http.request.method==”GET”
tcp contains “admin”
Output:
Figure 2: Drilling down into a packet to identify a network problem using Wireshark
Experiment 2
Objective - Detecting Suspicious Activity: Analyze network traffic to identify suspicious patterns.
Tool Used: Open WireShark
Procedure –
1. Open Wireshark.
2. Goto Wi-Fi.
4. On inspection of the protocol hierarchy, if the ‘Data’ tab is not visible, no suspicious activity is
detected as per Wireshark.
Output -
1. On inspection of the protocol hierarchy, if the ‘Data’ tab is visible, no suspicious activity is detected
as per Wireshark. File 1.
2. If ‘Data’ section is visible, it could be suspicious traffic. Right click Apply as Filter Selected.
Experiment 3
Objective - Malware Traffic Analysis: Analyze captured traffic to identify signs of malware
communication.
Procedure –
5. Open Wireshark.
6. Goto Wi-Fi.
Output -
3. Goto Virustotal.com and upload the saved file there to inspect for any possible malwares.
Experiment – 4
Objective - Malware Traffic Analysis: Analyze captured traffic to identify signs of malware
communication.
Procedure –
1. Open Wireshark.
2. Goto Wi-Fi.
Output -
6. Goto Virustotal.com and upload the saved file there to inspect for any possible malwares.
Experiment 05
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.
Brief Theory: ARP spoofing is an attack against an Ethernet or Wi-Fi network to get between the router
and the target user. In an ARP-spoofing attack, messages meant for the target are sent to the attacker
instead, allowing the attacker to spy on, deny service to, or man-in-the-middle a target. One of the most
popular tools for performing this attack is Ettercap, which comes preinstalled on Kali Linux.
On a regular network, messages are routed over Ethernet or Wi-Fi by associating the MAC address of a
connected device with the IP address used to identify it by the router. Usually, this happens via an address
resolution protocol (ARP) message indicating which device's MAC address goes with which IP address. It
lets the rest of the network know where to send traffic — but it can be easily spoofed to change the way
traffic is routed.
In an ARP-spoofing attack, a program like Ettercap will send spoofed messages attempting to get nearby
devices to associate the hacker's MAC address with the IP address of the target. When successful, they're
stored temporarily in a configuration setting on other network devices. If the rest of the network starts
delivering packets intended for the target to the attacker instead, the attacker effectively controls the
target's data connection.
Procedure:
You can connect to a network for ARP spoofing in two ways. The first is to connect via Ethernet, which is
very effective but may not always be practical and is rarely subtle. Instead, many people prefer to use a
wireless network adapter and perform the ARP spoofing over Wi-Fi.
Now, you'll see some text confirming that sniffing has started, and you'll be able to access more advanced
menu options such as Targets, Hosts, Mitm, Plugins, etc. Before we get started using any of them, we'll
need to identify our target on the network.
Once in the Connections view, you can filter the connections by IP address, type of connection, and
whether the connection is open, closed, active, or killed. This gives you a lot of snooping power, which
can be augmented by clicking the "View," then "Resolve IP addresses." This means Ettercap will try to
resolve the IP addresses it sees other devices on the network connecting to.
If you want to identify a target on a network and know what they're browsing, look over their shoulder at
what website they're on, and match the website to an IP address with an active connection to the same
website. Otherwise, you can usually tell by the MAC address, as you can look it up online to see the
manufacturer.
Go back to the "Hosts" screen, and select the IP address of the target you want to target. Click the IP
address to highlight it, then click on"Targets," followed by "Target list," to see a list of devices that have
been targeted for ARP spoofing.
13 KM STONE, GHAZIABAD-MEERUT ROAD, GHAZIABAD – 201206
Website: www.kiet.edu
KIET Group of Institutions, Ghaziabad
Department of CSE (AI) and CSE (AI&ML)
Now, we can go to the "Mitm" menu to start our attack on this target.
Once this attack has begun, you'll be able to intercept login credentials if the user you're targeting enters
them into a website that doesn't use HTTPS. This could be a router or a device on the network or even a
website that uses poor security.
To try another attack, you can click on "Plugins," then "Load plugins," to show the plugin menu. If you
select the DOS attack, it will begin dropping the packets sent to this target, cutting off their internet
access.
Enter a username and password, then hit "Submit." If Ettercap is successful, you should see the login and
password you typed appear on the attacker's screen!
In this result above, we can see that Ettercap successfully ARP poisoned the target and intercepted an
HTTP login request the target was sending to an insecure website.
EXPERIMENT 06
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.
Procedure:
Step 1: Setup DVWA for SQL Injection
After successfully installing DVWA, open your browser and enter the required URL 127.0.0.1/dvwa/login.php Log in using the
username “admin” and password as “password”. These are the default DVWA login credentials. After a successful login, set the
DVWA security to LOW then click on SQL Injection on the left-side menu.
ALSO READ
sql
D
VWA Basic SQL Injection
Interestingly, when you check the URL, you will see there is an injectable parameter which is the ID. Currently, my URL looks like this:
bash
http://172.16.15.128/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#
Let’s change the ID parameter of the URL to a number like 1,2,3,4 etc. That will also return the First_name and Surname of all users
as follows:
bash
ID: 2
Surname: Brown
ID: 3
Surname: Me
ID: 4
Surname: Picasso
If you were executing this command directly on the DVWA database, the query for User ID 3 would look like this:
sql
S
QL Injection
al
ways true injection
The percentage % sign does not equal anything and will be false. The '1'='1' query is registered as True since 1 will always equal 1.
If you were executing that on a database, the query would look like this:
sql
SQ
L Injection
bash
The database version will be listed under surname in the last line as shown in the image below.
ALSO READ
Dis
play database version
ADVERTISEMENT
bash
The Database user is listed next to the surname field in the last line as in the image below.
bash
The database name is listed next to the surname field in the last line.
Dis
play database name
bash
D
atabase schema
bash
%' and 1=0 union select null, table_name from information_schema.tables where table_name like 'user%'#
User tables
bash
%' and 1=0 union select null, concat(table_name,0x0a,column_name) from information_schema.columns where
table_name = 'users' #
Colu
mn fields
ALSO READ
bash
Col
umn fields contents
From the image above, you can see the password was returned in its hashed format. To extract the password, copy the MD5 hash
and use applications like John the Ripper to crack it. There are also sites available on the internet where you can paste the hash and
if lucky, you will be able to extract the password.
Experiment 8
Objective: Set up a CSRF attack in DVWA to demonstrate how attackers can manipulate
authenticated users into performing unintended actions.
Tool Used: DVWA
Brief Theory: About CSRF( Cross Site Request Forgery): CSRF, which stands for Cross-Site Request
Forgery, is a type of attack where someone takes advantage of a user’s active session on a website to make
them unintentionally perform actions they didn’t intend to. This attack works when the user is already logged
into the website or application.
Step: 1- We have to use CSRF php Source code. The flaw in this code is that it lacks proper CSRF protection.
It allows an attacker to craft a malicious URL and trick a logged-in user into unknowingly executing
unwanted actions on their behalf.
The vulnerability lies in the fact that the code doesn’t include any mechanism to verify the origin of the
request. As a result, an attacker can construct a URL containing the necessary parameters
(password_new and password_conf) and send it to a victim. If the victim clicks on the malicious link while
authenticated on the vulnerable website, the code will execute the password change without any further
authentication or user consent.
Now, We are going to perform the attack
First, I will Create a new password “123” and click on Change
After changing the password you can see in the url is that it lacks the necessary CSRF token. In the absence
of CSRF protection, an attacker can still exploit this vulnerability by tricking the victim into clicking on the
URL while logged in to the vulnerable website.Now we will Display the HTML code for the page, which
includes a link to download a game called “FIFA 2023. and password has been changed by attacker”
If attacker send this link to the victim, the password will be changed.
If the victim tries to open the html page. It will looks like this….
When victim tries to click on the FIFA link, the password “12345” will be changed automatically
We can see that password has been changed
lo
Security: Medium
First things first, lets change the security level of the DVWA.
vulnerability. The code uses the HTTP Referer header to check if the request came from the same server,
assuming it’s a trusted source. However, the Referer header can be easily manipulated by an attacker. This
allows an attacker to create a malicious website or craft a URL that makes a request to this script, tricking the
user’s browser into performing an unwanted action on their behalf, such as changing their password without
their knowledge or consent.
Can you see the difference? Within the legitimate request we see there is a Referer, where the request came
from. That matches up so the request goes ahead.
So what if we intercept the illegitimate request with Burp and add the HTTP Referer. Like so.
Paasword changed successfully Now we will try to intercept the website and add legitimate Referrer using
burp suite
Experiment 09
Objective: Explore remote and local file inclusion vulnerabilities in DVWA. Show how attackers can
include malicious files on a server and execute arbitrary code.
Brief Theory: Remote File inclusion (RFI) and Local File Inclusion (LFI) are vulnerabilities that are often
found in poorly-written web applications. These vulnerabilities occur when a web application allows the user
to submit input into files or upload files to the server. In order to demonstrate these attacks, we will be using
the Damn Vulnerable Web Application (DVWA).
1. XAMPP
Local File Inclusion in Action (Difficulty: LOW)Now start your machine and login to DVWA, then go to
DVWA security tab and change the difficulty level to low.
Go to file inclusion tab and change the URL from incude.php to ?page=../../../../../../etc/passwd.
Difficulty: MEDIUM
Now, go on and try the exploits we used in low difficulty. You will notice that you can’t read files like before
using the directory traversal method. So, as you can see in the below snapshot of source page, the server is
more secure and is filtering the ‘../’ or ‘..\’pattern. Let’s try to access the file without ‘../’ or ‘..\’.
As you can see, it worked by directly entering the name of the file. Let’s level up the difficulty to HIGH.
Difficulty: HIGH
Change the difficulty to HIGH and try all exploits from medium difficulty, and you’ll notice none of them
will works because the target is more secure, as it is only accepting “include.php” or inputs starting with the
word “file”. If you try anything else, it will show “File not Found”.
In this level of security, we can still gather sensitive info using the “File” URI scheme. (because it starts with
the word “file”)
This is how you can exploit file inclusion vulnerability using local files on the webserver.
Now, let’s try to exploit this vulnerability using remote files hosted on the attacker machine.
Difficulty: LOW
Let’s change include.php to http://www.google.com so the final URL will look something like this,
?page=http://www.google.com
Difficulty: MEDIUM
Change the difficulty to medium and check as we did it in the low difficulty. You’ll notice, it’s not working
anymore. The target is now filtering “http” and “https” as shown in source page.
so try the attack with “HTTP” (in CAPS) or any one word in caps like I used as shown in snapshot (httP)and
it’ll work.
?page=httP://imdb.com
Difficulty: HIGH
We can’t exploit the high difficulty using RFI as you can see in source page,we know that the target web-
server is only accepting “include.php” or anything that’s starting with the word “file” that’s why we can’t
include anything from an outside server.
Experiment 10
Objective: Use DVWA to simulate login pages and demonstrate brute-force and dictionary attacks against
weak passwords. Emphasize the importance of strong password policies.
Modern brute force attacks can now easily crack 8-characters alphanumeric password in just a mere 2 hours,
while more advanced encryption hashes can be cracked in a few months. This can be achieved by performing
exhaustive key search, in which the computer will try every possible combination of every single possible
character in order to find the right combination of characters as the password. For the purpose of this
demonstration, we will setting up the Damn Vulnerable Web Application (DVWA) to simulate a brute force
attack.
The attack will utilize Hydra as a parallelized login cracker and the ‘rockyou.txt’ wordlist that will be
demonstrated on the login form below.
Initially, barely any information was disclosed. However, a wild guess would be to use one of the most
popular usernames on any web application, which is “admin”. Before proceeding with the attack, we must
first collect more information. Open a Burp Suite browser and direct it to the DVWA page, which will look
exactly like the one on a regular browser. Now, try logging in using a random password. For this attempt, the
13 KM STONE, GHAZIABAD-MEERUT ROAD, GHAZIABAD – 201206
Website: www.kiet.edu
KIET Group of Institutions, Ghaziabad
Department of CSE (AI) and CSE (AI&ML)
username “admin” and password “admin123” was used. For Burp Suite to scan the web application, turn on
the Intercept mode right before clicking on the “Login” button.
As expected, the credentials entered were wrong, displaying an error message saying, “Username and/or
password incorrect”. Now, head back to Burp Suite and view the raw data of the connection request.
Through this, we have gathered several more information that may be useful (e.g., session cookies,
parameters of the request). The following table includes all the gathered information:
The next step is to use Hydra to crack the account password. There is no fixed format to Hydra’s command as
it will depend on the elements and/or information known to the pentester (e.g., username, hostname, URL
service, and cookies). Considering the list of disclosed information and available parameters obtained during
the vulnerability assessment step utilizing Burp Suite, the command used for this demonstration will be:
hydra 127.0.0.1 -l admin -P /usr/share/wordlists/rockyou.txt http-get-form
"/dvwa/vulnerabilities/brute:username=^USER^&password=^PASS^&Login=Login:H=Cookie\:PHPSESSID=9
cei1q7s10h39gdp538to6f3ut;security=low:F=Username and/or password incorrect."
With the incorporation of all the elements and components listed on the table, Hydra will systematically
attempt the various combinations of passwords from the ‘rockyou.txt’ wordlist in an attempt to crack the
password for the “admin” account.
The result of the attack reveals the password to be “password”, which will show that the login is successful
layers of security provide an added level of assurance, especially in the event that passwords are
compromised.
Mitigation of Insider Threats: Strong password policies not only guard against external threats but also
help mitigate the risk of insider threats. Employees with malicious intent or those who inadvertently
compromise their credentials pose a significant risk to an organization's security. Strong passwords add an
extra barrier against such threats.