diff options
-rw-r--r-- | cli-chansession.c | 45 | ||||
-rw-r--r-- | cli-session.c | 4 |
2 files changed, 45 insertions, 4 deletions
diff --git a/cli-chansession.c b/cli-chansession.c index c92f902..beb065c 100644 --- a/cli-chansession.c +++ b/cli-chansession.c @@ -368,14 +368,55 @@ static int cli_initchansess(struct Channel *channel) { void cli_send_chansess_request() { + unsigned int port = 0; + unsigned char* addr = NULL; + unsigned char* ipstring = "127.0.0.1"; + unsigned char* portstring = "22"; + + /* hack hack */ + static const struct ChanType cli_chan_tcphack = { + 0, /* sepfds */ + "direct-tcpip", + NULL, + NULL, + NULL, + cli_closechansess + }; + TRACE(("enter cli_send_chansess_request")) - if (send_msg_channel_open_init(STDIN_FILENO, &clichansess) + if (send_msg_channel_open_init(STDIN_FILENO, &cli_chan_tcphack) == DROPBEAR_FAILURE) { dropbear_exit("Couldn't open initial channel"); } - /* No special channel request data */ + if (cli_opts.localfwds == NULL) { + dropbear_exit("You need to give a \"-L ignored:host:port\" option with this hacked up dbclient."); + } + + addr = cli_opts.localfwds->connectaddr; + port = cli_opts.localfwds->connectport; + + buf_putstring(ses.writepayload, addr, strlen(addr)); + buf_putint(ses.writepayload, port); + + /* originator ip */ + buf_putstring(ses.writepayload, ipstring, strlen(ipstring)); + /* originator port */ + buf_putint(ses.writepayload, atol(portstring)); + encrypt_packet(); TRACE(("leave cli_send_chansess_request")) } + +#if 0 + while (cli_opts.localfwds != NULL) { + ret = cli_localtcp(cli_opts.localfwds->listenport, + cli_opts.localfwds->connectaddr, + cli_opts.localfwds->connectport); + if (ret == DROPBEAR_FAILURE) { + dropbear_log(LOG_WARNING, "Failed local port forward %d:%s:%d", + cli_opts.localfwds->listenport, + cli_opts.localfwds->connectaddr, + cli_opts.localfwds->connectport); +#endif diff --git a/cli-session.c b/cli-session.c index 360187f..6668914 100644 --- a/cli-session.c +++ b/cli-session.c @@ -230,10 +230,10 @@ static void cli_sessionloop() { } #ifdef ENABLE_CLI_LOCALTCPFWD - setup_localtcp(); + //setup_localtcp(); #endif #ifdef ENABLE_CLI_REMOTETCPFWD - setup_remotetcp(); + //setup_remotetcp(); #endif if (!cli_opts.no_cmd) { cli_send_chansess_request(); |