diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-01-06 20:12:03 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-01-06 20:12:03 +0000 |
commit | 9e6d35490a6542f9c97607f93c2ef8ca8e03cbcc (patch) | |
tree | dd2a1ddf0476664c2b823409c36cbccd52662ca7 /third_party/Python/module/pexpect-2.4/examples/bd_client.py | |
parent | 3bd2e91faeb9eeec1aae82c64a3253afff551cfd (diff) |
Notes
Diffstat (limited to 'third_party/Python/module/pexpect-2.4/examples/bd_client.py')
-rw-r--r-- | third_party/Python/module/pexpect-2.4/examples/bd_client.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/third_party/Python/module/pexpect-2.4/examples/bd_client.py b/third_party/Python/module/pexpect-2.4/examples/bd_client.py new file mode 100644 index 0000000000000..564739a0aad53 --- /dev/null +++ b/third_party/Python/module/pexpect-2.4/examples/bd_client.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +"""This is a very simple client for the backdoor daemon. This is intended more +for testing rather than normal use. See bd_serv.py """ + +import socket +import sys, time, select + +def recv_wrapper(s): + r,w,e = select.select([s.fileno()],[],[], 2) + if not r: + return '' + #cols = int(s.recv(4)) + #rows = int(s.recv(4)) + cols = 80 + rows = 24 + packet_size = cols * rows * 2 # double it for good measure + return s.recv(packet_size) + +#HOST = '' #'localhost' # The remote host +#PORT = 1664 # The same port as used by the server +s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +s.connect(sys.argv[1])#(HOST, PORT)) +time.sleep(1) +#s.setblocking(0) +#s.send('COMMAND' + '\x01' + sys.argv[1]) +s.send(':sendline ' + sys.argv[2]) +print recv_wrapper(s) +s.close() +sys.exit() +#while True: +# data = recv_wrapper(s) +# if data == '': +# break +# sys.stdout.write (data) +# sys.stdout.flush() +#s.close() + |