Cyber Security Ansh
Cyber Security Ansh
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.
Wire shark captures the data coming or going through the NICs on its device by using an underlying packet
capture library. By default, Wire shark captures on-device data only, but it can capture almost all the data on its
LAN if run in promiscuous mode. Currently, Wire shark uses NMAP’s Packet Capture library (called np cap).
Wire Shark–
Wire shark is a freeandopen-sourcepacketanalyzerusedfornetworktroubleshooting,analysis,softwareand
communications protocol development, and education. It is a data capturing program that can parse and
display the fields of different networking protocols.
Role of Packets–
Packets are like courier vessels that navigate networks.
They carry information payloads and deliver data from sender to receiver.
Functionality–
Packets are crucial for reliable data transmission in inter connected networks.
Comparison–
Analogous to courier vessels navigating cyberspace.
Importance–
Essential for sending messages across networks with precision.
Protocols–
Protocols are the guiding principles of digital communication, establishing rules for devices to interact harmoniously
across the digital landscape.
They play a crucial role in shaping the flow of information, from ubiquitous protocols like HTTP for web browsing to
robust suites like TCP/IP that under pin the internet itself.
Through meticulous standardization and adherence to specifications, protocols ensure seamless interoperability
and reliable data transmission in the interconnected world of digital communication.
These customizable filters empower analysts to extract actionable insights from packet data, aiding in
troubleshooting, security threat identification, and gaining deeper visibility into network behavior by refining their
focus on relevant information.
ColorizationinWireShark–
Colorization in Wire shark enhances the visual analysis of packet data by assigning different colors based on criteria like
protocol type, packet length, or error status. This visual representation facilitates pattern recognition and improves
readability, aiding in the interpretation of packet captures.
N mapScans–
N map is an industry-standard tool for mapping networks, identifying live hosts, and discovering services. It is a
commonly used network scanner tool that security analysts employ to identify network patterns created by various
scan types. Two common N maps can types are TCP Connect scans and SYN scans.
UDP Scans–
UDP scans differ from TCP Connect scans in that they do not require a hand shake process.
They do not prompt for open ports but instead generate an ICMP error message for closed ports.
Analyzing UDP scans can provide insights into network activity, including identifying potential security
threats and abnormal communication patterns.
The above image shows that the closed port returns an ICMP error packet. No further information is provided
about the error at first glance, so how can an analyst decide where this error message belongs? The ICMP
error message uses the original request as encapsulated data to show the source/reason of the packet.
Once you expand the ICMP section in the packet details pane, you will see the encapsulated data and the
original request, as shown in the below image.
Open TCP port (Connect)–
The above images provide the patterns in isolated traffic. However, it is not always easy to spot the given patterns in big
capture files.
Therefore, analysts need to use a generic filter to view the initial anomaly patterns, and then it will be easier
to focus on a specific traffic point. The given filter shows the TCP Connects can patterns in a capture file.
Here, knowing the network architecture and inspecting the traffic for a specific time frame can help detect
the anomaly. As an analyst, you should take notes of your findings before going further. This will help you be organised
and make it easier to correlate the further findings.
Look at the given picture; there is a conflict; the MAC address that ends with “b4”crafted an ARP request with the
“192.168.1.25”IPaddress,thenclaimedtohavethe“192.168.1.1”IPaddress.
Practical 3
Malware Traffic Analysis: Analyze captured traffic to identify signs of malware
communication, such as command-and-control traffic or data infiltration.
If you are not yet familiar with Malware – Traffic -Analysis.net (MTA), I strongly suggest visiting
the site to explore the valuable work Brad is doing. He has developed an impressive system for
identifying infected websites and malware, capturing relevant traffic in PCAPs, and offering
comprehensive insights into the traffic, malware, and other pertinent details.
One aspect of the site that I particularly enjoy is the inclusion of PCAPs with sets of questions, serving
as exercises for investigator store fine their packet analysis skills. I make it a point to engage with
these exercises as they provide a hands-on opportunity to delve into the latest exploit kits. Recently,
I delved into the exercise dated March 9, 2015, and wanted to share my analysis with others.
The SetUP–
Before delving into the analysis, let me provide a brief overview of my analysis setup. While a
significant portion of the traffic is live, I prefer to work in a dedicated environment for analyzing
historical PCAP data. In this setup, the tools utilize (as demonstrated in this example) include Suricata
2.0.7withthe latest Emerging Threats rule set, with Suricata logs directed to a single index within Elastic
search, and Wireshark.
Although there are numerous other tools at my disposal, for brevity, I will focus on these key tools for
Step1:ExecutingthePacket
Having a pre-configured environment allows me to efficiently process a PCAP through various tools,
quickly opening Wireshark and a web browser to expedite the analysis. I have a simple script that runs the
PCAP through Suricata. Here are the basic commands to replay the traffic:
By scripting these commands, I can initiate the necessary tools with a single command, including
opening a web browser to view Kibana. The '-r' switch is commonly used for this purpose.
Multiple alerts have been generated from the PCAP, indicating the presence of well-known Trojans, a
drive- by kit, malware check-ins, outdated Flash vulnerabilities, and PE/DLL downloads. This initial
analysis suggests:
The likelihood of malware being dropped, potentially due to a web vulnerability or exploit.
The presence of an executable or DLL being dropped, possibly resembling files associated with Kelihos
or Simda, noting that the file was delivered via HTTP.
Check-in alerts indicating that the malware may have executed and communicated outwards, with
multiple check-in alerts for each malware type.
As we delve into profiling the activity, maintaining detailed notes and context is crucial. Continuing
within the Kibana dashboard, we observe the surrounding activities related to the alert:
Highlighted in red, the event provides a timestamp and IPs, offering a window into the events
preceding and following the alert. The analysis reveals browsing activities on fortunet.biz, requests to
portal.0037.in for a PHP page, and subsequent requests to soquumaihi.co.vu/WQdbAk8CUx8J.html,
deviating from the expected browsing behavior. Additionally, there is application/octet-stream
content originating from the.co.vu domain, interspersed with alerts related to the Nuclear EK event
and Flash vulnerabilities.
Further down the dashboard, we encounter additional alerts and heightened activity from the.co.vu
domain, including more application/octet-stream content. To tie up loose ends from our initial
observations, let's delve into more events:
Malware traffic analysis involves scrutinizing captured network traffic to identify indications of malware
communication, such as command-and-control traffic or data infiltration.
Practical 4
Password Sniffing: Simulate a scenario where a password is transmitted in plain text. Use
Wireshark to capture and analyze the packets to demonstrate the vulnerability and the
importance of encryption.
Types of Sniffing
Web Password Sniffing: Captures passwords sent over a network, enabling ethical hackers to
identify security vulnerabilities or troubleshoot network issues.
LAN Sniffing: Monitors traffic on a local area network, providing insights in to data exchanges
between devices for troubleshooting or information gathering purposes.
Protocol Sniffing: Focuses on protocols used for communication between devices, allowing
ethical hackers to analyze data transmission and exchanged information.
ARP Sniffing: Involves mapping IP addresses to physical addresses using the Address Resolution
Protocol (ARP). Useful for obtaining information about network devices or troubleshooting network
issues.
ARP(AddressResolutionProtocol)–
ARP is a protocol used to map an IP address to a physical MAC address. It is used to obtain the
MAC address of a network device when only its IP address is known.
ARP works by broadcasting the IP address and requesting the corresponding MAC address
from the network. The MAC address is then used to send data to the device
- By analyzing the captured packets, we can see how the ARP poisoning attack works. The attacker's
machine (Kali Linux) is now positioned between the victim (Windows VM) and the gateway,
allowing it to intercept and inspect all traffic.
- This man-in-the-middle scenario enables the attacker to steal sensitive data like login credentials,
cookies, and other information from the victim's traffic. The attacker can also modify the traffic
to inject malicious content or redirect the victim to a malicious site.
To prevent ARP poisoning attacks, it is important to secure the network by implementing measures
such as network segmentation, firewall configuration, and network monitoring. Users should also be
educated about the risks of ARP poisoning and the importance of using secure protocols like HTTPS to
protect their data.
Practical 6
SQL Injection: Set up an SQL Injection Attack Using DVWA ( Damn Vulnerable Web Application
)
If a user Karen with the password ‘12345’ wanted to log in, after clicking the Submit or the Log in button, the
query that would be sent to the database would look like this:
If an attacker knew the username and wanted to bypass the login window, they would put something
like Karen;-- in the username field. The resulting SQL query would look like this:
What the attacker has done, is adding the -- (double-dash) which comments the rest of the SQL statement. The
above query will return the information entered in the password field making it easier for the attacker to bypass
the login screen.
Input validation: If the website allows user input, this input should be verified whether it’s allowed or
not.
Parametrized queries: This is a technique where the SQL statements are precompiled and all you have to
do is supply the parameters for the SQL statement to be executed.
Use Stored procedures
Avoid administrative privileges - Don't connect your application to the database using an account with
root access
Any penetration tester who wants to get started or advance their skills in SQL injection will need a vulnerable
platform to practice. There are many vulnerable applications available both for offline and online use.
In this particular tutorial, we will focus on the Damn Vulnerable Web Application (DVWA).
Pre-requisites –
This tutorial expects that you have an up and running DVWA setup. If you have not yet installed DVWA on your
Kali Linux system, please check out the article which gives a step-by-step guide.
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:
If you were executing this command directly on the DVWA database, the query for User ID 3 would look like this:
SQL Injection
Step 3: Always True Scenario
An advanced method to extract all the First_names and Surnames from the database would be to use the
input: %' or '1'='1'
SQL Injection
The database version will be listed under surname in the last line as shown in the image below.
Display database version
Step 5: Display Database User
To display the Database user who executed the PHP code powering the database, enter the text below in the
USER ID field.
The Database user is listed next to the surname field in the last line as in the image
Database schema
Step 8: Display all the user tables in information_schema
For this step, we will print all the tables that start with the prefix user as stored in the information_schema.
Enter the SQL code below in the User ID.
bash
%' and 1=0 union select null, table_name from information_schema.tables where table_name like 'user%'#
User tables
Step 9: Display all the columns fields in the information_schema user table
We will print all the columns present in the users’ table. This information will include column information like
User_ID, first_name, last_name, user, and password. Enter the input in the User_ID field.
bash
%' and 1=0 union select null, concat(table_name,0x0a,column_name) from information_schema.columns where
table_name = 'users' #
Column fields
Conclusion –
SQL injection proves to be a critical vulnerability that can exist in a system. Not only can attackers exploit it to
reveal user or customer information, but it can also be used to corrupt the entire database thus bringing the
whole system down. Injection is listed as the number one vulnerability in the OWASP Top 10 Vulnerabilities
summary. The DVWA acts as a reliable resource for both penetration testers who want to improve their skills
and web developers who want to develop systems with security in mind.