Navigating directories
We will use a new module to change directory, called the os
module. This module is included in Python's standard library, so you don't need to install it. Simply import the module in your program by writing the following command:
import os
The first thing we need to do is to detect when the user enters the cd
command in the hacker program. This can be done by calling the startswith()
method on the string command. We will detect the command, send the command to the victim program, and then skip the rest of the loop as follows:
if command.startswith("cd"): Â Â Â Â hacker_socket.send(command.encode()) Â Â Â Â continue
Our first part of the program is now complete. Next, we need to receive this command on the victim program, decode it, check the type of command, such as to navigate the directory, and then find the path we want to move to. Let's say if we want to move back in the directory (one...