| verzia 1.17, 2001/10/02 16:24:47 |
verzia 1.18, 2001/10/24 19:24:49 |
|
|
| /* |
/* |
| * Author: rajo <host8@kepler.fmph.uniba.sk> |
* Author: rajo <host8@kepler.fmph.uniba.sk> |
| * $Log$ |
* $Log$ |
| |
* Revision 1.18 2001/10/24 19:24:49 host8 |
| |
* Added parameter -p (look for password). |
| |
* |
| * Revision 1.17 2001/10/02 16:24:47 jombik9 |
* Revision 1.17 2001/10/02 16:24:47 jombik9 |
| * Added suport for Subject header. |
* Added suport for Subject header. |
| * Removed white characters in SMS message. |
* Removed white characters in SMS message. |
|
|
| * co robis. D. |
* co robis. D. |
| * }}}1 |
* }}}1 |
| */ |
*/ |
| /* Preprocesor {{{1 */ |
|
| #include <stdio.h> |
#include <stdio.h> |
| #include <stdlib.h> |
#include <stdlib.h> |
| #include <stdarg.h> |
#include <stdarg.h> |
|
|
| #include "http.h" |
#include "http.h" |
| #include "strings.h" |
#include "strings.h" |
| |
|
| /* }}}1 */ |
|
| /* global variables {{{ */ |
/* global variables {{{ */ |
| char *message, *scratch, *keybd; |
char *message, *scratch, *keybd; |
| GLOB g; |
GLOB g; |
| WWW www; |
WWW www; |
| |
SERVER servers[] = { |
| |
{ AZET, "azet", "62.168.116.69", 80, 420 }, |
| |
{ WHIZDIARY, "whizdiary", "196.38.82.17", 80, 0 }, |
| |
{ SPISNET, "spisnet", "195.168.233.131", 80, 132 }, |
| |
{ GLOBTELNET, "globtelnet", "213.151.200.27", 80, 0 }, |
| |
{ MTNSMS, "mtnsms", "196.36.119.197", 80, 0 }, |
| |
{ 0, NULL, NULL, 0, 0 } |
| |
}; |
| |
int id=-1; /* index to servers[] */ |
| |
|
| /* }}} */ |
/* }}} */ |
| // Function void_read_at_exit() {{{ |
// Function void_read_at_exit() {{{ |
| Riadok 79 int sendsms(char *str, int show_info) |
|
| Riadok 89 int sendsms(char *str, int show_info) |
|
| //int info=show_info; |
//int info=show_info; |
| |
|
| // GET http request {{{ |
// GET http request {{{ |
| if (g.gate == AZET) { |
if (id == AZET) { |
| http_request(HTTP_GET, "/index.phtml?", "sms.azet.sk", NULL); |
http_request(HTTP_GET, "/index.phtml?", "sms.azet.sk", NULL); |
| http_set_referer("sms2.azet.sk", "/"); |
http_set_referer("sms2.azet.sk", "/"); |
| http_request(HTTP_POST, "/index.phtml", "sms.azet.sk", |
http_request(HTTP_POST, "/index.phtml", "sms.azet.sk", |
| Riadok 89 int sendsms(char *str, int show_info) |
|
| Riadok 99 int sendsms(char *str, int show_info) |
|
| strlen(str), str); |
strlen(str), str); |
| |
|
| } |
} |
| else if (g.gate == WHIZDIARY) { |
else if (id == WHIZDIARY) { |
| http_request(HTTP_GET, "/home.asp", "www.whizdiary.com", NULL); |
http_request(HTTP_GET, "/home.asp", "www.whizdiary.com", NULL); |
| http_request(HTTP_GET, "/noCookies.asp", "www.whizdiary.com", NULL); |
http_request(HTTP_GET, "/noCookies.asp", "www.whizdiary.com", NULL); |
| http_request(HTTP_GET, "/default.asp", "www.whizdiary.com", NULL); |
http_request(HTTP_GET, "/default.asp", "www.whizdiary.com", NULL); |
| Riadok 101 int sendsms(char *str, int show_info) |
|
| Riadok 111 int sendsms(char *str, int show_info) |
|
| "Content-length: %d\r\n\r\n%s", |
"Content-length: %d\r\n\r\n%s", |
| strlen(str), str); |
strlen(str), str); |
| } |
} |
| else if (g.gate == SPISNET) { |
else if (id == SPISNET) { |
| http_request(HTTP_GET, "/top.php3", "sms.spisnet.sk", NULL); |
http_request(HTTP_GET, "/top.php3", "sms.spisnet.sk", NULL); |
| http_request(HTTP_POST, "/smssend.php3", "sms.spisnet.sk", |
http_request(HTTP_POST, "/smssend.php3", "sms.spisnet.sk", |
| "Content-type: " |
"Content-type: " |
| Riadok 111 int sendsms(char *str, int show_info) |
|
| Riadok 121 int sendsms(char *str, int show_info) |
|
| strlen(str), str); |
strlen(str), str); |
| // "smsn=421903123123&chars=0&smsm=sorry%2C+test&submit=Odoslat+SMS+spr%E1vu" |
// "smsn=421903123123&chars=0&smsm=sorry%2C+test&submit=Odoslat+SMS+spr%E1vu" |
| } |
} |
| else if (g.gate == GLOBTELNET) { |
else if (id == GLOBTELNET) { |
| /* Begin of frames * |
/* Begin of frames * |
| http_request(HTTP_GET, "/get/guest/app.php3.html", |
http_request(HTTP_GET, "/get/guest/app.php3.html", |
| "www.globtelnet.sk", NULL); |
"www.globtelnet.sk", NULL); |
| Riadok 131 int sendsms(char *str, int show_info) |
|
| Riadok 141 int sendsms(char *str, int show_info) |
|
| "charset=windows-1250\r\n" |
"charset=windows-1250\r\n" |
| "Content-length: 51\r\n\r\n"" |
"Content-length: 51\r\n\r\n"" |
| form_name=login" |
form_name=login" |
| "&next_page=&wa_na=********&wa_pa=********"); |
"&next_page=&wa_na=*****&wa_pa=*****"); |
| http_request(HTTP_POST, "/sms/do_sms_send.php3", "www.globtelnet.sk", |
http_request(HTTP_POST, "/sms/do_sms_send.php3", "www.globtelnet.sk", |
| "Content-type: " |
"Content-type: " |
| "application/x-www-form-urlencoded; " |
"application/x-www-form-urlencoded; " |
| Riadok 141 int sendsms(char *str, int show_info) |
|
| Riadok 151 int sendsms(char *str, int show_info) |
|
| http_request(HTTP_GET, "/comm/message.php3?readsess=1", |
http_request(HTTP_GET, "/comm/message.php3?readsess=1", |
| "www.globtelnet.sk", NULL); |
"www.globtelnet.sk", NULL); |
| } |
} |
| |
else if (id == MTNSMS) { |
| |
http_request(HTTP_GET, "/", "www.mtnsms.com", NULL); |
| |
http_request(HTTP_POST, "/session.asp", "www.mtnsms.com", |
| |
"Content-type: " |
| |
"application/x-www-form-urlencoded; " |
| |
"Content-length: 77\r\n\r\n%s", |
| |
"username=********&" |
| |
"password=********&email=&" |
| |
"joinusclick=no&returl=&x=40&y=39"); |
| |
} |
| // }}} |
// }}} |
| |
|
| fprintf(stderr, "text to sms [%d chars]:'%s'\n", |
fprintf(stderr, "text to sms [%d chars]:'%s'\n", |
| Riadok 235 void print_usage(char *argv0) |
|
| Riadok 255 void print_usage(char *argv0) |
|
| fprintf(stderr, "Usage: %s [OPTIONS] [MESSAGE] ...\n", argv0); |
fprintf(stderr, "Usage: %s [OPTIONS] [MESSAGE] ...\n", argv0); |
| fprintf(stderr, " --number povinne tel. cislo [421903838302]\n"); |
fprintf(stderr, " --number povinne tel. cislo [421903838302]\n"); |
| fprintf(stderr, " --gate " |
fprintf(stderr, " --gate " |
| "[azet|whizdiary|spisnet|globtelnet]\n"); |
"[azet|whizdiary|spisnet|globtelnet|mtnsms]\n"); |
| fprintf(stderr, " --mail standardny vstup je mail\n"); |
fprintf(stderr, " --mail standardny vstup je mail\n"); |
| fprintf(stderr, " --nomail standardny vstup nie je mail\n"); |
fprintf(stderr, " --nomail standardny vstup nie je mail\n"); |
| fprintf(stderr, " --reverse zmena poradia smsiek [123] -> [321]\n"); |
fprintf(stderr, " --reverse zmena poradia smsiek [123] -> [321]\n"); |
| Riadok 259 int main(int argc, char *argv[]) |
|
| Riadok 279 int main(int argc, char *argv[]) |
|
| } |
} |
| |
|
| while (1) { // Cmdline parsing {{{ |
while (1) { // Cmdline parsing {{{ |
| int c; |
int c, i; |
| int option_index = 0; |
int option_index = 0; |
| static struct option long_options[] = |
static struct option long_options[] = |
| { |
{ |
| {"number", 1, 0, 'n'}, |
{"number", 1, 0, 'n'}, |
| {"gate", 1, 0, 'g'}, |
{"gate", 1, 0, 'g'}, |
| |
{"passwd", 0, 0, 'p'}, |
| {"mail", 0, 0, 'm'}, |
{"mail", 0, 0, 'm'}, |
| {"nomail", 0, 0, 'M'}, |
{"nomail", 0, 0, 'M'}, |
| {"reverse", 0, 0, 'r'}, |
{"reverse", 0, 0, 'r'}, |
| Riadok 273 int main(int argc, char *argv[]) |
|
| Riadok 294 int main(int argc, char *argv[]) |
|
| {0, 0, 0, 0} |
{0, 0, 0, 0} |
| }; |
}; |
| |
|
| c = getopt_long (argc, argv, "n:g:mMrd::h", |
c = getopt_long (argc, argv, "n:g:pmMrd::h", |
| long_options, &option_index); |
long_options, &option_index); |
| if (c == -1) |
if (c == -1) |
| break; |
break; |
| Riadok 281 int main(int argc, char *argv[]) |
|
| Riadok 302 int main(int argc, char *argv[]) |
|
| switch (c) { |
switch (c) { |
| case 'n': |
case 'n': |
| g.number = optarg; // priradenie tel. cisla |
g.number = optarg; // priradenie tel. cisla |
| |
#ifdef DEBUG |
| fprintf(stderr, "n: number = %s\n", g.number); |
fprintf(stderr, "n: number = %s\n", g.number); |
| |
#endif |
| break; |
break; |
| case 'g': |
case 'g': |
| fprintf(stderr, "%s\n", optarg); |
#ifdef DEBUG |
| if (strcmp(optarg, "azet") == 0) { |
fprintf(stderr, "%s...", optarg); |
| g.gate = AZET; |
#endif |
| } |
for (i=0; servers[i].desc != NULL; i++) { |
| else if (strcmp(optarg, "whizdiary") == 0) { |
if (strcmp(servers[i].desc, optarg) == 0) { |
| g.gate = WHIZDIARY; |
id = servers[i].id; |
| } |
#ifdef DEBUG |
| else if (strcmp(optarg, "spisnet") == 0) { |
fprintf(stderr, "%d\n", id); |
| g.gate = SPISNET; |
#endif |
| } |
break; |
| else if (strcmp(optarg, "globtelnet") == 0) { |
} |
| g.gate = GLOBTELNET; |
|
| } |
} |
| else { |
if (id == -1) { |
| fprintf(stderr, "Invalid option '%s'\n", optarg); |
fprintf(stderr, "\nInvalid option '%s'\n", optarg); |
| exit(1); |
exit(1); |
| } |
} |
| break; |
break; |
| |
case 'p': |
| |
#ifdef DEBUG |
| |
fprintf(stderr, "p: \n"); |
| |
#endif |
| |
break; |
| case 'm': |
case 'm': |
| g.is_mail = 1; |
g.is_mail = 1; |
| |
#ifdef DEBUG |
| fprintf(stderr, "m: is_mail = %d\n", g.is_mail); |
fprintf(stderr, "m: is_mail = %d\n", g.is_mail); |
| |
#endif |
| break; |
break; |
| case 'M': |
case 'M': |
| g.is_mail = 0; |
g.is_mail = 0; |
| |
#ifdef DEBUG |
| fprintf(stderr, "M: is_mail = %d\n", g.is_mail); |
fprintf(stderr, "M: is_mail = %d\n", g.is_mail); |
| |
#endif |
| break; |
break; |
| case 'r': |
case 'r': |
| g.reverse = 1; |
g.reverse = 1; |
| |
#ifdef DEBUG |
| fprintf(stderr, "r: reverse = %d\n", g.reverse); |
fprintf(stderr, "r: reverse = %d\n", g.reverse); |
| |
#endif |
| break; |
break; |
| case 'd': |
case 'd': |
| if (optarg!=NULL) { |
if (optarg!=NULL) { |
| g.debug = atoi(optarg); |
g.debug = atoi(optarg); |
| } |
} |
| else g.debug = 1; |
else g.debug = 1; |
| |
#ifdef DEBUG |
| fprintf(stderr, "d: debug = %d\n", g.debug); |
fprintf(stderr, "d: debug = %d\n", g.debug); |
| |
#endif |
| break; |
break; |
| case 'h': |
case 'h': |
| print_usage(argv[0]); |
print_usage(argv[0]); |
| Riadok 338 int main(int argc, char *argv[]) |
|
| Riadok 373 int main(int argc, char *argv[]) |
|
| scratch = (char *) malloc(SCRATCH_LEN*sizeof(char)); |
scratch = (char *) malloc(SCRATCH_LEN*sizeof(char)); |
| keybd = (char *) malloc(KEYBD_LEN*sizeof(char)); |
keybd = (char *) malloc(KEYBD_LEN*sizeof(char)); |
| |
|
| if (g.gate == AZET) { |
if (id == AZET) { |
| //komu=0903&predvolba=0903&cislo=838302&sprava=caf+pokus1%0adaskfjkadf+%3Csipky%3E%0ahalo&oslovenie=Ahoj+Milacik%21+&velkost=420&odoslat=Ok&odoslat.x=0&odoslat.y=0", |
//komu=0903&predvolba=0903&cislo=838302&sprava=caf+pokus1%0adaskfjkadf+%3Csipky%3E%0ahalo&oslovenie=Ahoj+Milacik%21+&velkost=420&odoslat=Ok&odoslat.x=0&odoslat.y=0", |
| strcpy(message, "komu="); |
strcpy(message, "komu="); |
| strncat(message, g.number, 4); |
strncat(message, g.number, 4); |
| Riadok 348 int main(int argc, char *argv[]) |
|
| Riadok 383 int main(int argc, char *argv[]) |
|
| strncat(message, g.number + 4, (strlen(g.number) - 4) ); |
strncat(message, g.number + 4, (strlen(g.number) - 4) ); |
| strcat(message, "&sprava="); |
strcat(message, "&sprava="); |
| } |
} |
| else if (g.gate == WHIZDIARY) { |
else if (id == WHIZDIARY) { |
| strcpy(message, "theAction=Send+Message&cellnum=%2B"); |
strcpy(message, "theAction=Send+Message&cellnum=%2B"); |
| strncat(message, g.number, strlen(g.number)); |
strncat(message, g.number, strlen(g.number)); |
| strcat(message, "&message="); |
strcat(message, "&message="); |
| } |
} |
| else if (g.gate == SPISNET) { |
else if (id == SPISNET) { |
| strcpy(message, "smsn="); |
strcpy(message, "smsn="); |
| strncat(message, g.number, strlen(g.number)); |
strncat(message, g.number, strlen(g.number)); |
| strcat(message, "&chars=0"); |
strcat(message, "&chars=0"); |
| strcat(message, "&smsm="); |
strcat(message, "&smsm="); |
| } |
} |
| else if (g.gate == GLOBTELNET) { |
else if (id == GLOBTELNET) { |
| strcpy(message, "f_Slot_num=&f_Redirect=%2Fsms%2Fsms.php3" |
strcpy(message, "f_Slot_num=&f_Redirect=%2Fsms%2Fsms.php3" |
| "&f_TelNumber="); |
"&f_TelNumber="); |
| strncat(message, g.number, strlen(g.number)); |
strncat(message, g.number, strlen(g.number)); |
| strcat(message, "&x=25&y=10"); |
strcat(message, "&x=25&y=10"); |
| strcat(message, "&f_SMSBody="); |
strcat(message, "&f_SMSBody="); |
| } |
} |
| |
else if (id == MTNSMS) { |
| |
} |
| |
|
| if (optind < argc) { |
if (optind < argc) { |
| if (g.debug) |
if (g.debug) |
| Riadok 406 int main(int argc, char *argv[]) |
|
| Riadok 443 int main(int argc, char *argv[]) |
|
| } // end switch ( select() ) |
} // end switch ( select() ) |
| } // end while (!koniec) |
} // end while (!koniec) |
| strcat(message, g.text); |
strcat(message, g.text); |
| if (g.gate == AZET) { |
if (id == AZET) { |
| strcat(message, "&oslovenie=Ahoj+Milacik%21+&velkost=420" |
strcat(message, "&oslovenie=Ahoj+Milacik%21+&velkost=420" |
| "&odoslat=Ok&odoslat.x=0&odoslat.y=0"); |
"&odoslat=Ok&odoslat.x=0&odoslat.y=0"); |
| } |
} |
| else if (g.gate == WHIZDIARY) { |
else if (id == WHIZDIARY) { |
| strcat(message, "&charsLeft="); |
strcat(message, "&charsLeft="); |
| strcat(message, "130&theNetwork=NONE&I4.x=0&I4.y=0"); |
strcat(message, "130&theNetwork=NONE&I4.x=0&I4.y=0"); |
| } |
} |
| else if (g.gate == SPISNET) { |
else if (id == SPISNET) { |
| // "smsn=421903123123&chars=0&smsm=sorry%2C+test&submit=Odoslat+SMS+spr%E1vu" |
// "smsn=421903123123&chars=0&smsm=sorry%2C+test&submit=Odoslat+SMS+spr%E1vu" |
| strcat(message, "&submit=Odoslat+SMS+spr%E1vu"); |
strcat(message, "&submit=Odoslat+SMS+spr%E1vu"); |
| } |
} |
| else if (g.gate == GLOBTELNET) { |
else if (id == GLOBTELNET) { |
| |
/* empty */ |
| |
} |
| |
else if (id == MTNSMS) { |
| /* empty */ |
/* empty */ |
| } |
} |
| if (sendsms(message, g.debug-1) != 0) { |
if (sendsms(message, g.debug-1) != 0) { |