Itas Laboratory Manual
Itas Laboratory Manual
Name / PRN:
1|Page
INDEX
Exp No. Title Date Signature
2|Page
CERTIFICATE
Course Teacher
3|Page
Experiment no: 1
If we look at the first line of this response, it says, HTTP/1.1 200 OK. We have seen this response
many times in the previous module. The 200 response means that everything is okay.
Now, this is just one type of response. There are a few more important responses that we must know
about.
4|Page
30X: A response in the 300 range is used to signify redirection. For example, if you requested for page 1, but
are being redirected to page 2. In this case, the response
will say, “301 Moved Permanently to Location: page2”.
40X: These responses depict errors that occur due to the user’s fault. The most common response we
have all come across is 404:Not Found error. We get this
response when the page we have requested for does not exist. Another example is the 403:
Forbidden response. This comes when you request for a page that you are not supposed to visit.
50X: These responses occur when there has been some error on the server side. For example, if a
website is not able to connect to its database due to some server side
code error, you might see 500 internal server error.
So, these were some important responses sent in headers. You must remember these ranges and their
meaning well, since by looking at this we
can get an idea of what kind of response the server wants to give us.
Now, after the first line of the response headers, we see some standard HTTP response headers. These
headers basically tell the browser about the response and how to handle it. They are like the
configuration settings sent by a web server to be stored in the browser for later usage. In these
settings, you may choose to study about some of them in detail. These include the Content Security
Policy, Referrer Policy, Allow Origin, X-powered-by, etc. We will not be covering these in our topic,
but you can read more about them online.
There are multiple cases in which a security expert can know about the existence of a
link that is available after login:
1. As part of a White/Grey box exercise, he gets both all the user roles to test.
2. He guesses or brute forces (makes a script that tries all common page names).
3. He reads the source code and finds interesting links in the comments or in the code or even
in other files like JS, CSS, etc. linked inside the source code.
4. He finds a user manual or other screenshots of the application (from search engines or on the
website itself) and reads it to find a screenshot or a step telling the admin to visit a specific
post login page.
5. He uses google dorks like site:x.com inurl:seller/actions and find a page indexed in google.
6. He finds sitemap files like sitemap.xml and robots.txt using google dork site:x.com sitemap
robots.txt which contains a list of links on the website.
7. He uses social engineering on a phone call to the seller support and asks them their present
URL.
5|Page
These are also referred to as default files/folders/url that contains crucial information of servers.
Hackers exploit these default files which further helps them to plan their attacks. Below are a few
examples of default files that you may find in a website.
1. Robots.txt - One can find this file in the base directory of a website. This file is used by
server administrators to disallow search engines like Google, Bing, etc.
2. Phpinfo.php - This file is a common debug file in PHP applications that contains a huge
amount of information regarding the server.
3. Users.xml - This file generally contains usernames and passwords which hackers may
exploit.
4. Backup.sql - This default file is crucial as it may contain complete database backup.
5.
6. Config.bak - This may be a configuration file that stores passwords and keys.
7.
8. error_log / error.log - This file contains all error logs of the server which can reveal
vulnerabilities to hackers.
9. server-status and server-info - These are common Apache pages that contain server
information.
10. manager/html - This default url takes you to the Tomcat login page that can further
disclose sensitive server information.
11. phpmyadmin - It is the login page for PHPmyadmin - a software used for managing SQL
databases from the website. Exploiting a database can compromise all the data inside it.
Apart from these, there are many more default files that you should check and search for. You might
not be able to find these default files as they may have been restricted by server administrators.
2. Intense scan + UDP: Normal intense scan only scans TCP ports and using this scan, we can
also scan UDP ports too.
3. Intense scan all ports: Instead of scanning only the 1000 common ports, this will scan all
the possible ports 0-65535 (As it scans all the ports, this scan takes a lot of time to complete).
4. Intense scan no ping: This scan is used where firewalls are placed at the target.
5. Ping scan: This scan only checks if the host is reachable or not. The scan doesn’t scan any
port.
6. Quick scan: This scans lesser ports and does no service version detection. It is faster than
intense scan but can be a bit unreliable.
7. Quick scan plus: It scans fewer ports (same as the quick scan) but does version detection.
The scan is much more aggressive and hence can put a little stress on the network and be a
bit unreliable.
6|Page
8. Regular scan: Runs Nmap with default options i.e. simple port scanning and no service
version detection.
9. Slow comprehensive scan: It is an extremely slow scan that does deep level scanning with
the highest accuracy and least stress on the network.
7|Page
Experiment no: 2
For example, a buffer for log-in credentials may be designed to expect username and password inputs of 8
bytes, so if a transaction involves an input of 10 bytes (that is, 2 bytes more than expected), the program may
write the excess data past the buffer boundary.
Buffer overflows can affect all types of software. They typically result from malformed inputs or
failure to allocate enough space for the buffer. If the transaction overwrites executable code, it can
cause the program to behave unpredictably and generate incorrect results, memory access errors, or
crashes.
Below is the C code which demonstrate Buffer Overflow along with the screenshot of the output
when code was run in a compiler:
return 0;
}
9|Page
Experiment no: 3
KIOPTRIX-1
In this lab we have to gain root access of kioptrix level-1. We start with the following steps:
1. We have to find the IP Address of the kioptrix machine to gain the access, so we use the command
“netdiscover” in kali linux to find the ip.
2. Now we need to scan the IP for its ports information so as to gain the access through a
vulnerable port. For this we use “nmap”. It will give us all the information of the targets ports.
10 | P a g e
Now we have to select a port from the open ones. For this testing we have chosen “port 139”. This
particular has samba running on it.
Note: Samba is a strong network service for file and print sharing that works on the majority of
operating systems available today.
Now after selecting the port, we have to find the vulnerability of the services running on that port, in our
case we have to first determine the version of samba server and then its exploit.
After finding the version, we have to search for any know vulnerabilities of that particular version.
We can google it or use the command “searchsploit” for it.
11 | P a g e
After finding the vulnerability we again use Metasploit framework for exploitation. We set the exploit,
payloads, target ip and self ip.
After “run” command, the exploit begins and we can see that it is successful and a session has opened
between our OS and kioptrix. We check which user is active on the kioptrix machine by using the command
“whoami” and we get the answer “root”.
We can now change any and all settings of the kioptrix machine like for example, we will change
the login password and try it out on the actual machine.
12 | P a g e
In the above step we changed the password of kioptrix machine. Now let us see if it is actually
changed by loggin.
As we can see that we are able to login on the kioptrix machine, it proves that we have gained access of that particular
machine and we can do anything from our machine to kioptrix machine remotely.
CONCLUSION :
Here we have successfully gained access of the vulnerable machine using metasploit and brute forcing.
13 | P a g e
Experiment no: 4
A dictionary attack is a method that consists of breaking into a password-protected computer or server (in
this case a Wi-Fi network) by systematically entering every word in a dictionary as a password.
You won't magically have free Wi-Fi for the rest of your life, if that's what you're looking for. This is
just a tutorial with educational purposes that shows how to execute dictionary attacks to a normal Wi-Fi
network easily with Kali Linux and Aircrack. You need to know that dictionary based attacks needs a good
dictionary, otherwise this kind of attacks are generally innefective as not everybody uses only numbers as
passwords and that's precisely one of the goals of this article: you can warn clients, friends etc. that their Wi-
Fi password is really weak and shameful.
Requirements
You need, obviously Kali Linux (at least 2016.2) installed and working.
A wireless adapter capable of injection/monitor mode. Some computers have network cards
capable of this from the factory. If it isn't available you'll have to buy an external one.
A wordlist to attempt to "crack" the password once it has been captured (if you don't have
one, create your own in the step 7)
As first step, you need to check if you have an available Wi-Fi card in your computer that allow you to
continue with the hack, to list the interfaces use the ifconfig command. ifconfig is used to configure, or view
the configuration of, a network interface. Open a new terminal and execute the following command to list all
the network interfaces of your computer:
ifconfig
14 | P a g e
Then you should get an output similar to:
wlan0 is the name of the first wireless network interface on the system. Additional wireless interfaces
would be named wlan1, wlan2, etc. The name is important and you should remember it, in this case
we only have 1 Wi-Fi interface, therefore we are going to use the wlan0 name in the next step.
Execute the following command to change the MAC address of your interface:
This MAC address is known as it's always spoofed. After the execution of the command, the previous MAC
address and the new one will be printed as reference:
15 | P a g e
Now that the MAC address is changed, bring up the interface again using the following command:
ifconfig wlan0 up
You can verify it using ifconfig one more time if you want:
Monitor mode is one of the seven modes that 802.11 wireless cards can operate in: Master (acting as
an access point), Managed (client, also known as station), Ad hoc, Mesh, Repeater, Promiscuous,
and Monitor mode. The monitor mode sniffes the packets in the air without connecting (associating)
with any access point. As this mode doesn't need association to AP needed (and no authentication).
16 | P a g e
Enable the monitor mode with the following command:
In case you get an exception, a warning or a message that some processes could cause troubles during
the execution of this process, be sure to stop the processes using the following command:
We need to copy the WPA Handshake of the Wi-Fi router to hack it (as a dictionary attack that waits till the
signal goes to the router, then comes back, fails and repeats the process again and again is very unproductive
... ). A handshake is basically an automatic process of negotiation between two entities, usually your
computer and the network server it wants to connect to. It's the procedure that sets the configurations and
parameters needed to make the communication channel run smoothly without manually putting in
specifications and whatnot every time you connect heterogeneous systems or machines together.
As first, you need to dump all the Wi-Fi signals available in the environment. To do it we are going
to use airodump-ng that expects as first parameter the name of the interface in monitor mode. Execute
the following command to dump the Wi-Fi networks:
airodump-ng wlan0mon
This command will dump a table with all the available Wi-Fi networks similar to:
17 | P a g e
#|BSSID |PWR |Beacons | #Data | #/s |CH |MB |ENC |CIPHER
|AUTH | ESSID |
#|C8:0E:14:03:B0:EA |-34 |38 | 0 | 0 |1 |54e. |WPA2 |CCMP
|PSK | The network name |
From this table you should copy the information (the row) about the network that you want to hack
on in the notepad as you will need this information later (channel-CH and BSSID).
Now let's copy the WPA Handshake with airodump. The following command:
Will copy the WPA Handshake of the modem that you want providing the required parameters.
The channel and BSSID arguments can be retrieved from the previously obtained using airodump-
ng wlan0mon. The w argument needs to be the path of the folder in which you want to save the
Handshake of the modem, lastly the name of the interface in the monitor mode (wlan0mon). So, our
command to execute would look like:
We are going to save the files into /root/hacking (this folder needs to be previously created), you
are free to save it whereever you want as long as you remember the path later. This process could
take several minutes, in our case it took just 4 minutes, however this may vary in every network
and devices:
Tip
To speed the process of obtain the WPA Hanshake, you can use a mobile device or other computer
that is connected to the Wi-Fi network. Just turn off the Wi-Fi in your device and turn it on again,
this should speed the process.
Once the process show the WPA hanshake, the required files to start the dictionary attack. As
providen in our example command, the files generated should be stored in /root/hacking/:
18 | P a g e
The number of files may vary in your computer.
To capture the WPA/WPA2 handshake, we need to force the client to reauthenticate. This can be
achieved with aireplay, this attack sends disassociate packets to one or more clients which are
currently associated with a particular access point.
The recommended number of packages for this kind of attacks is 10 (you need to provide the BSSID
of the modem and the name of the monitor interface too). The command to execute should look
like:
That should generate the following output (note that in the image the BSSID is wrong, it should be
C8:0E:14:03:B0:EA):
19 | P a g e
6.Create (or use) a passwords dictionary
Before proceeding with the attack, you need a passwords dictionary. This dictionary is basically a
text file (filename.txt) with words that aircrack should use to access the network, so basically
the following text is a password dictionary (every password is divided by a new line):
hello possible_password1
possible_password2
hello123
ourcodeworld_password123
dummypassword321
For educational purposes, as this is a place to learn to code, we are going to write some C code.
Create a new file in the workspace (in our case /root/hacking) with the name
passwords_generator and extension c (passwords_generator.c). This file will contain the
following C code that generates a number sequence from 00000000 to 00009999 (a number for
every line):
Important
The bigger the number, the more the combinations to try, therefore more time take the process to
test.
#include<stdio.h> int
main()
{
int i;
for (i = 0; i<= 9999;i++){
printf("%08d\n",i);
}
return 0;
}
00000001
00000002
00000003
00000004
...
00009999
You only need to save the previous output into a file that will be used as a dictionary for our attack.
Execute the following command to save it to a passwords.txt file (note that the path is up to you,
we still using /root/hacking for it):
Note
gcc is a *nix-based C compiler usually operated via the command line, by default available in Kali
Linux
The trick is, that in this "passwords dictionary" there are 9999 possible combinations that will be
tried. Obviously if the network has a secure password, not any of the generated "numbers
passwords" should work, so if you are only testing, you can add the password of your Wi-Fi
network to test it in the next step.
Your dictionary is just a text file in which every line is a possible password that aircrack will try to
access the network later, in order to test if aircrack really works, you can simply create the
passwords.txt file with the password of your Wi-Fi network inside and in the next step, then the
access to the network should be granted (we'll write our own password too to prove that it works).
You can use obviously a "passwords database" to try with different combinations. Check out this
question in the Security Forum of Stack Exchange that offers a lot of sources to get started with a
passwords dictionary if you don't want to use simple numbers.
Finally, let's start our dictionary attack using the following command:
You need to provide the BSSID, then the w argument that specifies the txt file with all the passwords
to try and then the path to the .cap files generated while we retrieved the
handshake in the step 5. For example, replacing the values with our examples, the command should
look like:
aircrack-ng -a2 -b C8:0E:14:03:B0:EA -w /root/hacking/passwords.txt
/root/hacking/*.cap
The execution of the command should start the dictionary attack and will try to access the network with
every single password in our dictionary. The duration of the process will vary according to the number of
passwords in your dictionary.
If the password is found in the dictionary (if found in the dictionary generated by our C code, then it was a
really bad password ... ) the message KEY FOUND will appear.
That's it, you've just learned how to perform a dictionary attack to a Wi-Fi network using Aircrack
21 | P a g e
Experiment no: 5
Phishing attack using kali Linux is a form of a cyber attack that typically relies on email or other
electronic communication methods such as text messages and phone calls. It is one of the most
popular techniques of social engineering. Where hackers pose as a trustworthy organization or entity
and trick users into revealing sensitive and confidential information.
We will create a Facebook phishing page using Social Engineering Toolkit which is a preinstalled
functionality in Kali Linux OS. The phishing link can be sent to any user on the same Local Area
Network as you and the data that they enter on the fraudulent page will be stored in a file on the
attacker’s machine.
Social Engineering Toolkit or SET for short is the standard for social engineering testing among
security professionals and even beginners must have a basic idea about using the tool. Basically, it
implements a computer-based social engineering attack.
Open the terminal window in Kali and make sure you have root access as „setoolkit‟ needs you to have root
access
Type „setoolkit‟ in the command line.
22 | P a g e
You will be warned that this tool is to be used only with company authorization or for educational
purposes only and that the terms of service will be violated if you use it for malicious purposes.
A menu shows up next. Enter 1 as the choice as in this demo we attempt to demonstrate a social engineering
attack.
Under Social Engineering, there are various computer-based attacks and SET explains each in one line
before asking for a choice.
23 | P a g e
Enter 3 which will select the „Credential Harvester Attack Method‟ as the aim is to obtain user credentials
by creating a bogus page that will have certain form fields.
Now, the attacker has a choice to either craft a malicious web page on their own or to just clone an
existing trustworthy site.
Now you need to see the IP address of the attacker machine. Open a new terminal window and write ifconfig
Copy the IP address stated in „inet‟ field
24 | P a g e
SET will ask you to provide an IP where the credentials captured will be stored. Paste the address
that you copied in the earlier step.
Since we chose to clone a website instead of a personalized one, the URL to be cloned is to be
provided. In this example, it is www.facebook.com
Social Engineering Toolkit needs Apache Server running as captured data is written to the root
directory of Apache. Enter y when prompted about starting the Apache process.
The setup for a phishing attack is complete, you have cloned Facebook and hosted it on the server.
SET informs us of the directory at which the captured data will be stored.
25 | P a g e
The IP address is usually hidden carefully by using URL shortener services to change the URL so
that it is better hidden and then sent in urgent-sounding emails or text messages.
Go to browser and type http://yourIP (eg: http://192.168.0.108) Note: I am writing this article from
Maharashtra, India hence Facebook is in the native language Marathi.
If an unsuspecting user fills in their details and clicks on ‘Log In’, the fake page takes them to the
actual Facebook login page. Usually, people tend to pass it off as a glitch in FB or an error in their
typing.
Finally, reap the benefits. Go to /var/www/html and you can see the harvester file created there.
26 | P a g e
Hope this guide gave you a basic idea of how phishing attacks work.
CONCLUSION
Phishing is constantly evolving to entrap innocent computer users. Recommended safety tips will be
to always check the URL of a website in the browser and use two-factor authentication as it provides
an extra security layer to your account.
27 | P a g e
Experiment no: 6
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Explanation:
28 | P a g e
The cookie "username" is assigned "LordSudeep".
setMaxAge(365 * 24 * 60 * 60) ensures the cookie persists for one year.
setPath("/") makes the cookie accessible across the entire domain.
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
if (cookies != null) {
for (Cookie cookie : cookies) {
response.getWriter().println("Cookie Name: " + cookie.getName());
response.getWriter().println("Cookie Value: " + cookie.getValue());
}
} else {
response.getWriter().println("No cookies found!");
}
}
}
Explanation:
29 | P a g e
You can send cookies as JSON to another system.
import org.json.JSONObject;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;
if (cookies != null) {
for (Cookie cookie : cookies) {
json.put(cookie.getName(), cookie.getValue());
}
}
response.setContentType("application/json");
PrintWriter out = response.getWriter();
out.print(json.toString());
}
}
Explanation:
import javax.servlet.http.*;
import java.io.IOException;
import org.json.JSONObject;
Explanation:
5. Security Considerations
HttpOnly & Secure Cookies: Some cookies cannot be transferred if they have security flags
enabled.
Session Cookies: These expire when the browser is closed and cannot be transferred.
Domain Restrictions: Ensure the new machine is allowed to read and set cookies.
Conclusion
By following these steps, cookies can be:
This method allows seamless migration of cookies between machines while maintaining security!
31 | P a g e
Experiment no: 7
import org.springframework.context.annotation.Configuration;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBui
lder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/admin/**").authenticated() // Protect admin routes
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/admin/dashboard")
.permitAll()
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/login?logout");
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
32 | P a g e
auth.inMemoryAuthentication()
.withUser("admin").password("{noop}password").roles("ADMIN");
}
}
Explanation:
/admin/** routes require authentication.
Users must log in before accessing admin features.
inMemoryAuthentication() sets up a default admin user (admin/password).
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
if (!ALLOWED_IP.equals(remoteIP)) {
((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN,
"Access Denied");
return;
}
chain.doFilter(request, response);
}
Explanation:
Checks if the request is coming from a trusted IP.
Denies access if the IP does not match.
33 | P a g e
3. Secure Communication with HTTPS
Use HTTPS to encrypt data transmission.
bash
keytool -genkey -alias tomcat -keyalg RSA -keystore keystore.jks -validity 365 -storepass changeit
2. Configure server.xml:
xml
keystoreFile="conf/keystore.jks"
keystorePass="changeit"
clientAuth="false" sslProtocol="TLS"/>
@Configuration
@EnableWebSecurity
public class RoleBasedSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/admin/**").hasRole("ADMIN") // Only ADMIN role can access
.anyRequest().authenticated()
.and()
.formLogin()
.and()
.logout();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
34 | P a g e
.withUser("admin").password("{noop}adminpass").roles("ADMIN")
.and()
.withUser("user").password("{noop}userpass").roles("USER");
}
}
Explanation:
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
@Component
public class LoginAttemptListener implements
ApplicationListener<AuthenticationFailureBadCredentialsEvent> {
Explanation:
Tracks failed login attempts.
Locks accounts after 5 failed attempts.
35 | P a g e
6. Enable Session Security
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
Explanation:
Logs out inactive users after 15 minutes.
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import java.util.logging.Logger;
@Aspect
@Component
public class AdminActivityLogger {
private static final Logger logger = Logger.getLogger(AdminActivityLogger.class.getName());
@AfterReturning("execution(* com.example.controller.AdminController.*(..))")
public void logAdminActivity() {
logger.info("Admin activity recorded.");
}
}
Explanation:
Logs admin actions using Aspect-Oriented Programming (AOP).
36 | P a g e
8. Secure API Endpoints
Explanation:
JWT tokens authenticate admin users securely.
bash
mvn versions:display-dependency-updates
Conclusion
37 | P a g e
Experiment no: 8
Note:
If your machine isn't forwarding the packets, the internet connection of the user will freeze and
therefore the attack will be useless.
Run your command in a new terminal and let it running (don't close it until you want to stop the
attack).
This process will monitor the packet flow from the Victim to the Router.
Now that you're intercepting packets from the victim to the router (running on a terminal), you need now to
intercept the packets from the victim to the router with arpspoof. The structure of the command to start
intercepting packets from the router to the victim is the following:
38 | P a g e
Important
Run your command in a new terminal and let it running (don't close it until you want to stop the
attack).
As you can see, it's the same command of the previous step but we switched the possition of the
arguments. Till this point you're already infiltrated to the connection between your victim and the
router. Now you just need to learn how to read those packets using driftnet and urlsnarf.
To see the images from websites that our victim visits, you need to use driftnet. Driftnet is a program
which listens to network traffic and picks out images from TCP streams it observes. Fun to run on a
host which sees lots of web traffic. The strucure of the command to start driftnet and see the images
that the user see on the websites is the following:
Note:
If your machine isn't forwarding the packets, the internet connection of the user will freeze and
therefore the attack will be useless.
driftnet -i wlan0
To get information about the websites that our victim visits, you can use urlsnarf for it. It is a
command line tool that sniffs HTTP requests in Common Log Format. It outputs all requested URLs
sniffed from HTTP traffic in CLF (Common Log Format, used by almost all web servers), suitable
for offline post-processing with your favorite web log analysis tool (analog, wwwstat, etc.). The
structure of the command to sniff the URLs that your victim visits, is the following:
In this case, with the information we have, the command to execute will look like:
Note
If your machine isn't forwarding the packets, the internet connection of the user will freeze and
therefore the attack will be useless.
urlsnarf -i wlan0
39 | P a g e
Congratulations, if you have followed all the steps carefully, you should be now sniffing information
about the target you've chosen with a MITM attack. Once your victim visits a website, you should
be able to read information about his actions on the internet. To stop the attack, press CTRL + C on
every terminal where any process that you've opened is running.
# Same step but inverted (nope, it's not the same ...)
# Note: Run this command in a new terminal and let it running arpspoof
-i [Network Interface Name] -t [Router IP] [Victim IP]
# Note: Run this command in a new terminal and let it running urlsnarf -i
[Network Interface Name]
# Disable port forwarding once you're done with the attack sysctl -
w net.ipv4.ip_forward=0
40 | P a g e
Experiment no: 9
Installation
Ccrypt Manual
-e, –encrypt :Encrypt. This is the default mode. If filename arguments are given, encrypt the files
and append the suffix .cpt to their names. Otherwise, run as a filter.
-d, –decrypt: Decrypt. If filename arguments are given, decrypt the files and strip the suffix
.cpt from the filenames, if present. Otherwise, run as a filter.
-c, –cat: Decrypt one or more files to standard output. If no filename arguments are given,
decrypt as a filter. Implies -l.
-x, –keychange: Change the key of encrypted data. In this mode, ccrypt prompts for two
passwords: the old one and the new one. If filename arguments are given, modify the files.
Otherwise, run as a filter.
-u, –unixcrypt: Simulate the old unix crypt command. Note: the cipher used by unix crypt
has been broken and is not secure. Please use this option only to decrypt existing files. If
filename arguments are given, decrypt the files to stdout. Otherwise, run as a filter. Note that
for the unix crypt format, there is no easy way to detect whether a given key matches or not;
thus, for safety, this mode does not overwrite files.
41 | P a g e
Source file have been removed and only encrypted file is there:
ccrypt –d encryptedfilename
ccrypt –d impfile.cpt
42 | P a g e
Experiment no: 10
The Caesar cipher is the simplest and oldest method of cryptography. The Caesar cipher method is based on
a mono-alphabetic cipher and is also called a shift cipher or additive cipher. Julius Caesar used the shift
cipher (additive cipher) technique to communicate with his officers. For this reason, the shift cipher
technique is called the Caesar cipher. The Caesar cipher is a kind of replacement (substitution) cipher, where
all letter of plain text is replaced by another letter.
Let's take an example to understand the Caesar cipher, suppose we are shifting with 1, then A will
be replaced by B, B will be replaced by C, C will be replaced by D, D will be replaced by C, and this
process continues until the entire plain text is finished.
Caesar ciphers is a weak method of cryptography. It can be easily hacked. It means the message
encrypted by this method can be easily decrypted.
E (x) = (x + n) mod 26
n
If any case (Dn) value becomes negative (-ve), in this case, we will add 26 in the negative value.
Where,
E denotes the encryption
Note: "i" denotes the offset of the ith number of the letters, as shown in the table below.
43 | P a g e
Example: 1 Use the Caesar cipher to encrypt and decrypt the message "JAVATPOINT," and the
key (shift) value of this message is 3.
Encryption
We apply encryption formulas by character, based on alphabetical order. The formula of encryption is:
E (x) = (x + n) mod 26
n
The encrypted message is "MDYDWSRLQW". Note that the Caesar cipher is monoalphabetic, so
the same plaintext letters are encrypted as the same letters. For example, "JAVATPOINT" has "A",
encrypted by "D".
Decryption
We apply decryption formulas by character, based on alphabetical order. The formula of decryption is:
D (x) = (x - n) mod 26
n i
If any case (D ) value becomes negative (-ve), in this case, we will add 26 in the negative value.
n
Ciphertext: M → 12
Encryption
E (x) = (x + n) mod 26
n
Note that the Caesar cipher is monoalphabetic, so the same plaintext letters are encrypted as
the same letters. Like, "HELLO" has "L", encrypted by "A".
Decryption
Note: If any case (D ) value becomes negative (-ve), in this case, we will add 26 in the
n
D =
n (00 - 15) mod 26
= -15
45 | P a g e
The value of dn is negative, so 26 will be added to it.
= -15 + 26
= 11
1. It can be easily hacked. It means the message encrypted by this method can be easily
decrypted.
2. It provides very little security.
3. By looking at the pattern of letters in it, the entire message can be decrypted.
Program
1. #include<stdio.h>
2. #include<conio.h>
3. int main()
4. {
5. int i, f;
6. char pop[100], c;
46 | P a g e
17. if(c > 'z')
18. {
19. c = c - 'z' + 'a' - 1;
20. }
21. pop[i] = c;
22. }
23. else if(c >= 'A' && c < 'Z')
24. {
25. c = c + f;
26. if(c > 'Z')
27. {
28. c = c = 'Z' + 'A' - 1;
29. }
30. pop[i] = c;
31. }
32. }
33. printf(" Encrypted message: %s", pop);
34. return 0;
35. }
1. #include<stdio.h>
2. #include<conio.h>
3. int main()
4. {
5. int i, f;
6. char pop[100], c;
7. printf("enter a encrypted test \t");
8. gets(pop);
9. printf("enter key \t");
10. scanf("%d", &f);
11. for(i = 0; pop[i] != '\0'; i++)
12. {
13. c = pop[i];
14. if(c >= 'a' && c <= 'z')
15. {
16. c = c - f;
17. if(c < 'a')
18. {
19. c = c + 'z' - 'a' + 1;
20. }
21. pop[i] = c;
22. }
47 | P a g e
Experiment no: 11
Objective
To implement encryption and decryption in Java using:
Theory
Cryptography is the technique of securing information by transforming it into an unreadable format using
encryption. The receiver can decrypt the message back into a readable format using a secret key.
Algorithm
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.security.*;
import java.util.Base64;
49 | P a g e
public static byte[] decryptRSA(byte[] encryptedKey, PrivateKey privateKey) throws Exception
{
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
return cipher.doFinal(encryptedKey);
}
// Print results
System.out.println("Original Text: " + plainText);
System.out.println("Encrypted Text (AES): " +
Base64.getEncoder().encodeToString(encryptedData));
System.out.println("Encrypted AES Key (RSA): " +
Base64.getEncoder().encodeToString(encryptedAESKey));
System.out.println("Decrypted Text: " + decryptedData);
}
}
50 | P a g e
Experiment no: 12
Objective
This lab manual guides you through performing different types of Java code analysis using IBM Rational
AppScan. You will learn how to configure and run static, dynamic, and interactive security analysis to identify
vulnerabilities in your Java applications.
Prerequisites
1. Download and install IBM Rational AppScan Standard or IBM Security AppScan Source.
2. Open AppScan and create a new Static Analysis project.
3. Configure the workspace to point to your Java project directory.
4. Ensure JDK is correctly set up in the project settings.
51 | P a g e
Step 3: Analyze the Results
Conclusion
By completing this lab, you have learned how to perform static, dynamic, and interactive security analysis
on Java applications using IBM Rational AppScan. Regularly performing these tests helps in securing Java
applications against cyber threats.
52 | P a g e