python - Meterpreter Handler/listener -


i'm cybersecurity students, i'm not cracker, scriptkiddy or this, i'm working on python meterpreter's listener, found normal tcp reverse handler, working cmd reverse tpc (metasploit), no working meterpreter reverse tpc (metasploit)... know why? thanks.

#!/usr/bin/python # import python modules socket import * host = ''                 # '' means bind interfaces port = 4444                #  port  # create our socket handler s = socket(af_inet, sock_stream) # set when cancel out can reuse port s.setsockopt(sol_socket, so_reuseaddr, 1) # bind interface s.bind((host, port)) # print accepting connections print "listening on 0.0.0.0:%s" % str(port) # listen 10 connection s.listen(10) # accept connections conn, addr = s.accept() # print connected ipaddress print 'connected by', addr # receive initial connection data = conn.recv(1024) # start loop while 1:      # enter shell command      command = raw_input("enter shell command or quit: ")      # send shell command      conn.send(command)      # if specify quit break out of loop , close socket      if command == "quit": break      # receive output linux command      data = conn.recv(1024)      # print output of linux command      print data # close socket conn.close() 

this won't work meterpreter because meterpreter's transport's support custom protocol. in order "listener" work meterpreter, have implement protocol.

it's documented these days. can start reading on on metasploit github repo's wiki. information on process meterpreter goes through running, check out 44con talk (shameless plug), covers tlv packets well. you'll need support multiple transports, including ssl-wrapped tcp.

once you've got tlv stuff working, you'll need implement commands meterpreter supports. doesn't include single-shot commands (such getsystem or ls), you'll have support stuff channels.

i won't lie, you're in lot of work. making functional meterpreter listener isn't easy job, , there's quite bit more expect. fact there's no python implementation out there sign.

best of luck!


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -