EHDF Module 2
EHDF Module 2
● OWASP (Open Worldwide Application Security Project) is an open ● OWASP helps developers, security professionals, and
community organizations understand potential threats and adopt security best
● Dedicated to enabling organizations to design, develop, acquire, practices.
operate, and maintain software for secure applications that can be ● OWASP maintains a list of the ten most critical web application
trusted. security risks, along with effective processes, procedures, and
● Its programs include community-led open-source software projects and controls to mitigate them.
local and global conferences, involving hundreds of chapters ● OWASP also provides a list of the Top 10 API Security Risks to
worldwide with tens of thousands of members. educate those involved in API development and maintenance and
● Give awareness about web application security risks, and provides increase awareness of common API security weaknesses.
valuable resources, tools, documentation, and best practices to address
the increasing challenges of web application security.
Top Web Security Threats ● SQL Injection is a security flaw in web applications where attackers
insert harmful SQL code through user inputs.
● Cross-site scripting (XSS) ● This can allow them to access sensitive data, change database contents or
● SQL Injection
● Phishing even take control of the system. It’s important to know about SQL
● Ransomware Injection to keep web applications secure.
● Code Injection ● SQL Injection typically works when a web application improperly
● Viruses and worms validates user input, allowing an attacker to inject malicious SQL code.
● Spyware ● For example, if a web application takes user input (e.g., a username or
● Denial of Service password) and directly inserts it into an SQL query without proper
sanitization, an attacker can manipulate the query to perform unintended
actions.
Types of SQL Injection 3. Blind SQL Injection
1. In-band SQL Injection In blind SQL injection, the attacker does not receive error messages but can
infer information about the database by observing the behavior of the
the attacker sends malicious SQL queries directly through the application
application. The attacker uses boolean conditions to test various aspects of the
interface. This method allows attackers to extract sensitive information or
database.
manipulate the database.
4. Out-of-band SQL Injection
2. Error-based SQL Injection
Out-of-band SQL injection relies on the attacker using a different
This type of SQL injection exploits error messages generated by the database.
communication channel to exfiltrate data from the database. This type of
Attackers can use the information provided in error messages to learn about
attack is less common but can be very effective.
the database structure and craft more sophisticated attacks
● Unauthorized access to sensitive data: Attackers can retrieve ● Input validation testing: Test inputs by inserting special characters
personal, financial, or confidential information stored in the database. like --, ;, ', or " to see if they cause errors or unintended behavior.
● Data integrity issues: Attackers can modify, delete, or corrupt critical ● Automated tools: Use tools like SQLMap, Burp Suite, or OWASP
data, impacting the application’s functionality. ZAP to scan for vulnerabilities.
● Privilege escalation: Attackers can bypass authentication mechanisms ● Review source code: Inspect source code for insecure coding practices
and gain administrative privileges. such as concatenating user inputs directly into SQL queries.
● Service downtime: SQL injection can overload the server, causing ● Monitor error messages: Unexpected or detailed error messages can
performance degradation or system crashes. indicate that the application is vulnerable.
● Reputation damage: A successful attack can severely harm the ● Penetration testing: Regularly perform penetration testing to identify
reputation of an organization, leading to a loss of customer trust. security gaps.
Preventing SQL Injection Attacks Ransomware
6. Error Handling
● Data input interfaces can be vulnerable to code injection attacks. • In computing, a denial-of-service (DoS) or distributed
● Fuzzers and scanners can find code injection vulnerabilities. denial-of-service (DDoS) attack is an attempt to make a
● Fixing incorrect server configurations, avoiding untrusted data machine or network resource unavailable to its
sources, and eliminating other vulnerabilities can help prevent code intended users.
injection attacks. • A DoS attack generally consists of efforts to temporarily
or indefinitely interrupt or suspend services of a host
connected to the Internet.
A DoS attack may do the following
Symptoms of DoS attacks
●Flood the traffic, thereby preventing legitimate traffic
●Slow network performance ●Disrupt connections between two systems- preventing access to
●Unavailability of a particular website service
●Inability to access any website ●Prevent a particular individual from accessing a service
●Dramatic increase in number of Spam E-mails ●Disrupt service to a specific system or person
received
Smurf attack
Smurf attack
● A smurf attack is a type of denial of service attack in which a
system is flooded with spoofed ping messages.
● This creates high computer network traffic on the victim’s network,
which often renders it unresponsive.
● The DDoS Smurf malware creates a network data packet that
attaches to a false IP address. This is known as spoofing.
● The packet contains an ICMP ping message, which commands
network nodes to send a reply.
● This process, known as ICMP echoes, creates an infinite loop that
overwhelms a network with constant requests.
Unintentional DoS attack 3. Application Layer attacks
●This describes a situation where a website ends up denied, not ● Low and slow attacks
due to a deliberate attack by a single individual or group of ● targets windows and loopholes more
individuals, but simply due to a sudden enormous spike in ● Goal: crash server
popularity. ● target is flooded with incoming requests and responses for
● This can happen when an extremely popular website posts a files, images etc
prominent link to a second, less well-prepared site, for example, ● DoS occurs due to additional requests from legitimate
as part of a news story. traffic sources.
● Trinoo
● Tribe flood network
● Stachedraht
● Shaft
● Mstream
User Authentication
Web Security Considerations
● Data validation is the proper testing of any input supplied by the user or application. ● User authentication is the security paradigm as it refers to
It prevents improperly created data from entering the information system. Validation the mechanism by which the identity of a user is first
of data should be performed on both server-side and client-side. If we perform data
validation on both sides that will give us the authentication. Data validation should
confirmed before being granted access to a resource.
occur when data is received from an outside party, especially if the data is from ● It is the process of establishing the identity of an individual who
untrusted sources. wants to have access to a particular system or service.
● Password provides the first line of defense against unauthorized access to our device
● It involves a process of ensuring that the user claiming to be a
and personal information. It is necessary to use a strong password. Passwords must be
complex to protect against brute force. specific personality is substantial through providing credentials like
● It is good to enforce password requirements such as a minimum of eight characters passwords, biometric data, security tokens, or other authenticity
long must including uppercase letters, lowercase letters, special characters, and
factors.
numerals
How User Authentication Works
● Presentation of Credentials: It may be in the form of a user ID ● Granting Access: If the identification details provided are tied
and password, a fingerprint, or other such scans, a token that the up with that in the records and the system has succeeded in
user presents, or any other form of authentication factor that the authenticating the user, access can be granted to the system or
user presents. the service.
● Transmission to the Authenticating System: It forwards the ● Access Denied: If many of the details of the credentials given
materials to the authenticating system for verification and do not match the details of the database provided, or there is
authorization based on the included information in the evidence of phishing or hijacking, access can be denied, and
document. further security issues could arise, such as alerting the user or
● Verification: It checks that the provided information is system administrator or even authenticating the credentials
sufficient for the type of access by verifying it with the stored further.
entries.
● Cookies are small text files that websites store on a user's device How cookies are used
to track their browsing activity. While cookies can be useful, ● Authentication
they can also be a security vulnerability. Cookies can help identify a user and their account when they log
in to a website.
● When we visit a particular website, some information is saved ● Tracking
in your local system so that when you visit the same website Cookies can track a user's browsing history, including what pages
again, this website is able to recognize you and show you the they visit and what items they add to their shopping cart.
results according to your preferences. Cookies have been long ● Personalization
used in the internet history and have developed in a Cookies can be used to show personalized ads and improve a user's
magnificent way.
browsing experience.
Where are Cookies Stored?
● Session Management: Cookies store things like items in your
shopping cart or your language preference, so you don’t have to Cookies are stored on your device in special folders or files within
re-enter this information each time you visit. Cookies let your web browser. Here’s where they can typically be found:
websites allow users and recollect their individual login ● On Your Computer or Device: Cookies are stored as small text
information and preferences. files on your hard drive or in your device’s storage.
● In Your Web Browser: Each browser (like Chrome, Firefox, or
Safari) has its own way of storing cookies. They keep cookies in
a specific location within the browser’s data storage.
SSL
Types of cookies ● SSL or Secure Sockets Layer, is an Internet security protocol that
encrypts data to keep it safe.
1. Session cookies
● It was created by Netscape in 1995 to ensure privacy, authentication,
2. Persistent cookies
and data integrity in online communications.
3. First-party cookies ● SSL is the older version of what we now call TLS (Transport Layer
4. Third-party cookies Security).
5. Secure cookies ● Websites using SSL/TLS have “HTTPS” in their URL instead of
“HTTP.”
● Secure Socket Layer is a public key cryptosystem, which is used over
application layer to provide encryption to the data passing over HTTP.
● SSL breaks the incoming data into fixed size blocks, fragments
them, compresses them, encrypts and adds a MAC header and
passes it to the receiving end. It has four protocols.
i. Handshake protocol- Used for establishing a connection.
ii. Cipher-spec protocol- To notify the handshake is over.
iii. Record–protocol– Carries actual data.
iv. Alert protocol– Used for any notification.
Working of SSL
Working of HTTPs ● HTTP transfers data in a hypertext format between the browser
and the web server, whereas HTTPS transfers data in an
encrypted format.
● As a result, HTTPS protects websites from having their
information broadcast in a way that anyone eavesdropping on
the network can easily see.
● During the transit between the browser and the web server,
HTTPS protects the data from being accessed and altered by
hackers.
● Even if the transmission is intercepted, hackers will be unable to
use it because the message is encrypted.
Advantage of HTTPS
It uses an asymmetric public key infrastructure for securing a
communication link. There are two different kinds of keys used for ● Secure Communication: HTTPS establishes a secure
encryption: communication link between the communicating system by
providing encryption during transmission.
● Data Integrity: By encrypting the data, HTTPS ensures data
● Private Key: It is used for the decryption of the data that has integrity. This implies that even if the data is compromised at any
been encrypted by the public key. It resides on the server-side point, the hackers won’t be able to read or modify the data being
and is controlled by the owner of the website. It is private in exchanged.
nature. ● Privacy and Security: HTTPS prevents attackers from
● Public Key: It is public in nature and is accessible to all the
accessing the data being exchanged passively, thereby protecting
users who communicate with the server. The private key is
the privacy and security of the users.
used for the decryption of the data that has been encrypted by
the public key. ● Faster Performance: TTPS encrypts the data and reduces its
size. Smaller size accounts for faster data transmission in the
case of HTTPS.
Account Harvesting
Account Harvesting is the process of collecting legitimate ● Social Engineering: Manipulating individuals into divulging
account names on a system. Attackers use techniques like brute confidential information.
force, phishing, social engineering, and data breaches to gather ● Brute Force: Exhaustive attempts to guess passwords by trying all
this information. possible combinations.
● Domain Spoofing: Creating fake websites or email domains that
Techniques: appear legitimate to trick users.
● Phishing: Emails that lure recipients to malicious websites to
enter their credentials.
● Malware: Infected attachments in emails that deploy malware
to capture login credentials.
Signs Your Account May Be Compromised Preventing Account Harvesting: Best Practices
Preventing account harvesting is crucial for maintaining cybersecurity.
Recognizing the signs of a compromised account is crucial for maintaining
Implementing best practices can significantly reduce the risk of credential theft
cybersecurity. Here are some common indicators that your account may have
and unauthorized access. Here are some effective strategies to prevent account
been compromised:
harvesting:
● Unusual Activity: Unexpected login attempts or activity from unfamiliar ● Two-Factor Authentication: Adds an extra layer of security by requiring
locations. additional verification steps.
● Password Changes: Receiving notifications of password changes you ● Data Encryption: Ensures that intercepted data cannot be easily read or
did not initiate. used by attackers.
● Security Alerts: Alerts from services you use about suspicious activity. ● Regular Security Scans: Detects suspicious activities on the network
● Unauthorized Transactions: Unexplained transactions or changes in early.
your account. ● Employee Training: Educates staff to recognize and respond to
● Phishing Emails: Receiving emails asking for personal information or credential-harvesting attempts.
login credentials. ● Strong Password Policies: Enforces the use of complex, unique
passwords that are changed regularly.
● Spammers are also frequent users of web bugs, making Types of Web Bugs
email users leery of this tracking method. Functional bugs
● Again, these images help to determine which spam UI Bugs
Performance Bugs
recipients open and read the messages before deleting them.
Security Bugs
● Many email clients take steps to prevent this use of web
Compatibility Bugs
bugs by turning off the HTML display in emails and only Content bugs
displaying the text (though users have the option to turn Browsing bugs
HTML display back on for trusted mailers) or by turning off Mobile responsive bug
the image display function while still allowing HTML to run Validation Bug
any other functions. Session management bug
How to Protect Yourself from Web Bugs Sniffing
While web bugs can be difficult to detect and avoid, there are several steps ● Sniffing is the process of monitoring and capturing all the packets
users can take to protect themselves from online tracking and surveillance. passing through a given network using sniffing tools.
Here are some tips for protecting yourself from web bugs: ● It is a form of “tapping phone wires” and get to know about the
conversation. It is also called wiretapping applied to the computer
1. Updates
networks.
2. Codes and Coding
3. Create an Easy Way to Contact ● A sniffing attack in system hacking is a form of denial-of-service
4. Check for Broken Links and Errors attack which is carried out by sniffing or capturing packets on the
5. Use secure passwords network, and then either sending them repeatedly to a victim
6. Test your Website Thoroughly machine or replaying them back to the sender with modifications.
7. Use Third Party Software or Plugins
How it works
● A sniffer normally turns the NIC of the system to the
promiscuous mode so that it listens to all the data transmitted on
its segment.
● Promiscuous mode refers to the unique way of Ethernet hardware,
in particular, network interface cards (NICs), that allows an NIC to
receive all traffic on the network, even if it is not addressed to this
NIC.
● By default, a NIC ignores all traffic that is not addressed to it,
which is done by comparing the destination address of the
Ethernet packet with the hardware address (a.k.a. MAC) of the
device.
● While this makes perfect sense for networking, non-promiscuous
mode makes it difficult to use network monitoring and analysis
software for diagnosing connectivity issues or traffic accounting.
Sniffing In a network that uses hubs to connect systems, all hosts on the network
A sniffer can continuously monitor all the traffic to a computer through can see the traffic. Therefore, an attacker can easily capture traffic going
the NIC by decoding the information encapsulated in the data packets. through.
Types of Sniffing The good news is that hubs are almost obsolete nowadays. Most modern
networks use switches. Hence, passive sniffing is no more effective.
● Passive Sniffing
● Active Sniffing Active Sniffing
Passive Sniffing In active sniffing, the traffic is not only locked and monitored, but it may
also be altered in some way as determined by the attack. Active sniffing is
In passive sniffing, the traffic is locked but it is not altered in any used to sniff a switch-based network. It involves injecting address
way. Passive sniffing allows listening only. It works with Hub resolution packets (ARP) into a target network to flood on the switch
devices. On a hub device, the traffic is sent to all the ports. content addressable memory (CAM) table. CAM keeps track of which
host is connected to which port.
● MAC Flooding Protocols such as the tried and true TCP/IP were never designed with
● DHCP Attacks security in mind and therefore do not offer much resistance to potential
intruders. Several rules lend themselves to easy sniffing
● DNS Poisoning
● Spoofing Attacks HTTP − It is used to send information in the clear text without any
● ARP Poisoning encryption and thus a real target.
SMTP (Simple Mail Transfer Protocol) − SMTP is basically utilized in the
transfer of emails. This protocol is efficient, but it does not include any
protection against sniffing.
NNTP (Network News Transfer Protocol)− It is used for all types of
communications, but its main drawback is that data and even
passwords are sent over the network as clear text.
POP (Post Office Protocol) − POP is strictly used to receive emails ARP Poisoning
from the servers. This protocol does not include protection against
sniffing because it can be trapped. ● ARP Poisoning (also known as ARP Spoofing) is a type of cyber attack
FTP (File Transfer Protocol) − FTP is used to send and receive files, carried out over a Local Area Network (LAN) that involves sending
but it does not offer any security features. All the data is sent as clear malicious ARP packets to a default gateway on a LAN in order to change
text that can be easily sniffed. the pairings in its IP to MAC address table. ARP Protocol translates IP
IMAP (Internet Message Access Protocol) − IMAP is same as SMTP addresses into MAC addresses.
in its functions, but it is highly vulnerable to sniffing. ● Because the ARP protocol was designed purely for efficiency and not for
Telnet − Telnet sends everything (usernames, passwords, keystrokes) security, ARP Poisoning attacks are extremely easy to carry out as long
over the network as clear text and hence, it can be easily sniffed. as the attacker has control of a machine within the target LAN or is
directly connected to it.
● ARP spoofing: A hacker sends fake ARP packets that link an attacker's
MAC address with an IP of a computer already on the LAN.
● ARP poisoning: After a successful ARP spoofing, a hacker changes the
company's ARP table, so it contains falsified MAC maps. The contagion
spreads.
The goal is to link a hacker's MAC with the LAN. The result means any
traffic sent to the compromised LAN will head to the attacker instead.
Protection Tools
At the end of a successful ARP attack, a hacker can:
● Arpwatch: Monitor ethernet activity, including changing IP and
● Hijack: Someone may look over everything that heads to the LAN MAC addresses, via this Linux tool. Look over the log every day, and
access timestamps to understand just when the attack happened.
before releasing it.
● Deny service: Someone may refuse to release anything from the ● ARP-GUARD: Tap into a graphic overview of your existing network,
infected LAN unless some kind of ransom is paid. including illustrations of switches and routers. Allow the program to
develop an understanding of what devices are on your network and
● Sit in the middle: Someone conducting a man-in-the-middle attack
build rules to control future connections.
can do almost anything, including altering documents before sending
them out. These attacks both threaten confidentiality and reduce user ● XArp: Use this tool to detect attacks happening below your firewall.
Get notified as soon as an attack begins, and use the tool to determine
confidence. They are among the most dangerous attacks anyone can
what to do next.
perpetrate.
● Wireshark: Use this tool to develop a graphic understanding of all
Clickjacking
the devices on your network. This tool is powerful, but you may need
Definition: Clickjacking is an interface-based attack in which a user is
advanced skills to implement it properly.
tricked into clicking on actionable content on a hidden website by clicking
● Packet filtering: Use this firewall technique to manage network on some other content in a decoy website.
access by monitoring incoming and outgoing IP packets. Packets are
Example: A web user accesses a decoy website (perhaps this is a link
allowed or stopped based on source and destination IP addresses,
ports, and protocols. provided by an email) and clicks on a button to win a prize. Unknowingly,
they have been deceived by an attacker into pressing an alternative hidden
● Static ARP: These ARPs are added to the cache and retained on a button and this results in the payment of an account on another site. This
permanent basis. These will serve as permanent mappings between is an example of a clickjacking attack.
MAC addresses and IP addresses.
● The best way to prevent these attacks is by carefully reading the sender’s email
address.
● If you are not sure about the characters in an email address, then copy and paste it in
the notepad to check the use of numeric or special characters
● Misspelled URL Hackers buy domains that sound similar to popular websites.
● Then, they phish users by creating an identical website, where they ask targets to log
in by submitting personal information.
● In the example below, you can see that there’s a typo in the link that people can easily
miss: “www.citiibank.com…” instead of “www.citibank.com…”
Session Phishing
● Always use PKCE (Proof Key for Code Exchange) to prevent ● SQLMap
● HTTrack
authorization code interception.
● hping
● Use refresh tokens securely to extend sessions without ● Burp Suite
re-authentication. ● Wireshark
● Implement scopes and permissions to limit API access.