Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 103

Secure coding and Software

vulnerability
Lab Manual
Department of Computer Science and Engineering
The NorthCap University, Gurugram
SCV|2

Secure Coding and software Vulnerability


Lab Manual
CSL283

Dr. Mehak Khurana

Department of Computer Science and Engineering

NorthCap University, Gurugram- 122001, India

Session 2021-2022
SCV|3

Published by:

School of Engineering and Technology

Department of Computer Science & Engineering

The NorthCap University Gurugram

• Laboratory Manual is for Internal Circulation only

© Copyright Reserved

No part of this Practical Record Book may be

reproduced, used, stored without prior permission of The NorthCap University

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

S.N. Details Page No.


SCV|5

Syllabus VI-IX

1 Introduction X

2 Lab Requirement XI

3 General Instructions XII-XIII

4 List of Experiments XIV-XV

8 Annexure 1 (Format of Lab Report) XVII

9 Annexure 2 (Format of Lab Certificate) 48


SCV|6

COURSE TEMPLATE

1. Department: Department of Computer Science and Engineering


3. Course Code 4. L-T-P 5. Credits
2. Course Name: Secure Coding and
Vulnerabilities CSL283 2-0-4 4

6. Type of Course 
Programme Core Programme Elective Open Elective
(Check one):

7. Pre-requisite(s), if any: Any programming Language

8. Frequency of offering (check one):

Odd Even Either semester


 Every semester

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

Title: Introduction Computer Security and


Unit Number: 1 No. of hours: 5
Software Security
Content Summary:
Introduction Computer Security and Software Security, Defects & vulnerabilities, Trinity of Trouble,
Black hat and white hat hackers, Low level vulnerabilities, Security for world wide web: top 10
OWASP vulnerabilities, Penetration testing, Vulnerability cycle.
Title: Exposing Software Vulnerabilities
Unit Number: 2 No. of hours: 10
using Reverse Engineering
Content Summary:
Problems in software, Designing and building Secure Software, Applied Risk Management, Software
Security Touchpoints: seven touchpoints, Reverse Engineering and its tools (ollydbg), Reverse
Engineering through algorithm, Reverse engineering through File Manipulation
Unit Number: 3 Title: Low Level Security No. of hours: 10
Content Summary:
Buffer Overflow attack, Buffer overflow using immunity debugger, Introduction to Memory layout,
Memory attack, Heap overflow, Integer overflow, Defence against low level attacks.
Unit Number: 4 Title: Security for the web No. of hours: 5
Content Summary:
Introduction to SQL injection, Different methods of SQL injection, manual SQLi and SQL injection
countermeasures, secure code using prepared statements

12. Brief Description of Self-learning components by students (through books/resource material


etc.):

Supplementary MOOC Courses


https://www.coursera.org/specializations/secure-coding-practices
https://www.linkedin.com/learning/secure-coding-in-python

Testing methodologies
http://packetstormsecurity.nl/programming-tutorials/
http://irccrew.org/~cras/security/c-guide.html
http://www.dwheeler.com/secure-programs/
www.securecoding.org/

Best practices of secure coding in C/C++/Python/PHP


https://wiki.sei.cmu.edu/confluence/display/seccode/Top10SecureCodingPractices
http://www.isecom.org/ (formerly www.Ideahamster.org/)
https://www.classcentral.com/course/secure-coding-principles-14478

GATE/NET/other PSU Exams


https://www.sanfoundry.com/cyber-security-questions-answers-test/
https://www.sanfoundry.com/cyber-security-questions-answers-bugs-vulnerabilities/
SCV|8

13. Advance Learning Components

Advance project and material


https://github.com/trendmicro/SecureCodingDojo
https://www.coursera.org/learn/identifying-security-vulnerabilities-c-programming

Certification courses/programs for Skill Development


https://www.infosecacademy.io/training/secure-coding.html
https://binsec-academy.com/en/courses/secure-coding-training-web/
https://www.sei.cmu.edu/education-outreach/courses/course.cfm?coursecode=V35

Motivational Project ideas (To be deployed on any Cloud Platform):


1. Caesar Cipher
2. Hash Function
3. Packet Sniffer
4. https://potatopirates.game/blogs/cybersecurity/5-cybersecurity-projects-for-beginners

14. Books Recommended :

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

Interview/Placement related Commonly asked Questions:


SCV|9

 https://medium.com/set1-interview-questions
https://www.sanfoundry.com/cyber-security-questions-answers-buffer-overflow-1/
SCV|10

1. INTRODUCTION

That ‘learning is a continuous process’ cannot be over emphasized. The theoretical


knowledge gained during lecture sessions need to be strengthened through practical
experimentation. Thus, practical makes an integral part of a learning process.

The purpose of conducting experiments can be stated as follows:

 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

Software Requirements Virtual Machine, Olly Dbg, Immunity Debugger

Operating System Kali Linux, Window XP, windows 10

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

3.1 General discipline in the lab

 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

 Attendance in the lab class is compulsory.


 Students should not attend a different lab group/section other than the one assigned
