예제 #1
0
파일: fwd.py 프로젝트: simpoir/reach
    sys.stdout.write('listening on port %d\n'%socks_port)
    sys.stdout.write('[RETURN]')
    sys.stdout.flush()
    sys.stdin.readline()

    # Start a thread with the server -- that thread will then start one
    # more thread for each request
    server_thread = threading.Thread(target=socks_svr.serve_forever)
    # Exit the server thread when the main thread terminates
    server_thread.setDaemon(True)
    server_thread.start()


help_line = 'forward local port to remote channel.'

register_command("lfwd", help_line, setup_lfwd_cmd)

# threaded tcp server mixin
class SocksServer(ThreadingMixIn, TCPServer):
    pass

class LocalHandler(BaseRequestHandler, object):
    def __init__(self, request, client_address, server, dst, dport):
        self.__dst = dst
        self.__dport = dport
        super(LocalHandler, self).__init__(request, client_address, server)

    def handle(self):
        from reach.channel import Channel

        chan = Channel.get_instance().get_chan(dict(
예제 #2
0
파일: quit.py 프로젝트: simpoir/reach
# Reach, the remote acccess tool
# Copyright (C) 2010  Simon Poirier <*****@*****.**>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from reach.commands import register_command

import sys

def quit_cmd(*args):
    sys.exit(0)

help_line = 'Just quit.'

register_command("quit", help_line, quit_cmd)

예제 #3
0
파일: sftp.py 프로젝트: simpoir/reach
    global rcwd

    try:
        try:
            cmd = raw_input('SFTP> ')
        except EOFError:
            return
        except KeyboardInterrupt:
            return
        while not cmd or not 'quit'.startswith(cmd):
            args = [x for x in cmd.split(' ') if x]
            if args and args[0] in all_cmd:
                all_cmd[args[0]](sftp, args)
            else:
                print('invalid command')
            try:
                cmd = raw_input('SFTP> ')
            except EOFError:
                return
            except KeyboardInterrupt:
                return
    finally:
        readline.set_completer(old_completer)
        readline.set_completer_delims(old_delim)


help_line = 'Transfer files.'

register_command("sftp", help_line, sftp_cmd)

예제 #4
0
파일: socks.py 프로젝트: simpoir/reach
        sys.stdin.readline()

        # Start a thread with the server -- that thread will then start one
        # more thread for each request
        server_thread = threading.Thread(target=socks_svr.serve_forever)
        # Exit the server thread when the main thread terminates
        server_thread.setDaemon(True)
        server_thread.start()
    finally:
        socks_port = None
        socks_svr = None


help_line = 'bind a socks proxy to specified port.'

register_command("socks", help_line, setup_socks_cmd)

# threaded tcp server mixin
class SocksServer(ThreadingMixIn, TCPServer):
    pass

class SocksHandler(BaseRequestHandler):
    socks4header = struct.Struct('!H4s')
    socks4response = struct.Struct('!BBH4s')
    socks5response = struct.Struct('!BBBB')

    def handle(self):
        from reach.channel import Channel
        s_ver = ord(self.request.recv(1))

        chan = None
예제 #5
0
파일: version.py 프로젝트: simpoir/reach
  ,|||||||||_______________________________________.
  \-----------------------------------------------~'
                    Reach 2
'''

description = '''
Reach is a commandline tool to bounce ssh connections through one to
many hosts in order to access a system. It has a connection completion
API to be able to get and resolve a graph of hosts.
It also supports on-the-fly tunnelling.

Reach is also an electric toothbrush, but this has obviously nothing to do with
this tool.

Version 2 is a complete rewrite of another really nice tool.
'''

def version_cmd(*args):
    print(toothbrush)
    print("Version %d.%d.%d" % (VERSION_MAJOR, VERSION_MINOR,
                                VERSION_REVISION))
    print('')
    print(description)
    print('[return]')
    sys.stdin.readline()

help_line = 'Show version information.'

register_command("version", help_line, version_cmd)

예제 #6
0
파일: x11.py 프로젝트: simpoir/reach
    for x_port in xrange(10, 30):
        try:
            t.request_port_forward('localhost', 6000+x_port, x11_handler)
            Channel.get_instance().get_interactive_chan().send(
                'export DISPLAY=localhost:%d\n'%x_port)
            forwarded_port = x_port
            try:
                # setup xauth cookie
                # Some server may use the shared cookie authentication method.
                # Though we aren't using unix sockets, xlib apps
                # translate localhost to hostname/unix when it comes to
                # checking XAuthority files.
                cookie = commands.getoutput('xauth list %s' \
                                            % os.environ.get('DISPLAY'))
                h, p, c = [x for x in cookie.splitlines()[0].split(' ') if x]
                Channel.get_instance().get_interactive_chan().send(
                    'xauth add `hostname`/unix:%d %s %s\n' \
                    %(x_port, p, c))
            except:pass
            return
        except:
            continue
    print('Could not successfully forward any x11 port.')
    term.pause()


help_line = 'Tunnel X11 connections locally.'

register_command("x11", help_line, x11_cmd)

예제 #7
0
파일: help.py 프로젝트: simpoir/reach
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from reach.commands import register_command, registry

import sys

def help_cmd(*args):
    for cmd_name, cmd in registry.items():
        print(cmd_name)
        print('\t'+cmd[0])
    sys.stdout.write('[RETURN]')
    sys.stdout.flush()
    sys.stdin.readline()

help_line = 'Show this help.'

register_command("help", help_line, help_cmd)