/* grabs telnet banners from sqlite3 nmap dumps */ /* very simple somewhat boring */ /* fbff */ #include #include #include #include #include #include #include #include #include #include /* i'm not sure why there are here, they sounded good */ #define ALLOC(x) malloc((x)+1) #define ZERO(p,i) memset((p),'\0',(i+1)) #define DESTORY(x) free((x)) static void banner_grab(unsigned char *host, unsigned int port) { int sd; int ret; int ssize; unsigned char *q; struct sockaddr_in saddr; if ((sd = socket(AF_INET, SOCK_STREAM, 0))<0) return; saddr.sin_family = AF_INET; saddr.sin_port = htons(port); saddr.sin_addr.s_addr = inet_addr(host); //memset((&saddr.sin_zero, '\0', 8)); if ( (ret = connect(sd, (struct sockaddr *)&saddr, sizeof(struct sockaddr)))<0) return; q = ALLOC(1024); ZERO(q, 1024); if ( (ret = recv(sd, q, 1024, 0)) > 0) { printf("%s\n", q); } DESTORY(q); close(sd); return; } static int callback(void *NoteUsed, int argc, char **argv, char **azColName) { int i; unsigned char *ip; unsigned int port; port = 23; for (i=0;i