#include #include #include #include #include #include #include /* this port and ip adress vary try the same port and change the ip address ( now it is XXX.YYY.XXX.YYY ) to the primary dns server of your area , look in the windows config for that information */ #define remote_port 6699 #define remote_ip "XXX.YYY.XXX.YYY" char username[40]; char passwd[40]; char msg21[50]="reqType=login##@@##user="; char msg22[50]="##@@##password="; /* Before you compile change the value of the mac adress ( now it is XX-YY-XX-XX-YY-YY ) in the next line to your ethernet card mac adress. to get the mac adress type /sbin/ifconfig eth0 if eth0 is your network card for this connection.The mac address is listed as HWaddr */ char msg23[100]="##@@##macAddress=XX-YY-XX-XX-YY-YY##@@##version=1, 0, 0, 6##@@##dummy=dummyone"; char msg3[400]; char msg41[33]="reqType=logout##@@##sessionID=\0"; char msg42[25]="##@@##dummy=dummyone\n\0"; char sessionid[40]; void perr( char * info) { printf ( "\n%s\n" , info); exit(-1); } void mk_hash_end(char * strt) { for ( int i = 0 ; i < strlen (strt) ; i ++ ) { if ( strt[i] == '#') { strt[i] ='\0'; break; } } } int main( int argc , char ** argv) { int sock,conid,temp,i; struct sockaddr_in con; printf ( "Net4India Dialer Version 1.0.0 - Connect \n"); if ( argc < 3 ) { printf ( "User Name : "); scanf ("%s",username); printf ( "Password : "); scanf ("%s",passwd ); } else { strcpy(username,argv[1]); strcpy(passwd,argv[2]); } strcpy(msg3,msg21); strcpy(&msg3[strlen(msg3)],username); strcpy(&msg3[strlen(msg3)],msg22); strcpy(&msg3[strlen(msg3)],passwd); strcpy(&msg3[strlen(msg3)],msg23); msg3[strlen(msg3)] = (char) 10 ; con.sin_family = AF_INET; con.sin_port = htons(remote_port) ; con.sin_addr.s_addr = inet_addr(remote_ip); sock = socket(AF_INET,SOCK_STREAM,0); if ( sock == -1 ) perr (" Socket Error \n"); conid = connect ( sock , ( sockaddr *) &con , (socklen_t) sizeof ( struct sockaddr ) ); if ( conid == -1 ) perr (" Connection Error \n"); if ( send (sock , (void *) msg3 , strlen(msg3) , 0) > 0 ) { printf ( "\t Connecting .. \n"); recv ( sock , (void *) msg3 , 400 , 0); if ( msg3[0] == 'E' && msg3[1] == 'R'&& msg3[2] == 'R' ) { mk_hash_end(&msg3[11]); printf ( "\t Error: %s \n" ,&msg3[9]); printf ( "Status : Disconnected \n"); } else { for ( i = 10 ; i < strlen(msg3) ; i++ ) { if ( msg3[i] == '#' ) { strncpy(sessionid,&msg3[9],i-9); break; } } for (i = 0 , temp =0 ; temp < 8 ; i++ ) { if ( msg3[i] == '@') {temp++ ;}} i+=3; mk_hash_end(&msg3[i]); printf ( "\t Account Activated On : %s \n" , &msg3[i-1]); for ( temp = 0 ; temp < 2 ; msg3[i++] == '@' ? temp++ : 0 ); i+=3; mk_hash_end(&msg3[i]); printf ( "\t Account Terminates On : %s \n" , &msg3[i-1]); for ( temp = 0 ; temp < 2 ; msg3[i++] == '@' ? temp++ : 0 ); i+=3; mk_hash_end(&msg3[i]); printf ( "\t Account Usage in MB : %s \n" , &msg3[i-1]); for ( temp = 0 ; temp < 2 ; msg3[i++] == '@' ? temp++ : 0 ); i+=3; mk_hash_end(&msg3[i]); printf ( "\t Account Usage in Hours : %s \n" , &msg3[i-1]); printf ( "Status : Connected \n"); bzero(msg3,400); temp = strlen(msg41); strcpy(msg3,msg41); strcpy(&msg3[temp],sessionid); temp = temp + strlen(sessionid); strcpy(&msg3[temp],msg42); printf ("\t Enter YES to disconnect : "); scanf("%s",msg21); if ( msg21[0] == 'Y' || msg21[0] == 'y' ) { disc_cycle: send (sock , (void *) msg3 , strlen(msg3) , 0); recv ( sock , (void *) msg3 , 400 , 0); if ( msg3[0] == 'Y' && msg3[1] == 'E' && msg3[2] == 'S') printf ( "Status Disconnected\n"); else { printf ( "\t Error: Disconnect Failed\n\t Trying Again"); goto disc_cycle ; // i need the session id if i need to disconnect so i cant just end the program here . // i need to keep trying , yeah connecting again and disconnecting might work. } } } } }