at the beginning of the session.
 On account of illness or some family problems, if a student misses his/her lab
classes, he/she may be assigned a different group to make up the losses in
consultation with the concerned faculty / lab instructor. Or he/she may work in the
lab during spare/extra hours to complete the experiment. No attendance will be
granted for such case.

3.3 Preparation and Performance

 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

S.No. List of Experiments Software Unit CO Time


Used Covered Covered Required

1. Prepare a report on various Software 1 CO1 1 hrs


vulnerabilities Based
Report Latest Vulnerabilities
2. (i) Prepare a detailed report on Software 1 CO1 2hrs
Software Development Life Based
cycle.
(ii) Explain and compare
different SDLC models
(waterfall, Incremental, Spiral,
RAD, Iterative)
(iii) Explain Agile and
DevOps Methodology
3. Write a program in C/C++ Dev C++ 1 CO1 2 hrs
using string functions to
compare two strings
4. Find the Non-complaint codes Dev C++ 1 CO1 2 hrs
in C/C++ or Java and write the
complaint codes for the same
with its vulnerability and
mitigation
5. Prepare a report on the Software 1 CO1 4 hrs
Security Tools used for Based
Security analysis of Codes
(Static and Dynamic Tool)
6. Explain Structure of RAM and Software 1 CO1 2hrs
stack Based
Write a C code to find the size Software 1 CO1 2 hrs
of the memory varies in text, Based
data and BSS of RAM.
8. Installation of Olly Debugger. Olly 2 CO2 5hrs
Write a custom C program to Debugger
check valid purchased key for
a software.
Write a C program and find
addresses using Olly Debugger

9. Follow the process of reverse Olly 2 CO2 2 hrs


engineering to make a crack of Debugger
Power ISO
SCV|15

10. (i) Write a program to check miraclesalad.c 2 CO2 2 hrs


whether the hash at sender and om/Kali
receivers end is same. Linux
(ii) Use HashCat and Md5sum
to check hash of document
(iii) Write different messages
by changing different
characters and by adding
spaces and find its hash using
miraclesalad.com
11. Follow the process of reverse Olly 2 CO2 2hrs
engineering using File Debugger
manipulation to make a crack
of SMAC 2.0
12. Write a program in C/C++ to Dev C++ 3 CO3 2 hrs
show problem in Buffer
Overflow
13. Write a program in C/C++ to Dev C++ 3 CO3 2 hrs
show without problem of
buffer Overflow
14. Installation of Virtual Machine Kali Linux 3 CO3 6 hrs
and Kali Linux and Perform
Attack on SLmail application.
Install the vulnerable app and
exploit on Window XP

15. Write a program in C/C++ to Dev C++ 3 CO3 2 hrs


show problem in Stack
Overflow
16. Write a program in C/C++ to Dev C++ 3 CO3 2 hrs
show without problem of
buffer Overflow
17. Write a program to solve the Dev C++ 3 CO3 2hrs
integer Overflow

18. Perform SQL injection on real Software 4 CO4 2hrs


website Based

1. LIST OF PROJECTS
SCV|16

1. Reverse engineering on real time Software


2. Buffer Overflow attack on Pac Man

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

Secure Coding and Software Vulnerability


SCV|17

(CSL 283)

Lab Practical Report

Faculty name: Student name:

Roll No.:

Semester:

Group:

Department of Computer Science and Engineering

The NorthCap University, Gurugram- 122001, India

Session 2021-2022
INDEX
S.No Experiment Page Date of Date of Marks CO Signature
No. Experiment Submission Covere
d

1 Report on 16-1-23 16-1-23


software
vulnerabil
ities
2 Repor 20-1-23 20-1-23
t on
SDLC
agile
and
devop
s
metho
logy
3 Write a 23-1-23 23-1-23
program
using a
string
function
to
compare
two
string

4 Find non- 13-2-23 13-2-23


complain
t codes
and write
complain
t code

5 Report on 13-2-23 13-2-23


security
tools
used for
security
analysis
SCV|2
SCV|3

Experiment No. 1

Student Name and Roll Number:Vinay 21csu380


Semester /Section:4th cyber security
Link to Code:
Date:16-1-23
Faculty Signature:
Remarks:

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|4

Q1. What is secure coding?

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|5

Student Work Area

Algorithm/Flowchart/Code/Sample Outputs What is Software


Vulnerability?
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 .


How does a Software Vulnerability Work?

An attacker first finds out if a system has a software vulnerability by scanning it. The scan can
tell the attacker what types of software are on the system, are they up to date, and whether any
of the software packages find that out, he and she will have a better idea of what types of
attacks to launch against the system. A successful attack would result in the attacker being able
to run malicious commands on the target system.

What is Secure Coding?

Secure coding, the principle of designing code that adheres to code security best practices,
safeguards and protects published code from known, unknown and unexpected vulnerabilities
such as security exploits, the loss of cloud secrets, embedded credentials, shared keys,
confidential business data and personally identifiable information.

Which phase of software development life cycle needs to be made secure?

Any compromise to integrity, authentication and availability makes a software unsecure.


Software systems can be attacked to steal information, monitor content, introduce
vulnerabilities and damage the behavior of software. Malware can cause DoS (denial of service)
or crash the system itself.

Buffer overflow, stack overflow, command injection and SQL injections are the most common
attacks on the software.

Buffer and stack overflow attacks overwrite the contents of the heap or stack respectively by
writing extra bytes.
SCV|6

What is static and dynamic analysis of code? What are the different tools

Dynamic Code Analysis

Dynamic code analysis – also called Dynamic Application Security Testing (DAST) – is
designed to test a running application for potentially exploitable vulnerabilities. DAST
tools to identify both compile time and runtime vulnerabilities, such as configuration
errors that only appear within a realistic execution environment.

Static Code Analysis

Static analysis tools refer to a wide array of tools that examine source code,
executables, or even documentation, to find problems before they happen; without
actually running the code.

TYPES OF SOFTWARE VULNERABILITIES

1. Broken Access Control

User restrictions must be properly enforced. If they are broken, it can create a software
vulnerability. Untrustworthy agents can exploit that vulnerability.

2. Cryptographic Failures

Sensitive data — such as addresses, passwords, and account numbers — must be


properly protected. If it isn't, untrustworthy agents take advantage of the vulnerabilities
to gain access.

3. Injection

Injection flaws occur when untrusted data is sent as part of a command or query. The
attack can then trick the targeted system into executing unintended commands. An
attack can also provide untrustworthy agents access to protected data.

4. Insecure Design

Insecure design refers to risks related to design flaws, which often includes the lack of
at least one of the following:
• Threat modeling
SCV|7

• Secure design patterns


• Secure design principles
• Reference architecture

5. Security Logging and Monitoring Failures


Insufficient logging and monitoring processes are dangerous. This leaves your data
vulnerable to tampering, extraction, or even destruction.

Tools to find Software Vulnerability:-


(1.) W3AF:-

W3AF is a  free and open-source tool known as Web Application Attack and
Framework. This tool is an open-source vulnerability scanning tool for web
applications. It creates a framework which helps to secure the web application by
finding and exploiting the vulnerabilities. This tool is known for user-friendliness.Along
with vulnerability scanning options, W3AF has exploitation facilities used for penetration
testing work as well.
Moreover, W3AF covers a high-broaden collection of vulnerabilities. Domains that are
attacked frequently, especially with newly identified vulnerabilities, can select this tool.

(2.) Nmap :-

Nmap is one of the well-known free and open-source network scanning tools among
many security professionals. Nmap uses the probing technique to discover hosts in the
network and for operating system discovery.This feature helps in detecting
vulnerabilities in single or multiple networks. If you are new or learning with
vulnerabilities scanning, then Nmap is a good start.

(3.) Intruder :
Intruder is a paid vulnerability scanner specifically designed to scan cloud-based
storage. Intruder software starts to scan immediately after a vulnerability is released.
The scanning mechanism in Intruder is automated and constantly monitors for
vulnerabilities.
Intruder is suitable for enterprise-level vulnerability scanning as it can manage many
devices. In addition to monitoring cloud-storage, Intruder can help identify network
vulnerabilities as well as provide quality reporting and suggestions.

(4.) Aircrack :-

Aircrack also is known as Aircrack-NG, is a set of tools used for assessing the WiFi
network security. These tools can also be utilized in network auditing, and support
multiple OS’s such as Linux, OS X, Solaris, NetBSD, Windows, and more.

The tool will focus on different areas of WiFi security, such as monitoring the packets
and data, testing drivers and cards, cracking, replying to attacks, etc. This tool allows
you to retrieve the lost keys by capturing the data packets.
SCV|8

Some Software Vulnerabilities :-

(1.) Injection :-

Injection occurs when an attacker exploits insecure code to insert (or inject) their own
code into a program. Because the program is unable to determine code inserted in this
way from its own code, attackers are able to use injection attacks to access secure
areas and confidential information as though they are trusted users. Examples of
injection include SQL Injections, command injections, CRLF injections, and LDAP
injections. Application security testing can reveal injection flaws and suggest
remediation techniques such as stripping special characters from user input or writing
parameterized SQL queries.

(2.) Broken Authentication :-

Incorrectly implemented authentication and session management calls can be a huge


security risk. If attackers notice these vulnerabilities, they may be able to
easily assume legitimate users' identities.Multifactor authentication is one way to
mitigate broken authentication.
Implement DAST and SCA scans to detect and remove issues with implementation
errors before code is deployed.

(3.) Broken Access Control :-

If authentication and access restriction are not properly implemented, it's easy for
attackers to take whatever they want. With broken access control flaws,
unauthenticated or unauthorized users may have access to sensitive files and systems,
or even user privilege settings.
Configuration errors and insecure access control practices are hard to detect as
automated processes cannot always test for them. Penetration testing can detect
missing authentication, but other methods must be used to determine configuration
problems. Weak access controls and issues with credentials
management are preventable with secure coding practices, as well as preventative
measures like locking down administrative accounts and controls and using multi-factor
authentication.

(4.) Insecure Deserialization :-

Deserialization, or retrieving data and objects that have been written to disks or
otherwise saved, can be used to remotely execute code in your application or as a door
to further attacks. The format that an object is serialized into is eitherstructured or binary
text through common serialization systems like JSON andXML. This flaw occurs when
an attacker uses untrusted data to manipulate an application, initiate a denial of service
(DoS) attack, or execute unpredictable code to change the behavior of the application.
SCV|9
SCV|10

Experiment No. 2

Student Name and Roll Number: Vinay 21csu380


Semester /Section:4th cyber security
Link to Code:
Date:20-1-23
Faculty Signature:
Remarks:

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

(i) Prepare a detailed report on Software Development Life cycle.

(ii) Explain and compare different SDLC models (waterfall, Incremental, Spiral, RAD, Iterative)

(iii) Explain Agile and DevOps Methodology

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|11

Questions

Q1. What is the difference between SDLC and SSDLC?

Q2. Differentiate between Agile and DevOps Methodology

Q3. Does these Methodology include security?

Q4. What is a ticketing Tool? e.g., JIRA, SNOW

Student Work Area


SCV|12

Algorithm/Flowchart/Code/Sample Outputs
Introduction

Software Development Life Cycle

The software development life cycle (SDLC) is a process used by software development teams to
plan, design, build, test, and deploy software. The SDLC provides a structured approach to
software development and can be broken down into several phases:

Stage 1.Requirements gathering and analysis:

The team gathers and analyzes information about the software project to determine what needs to be
built. This phase involves interviewing stakeholders and end-users, reviewing existing systems, and
gathering information about the business needs and objectives of the project. For example, a team
SCV|13

developing a new e-commerce platform would gather information about the types of products that
will be sold, the payment methods that will be supported, and the shipping options that will be
available.

Stage 2 . Design:

The team creates a detailed design of the software, including its architecture, user interface, and data
structures. During this phase, the team develops a blueprint of the system that defines how the
various components of the software will interact with each other. For example, a team designing a
new mobile app would create wireframes and mockups of the app's user interface, and develop a plan
for how the app will access data from a remote server.

Stage 3. Implementation:

The team writes code to implement the software based on the design. This phase involves writing the
actual code for the software and integrating it with any external systems or libraries. For example, a
team implementing a new e-commerce platform would write the code for the website's shopping
cart, and integrate it with a payment gateway to support online transactions.

Stage 4 . Testing:

The team tests the software to ensure that it meets the requirements and is free of bugs. This phase
involves conducting various types of testing, such as unit testing, integration testing, and acceptance
testing. For example, a team testing a new mobile app would conduct testing on multiple devices to
ensure that the app is compatible with different screen sizes and operating systems.
SCV|14

Stage 5. Deployment:

The software is deployed to production and made available to users. This phase involves installing the
software on the target systems and configuring it for production use. For example, a team deploying a
new e-commerce platform would install the software on a web server, configure the database, and
test the system to ensure that it is running smoothly.

Stage 6 . Maintenance:

After the software is deployed, the team continues to maintain and support it, addressing any issues
that arise and making updates as needed. This phase involves monitoring the system for errors, fixing
bugs, and implementing new features as required. For example, a team maintaining a new mobile app
would release updates to fix any bugs that are reported, and add new features to enhance the user
experience.

SDLC Models

There are various software development life cycle models defined and designed which are followed
during the software development process. These models are also referred as Software Development
Process Models". Each process model follows a Series of steps unique to its type to ensure success in
the process of software development.

Following are the most important and popular SDLC models followed in the industry.

1. Waterfall Model

The Waterfall model is a linear, sequential approach to software development. Each phase of
the SDLC is completed in its entirety before moving on to the next phase. The Waterfall model
is best suited to projects with well-defined requirements and a clear end goal.
SCV|15

2. Incremental Model

Incremental Model is a process of software development where requirements divided into


multiple standalone modules of the software development cycle. In this model, each module
goes through the requirements, design, implementation and testing phases. Every subsequent
release of the module adds function to the previous release. The process continues until the
complete system achieved.
SCV|16

3. Spiral Model

Spiral model is one of the most important Software Development Life Cycle models, which
provides support for Risk Handling. In its diagrammatic representation, it looks like a spiral
with many loops. The exact number of loops of the spiral is unknown and can vary from
project to project. Each loop of the spiral is called a Phase of the software development
process.

4. Rad Model

RAD is a linear sequential software development process model that emphasizes a concise
development cycle using an element based construction approach. If the requirements are
well understood and described, and the project scope is a constraint, the RAD process enables
a development team to create a fully functional system within a concise time period.

When to use RAD Model?


SCV|17

 When the system should need to create the project that modularizes in a short span time (2-3
months).

 When the requirements are well-known.

 When the technical risk is limited.

 When there's a necessity to make a system, which modularized in 2-3 months of period.

 It should be used only if the budget allows the use of automatic code generating tools.

5. Iterative Model

The Iterative Model allows the accessing earlier phases, in which the variations made
respectively. The final output of the project renewed at the end of the Software Development
Life Cycle (SDLC) process.
SCV|18

When to use the Iterative Model?

 When requirements are defined clearly and easy to understand.

 When the software application is large.

 When there is a requirement of changes in future.

Other related methodologies are Agile Model, RAD Model, Rapid Application Development and
Prototyping Models.
SCV|19

Agile Methodology

Agile model believes that every project needs to be handled differently and the existing methods
need to be tailored to best suit the project requirements. In Agile, the tasks are divided to time boxes
(small time frames) to deliver specific features for a release.

Iterative approach is taken and working software build is delivered after each iteration. Each build is
incremental in terms of features; the final build holds all the features required by the customer.

Following are the Agile Manifesto principles −

 Individuals and interactions − In Agile development, self-organization and motivation are


important, as are interactions like co-location and pair programming.

 Working software − Demo working software is considered the best means of communication
with the customers to understand their requirements, instead of just depending on
documentation.

 Customer collaboration − As the requirements cannot be gathered completely in the


beginning of the project due to various factors, continuous customer interaction is very
important to get proper product requirements.

 Responding to change − Agile Development is focused on quick responses to change and


continuous development.
SCV|20

DevOps Methodology
SCV|21

DevOps defines an agile relationship between operations and Development. It is a process that is
practiced by the development team and operational engineers together from beginning to the final
stage of the product.

Learning DevOps is not complete without understanding the DevOps lifecycle phases. The DevOps
lifecycle includes seven phases as given below:

1) Continuous Development

This phase involves the planning and coding of the software. The vision of the project is decided
during the planning phase. And the developers begin developing the code for the application. There
are no DevOps tools that are required for planning, but there are several tools for maintaining the
code.

2) Continuous Integration

This stage is the heart of the entire DevOps lifecycle. It is a software development practice in which
the developers require to commit changes to the source code more frequently. This may be on a daily
or weekly basis. Then every commit is built, and this allows early detection of problems if they are
present. Building code is not only involved compilation, but it also includes unit testing, integration
testing, code review, and packaging.
SCV|22

3) Continuous Testing

This phase, where the developed software is continuously testing for bugs. For constant testing,
automation testing tools such as TestNG, JUnit, Selenium, etc are used. These tools allow QAs to test
multiple code-bases thoroughly in parallel to ensure that there is no flaw in the functionality. In this
phase, Docker Containers can be used for simulating the test environment.
SCV|23

4) Continuous Monitoring

Monitoring is a phase that involves all the operational factors of the entire DevOps process, where
important information about the use of the software is recorded and carefully processed to find out
trends and identify problem areas. Usually, the monitoring is integrated within the operational
capabilities of the software application.

5) Continuous Feedback

The application development is consistently improved by analyzing the results from the operations of
the software. This is carried out by placing the critical phase of constant feedback between the
operations and the development of the next version of the current software application.

6) Continuous Deployment

In this phase, the code is deployed to the production servers. Also, it is essential to ensure that the
code is correctly used on all the servers.
SCV|24

The new code is deployed continuously, and configuration management tools play an essential role in
executing tasks frequently and quickly. Here are some popular tools which are used in this phase, such
as Chef, Puppet, Ansible, and SaltStack.

7) Continuous Operations

All DevOps operations are based on the continuity with complete automation of the release process
and allow the organization to accelerate the overall time to market continuingly.
SCV|25

Experiment No:3

Student Name and Roll Number:Vinay 21csu380


Semester /Section:4th cyber security
Link to Code:
Date:23-1-23
Faculty Signature:
Remarks:

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.

Top 10 Secure Coding Practices

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|26

E.g.

Questions

Q1. What is secure coding?

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?

Q4. Why do we need to secure Code?


SCV|27

Student Work Area


Algorithm/Flowchart/Code/Sample OutputsWithout using inbuilt
function

#include <stdio.h>

#include <string.h>

int main()

char Str1[100], Str2[100];

int result, i;

printf("\n Please Enter the First String : ");

gets(Str1);

printf("\n Please Enter the Second String : ");

gets(Str2);
SCV|28

for(i = 0; Str1[i] == Str2[i] && Str1[i] == '\0'; i+


+);

if(Str1[i] < Str2[i])

printf("\n str1 is Less than str2");

else if(Str1[i] > Str2[i])

printf("\n str2 is Less than str1");

else

printf("\n str1 is Equal to str2");

return 0;

}
SCV|29

Using inbuilt function

#include<stdio.h>

#include<string.h>

int main()

char a[100], b[100];

printf("Enter the first string\n");

gets(a);

printf("Enter the second string\n");

gets(b);

if( strcmp(a,b) == 0 )

printf("Entered strings are equal.\n");

else

printf("Entered strings are not equal.\n");

return 0;

}
SCV|30

Experiment No: 4

Student Name and Roll Number: Vinay 21csu380


Semester /Section:4th cyber security
Link to Code:
SCV|31

Date:13-2-23
Faculty Signature:
Remarks:

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:

Consider the following noncompliant code:

n this noncompliant code example, a std::fstream object file is constructed. The constructor


for std::fstream calls std::basic_filebuf&lt;T&gt;::open(), which leaves the file open
SCV|32

when std::terminate() is invoked, terminating the program without performing any cleanup.


Consequently, the underlying std::basic_filebuf&lt;T&gt; object maintained by the file object is not
properly closed.

In the following compliant code, std::fstream::close() is called before std::terminate() is called, ensuring


that the file resources are properly closed:

Of course, this technique is common in C, provides a simpler approach:

Questions

Q1. What is Non-Complaint Code?

Q2. What are the impacts of non-complaint code?

Q3. How can non complaint code affect the Software and the company?
SCV|33

Q4. Which all sectors are impacted due to non-secure code?

Q5. Can we secure the code after delivery of the software?

Q6. How does it affect the cost, time and labour?

Student Work Area

Algorithm/Flowchart/Code/Sample Outputs import java.io.*;


import java.util.Arrays;
import java.util.Comparator;

// Greedy approach
class FractionalKnapSack {
SCV|34

// Function to get maximum value


private static double getMaxValue(ItemValue[] arr,
int capacity)
{
// Sorting items by value/weight ratio;
Arrays.sort(arr, new Comparator<ItemValue>() {
@Override
public int compare(ItemValue item1,
ItemValue item2)
{
double cpr1
= new Double((double)item1.value
/ (double)item1.weight);
double cpr2
= new Double((double)item2.value
/ (double)item2.weight);

if (cpr1 < cpr2)


SCV|35

return 1;
else
return -1;
}
});

double totalValue = 0d;

for (ItemValue i : arr) {

int curWt = (int)i.weight;


int curVal = (int)i.value;

if (capacity - curWt >= 0) {

// this weight can be picked while


capacity = capacity - curWt;
totalValue += curVal;
}
SCV|36

else {

// Item cant be picked whole


double fraction
= ((double)capacity / (double)curWt);
totalValue += (curVal * fraction);
capacity
= (int)(capacity - (curWt * fraction));
break;
}
}

return totalValue;
}

// Item value class


static class ItemValue {
SCV|37

int value, weight;

// Item value function


public ItemValue(int val, int wt)
{
this.weight = wt;
this.value = val;
}
}

// Driver code
public static void main(String[] args)
{

ItemValue[] arr = { new ItemValue(60, 10),


new ItemValue(100, 20),
new ItemValue(120, 30) };
SCV|38

int capacity = 50;

double maxValue = getMaxValue(arr, capacity);

// Function call
System.out.println(maxValue);
}
}
SCV|39
SCV|40

Experiment No: 5

Student Name and Roll Number:Vinay 21csu380


Semester /Section:4th cyber security
Link to Code:
Date:13-2-23
Faculty Signature:
Remarks:

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:

Static analysis is performed in a non-runtime environment. Static application security testing


(SAST) is a testing process that looks at the application from the inside out. This test process is
performed without executing the program, but rather by examining the source code, byte code or
application binaries for signs of security vulnerabilities. In the static test process, the application
data and control paths are modeled and then analyzed for security weaknesses. Static analysis is a
test of the internal structure of the application, rather than functional testing. 

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
SCV|41

application’s reactions, determining whether it is vulnerable. 

Having originated and evolved separately, static and dynamic analysis have, at times, been
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

Q4. Name the tools for static and Dynamic analysis?


SCV|42

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs

REPORT ON SECURITY TOOLS USED FOR


SECURITY ANALYSIS OF CODES
(STATIC AND DYNAMIC TOOLS)

What are security analysis tools ?


Security analytics tools help organizations implement real-time
monitoring of servers, endpoints and network traffic, consolidate and
coordinate diverse event data from application and network logs, and
perform forensic analysis to better understand attack methods and
system vulnerabilities.

What is the use of these security tools ?


Security Tools are all information used to verify Client when
implementing transactions, including but not limited to user name,
password, registered telephone number, online code, OTP, and other
types of information as prescribed for each trading mode.
SCV|43

Types of security analysis tools


There are 2 types of security analysis tools :

 Dynamic
 Static
Static code analysis also known as Static Application Security
Testing or SAST – is the process of analyzing computer software
without actually running the software. Developers use static code
analysis tools to find and fix vulnerabilities, bugs, and security risks in
their new applications while the source code is in its ‘static’ state –
meaning when it is not being run.
Dynamic code analysis also called Dynamic Application Security
Testing (DAST) – is designed to test a running application for
potentially exploitable vulnerabilities. DAST tools to identify both
compile time and runtime vulnerabilities, such as configuration errors
that only appear within a realistic execution environment.

Some static security analysis tools

SonarQube
SonarQube is one of the more popular static code analysis tools out
there. It is an open-source platform for continuous inspection of code
quality and performs automatic reviews via static code analysis. In
SCV|44

addition, it can detect and report bugs, code smells, and numerous other
security vulnerabilities.
SonarQube integrates with multiple platforms
It also supports an impressive 25+ programming languages, including
C#, Python, Cobol, PHP, and Java
This tool helps developers observe a three-pronged attack on their code
by avoiding bugs or undefined behavior, breaches or attacks, and easing
code updates

Checkmarx SAST

It can identify hundreds of security vulnerabilities in any code. It is used


by DevOps and security teams to scan code early in the SDLC to spot
vulnerabilities, compliance issues, and business logic problems – and
also offers advice on how to solve them.

Checkmarx can be easily integrated into IDEs, servers, and CI/CD


pipelines

It scales easily as the applications continue to grow.

It has customizable queries to handle even the most unique code,


actionable insights for quicker debugging.

Synopsys Coverity

With Synopsys Coverity Static Analysis, developers can look forward


to quickly finding and fixing bugs in their code. Coverity identifies
SCV|45

critical software quality defects and security vulnerabilities in code and


any lapses in industry compliance standards.

It is an easy-to-use, accurate, and scalable tool that irons out bugs in the
early stages of an SDLC.

The tool hits the ground running as it can immediately start spotting and
fixing bugs right out of the box – with no tuning required.

It integrates well into DevOps pipelines via REST APIs and offers


Continuous Integration (CI) and Software Configuration Management
(SCM).

Also, the tool offers a centralized aggregated risk profile of entire


application portfolios, while APIs allow for exporting the results to other
risk reporting tools.

Micro Focus Fortify Static Code Analyzer

Micro Focus Fortify Static Code Analyzer (SCA) is a static code


analysis tool that locates the root causes of security vulnerabilities in
source code, prioritizes issues by severity, and provides detailed
resolution guides on how to fix them.

This tool offers dynamic (DAST) application testing as well as source


code analysis (SAST).

SCA helps developers find and fix security defects in real-time while
they code, thanks to it integrating into IDEs like Eclipse or Visual
Studio.
SCV|46

Developers enhance their secure coding skills thanks to its game-like


training.

Apart from supporting over 25 major programming languages and


frameworks, this tool offers agile updates backed by their in-house
security research team.

SCA also integrates well with numerous solutions and platforms – with a
few examples including Visual Studio, Bamboo, GitHub, Jira, Slack,
and SAP.

Some dynamic security analysis tools


SCV|47

Smartbear
Smartbear is a test automation and performance testing platform
that ensures the highest quality with a suite of tools available to help
you ensure your application is functional and secure. They provide
tools like Test Complete, BitBar, Load Ninja, and Cucumber.

gcov
gcov is a tool you can use in conjunction with GCC to test code
coverage in your programs. It helps you determine what area of
your code needs to be optimized. You can use gcov as a profiling tool
to help discover where your optimization efforts will best affect
your code.
gcov creates a log file called sourcefile.gcov, which indicates how
many times each line of a source file sourcefile.c has been executed.
This annotated source file can be used with gprof, another profiling
tool, to extract timing information about the program.

Code Pulse
Code Pulse is a free real-time code coverage tool for penetration
testing activities. This tool automatically detects coverage
information while tests are being conducted and will make it
possible to understand the overlaps and boundaries of the different
tool coverage.
Code Pulse presents coverage information visually to make it easy to
understand which parts of an application have been covered and
how much.
SCV|48

Experiment No: 6

Student Name and Roll Number:


Semester /Section:
SCV|49

Link to Code:
Date:
Faculty Signature:
Remarks:

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:

Memory Layout of C Program in Big Block of RAM

Typical Memory representation of C program consists of following section

 Text
 Data (initialized /Uninitialized)
 Stack
 Heap
 Kernel
SCV|50

Questions

Q1. How do you classify the memory?

Q2. Explain the memory layout?

Q3. What are initialized and uninitialized variable?

Q4. What do you understand by text, data and BSS of RAM?

Q5. What is the minimum and maximum address?

Q6. What is the difference between stack and heap?


SCV|51

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|52

Experiment No: 7

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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.

Special highlights are:

 Intuitive user interface, no cryptical commands


 Code analysis - traces registers, recognizes procedures, loops, API calls, switches, tables,
constants and strings
 Directly loads and debugs DLLs
 Object file scanning - locates routines from object files and libraries
 Allows for user-defined labels, comments and function descriptions
SCV|53

 Understands debugging information in Borland® format


 Saves patches between sessions, writes them back to executable file and updates fixups
 Open architecture - many third-party plugins are available
 No installation - no trash in registry or system directories

Questions

Q1. What is the debugger?

Q2. What is DLL? How does it provide linkage to a software?

Q3. What is assembler?

Q4. What is the difference between 32-bit and 64-bit assembler? Do they both work similarly?

Q5. What are object files and libraries?

