Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ please ----- In the world of information security and cyber, we are dealing with attempts by hackers (hereinafter - malicious attack) to break

in C++ please

-----

In the world of information security and cyber, we are dealing with attempts by hackers (hereinafter - "malicious attack") to break into software systems by various methods. One of the known hacking methods is to obtain the source code of the software and try to understand from it what the security vulnerabilities in the system are. One method of dealing with such assaults is called obfuscation. In this method we intentionally change the source code so that it is less readable and less significant, and so even if a malicious attacker manages to obtain the source code, he will have difficulty understanding it and identifying the security vulnerabilities in it. In this exercise obfuscators were built that use different methods to obscure the source code.

Write an abstract class called Obfuscator that will serve as the base class for misters. Define the public attribute in the department: const string OUT = newCode.c; The class will contain the following functions: virtual void obfuscate (string fileName) = 0 - A pure virtual function that implements the obfuscation method in any inherited class. The function will get the name of a file that contains obscure code. The function will obscure the code (see details below) and write it back to a file whose name is specified in the OUT variable. string generateRandomVar () - The function will generate and return a valid random name of a variable, for example m78_fv or _uji98hf. The name must be a valid name in the language c. string * parseFile (string filename) - The function will get as a parameter a file name and return an array of strings, with each line in the file displayed in one string in the array. void writeToFile (string * codeArray) - The function will get an array of strings as a parameter when each string represents one line of code. The function will write the obscure code back into a new file, named in the OUT variable.

Define the following classes that inherit from the Obfuscator class: The LineObfuscator class will implement "line obfuscation" - the implementation of the obfuscate function will add meaningless line code in the following format - The function will add at the beginning of the main setting an int variable with a random name, for example - int dfsa5asf; And add at some random location in the line code in the following format: dfsa5asf = 234 + 876; That is, the obfuscation will be done by defining a random variable, and placing a value on it (adding two random numbers). The VarObfuscator class will implement "variable blur". Implementing the obfuscate function will randomly select one of the int variables defined in the code, and change its name to a random name (note - the name must be changed in all places where it appears in the code, otherwise the code will not fold). The CommentObfuscator class will implement "Document Blurring". Implementing the obfuscate function will delete all comments from the code, and will plant random notes in random locations. Define in the class an array of several strings and use them as notes.

For example, suppose the following source code file is given: #include // the program calculates the sum of all numbers between two given numbers void main () { int firstNum; int secondNum; int sum = 0; prinf (Enter two numbers: \ n); scanf ("% d% d", & firstNum, & secondNum); // gets input

// calculate the sum for (int i = firstNum; i <= secondNum; i ++) sum + = i; printf ("The total sum is:% d \ n", sum); } After activating the various mists, the new code can look like this:

#include // the program calculates the sum of all numbers between two given numbers void main () { int firstNum; int secondNum; int sum = 0; prinf (Enter two numbers: \ n); scanf ("% d% d", & firstNum, & secondNum); // gets input

// calculate the sum for (int i = firstNum; i <= secondNum; i ++) sum + = i; printf ("The total sum is:% d \ n", sum); } After activating the various mists, the new code can look like this: #include

void main () { int firstNum; int ytr431; int sum = 0; int h_h_g1; // check if number is prime prinf (Enter two numbers: \ n); scanf ("% d% d", & firstNum, & ytr431); h_h_g1 = 987 + 5; for (int i = firstNum; i <= ytr431; i ++) sum + = i; printf ("The total sum is:% d \ n", sum); }

- The variable ytr431 changed the name secondNum as a result of VarObfuscator operation. - the variable int h_h_g1 and the row h_h_g1 = 987 + 5; Were added as a result of the LineObfuscator operation. - All comments have been deleted and the comment // check if number is prime has been added as a result of the CommentObfuscator action. Example of operating the fog The misting can be activated as follows: #include using namespace std; void main () { Obfuscator * obfs [3]; obfs [0] = new VarObfuscator (); obfs [1] = new LineObfuscator (); obfs [2] = new CommentObfuscator (); obfs [0] -> obfuscate ("test.c"); for (int i = 1; i <3; i ++) obfs [i] -> obfuscate (obfs [i-1] -> OUT); delete [] obfs; }

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions