[Solved (I think)] MSEB Online Payment
Posted: Apr 28, 2009, 19:12Finally! Here's how I went about it:
First, I wrote a simple program that downloads a page from http://billing.mahadiscom.in
#include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #define BUF_SIZE 2048 int main(int argc, char *argv[]) { char *host="billing.mahadiscom.in"; char *port="80"; int n=0, iter=0; struct addrinfo hints; struct addrinfo *result, *rp; int sfd, s; char buf[BUF_SIZE]; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = 0; hints.ai_protocol = 0; s = getaddrinfo(host, port, &hints, &result); if (s != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s)); exit(EXIT_FAILURE); } for (rp = result; rp != NULL; rp = rp->ai_next) { sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (sfd == -1) continue; if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1) break; /* Success */ else perror("connect"); close(sfd); } if (rp == NULL) { /* No address succeeded */ fprintf(stderr, "Could not connect\n"); exit(EXIT_FAILURE); } freeaddrinfo(result); /* No longer needed */ if(write(sfd, "GET /billinfo.php HTTP/1.1\r\n", strlen("GET /billinfo.php HTTP/1.1\r\n") ) < 0 ) perror("write1"); if (write(sfd, "Host: billing.mahadiscom.in\r\n", strlen("Host: billing.mahadiscom.in\r\n") )<0) perror("write2"); if(write(sfd, "\r\n", strlen("\r\n") )<0) perror("write3"); memset(buf, 0, BUF_SIZE); while((n = read(sfd, buf, BUF_SIZE-1)) >0) { printf("%s\n\n==========================\n\n" "%d bytes received (Iter %d)\n\n" "===============================\n\n", buf, n, ++iter); memset(buf, 0, BUF_SIZE); } if (n<0) perror("error"); return 0; }
On first run, data came in at 1448 bytes per burst and then hung up in about 3 bursts. Then I connected to the UK based VPN and tried again. This time data came in at 1360 bytes per burst and the entire page got downloaded. I discussed this with Ranjith Rajaram at work and he told me about MTU, which affects this window size.
Sure enough, tun0 was configured with an MTU of 1412 while eth0 had an MTU of 1500. I modified the MTU for eth0 and presto! It worked! I'm still wondering how this works for Windows systems without any such interference.
PS: Yes, the code's really dirty... but that's not the point.
Online Payment on Mahadiscom and SBI card
Posted: Mar 31, 2009, 10:07The MSEB billing site opens only when I access it from a UK based proxy. It does not work when I access it from home -- be it from my Airtel connection or from Sify. The same was true for SBI card today, although it is normally accessible from home; unlike MSEB, where I have been trying to pay my bills online unsuccessfully for months before I stumbled on to a UK proxy.