operatorequals / covertutils

A framework for Backdoor development!
http://covertutils.readthedocs.io
437 stars 69 forks source link

Need help with handling multiple sessions #16

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hey I am exploring your project and see ton of potential with this one. I have been trying to wrap my head around this concept ( I have seen your blog, pdf and articles written about it ) you have a nice way of explaining difficult subject in an accessible manner, thank you for sharing your insight. Now the challenge i tried to tackle for the last two days: I am trying to handle multiple connections to my handler. For that I understand I need a covertpreter. I know how to bring it to life. That's how my handler looks like:

-----shell bit-------

from covertutils.shells.multi import *

shell = MultiShell() shell.start()

from time import sleep while True : sleep(10)

------------------------------

` I can receive the connections but no sessions show up one the list. I thought that I probably need to use Multihandler, but for the love of god, don't know how to structure it. Can you please nudge me in the right direction ?

Ok, I have just noticed a bit about additional handler that I will have to import has to contain BaseShell object. Brilliant! Here is my additional handler code:

`from covertutils.orchestration import SimpleOrchestrator

orch_obj = SimpleOrchestrator( "pass", out_length = 20, in_length = 20, reverse = True, # <------- )

import socket

s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # To make the port immediately available after killing - gimmick s.bind( ("0.0.0.0", 4444) ) s.listen(5)

client, client_addr = s.accept()

def recv () : # Create wrappers for networking return client.recv( 20 )

def send( raw ) : # Create wrappers for networking return client.send( raw )

from covertutils.handlers import BaseHandler

class MyHandler_Handler( BaseHandler ) : """ This class tries hard to be self-explanatory """

    def __init__(self, recv, send, orch, **kw) :
            super( MyHandler_Handler, self ).__init__( recv, send, orch, **kw )
            print ( "[!] Handler with Orchestrator ID: '{}' started!".format( orch.getIdentity() ) )

    def onMessage( self, stream, message ) :        pass

    def onChunk( self, stream, message ) :  pass

    def onNotRecognised(self) :     pass

handler_obj = MyHandler_Handler(recv, send, orch_obj)

from covertutils.shells import *

shell = BaseShell(handler_obj) shell.start() `

But that gives me error: subshells = arguments['subshells'] KeyError: 'subshells'

UPDATE: Ok, I have found how to add a handler that will handle sessions. Now I am wondering how to interact with the sessions using ctrl+c ?

ghost commented 5 years ago

I answered my own question through inquisitive inquiry. Subject closed.