FinalCSS - Lab Manual - Finalmost - TE2023 - Stud
FinalCSS - Lab Manual - Finalmost - TE2023 - Stud
Expt. Page
Name of the Experiment
No. No.
1
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
EXPERIMENT NO- 1
AIM: Find the multiplicative inverse of any number using Extended Euclidean algorithm.
Also find the GCD and t values. Show the output of each step.
THEORY: The GCD of two integers can be found by repeated application of the division
algorithm, this is known as the Euclidean Algorithm. You repeatedly divide the divisor by the
remainder until the remainder is 0. The gcd is the last non-zero remainder in this algorithm. The
Extended Euclidean Algorithm finds the multiplicative inverse of b in Zn when n and b are
given and gcd(n,b)=1.The multiplicative inverse of b is the value of t after being mapped to Zn.
The following example shows the algorithm.
2
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
3
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Example:
Given a =161 and b=28 find gcd(a,b) and value of s and t.
Solution:
q r1 r2 r s1 s2 s t1 t2 t
5 161 28 21 1 0 1 0 1 -5
1 28 21 7 0 1 -1 1 -5 6
3 21 7 0 1 -1 4 -5 6 -23
7 0 -1 4 6 -23
We get gcd(161,28)=7 s=-1 and t=6.
The answer can be tested,(-1) x 161 + 6 x 28 = 7
PROGRAM WITH OUTPUT
4
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
CONCLUSION:
Thus, we have learnt how to find multiplicative inverse using Extended Euclidean Theorem.
5
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
EXPERIMENT NO-2
THEORY:
Euler’s Totient function Φ (n) for an input n is the count of numbers in {1, 2, 3, …, n} that are
relatively prime to n, i.e., the numbers whose GCD (Greatest Common Divisor) with nis 1. All
positive integers less than n are relatively prime to it.
For Example:
Soln:
Φ (n) = Φ (4) = 1 and 3 are relatively prime to 4 because their gcd is 1. (The number issaid
to relatively prime if their gcd is always 1)
2. find Φ (5) = ?
∴ Φ (5) = 4
6
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
This implies that Φ (n) will be easy to calculate if n has exactly two different prime factors
say p and q
∴ Φ (n) = p x q
1. Φ (1) = 0.
If the prime factorisation of n is given by n = p1e1 *...* pnen, then φ(n) = n *(1 - 1/p1)* ...(1
- 1/pn).
For example:
7
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
PROGRAM
8
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
EXPERIMENT NO - 3
THEORY:
The Caesar Cipher technique is one of the earliest and simplest method of encryption
technique. It’s simply a type of substitution cipher, i.e., each letter of a given text is
replaced by a letter some fixed number of positions down the alphabet. For example with
a shift of 1, A would be replaced by B, B would become C, and so on. The method is
apparently named after Julius Caesar, who apparently used it to communicate with his
officials.
Thus to cipher a given text we need an integer value, known as shift which indicates the
number of position each letter of the text has been moved down.
The encryption can be represented using modular arithmetic by first transforming the
letters into numbers, according to the scheme, A = 0, B = 1,…, Z = 25. Encryption of a
letter by a shift n can be described mathematically as.
Examples :
9
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Encryption
Decryption
If any case (Dn) value becomes negative (-ve), in this case, we will add 26 in the negative
value. E.g: -15+26=11
PROGRAM
10
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
OUTPUT
CONCLUSION: Hence, we have learnt the concept of encryption and decryption. We have
implemented ceaser cipher in python and have created cipher text and then decipher it.
11
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Experiment No: 04
o Public key
o Private key
The Public key is used for encryption, and the Private Key is used for decryption. Decryption
cannot be done using a public key. The two keys are linked, but the private key cannot be
derived from the public key. The public key is well known, but the private key is secret and
it is known only to the user who owns the key. It means that everybody cansend a
message to the user using user's public key. But only the user can decrypt the message
using his private key.
Example:
• Choose p = 3 and q = 11
• Compute n = p * q = 3 * 11 = 33
• Compute φ(n) = (p - 1) * (q - 1) = 2 * 10 = 20
12
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
• Choose e such that 1 < e < φ(n) and e and φ (n) are coprime. Let e = 7
• Compute a value for d such that (d * e) % φ(n) = 1. One solution is d = 3 [(3 * 7) %
20 = 1]
• Public key is (e, n) => (7, 33)
• Private key is (d, n) => (3, 33)
• The encryption of m = 2 is c = 27 % 33 = 29
• The decryption of c = 29 is m = 293 % 33 = 2
PROGRAM
13
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
OUTPUT
14
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
CONCLUSION: Hence, we have implemented RSA Key Generation Algorithm. And performed
Encryption and decryption using RSA algorithm.
15
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Experiment No: 05
AIM: For varying message sizes, generate message digest using MD5 algorithm and check
the integrity of message
THEORY:
MD5 (Message-Digest algorithm 5) is a widely used cryptographic hash function that results
in a 128-bit hash value. The 128-bit (16-byte) MD5 hashes (also termed message digests)
typically are represented as 32-digit hexadecimal numbers (for example,
ec55d3e698d289f2afd663725127bace).
EAP-MD-5 typically is not recommended for wireless LAN implementations because it may
expose the user’s password, and because several collision-based weaknesses have been
demonstrated. It provides for only one way authentication – there is no mutual
authentication of wireless client and the network.And very importantly it does not provide
a means to derive dynamic, per-session wired equivalent privacy (WEP) keys.
PROGRAM
16
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
OUTPUT
CONCLUSION: Thus, for varying message sizes, we have generated message digests using MD5
algorithm and checked the integrity of message. We observed that the size of message digest
remains same for varying message sizes.
17
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Experiment No: 06
AIM: For varying message sizes, generate message digest using SHA-1 algorithm and check
the integrity of message.
THEORY:
SHA-1 produces a 160-bit hash value or message digests from the inputted data (data that
requires encryption), which resembles the hash value of the MD5 algorithm. It uses 80
rounds of cryptographic operations to encrypt and secure a data object. Some of the
protocols that use SHA-1 include:
SHA-1 is commonly used in cryptographic applications and environments where the need
for data integrity is high. It is also used to index hash functions and identify data corruption
18
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
SHA-1 or Secure Hash Algorithm 1 is a cryptographic hash function which takes an input and
produces a 160-bit (20-byte) hash value. This hash value is known as a message digest. This
message digest is usually then rendered as a hexadecimal number which is 40 digits long.
PROGRAM
OUTPUT
19
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
CONCLUSION: Thus, for varying message sizes, we have generated message digests using SHA-
1 algorithm and checked the integrity of message. We observed that the size of message digest
remains same for varying message sizes.
20
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Experiment No: 07
AIM: Implementation of Diffie Hellman Algorithm in Python. Also, perform Diffie Hellman
Practical using Cryptographic Lab of Virtual Labs of IIT Bombay.
RESOURCE REQUIREMENTS: Python, P IV and above, Printer, Pages, Virtual Lab IIT
Bombay
THEORY:
Diffie-Hellman algorithm is one of the most important algorithms used for establishing a
shared secret. At the time of exchanging data over a public network, we can use the shared
secret for secret communication. We use an elliptic curve for generating points and getting
a secret key using the parameters.
1. We will take four variables, i.e., P (prime), G (the primitive root of P), and a and b
(private values).
2. The variables P and G both are publicly available. The sender selects a private value,
either a or b, for generating a key to exchange publicly. The receiver receives the key,
and that generates a secret key, after which the sender and receiver both have the same
secret key to encrypt.
21
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
STEP 1 : Firslty,choose a large prime number p and a generator g for that prime.
STEP 2 : Secondly,both Alice and Bob generate their respective keys A and B. And (ga,gb)for
their keys respectively.
STEP 4 : Finally,both calculate their public keys gab and gba repectively.
STEP 5 : If both gab and gba are equal then Deffie-Hellman key exchange is verified.
Output:
22
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
PROGRAM
Output
23
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
24
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Experiment No: 08
Applications of Wireshark:
Here are some reasons people use Wireshark:
⚫ Network administrators use it to troubleshoot network problems.
⚫ Network security engineers use it to examine security problems.
⚫ QA engineers use it to verify network applications.
⚫ Developers use it to debug protocol implementations.
⚫ Student use it to learn network protocol internals.
Features:
⚫ Available for UNIX and Windows.
⚫ Capture live packet data from a network interface.
⚫ Display packets with very detailed protocol information.
25
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
⚫ Similarly, received packets are never explicitly addressed to the packet sniffer.
⚫ Instead, a packet sniffer receives a copy of packets that are sent / received from/by
application and protocols executing on your machine.
26
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
⚫ If everything goes according to plan, you’ll now see all the network traffic in your network.
⚫ 'Promiscuous' is a mode which some NICs can assume that would allow them to receive
any packet that comes their way regardless of that packet's destination address. By
default, NICs are supposed to discard all packets not addressed to them.
⚫ If you have promiscuous mode enabled—it’s enabled by default—you’ll also see all the
other packets on the network instead of only packets addressed to your network adapter.
ScreenShot:
27
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
28
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
29
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
30
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
31
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
32
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
CONCLUSION: Hence we have successfully implemented packet sniffer tools using Wireshark.
And also implemented icmp, tcp and http packets in promiscuous mode as well as explored how
the packets can be traced based on different filters.
33
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Experiment No: 9
AIM: Simulate buffer overflow attack using Ollydbg, Splint, Cppcheck etc
RESOURCES REQUIRED: Unix/Linux/Windows, Ollydbg, Splint, cppcheck
THEORY:
1. Cppcheck : Cppcheck is a tool for static C/C++ code analysis (CLI). Cppcheck is a command-line
tool that tries to detect bugs that your C/C++ compiler doesn't see. It is versatile, and can check
non-standard code including various compiler extensions, inline assembly code, etc. Its internal
preprocessor can handle includes, macros, and several pre-processor commands. While Cppcheck
is highly configurable, you can start using it just by giving it a path to the source code.
34
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
$ cppcheck sample2.c
Splint : Splint is a tool for statically checking C programs for security vulnerabilities and
programming mistakes. Splint does many of the traditional lint checks including unused
declarations, type inconsistencies, use before definition, unreachable code, ignored return values,
execution paths with no return, likely infinite loops, and fall through cases. More powerful checks
are made possible by additional information given in source code annotations. Annotations are
stylized comments that document assumptions about functions, variables, parameters and types.
In addition to the checks specifically enabled by annotations, many of the traditional lint checks are
improved by exploiting this additional information.
Splint is designed to be flexible and allow programmers to select appropriate points on the effort-
benefit curve for particular projects. As different checks are turned on and more information is
given in code annotations the number of bugs that can be detected increases dramatically.
Problems detected by Splint include:
35
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Example 2:
36
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
$splint sample3.c
37
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
3. Ollydbg: OllyDbg is a 32-bit assembler level analysing debugger for Windows. It emphasizes
binary code analysis, which is useful when source code is not available. It traces registers,
recognizes procedures, API calls, switches, tables, constants and strings, as well as locates routines
from object files and libraries. It has a user friendly interface, and its functionality can be extended
by third-party plugins.
Installation: Download Ollydbg from ollydbg.org and install it on windows. Make executable of
following C program rtrace.c and open it in ollydbg for debugging.
38
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
39
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
40
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Conclusion:
Software vulnerabilities causing buffer overflow are studied and detected using Ollydbg, Splint and
cppcheck.
41
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Experiment No: 10
AIM: Study the use of network reconnaissance tools like WHOIS, dig, tracert, nslookup.
THEORY:
Tools for active reconnaissance are designed to interact directly with machines on the
target network in order to collect data that may not be available by other means. Active
reconnaissance can provide a hacker with much more detailed information about the
targetbut also runs the risk of detection.
Whois
Whois servers are databases that are maintained by domain name authorities around the
world. A whois database can contain a plethora of information, but typically it contains
such information as location, contact information, and IP address ranges for every domain
name under its authority.
Traceroute
If you are curious as to what path your requests are taking, as well as how long it takes to
get from point A to point B (as well as intermediary stops), you can usethe
Traceroute tool. This can help you with things like:
42
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
NsLookup
The NsLookup tool allows you to provide a hostname and request one or more types of
DNS records (e.g., A, NS, CNAME records).
dig
dig (Domain Information Groper) is a powerful command-line tool for querying DNS name
servers. The dig command, allows you to query information about various DNS records,
including host addresses, mail exchanges, and name servers. It is the most commonly
used tool among system administrators for troubleshooting DNS problemsbecause of its
flexibility and ease of use.
43
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
OUTPUT
Whois
Tracert
44
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
DIG
45
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
Nslookup
46
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
47
SɅRɅSWɅTI
College of
Department of SɅRɅSWɅTI Engineering
Computer Engineering
48
SɅRɅSWɅTI
Experiment No: 11
Theory:
Denial-of-service (DoS) attack is an attempt to make a machine or network resource unavailable to
its intended users, such as to temporarily or indefinitely interrupt or suspend services. A distributed
denial-of-service (DDoS) is where the attack source is more than one, often thousands of, unique IP
addresses. It is analogous to a group of people crowding the entry door or gate to a shop or business,
and not letting legitimate parties enter into the shop or business, disrupting normal operations.
A DoS attack tries to make a web resource unavailable to its users by flooding the target URL with
more requests than the server can handle. That means that during the attack period, regular traffic on
the website will be either slowed down or completely interrupted.
A Distributed Denial of Service (DDoS) attack is a DoS attack that comes from more than one source
at the same time. A DDoS attack is typically generated using thousands (potentially hundreds of
thousands) of unsuspecting zombie machines. The machines used in such attacks are collectively
known as “botnets” and will have previously been infected with malicious software, so they can be
remotely controlled by the attacker. According to research, tens of millions of computers are likely
to be infected with botnet programs worldwide.
Cybercriminals use DoS attacks to extort money from companies that rely on their websites being
accessible. But there have also been examples of legitimate businesses having paid underground
elements of the Internet to help them cripple rival websites. In addition, cybercriminals combine DoS
attacks and phishing to target online bank customers. They use a DoS attack to take down the bank's
website and then send out phishing e-mails to direct customers to a fake emergency site instead.
Installation Steps:
Output
49
50
51
Conclusion:
DoS attacks affects availability of resources. DoS attack is simulated using Hping3 and resources are
monitored using wireshark.
52
Experiment No: 12
AIM: Case Study on analysing the Security Vulnerabilities of E-commerce websites (Content
beyond syllabus).
THEORY:
1. Security Vulnerabilities of E-commerce services
Vulnerability is a weakness which allows an attacker to reduce a system's information
assurance. Vulnerability is the intersection of three elements: a
system susceptibility or flaw, attacker access to the flaw, and attacker capability to exploit
the flaw. To exploit vulnerability, an attacker must have at least one applicable tool or
technique that can connect to a system weakness
1.1 Software life cycle not secure.
Over the years, efforts to enhance software development life cycle (SDLC) practices have
been shown to improve software quality, reliability, and fault-tolerance. Now-a-days
strategies to improve the security of software in organizations such as Microsoft, Oracle, and
Motorola have resulted in software products with less vulnerabilities and greater
dependability, trustworthiness, and robustness.
As per the SANS Institute’s Top 20 list of security vulnerabilities, the MITRE Common
Vulnerabilities and Exposures (CVE) site, the US-CERT Technical Cyber Security Alerts site,
and the Microsoft Security Advisory site show that common software defects are the leading
cause of security vulnerabilities (buffer overflows have been the most common software
defect leading to security vulnerabilities).
Some of the things that can be incorporated in SDLC are:
1. Software should be installed using security defaults
2. A software patch management process should be there.
53
Buffer Overflow: A buffer overflow condition occurs when a program attempts to copy more
data in a buffer than it can hold. Buffer overflow is probably the best known form of software
security vulnerability. At the code level, buffer overflow vulnerabilities usually involve the
violation of a programmer's assumptions. Hackers use buffer overflows to corrupt the
execution stack of a web application. Buffer overflow flaws can be present in both the web
server or application server products that serve the static and dynamic aspects of the site.
Buffer overflows generally resulted in to crashes. Other type of attacks will create the
situation like lack of availability are possible, including putting the program into an infinite
loop.
1.4 Missing XML Validation: Failure to implement validation when parsing XML gives an attacker
the way to supply malicious input. By accepting an XML document without validating it against a
DTD or XML schema, the programme gives chance to attackers to copy unexpected,
unreasonable, or malicious input. It is not possible for an XML parser to validate all aspects of a
document's content; a parser cannot understand the complete semantics of the data. However,
a parser can do a complete and thorough job of checking the document's structure and therefore
guarantee to the code that processes the document that the content is well-formed.
54
1.5 Validation checks in client: Performing validation check in client side code, mostly
JavaScript, provides no protection for server-side code. An attacker can simply disable
JavaScript, use telnet, or use a security testing proxy to bypass the client side validation. Client-
side validation is widely used, but is not security relevant.
1.6 Vulnerabilities in database servers: There are various techniques to attack a database.
External attacks may exploit configuration weaknesses that expose the database server. Also
weak and insecure Web application can be used to exploit the database. An application with
excess privilege in the database can put database at risk. The main threats to a database server
are:
Fig 1: Main threats to a database server
i. SQL injection: Technique used to attack database through website entry fields.
ii. Network eavesdropping: It is a network level attack consisting of capturing packets from
the networked computers.
iii. Unauthorized server access: Attacked made unauthorised access through various
loopholes in the system such as O/S, non availability of firewall etc.
iv. Password cracking: Technique of recovering password from data stored in computer.
55
(Transmission Control Protocol), deals with ensuring that the data packets are delivered in a
reliable manner from one computer to another.
2.2 Vulnerability in IPS: The main function of intrusion prevention systems is to identify
malicious activity, log information about malicious activity, attempt to block/stop activity, and
report activity. Some of the IPS Vulnerabilities are as follows:
i. Under estimation of security capabilities, including information gathering, logging,
detection, and prevention.
ii. Focus on Performance rather than security, including maximum capacity and
performance features.
56
iii. Non-defined Management policies, including design and implementation (e.g.,
reliability, interoperability, scalability, product security), operation and maintenance
(including software updates), and training, documentation, and technical support.
CONCLUSION: Thus, we have studied the Security Vulnerabilities of E-commerce websites through
a case study.
REFERENCES :
1. https://community.broadcom.com/symantecenterprise/viewdocument/common-security-
vulnerabilities-in?CommunityKey=1ecf5f55-9545-44d6-b0f4-
4e4a7f5f5e68&tab=librarydocuments
2. https://www.n-ix.com/6-types-security-vulnerabilities-ecommerce-solve-them/
57