CSS Practical File
CSS Practical File
Code Explanation:
This C program is designed to print the name of the executable and a substring of
the first command-line argument provided to it. It includes the necessary header
files, `stdio.h` for input/output functions and `string.h` for string manipulation.
Within the `main` function, the program initializes a character array `a` with a size
of 5 to store part of the input string. It first outputs the name of the program,
which is accessed through the first element of the `argv` array. Next, it utilizes
`strncpy` to copy up to 5 characters from `argv[1]`, representing the first command-
line argument, into the array `a`. Finally, the program prints the contents of `a`.
However, it’s important to note that if `argv[1]` is shorter than 5 characters, `a` may
not be null-terminated, potentially leading to undefined behavior when printed.
Proper handling of null termination is crucial when using `strncpy` to avoid such
issues.
Practical 2
Aim: Practical demonstration of race conditions and vulnerability and attack. What
are possible solutions for race conditioning vulnerability.
Code Snippet:
• Soln:
Code Explanation:
The code consists of two implementations for managing a bank account balance
with threads in C. In the first implementation, two threads increment (deposit) and
decrement (withdraw) the balance without any synchronization, leading to race
conditions and an inconsistent final balance. The second implementation uses a
mutex to synchronize access to the balance, ensuring that only one thread modifies
it at a time. This prevents race conditions, resulting in a correct final balance that
matches the expected value.
Practical 3
Code Snippet:
Code Explanation:
This C program modifies a file's memory mapping using two threads. It takes a
target file and new content as arguments. The first thread repeatedly advises the
kernel to discard the mapped memory with `madvise`, while the second thread
writes the new content to `/proc/self/mem` at the mapped address. After running
for 5 seconds, both threads are stopped, and resources are cleaned up. The
program demonstrates a way to manipulate memory mapping and file content
concurrently.
Practical 4
7. Now your burp is ready for use after the completion of the setup.
Result: The following experiment shows how the installation process the
completed successfully.
Practical 5
Demonstration:
Set up Burp Suite: Open Burp Suite, go to the proxy tab, and ensure
Intercept is on. Configure your browser to use Burp Suite proxy.
Find XSS Vulnerability: Find a web page with an input field for example
search box, comment section.
Intercept Request: Burp Suite intercepts the request. Go to the Proxy and
make sure the intercept is on before sending the request.
Test with Repeater: In the Repeater tab, modify the request with the
following payload and resend it.
<script>alert(1)</script>
Verify XSS: You can see in the Response the script is embedded inside the
response as a javascript rather than a simple string.
Also, if you check on the browser it will show up the alert box in the web
page which confirms the presence of XSS Vulnerability.
Aim: Practical demonstration of CSRF vulnerability and attack and the possible
solutions for CRSF attack also.
Code Snippet:
1. HTML Code:
Result: This code represents the working of CSRF Attack and it also
shows the protection.
Practical 7
Code Snippet: