/* Name: banner.c v0.5 beta
   Author: Cyber_Bob
   Made: Pico 3.5 (very l33t scr1pt maker y0 ;)
   Compiled: linux 2.2.12-15 i586 (red hat 6.1)
             gcc version egcs-2.91.66
             gcc banner.c -o banner

   Well, here's another release by the all mighty person who is all up in
   his own shit... This script let's you connect to a host and rip off a
   banner from the port you chose... lets you find exploitable daemon's
   of your choice faster and more conveniently... That's about it.... If
   you don't like it.... You hurt my feelings... ;>

   [phr4se of the d4y] Make 7, UP YOURS!!

   [Shoutz] #NEUA , #NuKeZ , #OutLaw and #CTG cr3w'z

   [Shoutz/People] ^Paladin^, Sleep, L^WaRrioR, DePhAzEr, Dark, skalore,
                   Jackery, firebird1, trunck, Cyber_Egg (stupid ass bot),
                   VIRILATOR, evilgh0st, Phear, anybody else I forgot and
                   deserves to be in here..

   [Fuck You'z] #ViRii, #C (FUCK YOU AND YOUR DoS SCRIPT HATING ASSES),
                fusi0n (where the hell did your anoying ass go?), and
                of course R2-D2..
*/


#include        <stdio.h>
#include        <stdlib.h>
#include        <sys/time.h>
#include        <sys/types.h>
#include        <unistd.h>
#include        <sys/socket.h>
#include        <netinet/in.h>
#include        <netdb.h>
#include        <sys/errno.h>

#define VERSION "0.5 beta"

char	data[1001];
int     sock,port,i;
struct  sockaddr_in sa;
struct  hostent *hp;
void banner(void);

main (int argc, char *argv[]) {
	banner();
        if(argc<2) {
                printf("\nUsage: %s <host> <port>\n",argv[0]);
                exit(1);
        }
        if(argc>2) {
        	port=atoi(argv[2]);
	}
        /* Resolve remote hostname & connect*/
        if((hp=(struct hostent *)gethostbyname(argv[1]))==NULL) {
                perror("gethostbyname()");
                exit(1);
        }
        if((sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP))<0) {
                perror("socket()");
                exit(1);
        }
        sa.sin_family=AF_INET;
        sa.sin_port=htons(port);
        memcpy((char *)&sa.sin_addr,(char *)hp->h_addr,hp->h_length);
        if(connect(sock,(struct sockaddr *)&sa,sizeof(sa))!=0) {
                perror("connect()");
                exit(0);
        }
        printf("Connected to %s... Reading Banner...\n",argv[1]); 
        fflush(stdin);
        read(sock,&data,1000);
        printf("Banner: %s\n", data);
	return 0;
}

void banner(void)
{
  printf("\n\n                      Banner v%s\n",VERSION);
  printf("                       By - Cyber_Bob\n\n");
}

