version 1.1.1.1.2.4, 2011/10/13 16:08:52
|
version 1.3.6.1, 2013/01/18 09:31:47
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 | Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 47 SUCH DAMAGE.
|
Line 47 SUCH DAMAGE.
|
#include "ansh.h" |
#include "ansh.h" |
|
|
|
|
int Timeout, Verbose, Kill; | intptr_t Kill; |
| int Timeout, Verbose; |
u_int Crypted; |
u_int Crypted; |
|
char Key[STRSIZ]; |
|
|
extern char compiled[], compiledby[], compilehost[]; |
extern char compiled[], compiledby[], compilehost[]; |
|
|
static void |
static void |
Usage() |
Usage() |
{ |
{ |
printf( " -= ansh =- ELWIX Layer3 remote management client over ICMP\n" | printf( " -= ansh3 =- ELWIX Layer3 remote management client over ICMP\n" |
"=== %s === %s@%s ===\n\n" |
"=== %s === %s@%s ===\n\n" |
" Syntax: ansh [options] <connect2host>\n\n" |
" Syntax: ansh [options] <connect2host>\n\n" |
|
"\t-a <address>\tBind to address\n" |
"\t-i <id>\tService ID (default is 42)\n" |
"\t-i <id>\tService ID (default is 42)\n" |
"\t-t <timeout>\tClient session timeout (default is 0 sec)\n" |
"\t-t <timeout>\tClient session timeout (default is 0 sec)\n" |
|
"\t-k <key>\tService cipher key\n" |
"\t-u\t\tSwitch to unencrypted traffic between hosts\n" |
"\t-u\t\tSwitch to unencrypted traffic between hosts\n" |
"\t-v\t\tVerbose (more -v, more verbosity ...)\n" |
"\t-v\t\tVerbose (more -v, more verbosity ...)\n" |
"\t-h\t\tThis help screen!\n" |
"\t-h\t\tThis help screen!\n" |
Line 69 Usage()
|
Line 73 Usage()
|
int |
int |
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
struct sockaddr sa = { 0 }; | sockaddr_t sa, ba; |
struct sockaddr_in *sin4 = (struct sockaddr_in*) &sa; | |
struct sockaddr_in6 *sin6 = (struct sockaddr_in6*) &sa; | |
struct hostent *host; |
struct hostent *host; |
char ch; |
char ch; |
int h, len; |
int h, len; |
u_short id = ANSH_ID; |
u_short id = ANSH_ID; |
|
|
|
memset(&sa, 0, sizeof sa); |
|
memset(&ba, 0, sizeof ba); |
|
|
srandomdev(); |
srandomdev(); |
do { |
do { |
Crypted = (u_int) random() % UINT_MAX; |
Crypted = (u_int) random() % UINT_MAX; |
} while (!Crypted); |
} while (!Crypted); |
|
|
while ((ch = getopt(argc, argv, "hvui:t:")) != -1) | strlcpy(Key, DEFAULT_KEY, sizeof Key); |
| |
| while ((ch = getopt(argc, argv, "hvui:t:k:a:")) != -1) |
switch (ch) { |
switch (ch) { |
|
case 'a': |
|
host = gethostbyname(optarg); |
|
if (!host) { |
|
printf("Error:: in bind address '%s' #%d - %s\n", |
|
optarg, h_errno, hstrerror(h_errno)); |
|
return 1; |
|
} |
|
switch (host->h_addrtype) { |
|
case AF_INET: |
|
ba.sin.sin_len = sizeof(struct sockaddr_in); |
|
ba.sin.sin_family = AF_INET; |
|
memcpy(&ba.sin.sin_addr.s_addr, host->h_addr, host->h_length); |
|
break; |
|
case AF_INET6: |
|
ba.sin6.sin6_len = sizeof(struct sockaddr_in6); |
|
ba.sin6.sin6_family = AF_INET6; |
|
memcpy(&ba.sin6.sin6_addr.s6_addr, host->h_addr, host->h_length); |
|
break; |
|
default: |
|
printf("Error:: Unknown address type %d !!!\n", host->h_addrtype); |
|
return 1; |
|
} |
|
break; |
case 't': |
case 't': |
Timeout = abs(strtol(optarg, NULL, 0)); |
Timeout = abs(strtol(optarg, NULL, 0)); |
break; |
break; |
case 'i': |
case 'i': |
id = strtol(optarg, NULL, 0); |
id = strtol(optarg, NULL, 0); |
break; |
break; |
|
case 'k': |
|
strlcpy(Key, optarg, sizeof Key); |
|
break; |
case 'u': |
case 'u': |
Crypted ^= Crypted; |
Crypted ^= Crypted; |
break; |
break; |
Line 116 main(int argc, char **argv)
|
Line 149 main(int argc, char **argv)
|
} |
} |
switch (host->h_addrtype) { |
switch (host->h_addrtype) { |
case AF_INET: |
case AF_INET: |
sin4->sin_len = sizeof(struct sockaddr_in); | sa.sin.sin_len = sizeof(struct sockaddr_in); |
sin4->sin_family = AF_INET; | sa.sin.sin_family = AF_INET; |
memcpy(&sin4->sin_addr.s_addr, host->h_addr, host->h_length); | memcpy(&sa.sin.sin_addr.s_addr, host->h_addr, host->h_length); |
break; |
break; |
case AF_INET6: |
case AF_INET6: |
sin6->sin6_len = sizeof(struct sockaddr_in6); | sa.sin6.sin6_len = sizeof(struct sockaddr_in6); |
sin6->sin6_family = AF_INET6; | sa.sin6.sin6_family = AF_INET6; |
memcpy(&sin6->sin6_addr.s6_addr, host->h_addr, host->h_length); | memcpy(&sa.sin6.sin6_addr.s6_addr, host->h_addr, host->h_length); |
break; |
break; |
default: |
default: |
printf("Error:: Unknown address type %d !!!\n", host->h_addrtype); |
printf("Error:: Unknown address type %d !!!\n", host->h_addrtype); |
return 1; |
return 1; |
} |
} |
|
|
h = PrepareL3(&sa, &len); | h = PrepareL3(&ba, &len); |
if (h == -1) { |
if (h == -1) { |
printf("Error:: Descriptor not opened ... \n"); |
printf("Error:: Descriptor not opened ... \n"); |
return 1; |
return 1; |