Q6. How does OllyDbg Works?


SCV|54

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|55

Experiment No: 8

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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?

Q2. Give examples of forward engineering and reverse engineering.

Q3. When company release the product or software, do they provide software code along with it? Why?

Q4. Which file is provided when you buy or download a software?


SCV|56

Q5 How can you make changes if code is not provided?

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|57

Experiment No: 9

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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|58

data integrity when digital files are transferred or stored.

Questions

Q1. What do youunderstand by the concept of hash?

Q2. What is the difference between hash of two different words?

Q3. What is the different algorithm for hash technique?

Q4. What is the difference between Hash and Encryption?

Q5. What type of the data can be converted in digest?

Q6. How can we identify what type of hashing technique has been applied on the digest by just seeing it?
SCV|59

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|60

Experiment No: 10

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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

Q1. What is Reverse Engineering via File Manipulation


SCV|61

Q2. What is the difference between two techniques?

Q3. Should the key be stored in the code?

Q4. Should license Key should be stored in encrypted form in the code?

Q5. What techniques should be applied to make a software secure?

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|62

Experiment No: 11

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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

Write a program in C/C++ to show problem in Buffer Overflow

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|63

data to leak out into other buffers, which can corrupt or overwrite whatever data they were holding.
SCV|64

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|65

Experiment No: 12

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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

Write a program in C/C++ to show without problem of buffer Overflow

Background Study:

Attacker would use a buffer-overflow exploit to take advantage of a program that is waiting on a
user’s input.
SCV|66

Questions
SCV|67

Q1. How can the vulnerability be removed from C code?

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?

Q4. Why is this Vulnerability called low level Vulnerability?


SCV|68

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|69

Experiment No: 13

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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|70

Questions

Q1. What is immunity debugger?

Q2. What is buffer-overflow attack?

Q3. What is stack-based and heap-based?

Q4. Why is Metasploit is used? What is the purpose of Metasploit?

Q5. What are the other tools that are used in exploitation in buffer overflow?

Q6. What are the steps of exploitation?


SCV|71

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|72

Experiment No: 14

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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

Write a program in C/C++ to show problem in Stack Overflow

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|73

Questions

Q1. What is Stack Overflow Vulnerability?

Q2. How can you detect vulnerability of Stack Overflow in Code?

Q3. How does this vulnerability can be exploited?

Q4. What are the methods to patch this vulnerability?


SCV|74

Q5. Does this vulnerability still exist?

Q6. Is it Language dependent vulnerability?


SCV|75

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|76

Experiment No: 15

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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

Write a program in C/C++ to show without problem of Stack Overflow.

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|77

Questions

Q1. Explain the working of stack using a sample C code.

Q2. Explain buffer overflow using a sample C code and show how overflow of stack will happen.
SCV|78

Student Work Area


Algorithm/Flowchart/Code/Sample Outputs
SCV|79

Experiment No: 15

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

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

Write a program to solve the integer Overflow

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|80

Questions
SCV|81

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

below code snippet:


// structurestruct example1 {
int a;
unsigned int b;
unsigned int c;
};// unionunion example2 {
int a;
unsigned int b;
unsigned int c;
};

Q3. What is Integer Overflow Vulnerability?

Q4. How can you detect vulnerability of Integer Overflow in Code?

Q5. How does this vulnerability can be exploited?

Q6. What are the methods to patch this vulnerability?

Q7. Does this vulnerability still exist?

Q8. Is it Language dependent vulnerability?


SCV|82

Student Work
Algorithm/Flowchart/Code/Sample Outputs
SCV|83

Experiment No: 17

Student Name and Roll Number:


Semester /Section:
Link to Code:
Date:
Faculty Signature:
Remarks:

Objective

To familiarize the students with the concept of SQL injection.

Program Outcome

 The students will be able secure the website from SQL injection.

Problem Statement

Perform SQL injection-based query on any real website


(i) Perform different methods to find the vulnerable php website
(ii) Find number of columns in the application
(iii) Find the name of the database, version and user
(iv) Find the all the tables in database
(v) Find the column names/ attributes
(vi) Find the values in the columns (username n password)

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|84

Questions

Q1.What is Blind SQL Injection?

Q2. How do we prevent SQL Injection in our applications?

Algorithm/Flowchart/Code/Sample Outputs
SCV|85

Secure Coding and Software Vulnerability


CSL283

Faculty name: Student name:

Roll No.:

Semester:

Group:

Department of Computer Science and Engineering


The NorthCap University, Gurugram- 122001, India
Session 2021-2022
SCV|86

Table of Contents
S.No Page
No.
1. Project Description

2. Problem Statement

3. Analysis

3.1 Hardware Requirements

3.2 Software Requirements

4. Design

4.1 Data/Input Output Description:

4.2 Algorithmic Approach / Algorithm / DFD / ER


diagram/Program Steps

5. Implementation and Testing (stage/module


wise)

6. Output (Screenshots)

7. Conclusion and Future Scope

You might also like