Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need these Secure Coding Questions in C PLEASE DO NOT COPY ANSWERS FROM CHEGG, BECAUSE THEY ARE WRONG In class, we gave a very

I need these Secure Coding Questions in C PLEASE DO NOT COPY ANSWERS FROM CHEGG, BECAUSE THEY ARE WRONG

In class, we gave a very basic macro design to implement stack guard with canary. In that design, we havent talk about how to define __SECRET_VAR in the macros. A simple way to define __SECRET_VAR is some marco like #define __SECRET_VAR 11223344 But the issue is that it is a constant so an attacker can know. A better strategy is to make it a variable and assign a random number to it at run time. You job is to write the entire set of macros in a head file mycanary.h so a users program can include the header file and use all macros for stack protection. You have already been given the following users code, which uses four macros: DEF_CANARY(), PLACE_CANARY(), SAFE_RETURN(), and INIT_CANARY(). Please complete all four macros in the header file mycanary.h so __SECRET_VAR can be assigned randomly at run time. Submit the content of your mycanary.h. Screen-shot the result to show your macros can successfully detect buffer overflow in the following code. (50pts) #include #include #include"mycanary.h" DEF_CANARY(); /* define canary as global*/ void vul_fun(char *str) { PLACE_CANARY(); /* place a canary */ char buf[16]; strcpy(buf, str); printf("buf=%s ", buf); SAFE_RETURN(); /* check canary and return */ } int main(){ INIT_CANARY(); /* randomize the value of canary */ vul_fun("123456789012345678901234567890"); } Hints: You can define a global variable in DEF_CANARY, then assign a random value (using random functions in C) to __SECRET_VAR in INIT_CANARY. PLACE_CANARY() and SAFE_RETURN() c

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago