diff --git a/forward-tunnel b/forward-tunnel index 2f9fcfb..16028ab 100644 Binary files a/forward-tunnel and b/forward-tunnel differ diff --git a/forward-tunnel.c b/forward-tunnel.c index 8f5054e..6eaed86 100644 --- a/forward-tunnel.c +++ b/forward-tunnel.c @@ -12,7 +12,7 @@ char *server_ssh_passwd = "123456"; const char *local_listenip = "0.0.0.0"; unsigned int local_listenport = 3009; -const char *remote_desthost = "0.0.0.0"; /* resolved by the server */ +char *remote_desthost = "0.0.0.0"; /* resolved by the server */ unsigned int remote_destport = 3306; enum { @@ -279,6 +279,7 @@ int main(int argc, char *argv[], char **env) int listensock = -1, forwardsock = -1; int daemon_ = 0; int opt; + char *p = NULL; char optstring[] = ":dr:s:p:l:u:e:h?"; @@ -291,7 +292,24 @@ int main(int argc, char *argv[], char **env) server_ssh_ip = strdup(optarg); break; case 's': - remote_destport = atoi(optarg); + p = strchr(optarg, ':'); + if (p != NULL) { + remote_destport = atoi(p + 1); + + *p = '\0'; + remote_desthost = optarg; + + } else { + if (NULL == (p = strchr(optarg, '.'))) + { + remote_destport =atoi(optarg); + remote_desthost = "0.0.0.0"; + } else { + help_info(); + exit(0); + } + } + break; case 'p': server_ssh_port = atoi(optarg); @@ -315,6 +333,19 @@ int main(int argc, char *argv[], char **env) } } + int i, j; + for (i = 1; i < argc; i++) { + + if (0 == strcmp(argv[i], "-e") || 0 == strcmp(argv[i], "-u") || 0 == strcmp(argv[i], "-p")) + { + for (j = strlen(argv[i+1]) - 1; j >= 0; j--) { + argv[i+1][j] = 'x'; + } + } + + } + + printf("SSH Server: %s:%d, Local listen: %s:%d, User&Passwd: [%s]['%s']\n", server_ssh_ip, remote_destport, local_listenip, local_listenport, server_ssh_user, server_ssh_passwd); diff --git a/forward-tunnel.o b/forward-tunnel.o index 53df83f..159cad4 100644 Binary files a/forward-tunnel.o and b/forward-tunnel.o differ diff --git a/reverse-tunnel b/reverse-tunnel index 21a1a9b..d8d1df0 100644 Binary files a/reverse-tunnel and b/reverse-tunnel differ diff --git a/reverse-tunnel.o b/reverse-tunnel.o index d380f45..a4ea6ab 100644 Binary files a/reverse-tunnel.o and b/reverse-tunnel.o differ