comparison cli-chansession.c @ 296:6b41e2cbf071 dbclient-netcat-alike

A hack to make dbclient to tcp forwarding netcat style. eg ./dbclient -i testkey -L 1234:remotehost:remoteport tunnelhost will ssh to tunnelhost (using testkey, there's no way to ask for a password) and then tcpfwd to remotehost:remoteport on stdin/stdout. There's no way to give a cmdline password, so -i for a keyfile will have to do. Yet another reason for agent forwarding. The 1234 is a dummy var, I think it has to be a valid portnumber though.
author Matt Johnston <matt@ucc.asn.au>
date Tue, 21 Mar 2006 16:16:41 +0000
parents 84925eceeb13
children d4f32c3443ac
comparison
equal deleted inserted replaced
295:03f65e461915 296:6b41e2cbf071
365 365
366 } 366 }
367 367
368 void cli_send_chansess_request() { 368 void cli_send_chansess_request() {
369 369
370 unsigned int port = 0;
371 unsigned char* addr = NULL;
372 unsigned char* ipstring = "127.0.0.1";
373 unsigned char* portstring = "22";
374
375 /* hack hack */
376 static const struct ChanType cli_chan_tcphack = {
377 0, /* sepfds */
378 "direct-tcpip",
379 NULL,
380 NULL,
381 NULL,
382 cli_closechansess
383 };
384
370 TRACE(("enter cli_send_chansess_request")) 385 TRACE(("enter cli_send_chansess_request"))
371 if (send_msg_channel_open_init(STDIN_FILENO, &clichansess) 386 if (send_msg_channel_open_init(STDIN_FILENO, &cli_chan_tcphack)
372 == DROPBEAR_FAILURE) { 387 == DROPBEAR_FAILURE) {
373 dropbear_exit("Couldn't open initial channel"); 388 dropbear_exit("Couldn't open initial channel");
374 } 389 }
375 390
376 /* No special channel request data */ 391 if (cli_opts.localfwds == NULL) {
392 dropbear_exit("You need to give a \"-L ignored:host:port\" option with this hacked up dbclient.");
393 }
394
395 addr = cli_opts.localfwds->connectaddr;
396 port = cli_opts.localfwds->connectport;
397
398 buf_putstring(ses.writepayload, addr, strlen(addr));
399 buf_putint(ses.writepayload, port);
400
401 /* originator ip */
402 buf_putstring(ses.writepayload, ipstring, strlen(ipstring));
403 /* originator port */
404 buf_putint(ses.writepayload, atol(portstring));
405
377 encrypt_packet(); 406 encrypt_packet();
378 TRACE(("leave cli_send_chansess_request")) 407 TRACE(("leave cli_send_chansess_request"))
379 408
380 } 409 }
410
411 #if 0
412 while (cli_opts.localfwds != NULL) {
413 ret = cli_localtcp(cli_opts.localfwds->listenport,
414 cli_opts.localfwds->connectaddr,
415 cli_opts.localfwds->connectport);
416 if (ret == DROPBEAR_FAILURE) {
417 dropbear_log(LOG_WARNING, "Failed local port forward %d:%s:%d",
418 cli_opts.localfwds->listenport,
419 cli_opts.localfwds->connectaddr,
420 cli_opts.localfwds->connectport);
421 #endif