Beispiel #1
0
def test_backdoor():
    runner = object()
    green_socket, gt = setup_backdoor(runner, 0)
    eventlet.sleep(0)  # give backdoor a chance to spawn
    socket_name = green_socket.fd.getsockname()
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect(socket_name)
    recv_until_prompt(sock)  # banner

    sock.sendall(b"runner\n")
    runner_repr = recv_until_prompt(sock)
    assert repr(runner) in str(runner_repr)

    sock.sendall(b"quit()\n")
    error = recv_until_prompt(sock)
    assert 'RuntimeError: This would kill your service' in str(error)
    sock.close()
    gt.kill()
Beispiel #2
0
def test_backdoor():
    runner = object()
    green_socket, gt = setup_backdoor(runner, 0)
    eventlet.sleep(0)  # give backdoor a chance to spawn
    socket_name = green_socket.fd.getsockname()
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect(socket_name)
    recv_until_prompt(sock)  # banner

    sock.sendall(b"runner\n")
    runner_repr = recv_until_prompt(sock)
    assert repr(runner) in str(runner_repr)

    sock.sendall(b"quit()\n")
    error = recv_until_prompt(sock)
    assert 'RuntimeError: This would kill your service' in str(error)
    sock.close()
    gt.kill()
Beispiel #3
0
def running_backdoor():
    runner = object()
    green_socket, gt = setup_backdoor(runner, 0)
    eventlet.sleep(0)  # give backdoor a chance to spawn
    socket_name = green_socket.fd.getsockname()
    return socket_name