Binary IP+Port Fuzzer (Simple)

This is my simpe IP + PORT + BINARY fuzzer.

I am working on a paging protocol fuzzer and this was the first step.
You like it good, you don’t: I do not care.

Code is in C.

———– Start
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

void error(const char *msg)
{
perror(msg);
exit(0);
}

int main(int argc, char *argv[])
{
int sockfd, portno, n;

struct sockaddr_in serv_addr;
struct hostent *server;

if (argc < 3) { fprintf(stderr,”usage %s hostname port filenamen”, argv[0]); exit(0); } portno = atoi(argv[2]); sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) error(“ERROR opening socket”); server = gethostbyname(argv[1]); if (server == NULL) { fprintf(stderr,”ERROR, no such hostn”); exit(0); } bzero((char *) &serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; bcopy((char *)server->h_addr,
(char *)&serv_addr.sin_addr.s_addr,
server->h_length);
serv_addr.sin_port = htons(portno);

if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) error(“ERROR connecting”); long long sizer = 0; struct stat abc; if (stat(argv[3], &abc) == 0) sizer = abc.st_size; else fprintf(stderr,”ERROR, file sizer failedn”); char buffer[sizer]; std::ifstream mystream (argv[3], std::ios::in | std::ios::binary); mystream.read (buffer, sizer); fprintf(stderr,”READ FILEn”); n = write(sockfd,buffer,strlen(buffer)); if (n < 0) error(“ERROR writing to socket”); // bzero(buffer,256); //mystream.close(); /* n = read(sockfd,buffer,255); if (n < 0) error(“ERROR reading from socket”); printf(“%sn”,buffer); close(sockfd); */ return 0; } ———-END

Leave a Reply