SCSV Lab Manual 2023
SCSV Lab Manual 2023
vulnerability
Lab Manual
Department of Computer Science and Engineering
The NorthCap University, Gurugram
SCV|2
Session 2021-2022
SCV|3
Published by:
© Copyright Reserved
Copying or facilitating copying of lab work comes under cheating and is considered as use of
unfair means. Students indulging in copying or facilitating copying shall be awarded zero marks
for that particular experiment. Frequent cases of copying may lead to disciplinary action.
Attendance in lab classes is mandatory.
Labs are open up to 7 PM upon request. Students are encouraged to make full use of labs beyond
normal lab hours.
PREFACE
SCV|4
Secure Coding and Software Vulnerability Lab Manual is designed to meet the course and
program requirements of NCU curriculum for B.Tech IIIsemester students of CSE Cyber
Security Specialization . The concept of the lab work is to give brief practical experience for
basic lab skills to students. It provides the space and scope for self-study so that students can
come up with new and creative ideas.
The Lab manual is written on the basis of “teach yourself pattern” and expected that students
who come with proper preparation should be able to perform the experiments without any
difficulty. Brief introduction to each experiment with information about self-study material is
provided.
The Laboratory includes common softwarevulnerabilities and how to find them, as well as how
the vulnerabilities can be exploited usingreverse engineering &its tools. It also includes how
buffer overflow attack happens and howattackers utilize it to gain access to the vulnerable
system. Finally, at the end popular web SQLinjection attack, and their common defense is
implemented.At the start of each experiment a question bank for preparation and practice is
suggested which may be used to test the basic understanding of the students about the
experiment. Students are expected to come thoroughly prepared for the lab. General disciplines,
safety guidelines and report writing are also discussed.
The lab manual is a part of curriculum for the TheNorthCap University, Gurugram. Teacher’s
copy of the experimental results and answer for the questions are available as sample guidelines.
We hope that lab manual would be useful to students of CSE, IT, ECE and BSc branches and
author requests the readers to kindly forward their suggestions / constructive criticism for further
improvement of the workbook.
Author expresses deep gratitude to Members, Governing Body-NCU for encouragement and
motivation.
Authors
The NorthCap University
Gurugram, India
CONTENTS
Syllabus VI-IX
1 Introduction X
2 Lab Requirement XI
COURSE TEMPLATE
6. Type of Course
Programme Core Programme Elective Open Elective
(Check one):
9. Brief Syllabus:
This course deals with security architecture elements within modern object-oriented programming
languages that create the framework for secure programming. This course would cover the design
and implementation of secure systems. Coding Standards, best practices, guidelines and style will
further enhance the ability to develop secure code. This course includes common software
vulnerabilities and how to find them, as well as how the vulnerabilities can be exploited using
reverse engineering & its tools. It also includes how buffer overflow attack happens and how
attackers utilize it to gain access to the vulnerable system. Finally, at the end popular web SQL
injection attack, and their common defenseis implemented.
Total lecture, Tutorial and Practical Hours for this course (Take 15 teaching weeks per
semester): 90
Practice
Lectures: 30 hours
Tutorials: 15 hours Lab Work: 45 hours
10. Course Outcomes (COs)
Possible usefulness of this course after its completion i.e. how this course will be practically
useful to him once it is completed
Understand the need for secure coding and follow fundamental secure coding
CO 1
guidelines.
Describe and compare software engineering practices and apply reverse engineering on
CO 2
vulnerable software.
Develop skills to find the low-level vulnerabilities in software application and exploit
CO 3
these vulnerabilities using buffer overflow attack.
CO 4
Identify the vulnerabilities of database in the web application and fix these
SCV|7
vulnerabilities.
11. UNIT WISE DETAILS No. of Units: 4
Testing methodologies
http://packetstormsecurity.nl/programming-tutorials/
http://irccrew.org/~cras/security/c-guide.html
http://www.dwheeler.com/secure-programs/
www.securecoding.org/
Text Books:
1. Gray R.,"Software Security, “Building Security In", Addison-Wesley Software Security, 2nd
Edition, 2006
2. Dafydd stuttard, Marcus Pinto, “The Web Application Hacker's Handbook", Wiley Publishing,
2nd Edition, 2011
Reference Books:
1. Kenneth van Wyk, Mark Graff, “Secure Coding: Principles and Practices”, O'Reilly Media 2nd
Edition, 2003
2. Robert C. Seacord, "Secure Coding in C and C++ ", SEI Series in Software Engineering, 2nd
Edition, 2013
3. Michael Howard, David LeBlanc, "Writing Secure Code", 2nd Edition, 2003
Reference Websites: (nptel, swayam, coursera, edx, udemy, lms, official documentation
weblink)
https://nptel.ac.in/noc/individual_course.php?id=noc19-cs29
https://www.cybrary.it/course/cryptography/
https://nptel.ac.in/courses/106106199/
https://www.cybrary.it/course/secure-coding/
eBooks:
secure coding in JAVA
https://medium.com/set1-interview-questions
https://www.sanfoundry.com/cyber-security-questions-answers-buffer-overflow-1/
SCV|10
1. INTRODUCTION
To familiarize the students with the basic concepts, of secure programming and the
take home laboratory assignments mainly implementation-oriented which includes
threats, mitigation and detection techniques. The lab sessions will be based on
exploring the concepts discussed in class.
Observing Security problems in Software Programs
Reporting and analysing the security threats and exploits in programs.
Hands on experience on mitigation techniques
SCV|11
1. LAB REQUIREMENTS
Requirements Details
Hardware Requirements Windows and Linux: Intel 64/32 or AMD Athlon 64/32,
or AMD Opteron processor
16 GB RAM
256 GB hard disk space
Required Bandwidth NA
SCV|12
3. GENERAL INSTRUCTIONS
Students must turn up in time and contact concerned faculty for the experiment they
are supposed to perform.
Students will not be allowed to enter late in the lab.
Students will not leave the class till the period is over.
Students should come prepared for their experiment.
Experimental results should be entered in the lab report format and certified/signed
by concerned faculty/ lab Instructor.
Students must get the connection of the hardware setup verified before switching on
the power supply.
Students should maintain silence while performing the experiments. If any necessity
arises for discussion amongst them, they should discuss with a very low pitch
without disturbing the adjacent groups.
Violating the above code of conduct may attract disciplinary action.
Damaging lab equipment or removing any component from the lab may invite
penalties and strict disciplinary action.
3.2 Attendance
Students should come to the lab thoroughly prepared on the experiments they are
assigned to perform on that day. Brief introduction to each experiment with
information about self study reference is provided on LMS.
Students must bring the lab report during each practical class with written records
of the last experiments performed complete in all respect.
Each student is required to write a complete report of the experiment he has
performed and bring to lab class for evaluation in the next working lab. Sufficient
space in work book is provided for independent writing of theory, observation,
calculation and conclusion.
SCV|13
Students should follow the Zero tolerance policy for copying / plagiarism. Zero
marks will be awarded if found copied. If caught further, it will lead to disciplinary
action.
Refer Annexure 1 for Lab Report Format
SCV|14
1. LIST OF EXPERIMENTS
1. LIST OF PROJECTS
SCV|16
2. RUBRICS
Marks Distribution
Continuous Evaluation(50 Marks) End Semester Exam (20 Marks)
Each experiment shall be evaluated for 10 End semester practical evaluation including
marks and at the end of the semester carries 20 marks.
proportional marks shall be awarded out of
50.
Following is the breakup of 10 marks for each
4 Marks: Observation & conduct of
experiment. Teacher may ask questions about
experiment.
3 Marks: For report writing
3 Marks: For the 15 minutes quiz to be conducted
in every lab.
Annexure1
(CSL 283)
Roll No.:
Semester:
Group:
Session 2021-2022
INDEX
S.No Experiment Page Date of Date of Marks CO Signature
No. Experiment Submission Covere
d
SCV|2
Experiment No. 1
Objective
To familiarize the students about the secure coding Concepts
Program Outcome
The students will understand the concepts of vulnerabilities and coding securely
Problem Statement
Prepare a report on software vulnerabilities? Types of software Vulnerabilities? Name atleast 3 Latest
Software vulnerabilities.
Background Study:
A software vulnerability is a defect in software that could allow an attacker to gain control of a
system. These defects can be because of the way the software is designed, or because of a flaw in
the way that it’s coded.
WhatCan Cause a Software Vulnerability?There are two main things that can cause a software
vulnerability. A flaw in the program’s design, such as in the login function, could introduce a
vulnerability. But, even if the design is perfect, there could still be a vulnerability if there’s a mistake
in the program source code.
Coding errors could introduce several types of vulnerabilities, which include the following:Buffer
overflows – These allow someone to put more data into an input field than what the field is supposed
to allow. An attacker can take advantage of this by placing malicious commands into the overflow
portion of the data field, which would then execute.
Questions
SCV|3
Q2. Which phase of software development life cycle needs to be made secure?
Q3. What is Static and Dynamic analysis of code? What are the different tools
SCV|4
Experiment No. 2
Objective
To familiarize the students about the various software models and methodology
Program Outcome
The students will understand the Basics of Software Engineering
Problem Statement
(ii) Explain and compare different SDLC models (waterfall, Incremental, Spiral, RAD, Iterative)
Background Study:
Security is an important part of any application that encompases critical functionality. This can
be as simple as securing your database from attacks by nefarious actors or as complex as
applying fraud processing to a qualified lead before importing them into your platform.
Security applies at every phase of the software development life cycle (SDLC) and needs to be at
the forefront of your developers’ minds as they implement your software’s requirements. In this
article, we’ll explore ways to create a secure SDLC, helping you catch issues in requirements
before they manifest as security problems in production.
SCV|6
Questions
Algorithm/Flowchart/Code/Sample Outputs
SCV|8
Experiment No:3
Objective
To familiarize the students about the secure coding language.
Program Outcome
The students will understand the how to write a secure code in C/C++
Problem Statement
Write a secure program in C/C++ using string functions to compare two strings.
Background Study:
Secure coding is the practice of developing computer software in a way that guards against the
accidental introduction of security vulnerabilities. Defects, bugs and logic flaws are consistently
the primary cause of commonly exploited software vulnerabilities.
1. Validate input.
2. Heed compiler warnings.
3. Architect and design for security policies.
4. Keep it simple.
5. Default deny.
6. Adhere to the principle of least privilege.
7. Sanitize data sent to other systems.
8. Practice defense in depth.
9. Use effective quality assurance techniques.
10. Adopt a secure coding standard.
SCV|9
E.g.
Questions
Q2. Which phase of software development life cycle needs to be made secure?
Q3. What all work has been done in direction of making the code secure?
Experiment No: 4
Objective
To familiarize the students about the vulnerabilities in the software codes.
Program Outcome
The students will understand what non-complaint codes are and how the vulnerabilities in the code
can lead to exploitation.
Problem Statement
Find the Non-complaint codes in C/C++ or Java and write the complaint codes for the same with its
vulnerability and mitigation.
Background Study:
Let us examine rule Close files when they are no longer needed. The C++ rule exists because C++
provides a technique to simplify compliance, as follows:
Questions
Q3. How can non complaint code affect the Software and the company?
Experiment No: 5
Objective
To familiarize the students about the Security Analysis Tools.
Program Outcome
The students will understand the Static and Dynamic analysis of Software codes
Problem Statement
Prepare a report on the Security Tools used for Security analysis of Codes (Static and Dynamic
Tool).
Background Study:
Dynamic analysis adopts the opposite approach and is executed while a program is in
operation. Dynamic application security testing (DAST) looks at the application from the outside in
— by examining it in its running state and trying to manipulate it in order to discover security
vulnerabilities. The dynamic test simulates attacks against a web application and analyzes the
application’s reactions, determining whether it is vulnerable.
Having originated and evolved separately, static and dynamic analysis have, at times, been
SCV|16
mistakenly viewed in opposition. There are, however, a number of strengths and weaknesses
associated with both approaches to consider.
Questions
Q1. How can you secure the code? What are the methods and techniques to secure it?
Q2. Show the latest trend of vulnerability increase till year 2020 with the help of graph?
Q3. Present different case studies of latest attacks on software due to vulnerable software
Experiment No: 6
Objective
To familiarize the students about the Big Block of RAM.
Program Outcome
The students will understand the memory layout of C program in block of RAM
Problem Statement
Write C codes to find the size of the memory that varies in text, data and BSS of RAM with change in
initialized and uninitialized variables of global and static variables.
Background Study:
Text
Data (initialized /Uninitialized)
Stack
Heap
Kernel
SCV|19
Questions
Experiment No: 7
Objective
To familiarize the students about the programming done for licensed software.
Program Outcome
The students will understand programming done for developing a licensed version software.
The students will understand the role of debugger
Problem Statement
Installation of Olly Debugger
Write a custom C program to check valid purchased key for a software.
Write a C program and find addresses using Olly Debugger
Background Study:
Olly Debugger (OllyDbg) is a 32-bit assembler level analyzing debugger for Microsoft Windows.
Emphasis on binary code analysis makes it particularly useful in cases where source is unavailable.
Questions
Q4. What is the difference between 32-bit and 64-bit assembler? Do they both work similarly?
Experiment No: 8
Objective
To familiarize the students with the concept of Reverse Engineering using Algorithm Manipulation.
Program Outcome
The students will understand the Reverse Engineering.
The students will be able to reverse engineer any EXE to crack the licensing problem in the
software.
Problem Statement
Perform the steps to crack licensed version of PowerISO.exe using reverse engineering
Questions
Q1. What is Reverse Engineering? What is the difference between forward engineering and Reverse
engineering?
Q3. When company release the product or software, do they provide software code along with it? Why?
Experiment No: 9
Objective
To familiarize the students with the concept of hash.
Program Outcome
The students will be able to understand the concept of hash in C programming using various hash
algorithms.
Problem Statement
Write different messages by changing different characters and by adding spaces and find its hash
using miraclesalad.com
Background Study:
A hash algorithm is a function that converts a data string into a numeric string output of fixed
length. The output string is generally much smaller than the original data. Hash algorithms are
designed to be collision-resistant, meaning that there is a very low probability that the same string
would be created for different data.
Two of the most common hash algorithms are the MD5 (Message-Digest algorithm 5) and the
SHA-1 (Secure Hash Algorithm). MD5 Message Digest checksums are commonly used to validate
SCV|27
Questions
Q6. How can we identify what type of hashing technique has been applied on the digest by just seeing it?
SCV|28
Experiment No: 10
Objective
To familiarize the students with the concept of Reverse Engineering via File Manipulation for different
software.
Program Outcome
The students will be able to reverse engineer a software which are hash protected.
Problem Statement
Follow the process of reverse engineering using File manipulation to make a crack of SMAC 2.0
Questions
Q4. Should license Key should be stored in encrypted form in the code?
Experiment No: 11
Objective
To familiarize the students the concept of Low Level-Buffer Overflow vulnerabilities in Code
Program Outcome
The students will be able identify the Buffer Overflow vulnerability of the software code.
Problem Statement
Background Study:
A buffer is a temporary area for data storage. When more data (than was originally allocated to be
stored) gets placed by a program or system process, the extra data overflows. It causes some of that
SCV|32
data to leak out into other buffers, which can corrupt or overwrite whatever data they were holding.
SCV|33
Experiment No: 12
Objective
To familiarize the students the concept of Low Level-Buffer Overflow vulnerabilities in Code
Program Outcome
The students will be able secure the Buffer Overflow vulnerability in a software code
Problem Statement
Background Study:
Attacker would use a buffer-overflow exploit to take advantage of a program that is waiting on a
user’s input.
SCV|35
Questions
SCV|36
Q2. What are the tools that can be used to remove this type of vulnerability?
Q3. How will the output vary for non-complaint and complaint code?
Experiment No: 13
Objective
To familiarize the students the concept of buffer Overflow
Program Outcome
The students will be able to exploit the vulnerability of the software using debugger and Metasploit
Problem Statement
Exploit the vulnerability in the software application using immunity debugger and Metasploit
Background Study:
A buffer is a temporary area for data storage. When more data (than was originally allocated to be
stored) gets placed by a program or system process, the extra data overflows. It causes some of that
data to leak out into other buffers, which can corrupt or overwrite whatever data they were holding.
In a buffer-overflow attack, the extra data sometimes holds specific instructions for actions
intended by a hacker or malicious user; for example, the data could trigger a response that damages
files, changes data or unveils private information.
Attacker would use a buffer-overflow exploit to take advantage of a program that is waiting on a
user’s input. There are two types of buffer overflows: stack-based and heap-based. Heap-based,
which are difficult to execute and the least common of the two, attack an application by flooding
the memory space reserved for a program. Stack-based buffer overflows, which are more common
among attackers, exploit applications and programs by using what is known as a stack: memory
space used to store user input.
SCV|39
Questions
Q5. What are the other tools that are used in exploitation in buffer overflow?
Experiment No: 14
Objective
To familiarize the students the concept of Low Level-Stack Overflow vulnerabilities in Code
Program Outcome
The students will be able identify the Stack Overflow vulnerability in a software code
Problem Statement
Background Study:
A stack overflow is an undesirable condition in which a particular computer program tries to use
more memory space than the call stack has available. In programming, the call stack is a buffer
that stores requests that need to be handled
SCV|42
Questions
Experiment No: 15
Objective
To familiarize the students the concept of Low Level-Stack Overflow vulnerabilities in Code
Program Outcome
The students will be able secure the Stack Overflow vulnerability in a software code.
Problem Statement
Background Study:
Stack is a special region of our process’s memory which is used to store local variables used
inside the function, parameters passed through a function and their return addresses. Whenever a
new local variable is declared it is pushed onto the stack. All the variables associated with a
function are deleted and memory they use is freed up, after the function finishes running. The
user does not have any need to free up stack space manually. Stack is Last-In-First-Out data
structure.
SCV|46
Questions
Q2. Explain buffer overflow using a sample C code and show how overflow of stack will happen.
SCV|47
Experiment No: 15
Objective
To familiarize the students with the concept of Low Level-Integer Overflow vulnerabilities in Code
Program Outcome
The students will be able secure the Integer Overflow vulnerability in a software code.
Problem Statement
Background Study:
Integer overflow vulnerabilities are caused when a value is moved into a variable type too small
to hold it. One example is downcasting from a long (which has eight bytes allocated to it) to an
int (which uses two or four bytes). This is accomplished by cutting the value down to a small
enough size that it fits in the smaller value. If any of the bits that are dropped are non-zero, then
the value suddenly becomes a lot smaller.
Integer overflows can also occur when typecasting from an unsigned to a signed variable type.
Both a signed and an unsigned short are stored in two bytes, but the most significant bit of a
signed short indicates whether it is positive or negative. An unsafe cast from unsigned to signed
of a value with a one in the most significant bit changes it from a large positive number to a
negative one.
SCV|49
Questions
SCV|50
Q1. Write a code for Integer Overflow then some questions on that same code including unsigned
int and signed int (according to the code as I had written a simple code which does the addition
of INT_MAX value to overflow it). They even modified the code a bit then asked me the overflowed
value in the case of integer overflow like for example: UINT_MAX + 2 = ?? like that.
Q2. Difference between structure and union and calculate the size of the structure and union in
Student Work
Algorithm/Flowchart/Code/Sample Outputs
SCV|52
Experiment No: 17
Objective
Program Outcome
The students will be able secure the website from SQL injection.
Problem Statement
Background Study:
SQL injection is a web security vulnerability that allows an attacker to interfere with the queries
that an application makes to its database. It generally allows an attacker to view data that they are
not normally able to retrieve. This might include data belonging to other users, or any other data
that the application itself is able to access. In many cases, an attacker can modify or delete this data,
causing persistent changes to the application's content or behavior.
In some situations, an attacker can escalate an SQL injection attack to compromise the underlying
server or other back-end infrastructure, or perform a denial-of-service attack.
A successful SQL injection attack can result in unauthorized access to sensitive data, such as
passwords, credit card details, or personal user information. Many high-profile data breaches in
recent years have been the result of SQL injection attacks, leading to reputational damage and
regulatory fines. In some cases, an attacker can obtain a persistent backdoor into an organization's
systems, leading to a long-term compromise that can go unnoticed for an extended period.
SCV|53
Questions
Algorithm/Flowchart/Code/Sample Outputs
SCV|54
Roll No.:
Semester:
Group:
Table of Contents
S.No Page
No.
1. Project Description
2. Problem Statement
3. Analysis
4. Design
6. Output (Screenshots)