CSS-Lab
CSS-Lab
Learning Objective: Student should be able to design and implementation of a product cipher using
Substitution and Transposition Cipher.
Theory:
A substitution cipher is a method of encoding by which units of plaintext are replaced with ciphertext,
according to a fixed system; the "units" may be single letters (the most common), pairs of letters,
triplets of letters, mixtures of the above, and so forth. The receiver deciphers the text by performing
the inverse substitution.
There are a number of different types of substitution cipher. If the cipher operates on single letters, it
is termed a simple substitution cipher; a cipher that operates on larger groups of letters is
termed polyalphabetic. A monoalphabetic cipher uses fixed substitution over the entire message,
whereas a polyalphabetic cipher uses a number of substitutions at different positions in the message,
where a unit from the plaintext is mapped to one of several possibilities in the ciphertext and vice
versa.
The function for Additive/Shift/Generalized Caesar Cipher is given as follows:
It can use any shift from 1 to 25, i.e., replace each letter by a letter a fixed distance away.
Ci=E(Pi)=(Pi+k) mod 26 and Pi=D(Ci)=(Ci-k) mod 26.
In Cryptography, a Caesar Cipher, also known as Caesar's Cipher, the Shift Cipher, Caesar's
Code or Caesar Shift, is one of the simplest and most widely known encryption techniques. It is a type
of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of
positions down the alphabet. For example, with a left shift of 3, A would be replaced by D, E would
become H, and so on. The method is named after Julius Caesar, who used it in his private
correspondence.
Substitution ciphers can be compared with transposition ciphers. In a transposition cipher, the units of
the plaintext are rearranged in a different and usually quite complex order, but the units themselves
are left unchanged. By contrast, in a substitution cipher, the units of the plaintext are retained in the
same sequence in the ciphertext, but the units themselves are altered.
Transposition Ciphers does not substitute one symbol for another, instead it changes the location of
the symbols.
A symbol in the first position of the plaintext may appear in the tenth position of the ciphertext. A
symbol in the eight position in the plaintext may appear in the first position of the ciphertext. A
transposition cipher reorders (transposes) the symbols. Simple transposition ciphers, which were
used in the past, are keyless.
There are two methods for permutation of characters. In the first method, the text is written into a
table column by column and then transmitted row by row. In the second method, the text is written
into a table row by row and then transmitted column by column.
Method I-
Method II-
Source Code:
Output:
1. Affine Cipher
2. Transposition cipher
Learning Outcomes: The student should have the ability to design & implement product
cipher using Substitution and Transposition Cipher
LO1: To describe & understand about Substitution and Transposition cipher techniques
Course Outcomes: Upon completion of the course students will be able to understand & implement
Substitution and Transposition Cipher.
Conclusion :
Theory:
2. Traceroute:
Traceroute prints the route that packets take to a network host. Traceroute utility uses the
TTL field in the IP header to achieve its operation. The TTL field, describes how much hops
a particular packet will take while traveling on network. So, this effectively outlines the
lifetime of the packet on network. This field is usually set to 32 or 64. Each time the packet is
held on
3. Nslookup: The nslookup command is used to query internet name servers interactively for
information. nslookup, which stands for "name server lookup", is a useful tool for finding out
information about a domain name. By default, nslookup will translate a domain name to an IP
address (or vice versa).
4. WHOIS: WHOIS is the Linux utility for searching an object in a WHOIS database. The
WHOIS database of a domain is the publicly displayed information about a domains
ownership, billing, technical, administrative, and nameserver information. Running a WHOIS
on your domain will look the domain up at the registrar for the domain information. All
domains have WHOIS information. WHOIS database can be queried to obtain the following
information via WHOIS:
• Administrative contact details, including names, email addresses, and telephone numbers
• Mailing addresses for office locations related to the target organization
• Details of authoritative name servers for each given domain
Output:
Course Outcomes: Upon completion of the course students will be able to study the various
network reconnaissance tools & how to use them to gather primary network information.
Conclusion:
In this experiment we used various network commands to gather information about the network
host is present in and learned to read and understand their outputs.
40%]
Marks
Obtained
Theory:
Nmap (Network Mapper) is a security scanner originally written by Gordon Lyon (also known by
his pseudonym Fyodor Vaskovich) used to discover hosts and services on a computer network,
thus creating a "map" of the network. To accomplish its goal, Nmap sends specially crafted
packets to the target host and then analyses the responses. Unlike many simple port scanners that
just send packets at some predefined constant rate, Nmap accounts for the network conditions
(latency fluctuations, network congestion, the target interference with the scan) during the run.
Also, owing to the large and active user community providing feedback and contributing to its
features, Nmap has been able to extend its discovery capabilities beyond simply figuring out
whether a host is up or down and which ports are open and closed; it can determine the operating
system of the target, names and versions of the listening services, estimated uptime, type of
device, and presence of a firewall.
Port Scanning – Enumerating the open ports on one or more target hosts.
OS Detection – Remotely determining the operating system and some hardware characteristics of
network devices.
Course Outcomes: Upon completion of the course students will be able to install and use
nmap and use it for gathering detailed network and remote host information
Conclusion:
In this experiment we learned about the NMAP network tool and its various usecases. We
executed a number of NMAP commands such as network scan for active hosts, OS
fingerprinting, services and applications detection along with it’s version on a target host as
well as a Port scan to find open ports for TCP or UDP connection in order to exploit any
potential vulnerabilities.
[ 40%]
Marks
Obtained
Theory:
In cryptography, RSA (which stands for Rivest, Shamir and Adleman who first publicly
described it) is an algorithm for public-key cryptography. It is the first algorithm known to
be suitable for signing as well as encryption, and was one of the first great advances in
public key cryptography. RSA is widely used in electronic commerce protocols, and is
believed to be sufficiently secure given sufficiently long keys and the use of up-to-date
implementations.
KEY GENERATION:
The RSA algorithm involves three steps: key generation, encryption and decryption.
RSA involves a public key and a private key. The public key can be known to everyone and
is used for encrypting messages. Messages encrypted with the public key can only be
decrypted using the private key. The keys for the RSA algorithm are generated the following
way:
For security purposes, the integers p and q should be chosen at random, and
should be of similar bit-length. Prime integers can be efficiently found using
a primality test.
2. Compute n = pq.
n is used as the modulus for both the public and private keys.
3. Compute φ(n) = (p–1)(q–1), where φ is Euler's totient function.
4. Choose an integer e such that 1 < e < φ(n) and gcd(e,φ(n)) = 1, i.e. e and φ(n)
are coprime.
e is released as the public key exponent.
5. Determine d = e–1 mod φ(n); i.e. d is the multiplicative inverse of e mod φ(n).
This is more clearly stated as solve for d given (d*e)mod φ(n) = 1
This is often computed using the extended Euclidean algorithm.
6. The public key consists of the modulus n and the public (or encryption) exponent e.
The private key consists of the private (or decryption) exponent d which must be kept
secret.
ENCRYPTION:
Alice transmits her public key (n,e) to Bob and keeps the private key secret. Bob then wishes to
send message M to Alice.
He first turns M into an integer m, such that 0 < m < n by using an agreed-upon reversible
protocol known as a padding scheme. He then computes the ciphertext c corresponding to
c = me (mod n).
This can be done quickly using the method of exponentiation by squaring. Bob then transmits c
to Alice.
DECRYPTION:
Alice can recover m from c by using her private key exponent d via computing
m = cd (mod n).
Source Code:
import math
import random
def modInverse(a,
m): m0 = m
y = 0
x = 1
if (m == 1):
return 0
while (a > 1):
q = a //
mt =m
m=a%m
def check_prime(n):
for i in
range(2,n//2):
if n%i==0:
return
False return
True
prime_list=[i for i in range(2,150) if
check_prime(i)]
p=prime_list[random.randint(0,len(prime_list
)-1)]
q=2
flag=0
m=input("Enter the message to be
encrypted : ") try:
m=int(m)
except:
m=m.uppe
r() if
type(m)!
=int:
flag=1
Ascii_conversion=
"" for char in m:
Ascii_conversion+=str(ord(char))
m=int(Ascii_conversion)
q
=
0
i=
2
while q==0:
if
check_prime(i)==
True: if
(p*i)>int(m):
q=i
bre
ak
i+=1
n=p*q
encrypted_msg=(m**e)%n
res(e,n)
Output:
Applications:
1. RSA algorithm is commonly used by banks to protect their data, like customer
information and transaction record. Some scenarios are credit card and office computers.
2. RSA algorithm is useful to encrypt the call data as a concern for privacy issues because
it is Asymmetrical Encryption Algorithm.
Learning Outcomes: The student should have the ability to understand RSA
Course Outcomes: Upon completion of the course students will be able to understand &
implement RSA Algorithm
Conclusion : We learned the RSA algorithm in detail and understood how RSA overcome
the weaknesses of symmetrical algorithm in Authenticity and Confidentiality of data. Since
RSA is Asymmetrical algorithm, it uses two keys. i.e. public key and private key. RSA is
stronger than any other symmetrical algorithms but it requires more computation.
[ 40%]
Marks
Obtained
The Diffie–Hellman key agreement was invented in 1976 during a collaboration between
Whitfield Diffie and Martin Hellman and was the first practical method for establishing
a shared secret over an unprotected communication channel.
Diffie–Hellman establishes a shared secret that can be used for secret communications by
exchanging data over a public network.
A= gX mod n
B= gY mod n
K1= BX mod n
K2= AY mod n
NOTE:
It should be difficult for Alice to solve for Bob's private key or for Bob to solve for Alice's
private key. If it is not difficult for Alice to solve for Bob's private key (or vice versa), Eve
may simply substitute her own private / public key pair, plug Bob's public key into her
private key, produce a fake shared secret key, and solve for Bob's private key (and use that to
solve for the shared secret key. Eve may attempt to choose a public / private key pair that
will make it easy for her to solve for Bob's private key).
OUTPUT :
Course Outcomes: Upon completion of the course students will be able to analyze and
implement Diffie-Hellman Key Exchange Algorithm for generation of shared symmetric key
Conclusion: After performing this Experiment, we understood about the Diffie-Hellman Key
Exchange Algorithm in detail. We learned how attacker can alter the messages and may alter
the communication between two users if there private keys are easy to solve.
[ 40%]
Marks
Obtained
Download and install wireshark and capture icmp, tcp, and http packets in promiscuous mode
and explore how the packets can be traced based on different filters.
Objectives: • Understand the need for traffic analysis. • Understand the how packet sniffing
is done using wireshark. • Trace and understand various packets from dynamic traffic.
Outcomes: The learner will be able to • Sniff network packets and study insights of packets
to get detail network information.
Theory:
Wireshark, a network analysis tool formerly known as Ethereal, captures packets in real time
and display them in human-readable format. Wireshark includes filters, color-coding and
other features that let you dig deep into network traffic and inspect individual packets.
Features of Wireshark:
• Open files containing packet data captured with tcpdump/WinDump, Wireshark, and a
• Import packets from text files containing hex dumps of packet data.
Capturing Packets:
After downloading and installing wireshark, you can launch it and click the name of an interface
under Interface List to start capturing packets on that interface. For example, if you want to
capture traffic on the wireless network, click your wireless interface. You can configure
advanced features by clicking Capture Options.
After downloading and installing wireshark, you can launch it and click the name of an interface
under Interface List to start capturing packets on that interface. For example, if you want to
capture traffic on the wireless network, click your wireless interface. You can configure
advanced features by clicking Capture Options.
As soon as you click the interface‘s name, you‘ll see the packets start to appear in real time.
Wireshark captures each packet sent to or from your system. If you‘re capturing on a wireless
interface and have promiscuous mode enabled in your capture options, you‘ll also see other
the other packets on the network.
Click the stop capture button near the top left corner of the window when you want to stop
capturing traffic.
Wireshark uses colors to help you identify the types of traffic at a glance. By default, green is
TCP traffic, dark blue is DNS traffic, light blue is UDP traffic, and black identifies TCP
packets with problems — for example, they could have been delivered out-of-order.
Filtering Packets:
The most basic way to apply a filter is by typing it into the filter box at the top of the window and
clicking Apply (or pressing Enter). For example, type ―dns‖ and you‘ll see only DNS
packets. When you start typing, Wireshark will help you autocomplete your filter.
2. Ip.addr==192.168.0.1 :
4. ip.dst==192.168.0.1 :
Course Outcomes: Upon completion of the course students will be able to download and install
wireshark and capture icmp, tcp, and http packets in promiscuous mode and explore how the
packets can be traced based on different filters
Conclusion: Wireshark installation and network traffic analysis using packet sniffing is done.
Detailed information about packets are explored by applying filters.
[ 40%]
Marks
Obtained
Outcomes: The learner will be able to understand Web Security Testing and simulate using
Tools
Theory:
Web application security testing is the process of testing, analyzing and reporting on the
security level and/or posture of a Web application. It is used by Web developers and security
administrators to test and gauge the security strength of a Web application using manual and
automated security testing techniques.
Web application security testing is a broad process that includes a multitude of processes that
enable security testing of a Web application. It is a systematic process that starts from
identifying and scoping the entire application, followed by planning multiple tests.
Typically, Web application security testing is performed after the Web application is
developed. The Web application undergoes a rigorous testing process that includes a series of
fabricated malicious attacks to see how well the Web application performs/responds. The
overall security testing process is generally followed by a format report that includes the
identified vulnerabilities, possible threats and recommendations for overcoming the security
shortfalls.
Interception :
Details of Target :
Course Outcomes: Upon completion of the course students will be able to understand and
simulate Web Security Testing
Conclusion: After performing this Experiment, we understood about how simulate Web
Security testing and the use of Web Security testing . We intercepted the vulnerable website
and also modified the request by intercepting it and changing its content before passing it on
to server.
[ 40%]
Marks
Obtained
Outcomes: The learner will be able to understand and simulate SQL Injection Attack
Theory:
SQL injection (SQLi) refers to an injection attack wherein an attacker can execute malicious
SQL statements (also commonly referred to as a malicious payload) that control a web
application’s database server (also commonly referred to as a Relational Database
Management System – RDBMS). Since an SQL injection vulnerability could possibly affect
any website or web application that makes use of an SQL-based database, the vulnerability is
one of the oldest, most prevalent and most dangerous of web application vulnerabilities.
By leveraging an SQL injection vulnerability, given the right circumstances, an attacker can
use it to bypass a web application’s authentication and authorization mechanisms and
retrieve the contents of an entire database. SQL injection can also be used to add, modify and
delete records in a database, affecting data integrity.
To such an extent, SQL injection can provide an attacker with unauthorized access to
sensitive data including, customer data, personally identifiable information (PII), trade
secrets, intellectual property and other sensitive information.
In order to run malicious SQL queries against a database server, an attacker must first find
an input within the web application that is included inside of an SQL query.
In order for an SQL injection attack to take place, the vulnerable website needs to directly
include user input within an SQL statement. An attacker can then insert a payload that will
be included as part of the SQL query and run against the database server.
# SQL query vulnerable to SQLi sql = “SELECT id FROM users WHERE username=’” +
uname + “’ AND password=’” + passwd + “’”
The above script is a simple example of authenticating a user with a username and a password
against a database with a table named users, and a username and password column.
The above script is vulnerable to SQL injection because an attacker could submit malicious
input in such a way that would alter the SQL statement being executed by the database server.
A simple example of an SQL injection payload could be something as simple as setting the
password field to password’ OR 1=1.
This would result in the following SQL query being run against the database server.
An attacker can also comment out the rest of the SQL statement to control the execution of the
SQL query further.
Once the query executes, the result is returned to the application to be processed, resulting
in an authentication bypass. In the event of authentication bypass being possible, the
application will most likely log the attacker in with the first account from the query result —
the first account in a database is usually of an administrative user.
To check whether website is vulnerable, replace the value in the get request parameter with
an asterisk (*)
http://testphp.vulnweb.com/listproducts.php?cat=*
If this results in an error such as the error given below, then we can say that the website is
vulnerable.
To check access to a database, - - dbs option can be used. - - dbs lists all the available
databases.
Each of the database can further explored to get tables information from them. Option -D
can be used to specify the name of the database we need to explore. If access to the database
is allowed, we can access the tables using --tables option along with name of database. Here,
acuart database is accessed and all available tables in that database are listed as an output of
the following command.
Columns of a particular table can be viewed by specifying -T option before table name and -
-columns option to query the column names. Access to table and its column for table
"products" is displayed by following command.
Information from specific column can be retrieved and displayed using -C. Multiple
column can also be listed separated by a comma and the –dump query retrieves the data.
Flowing command shows all Domain values of column name from product table from
acuart database.
Implementation :
http://testphp.vulnweb.com/artists.php?artist=1
using ORDER BY keyword to sort the records in ascending or descending order for
1,version(),current_user()
concat function is used for concatenation of two or more string into a single string.
Course Outcomes: Upon completion of the course students will be able to understand and
simulate SQL Injection Attack
[ 40%]
Marks
Obtained