Question: The program we provide: - Takes as a command - line argument the name of a file, which it opens. - The program then asks
The program we provide: Takes as a commandline argument the name of a file, which it opens. The program then asks your function yourfcn for a string, writes that string to the file, and closes the file. It then reopens the file, and attempts to "sanitize" the string you provided by removing all instances of the substring from it Finally, it overwrites the file with this "sanitized" version of the string.For example, if your function generated the string "I love CMSC thenwe would get the following output:cmsc@cmsc:~$ taskax file.txtcmsc@cmsc:~$ cat file.txtI love CMSCYour goal is to write yourfcn in such a way that the file whose name isprovided on the commandline still has the substring in itA simple way to test for this is with the command grep which returns linescontaining the string as follows:cmsc@cmsc:~$ grep file.txtIf this returns nothing as the above case would then that means the filedoes not have in it resulting in no credit.you must provide afunctionally unique solution in each of the three; they cannot simply beslight variations of one another eg if one of your solutions wasprintfx then another cannot be putsx as those are functionally the samethingThere are many different ways to solve this! Some might involve bufferoverflows, and some might not. We are not requiring any one particularsolution; just like with any attack, what matters is whether it achievesthe goal, even if it's not a method we anticipated. Be creative and have funwith itHere's a working example:int yourfuncchar yourstring strcpyyourstring, ; return ;Heres the function that removes the string:char strremovechar str const char sub sizet len strlensub; if len char p str; while p strstrp sub NULL memmovep p len, strlenp len; return str;Rewrite yourfuncchar yourstring at least in different ways that will cause to still be in file.txt
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
