We will start by assuming that some important file by the name of file2.txt already exists on your computer and contains some sensitive information. Here are the steps that a malicious user or hacker can use in your program to create a file to overwrite file2.txt:
- A file pointer is defined.
- The hacker might create a soft link and attach a sensitive file to the file that we want to create.
- Open the file to which we want to write the content. But in reality, the sensitive file that is attached to our file will be opened in write-only mode.
- Prompt the user to enter the lines of text to be written into the file.
- Write the lines entered by the user into the file.
- Repeat steps 4 and 5 until the user enters stop.
- Close the file ...