SlideShare una empresa de Scribd logo
1 de 11
/* Test flawfinder. This program won't compile or run; that's
not necessary
for this to be a useful test. */
#include <stdio.h>
#define hello(x) goodbye(x)
#define WOKKA "stuff"
main() {
printf("hellon");
}
/* This is a strcpy(a, "n"); test. */
int demo(char *a, char *b) {
strcpy(a, "n"); // Did this work?
strcpy(a, gettext("Hello there")); // Did this work?
strcpy(b, a);
sprintf(s, "n");
sprintf(s, "hello");
sprintf(s, "hello %s", bug);
sprintf(s, gettext("hello %s"), bug);
sprintf(s, unknown, bug);
printf(bf, x);
scanf("%d", &x);
scanf("%s", s);
scanf("%10s", s);
scanf("%s", s);
gets(f); // Flawfinder: ignore
printf("");
/* Flawfinder: ignore */
gets(f);
gets(f);
/* These are okay, but flawfinder version < 0.20 incorrectly
used
the first parameter as the parameter for the format string */
syslog(LOG_ERR,"cannot open config file (%s):
%s",filename,strerror(errno))
syslog(LOG_CRIT,"malloc() failed");
/* But this one SHOULD trigger a warning. */
syslog(LOG_ERR, attacker_string);
}
demo2() {
char d[20];
char s[20];
int n;
_mbscpy(d,s); /* like strcpy, this doesn't check for buffer
overflow */
memcpy(d,s);
CopyMemory(d,s);
lstrcat(d,s);
strncpy(d,s);
_tcsncpy(d,s);
strncat(d,s,10);
strncat(d,s,sizeof(d)); /* Misuse - this should be flagged as
riskier. */
_tcsncat(d,s,sizeof(d)); /* Misuse - flag as riskier */
n = strlen(d);
/* This is wrong, and should be flagged as risky: */
MultiByteToWideChar(CP_ACP,0,szName,-
1,wszUserName,sizeof(wszUserName));
/* This is also wrong, and should be flagged as risky: */
MultiByteToWideChar(CP_ACP,0,szName,-
1,wszUserName,sizeof wszUserName);
/* This is much better: */
MultiByteToWideChar(CP_ACP,0,szName,-
1,wszUserName,sizeof(wszUserName)/sizeof(wszUserName[0])
);
/* This is much better: */
MultiByteToWideChar(CP_ACP,0,szName,-
1,wszUserName,sizeof wszUserName
/sizeof(wszUserName[0]));
/* This is an example of bad code - the third paramer is NULL,
so it creates
a NULL ACL. Note that Flawfinder can't detect when a
SECURITY_DESCRIPTOR structure is manually created
with a NULL value
as the ACL; doing so would require a tool that handles
C/C++
and knows about types more that flawfinder currently does.
Anyway, this needs to be detected: */
SetSecurityDescriptorDacl(&sd,TRUE,NULL,FALSE);
/* This one is a bad idea - first param shouldn't be NULL */
CreateProcess(NULL, "C:Program
FilesGoodGuyGoodGuy.exe -x", "");
/* Test interaction of quote characters */
printf("%cn", 'x');
printf("%cn", '"');
printf("%cn", '"');
printf("%cn", ''');
printf("%cn", '177');
printf("%cn", 'xfe');
printf("%cn", 'xd');
printf("%cn", 'n');
printf("%cn", '');
printf("%cn", "'");
}
int getopt_example(int argc,char *argv[]) {
while ((optc = getopt_long (argc, argv, "a",longopts, NULL
)) != EOF) {
}
}
int testfile() {
FILE *f;
f = fopen("/etc/passwd", "r");
fclose(f);
}
/* Regression test: handle n after end of string */
#define assert(x) {
if (!(x)) {
fprintf(stderr,"Assertion failed.n"
"File: %snLine: %dn"
"Assertion: %snn"
,__FILE__,__LINE__,#x);
exit(1);
};
}
int accesstest() {
int access = 0; /* Not a function call. Should be caught by the
false positive test, and NOT labelled as a
problem. */
}
Page | 1
This document is licensed with a Creative Commons
Attribution 4.0 International License ©2017
CSCE 5565: SECURE SOFTWARE SYSTEMS
LAB 2: SOURCE CODE ANALYSIS
Lab Description
Students are provided with a vulnerable C code. You will
analyze the C
code by using two static analysis tools, e.g., FlawFinder and
cppcheck,
understand their outputs, and correct the vulnerabilities
accordingly.
Lab Goal
The goal of the following laboratory exercises is for you to get
familiar with
source code analysis tools, understand their outputs, and
improve your
code accordingly.
Lab Environment
A personal computer with one of the Linux Operating Systems
installed
(strongly recommend Ubuntu 20.04). You can create an Ubuntu
VM within
VirtualBox.
What to Submit
Students will submit a document with:
1) The screenshot or printout of execution results of step C.
2) Your analysis and comparison description of step D.
3) For step E, write the corrected program, and
printouts/screenshots of
the results of the corrected program running with FlawFinder
and
cppcheck.
4) List the functions you corrected, and write briefly how you
corrected it.
Bonus: Submit the report to Canvas in class.
Reminder
Keep academic integrity in mind! It will be strictly enforced!
Page | 2
This document is licensed with a Creative Commons
Attribution 4.0 International License ©2017 Catalyzing
Computing and Cybersecurity in
Community Colleges (C5).
Lab Exercise
A. Download & install FlawFinder https://github.com/david-a-
wheeler/flawfinder
a. Various installation ways.
b. Hint: two of the easiest installation methods are Python’s
"pip"
or your system's package manage (e.g., apt install …)
B. Download & install cppcheck
a. cppcheck, https://cppcheck.sourceforge.io/
b. usage: https://linux.die.net/man/1/cppcheck
c. Hint: cppcheck –-enable=all <file_name>
C. Use the given “vulnerable_code.c” file as input, Run
FlawFinder and
cppcheck to scan security vulnerabilities.
D. Analyze and compare the results of FlawFinder and cppcheck
on
“vulnerable_code.c”
a. Compare the severity found for similar vulnerability found
b. Compare vulnerabilities that found in each tool that were
similar or different.
E. Modify the programs based on the results of FlawFinder and
cppcheck. Run FlawFinder and cppcheck again to check whether
some of the complaints no longer exist.
a. For the modified “vulnerable_code.c” based on cppcheck, run
it
in FlawFinder.
b. For the modified “vulnerable_code.c” based on FlawFinder,
run
it in cppcheck.

Más contenido relacionado

Similar a Test flawfinder. This program wont compile or run; thats not

OCP Java SE 8 Exam - Sample Questions - Java Streams API
OCP Java SE 8 Exam - Sample Questions - Java Streams APIOCP Java SE 8 Exam - Sample Questions - Java Streams API
OCP Java SE 8 Exam - Sample Questions - Java Streams APIGanesh Samarthyam
 
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QACreating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QAarchwisp
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceJesse Vincent
 
05 -working_with_the_preproce
05  -working_with_the_preproce05  -working_with_the_preproce
05 -working_with_the_preproceHector Garzo
 
Php5 certification mock exams
Php5 certification mock examsPhp5 certification mock exams
Php5 certification mock examsecho liu
 
88 c programs 15184
88 c programs 1518488 c programs 15184
88 c programs 15184Sumit Saini
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3alish sha
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures Pradipta Mishra
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testinganandarajta
 
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" DependenciesAnalyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" DependenciesPVS-Studio
 
Sony C#/.NET component set analysis
Sony C#/.NET component set analysisSony C#/.NET component set analysis
Sony C#/.NET component set analysisPVS-Studio
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
JSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklJSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklChristoph Pickl
 

Similar a Test flawfinder. This program wont compile or run; thats not (20)

OCP Java SE 8 Exam - Sample Questions - Java Streams API
OCP Java SE 8 Exam - Sample Questions - Java Streams APIOCP Java SE 8 Exam - Sample Questions - Java Streams API
OCP Java SE 8 Exam - Sample Questions - Java Streams API
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QACreating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
 
Programming in c
Programming in cProgramming in c
Programming in c
 
comp2
comp2comp2
comp2
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
 
05 -working_with_the_preproce
05  -working_with_the_preproce05  -working_with_the_preproce
05 -working_with_the_preproce
 
Php5 certification mock exams
Php5 certification mock examsPhp5 certification mock exams
Php5 certification mock exams
 
88 c programs 15184
88 c programs 1518488 c programs 15184
88 c programs 15184
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
C programs
C programsC programs
C programs
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testing
 
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" DependenciesAnalyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
 
Sony C#/.NET component set analysis
Sony C#/.NET component set analysisSony C#/.NET component set analysis
Sony C#/.NET component set analysis
 
Structures-2
Structures-2Structures-2
Structures-2
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
JSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklJSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph Pickl
 

Más de MoseStaton39

(U) WHAT INSIGHTS ARE DERIVED FROM OPERATION ANACONDA IN REGARDS T
(U) WHAT INSIGHTS ARE DERIVED FROM OPERATION ANACONDA IN REGARDS T(U) WHAT INSIGHTS ARE DERIVED FROM OPERATION ANACONDA IN REGARDS T
(U) WHAT INSIGHTS ARE DERIVED FROM OPERATION ANACONDA IN REGARDS TMoseStaton39
 
(Remarks)Please keep in mind that the assi
(Remarks)Please keep in mind that the assi(Remarks)Please keep in mind that the assi
(Remarks)Please keep in mind that the assiMoseStaton39
 
(This is provided as an example of the paper layout and spac
(This is provided as an example of the paper layout and spac(This is provided as an example of the paper layout and spac
(This is provided as an example of the paper layout and spacMoseStaton39
 
(Student Name)Date of EncounterPreceptorClinical SiteCl
(Student Name)Date of EncounterPreceptorClinical SiteCl(Student Name)Date of EncounterPreceptorClinical SiteCl
(Student Name)Date of EncounterPreceptorClinical SiteClMoseStaton39
 
(TITLE)Sung Woo ParkInternational American UniversityFIN
(TITLE)Sung Woo ParkInternational American UniversityFIN(TITLE)Sung Woo ParkInternational American UniversityFIN
(TITLE)Sung Woo ParkInternational American UniversityFINMoseStaton39
 
(Student Name) UniversityDate of EncounterPreceptorClini
(Student Name) UniversityDate of EncounterPreceptorClini(Student Name) UniversityDate of EncounterPreceptorClini
(Student Name) UniversityDate of EncounterPreceptorCliniMoseStaton39
 
(Student Name)Miami Regional UniversityDate of Encounter
(Student Name)Miami Regional UniversityDate of Encounter(Student Name)Miami Regional UniversityDate of Encounter
(Student Name)Miami Regional UniversityDate of EncounterMoseStaton39
 
(Student Name)Miami Regional UniversityDate of EncounterP
(Student Name)Miami Regional UniversityDate of EncounterP(Student Name)Miami Regional UniversityDate of EncounterP
(Student Name)Miami Regional UniversityDate of EncounterPMoseStaton39
 
(Monica)Gender rarely shapes individual experience in isolation bu
(Monica)Gender rarely shapes individual experience in isolation bu(Monica)Gender rarely shapes individual experience in isolation bu
(Monica)Gender rarely shapes individual experience in isolation buMoseStaton39
 
(Monica) A summary of my decision-making process starts with flipp
(Monica) A summary of my decision-making process starts with flipp(Monica) A summary of my decision-making process starts with flipp
(Monica) A summary of my decision-making process starts with flippMoseStaton39
 
(Note This case study is based on many actual cases. All the name
(Note This case study is based on many actual cases. All the name(Note This case study is based on many actual cases. All the name
(Note This case study is based on many actual cases. All the nameMoseStaton39
 
(Minimum 175 words)In your own words, explain class conflict the
(Minimum 175 words)In your own words, explain class conflict the(Minimum 175 words)In your own words, explain class conflict the
(Minimum 175 words)In your own words, explain class conflict theMoseStaton39
 
(Individuals With Disabilities Act Transformation Over the Years)D
(Individuals With Disabilities Act Transformation Over the Years)D(Individuals With Disabilities Act Transformation Over the Years)D
(Individuals With Disabilities Act Transformation Over the Years)DMoseStaton39
 
(Kaitlyn)To be very honest I know next to nothing about mythology,
(Kaitlyn)To be very honest I know next to nothing about mythology,(Kaitlyn)To be very honest I know next to nothing about mythology,
(Kaitlyn)To be very honest I know next to nothing about mythology,MoseStaton39
 
(Harry)Dante’s Inferno is the first of the three-part epic poem, D
(Harry)Dante’s Inferno is the first of the three-part epic poem, D(Harry)Dante’s Inferno is the first of the three-part epic poem, D
(Harry)Dante’s Inferno is the first of the three-part epic poem, DMoseStaton39
 
(Lucious)Many steps in the systems development process may cause a
(Lucious)Many steps in the systems development process may cause a(Lucious)Many steps in the systems development process may cause a
(Lucious)Many steps in the systems development process may cause aMoseStaton39
 
(Eric)Technology always seems simple when it works and it is when
(Eric)Technology always seems simple when it works and it is when (Eric)Technology always seems simple when it works and it is when
(Eric)Technology always seems simple when it works and it is when MoseStaton39
 
(ELI)At the time when I first had to take a sociology class in hig
(ELI)At the time when I first had to take a sociology class in hig(ELI)At the time when I first had to take a sociology class in hig
(ELI)At the time when I first had to take a sociology class in higMoseStaton39
 
(Click icon for citation) Theme Approaches to History
(Click icon for citation) Theme Approaches to History(Click icon for citation) Theme Approaches to History
(Click icon for citation) Theme Approaches to HistoryMoseStaton39
 
(Executive Summary)MedStar Health Inc, a leader in the healthc
(Executive Summary)MedStar Health Inc, a leader in the healthc(Executive Summary)MedStar Health Inc, a leader in the healthc
(Executive Summary)MedStar Health Inc, a leader in the healthcMoseStaton39
 

Más de MoseStaton39 (20)

(U) WHAT INSIGHTS ARE DERIVED FROM OPERATION ANACONDA IN REGARDS T
(U) WHAT INSIGHTS ARE DERIVED FROM OPERATION ANACONDA IN REGARDS T(U) WHAT INSIGHTS ARE DERIVED FROM OPERATION ANACONDA IN REGARDS T
(U) WHAT INSIGHTS ARE DERIVED FROM OPERATION ANACONDA IN REGARDS T
 
(Remarks)Please keep in mind that the assi
(Remarks)Please keep in mind that the assi(Remarks)Please keep in mind that the assi
(Remarks)Please keep in mind that the assi
 
(This is provided as an example of the paper layout and spac
(This is provided as an example of the paper layout and spac(This is provided as an example of the paper layout and spac
(This is provided as an example of the paper layout and spac
 
(Student Name)Date of EncounterPreceptorClinical SiteCl
(Student Name)Date of EncounterPreceptorClinical SiteCl(Student Name)Date of EncounterPreceptorClinical SiteCl
(Student Name)Date of EncounterPreceptorClinical SiteCl
 
(TITLE)Sung Woo ParkInternational American UniversityFIN
(TITLE)Sung Woo ParkInternational American UniversityFIN(TITLE)Sung Woo ParkInternational American UniversityFIN
(TITLE)Sung Woo ParkInternational American UniversityFIN
 
(Student Name) UniversityDate of EncounterPreceptorClini
(Student Name) UniversityDate of EncounterPreceptorClini(Student Name) UniversityDate of EncounterPreceptorClini
(Student Name) UniversityDate of EncounterPreceptorClini
 
(Student Name)Miami Regional UniversityDate of Encounter
(Student Name)Miami Regional UniversityDate of Encounter(Student Name)Miami Regional UniversityDate of Encounter
(Student Name)Miami Regional UniversityDate of Encounter
 
(Student Name)Miami Regional UniversityDate of EncounterP
(Student Name)Miami Regional UniversityDate of EncounterP(Student Name)Miami Regional UniversityDate of EncounterP
(Student Name)Miami Regional UniversityDate of EncounterP
 
(Monica)Gender rarely shapes individual experience in isolation bu
(Monica)Gender rarely shapes individual experience in isolation bu(Monica)Gender rarely shapes individual experience in isolation bu
(Monica)Gender rarely shapes individual experience in isolation bu
 
(Monica) A summary of my decision-making process starts with flipp
(Monica) A summary of my decision-making process starts with flipp(Monica) A summary of my decision-making process starts with flipp
(Monica) A summary of my decision-making process starts with flipp
 
(Note This case study is based on many actual cases. All the name
(Note This case study is based on many actual cases. All the name(Note This case study is based on many actual cases. All the name
(Note This case study is based on many actual cases. All the name
 
(Minimum 175 words)In your own words, explain class conflict the
(Minimum 175 words)In your own words, explain class conflict the(Minimum 175 words)In your own words, explain class conflict the
(Minimum 175 words)In your own words, explain class conflict the
 
(Individuals With Disabilities Act Transformation Over the Years)D
(Individuals With Disabilities Act Transformation Over the Years)D(Individuals With Disabilities Act Transformation Over the Years)D
(Individuals With Disabilities Act Transformation Over the Years)D
 
(Kaitlyn)To be very honest I know next to nothing about mythology,
(Kaitlyn)To be very honest I know next to nothing about mythology,(Kaitlyn)To be very honest I know next to nothing about mythology,
(Kaitlyn)To be very honest I know next to nothing about mythology,
 
(Harry)Dante’s Inferno is the first of the three-part epic poem, D
(Harry)Dante’s Inferno is the first of the three-part epic poem, D(Harry)Dante’s Inferno is the first of the three-part epic poem, D
(Harry)Dante’s Inferno is the first of the three-part epic poem, D
 
(Lucious)Many steps in the systems development process may cause a
(Lucious)Many steps in the systems development process may cause a(Lucious)Many steps in the systems development process may cause a
(Lucious)Many steps in the systems development process may cause a
 
(Eric)Technology always seems simple when it works and it is when
(Eric)Technology always seems simple when it works and it is when (Eric)Technology always seems simple when it works and it is when
(Eric)Technology always seems simple when it works and it is when
 
(ELI)At the time when I first had to take a sociology class in hig
(ELI)At the time when I first had to take a sociology class in hig(ELI)At the time when I first had to take a sociology class in hig
(ELI)At the time when I first had to take a sociology class in hig
 
(Click icon for citation) Theme Approaches to History
(Click icon for citation) Theme Approaches to History(Click icon for citation) Theme Approaches to History
(Click icon for citation) Theme Approaches to History
 
(Executive Summary)MedStar Health Inc, a leader in the healthc
(Executive Summary)MedStar Health Inc, a leader in the healthc(Executive Summary)MedStar Health Inc, a leader in the healthc
(Executive Summary)MedStar Health Inc, a leader in the healthc
 

Último

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 

Último (20)

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 

Test flawfinder. This program wont compile or run; thats not

  • 1. /* Test flawfinder. This program won't compile or run; that's not necessary for this to be a useful test. */ #include <stdio.h> #define hello(x) goodbye(x) #define WOKKA "stuff" main() { printf("hellon"); } /* This is a strcpy(a, "n"); test. */ int demo(char *a, char *b) { strcpy(a, "n"); // Did this work? strcpy(a, gettext("Hello there")); // Did this work? strcpy(b, a);
  • 2. sprintf(s, "n"); sprintf(s, "hello"); sprintf(s, "hello %s", bug); sprintf(s, gettext("hello %s"), bug); sprintf(s, unknown, bug); printf(bf, x); scanf("%d", &x); scanf("%s", s); scanf("%10s", s); scanf("%s", s); gets(f); // Flawfinder: ignore printf(""); /* Flawfinder: ignore */ gets(f); gets(f); /* These are okay, but flawfinder version < 0.20 incorrectly used the first parameter as the parameter for the format string */
  • 3. syslog(LOG_ERR,"cannot open config file (%s): %s",filename,strerror(errno)) syslog(LOG_CRIT,"malloc() failed"); /* But this one SHOULD trigger a warning. */ syslog(LOG_ERR, attacker_string); } demo2() { char d[20]; char s[20]; int n; _mbscpy(d,s); /* like strcpy, this doesn't check for buffer overflow */ memcpy(d,s); CopyMemory(d,s);
  • 4. lstrcat(d,s); strncpy(d,s); _tcsncpy(d,s); strncat(d,s,10); strncat(d,s,sizeof(d)); /* Misuse - this should be flagged as riskier. */ _tcsncat(d,s,sizeof(d)); /* Misuse - flag as riskier */ n = strlen(d); /* This is wrong, and should be flagged as risky: */ MultiByteToWideChar(CP_ACP,0,szName,- 1,wszUserName,sizeof(wszUserName)); /* This is also wrong, and should be flagged as risky: */ MultiByteToWideChar(CP_ACP,0,szName,- 1,wszUserName,sizeof wszUserName); /* This is much better: */ MultiByteToWideChar(CP_ACP,0,szName,- 1,wszUserName,sizeof(wszUserName)/sizeof(wszUserName[0]) ); /* This is much better: */ MultiByteToWideChar(CP_ACP,0,szName,- 1,wszUserName,sizeof wszUserName /sizeof(wszUserName[0]));
  • 5. /* This is an example of bad code - the third paramer is NULL, so it creates a NULL ACL. Note that Flawfinder can't detect when a SECURITY_DESCRIPTOR structure is manually created with a NULL value as the ACL; doing so would require a tool that handles C/C++ and knows about types more that flawfinder currently does. Anyway, this needs to be detected: */ SetSecurityDescriptorDacl(&sd,TRUE,NULL,FALSE); /* This one is a bad idea - first param shouldn't be NULL */ CreateProcess(NULL, "C:Program FilesGoodGuyGoodGuy.exe -x", ""); /* Test interaction of quote characters */ printf("%cn", 'x'); printf("%cn", '"'); printf("%cn", '"'); printf("%cn", '''); printf("%cn", '177'); printf("%cn", 'xfe');
  • 6. printf("%cn", 'xd'); printf("%cn", 'n'); printf("%cn", ''); printf("%cn", "'"); } int getopt_example(int argc,char *argv[]) { while ((optc = getopt_long (argc, argv, "a",longopts, NULL )) != EOF) { } } int testfile() { FILE *f; f = fopen("/etc/passwd", "r"); fclose(f); }
  • 7. /* Regression test: handle n after end of string */ #define assert(x) { if (!(x)) { fprintf(stderr,"Assertion failed.n" "File: %snLine: %dn" "Assertion: %snn" ,__FILE__,__LINE__,#x); exit(1); }; } int accesstest() { int access = 0; /* Not a function call. Should be caught by the false positive test, and NOT labelled as a problem. */ }
  • 8. Page | 1 This document is licensed with a Creative Commons Attribution 4.0 International License ©2017 CSCE 5565: SECURE SOFTWARE SYSTEMS LAB 2: SOURCE CODE ANALYSIS Lab Description Students are provided with a vulnerable C code. You will analyze the C code by using two static analysis tools, e.g., FlawFinder and cppcheck, understand their outputs, and correct the vulnerabilities accordingly. Lab Goal The goal of the following laboratory exercises is for you to get familiar with source code analysis tools, understand their outputs, and improve your code accordingly.
  • 9. Lab Environment A personal computer with one of the Linux Operating Systems installed (strongly recommend Ubuntu 20.04). You can create an Ubuntu VM within VirtualBox. What to Submit Students will submit a document with: 1) The screenshot or printout of execution results of step C. 2) Your analysis and comparison description of step D. 3) For step E, write the corrected program, and printouts/screenshots of the results of the corrected program running with FlawFinder and cppcheck. 4) List the functions you corrected, and write briefly how you corrected it. Bonus: Submit the report to Canvas in class. Reminder Keep academic integrity in mind! It will be strictly enforced! Page | 2
  • 10. This document is licensed with a Creative Commons Attribution 4.0 International License ©2017 Catalyzing Computing and Cybersecurity in Community Colleges (C5). Lab Exercise A. Download & install FlawFinder https://github.com/david-a- wheeler/flawfinder a. Various installation ways. b. Hint: two of the easiest installation methods are Python’s "pip" or your system's package manage (e.g., apt install …) B. Download & install cppcheck a. cppcheck, https://cppcheck.sourceforge.io/ b. usage: https://linux.die.net/man/1/cppcheck c. Hint: cppcheck –-enable=all <file_name> C. Use the given “vulnerable_code.c” file as input, Run FlawFinder and cppcheck to scan security vulnerabilities. D. Analyze and compare the results of FlawFinder and cppcheck on “vulnerable_code.c” a. Compare the severity found for similar vulnerability found b. Compare vulnerabilities that found in each tool that were similar or different. E. Modify the programs based on the results of FlawFinder and
  • 11. cppcheck. Run FlawFinder and cppcheck again to check whether some of the complaints no longer exist. a. For the modified “vulnerable_code.c” based on cppcheck, run it in FlawFinder. b. For the modified “vulnerable_code.c” based on FlawFinder, run it in cppcheck.