def main(): options = parse_options() if options.verbose: logging.basicConfig(level=logging.DEBUG) print("[*] Setting a proxy between %s:%d and remote SAP Router %s:%d (talk mode %s)" % (options.local_host, options.local_port, options.remote_host, options.remote_port, options.talk_mode)) options.talk_mode = {"raw": 1, "ni": 0}[options.talk_mode] proxy = SAPRouterNativeProxy(options.local_host, options.local_port, options.remote_host, options.remote_port, SAPRouterNativeRouterHandler, target_address=options.target_host, target_port=options.target_port, target_pass=options.target_pass, talk_mode=options.talk_mode, keep_alive=False, options=options) try: while True: try: proxy.handle_connection() except SocketError as e: print("[*] Socket Error %s" % e) except KeyboardInterrupt: print("[*] Cancelled by the user !") except SAPRouteException as e: print("[*] Closing routing do to error %s" % e)
def main(): options = parse_options() level = logging.INFO if options.verbose: level = logging.DEBUG logging.basicConfig(level=level, format='%(message)s') logging.info( "[*] Setting a proxy between %s:%d and remote SAP Router %s:%d (talk mode %s)" % (options.local_host, options.local_port, options.remote_host, options.remote_port, options.talk_mode)) options.talk_mode = { "raw": ROUTER_TALK_MODE_NI_RAW_IO, "ni": ROUTER_TALK_MODE_NI_MSG_IO }[options.talk_mode] proxy = SAPRouterNativeProxy(options.local_host, options.local_port, options.remote_host, options.remote_port, SAPRouterNativeRouterHandler, target_address=options.target_host, target_port=options.target_port, target_pass=options.target_pass, talk_mode=options.talk_mode, keep_alive=False, options=options) try: while True: try: proxy.handle_connection() except SocketError as e: logging.error("[*] Socket Error %s" % e) except KeyboardInterrupt: logging.error("[*] Cancelled by the user !") except SAPRouteException as e: logging.error("[*] Closing routing do to error %s" % e)