PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Blöde Compler Meldung



li0n
31.05.2010, 20:26
Hi.
Ich bastle grade an nem Tool das dem -3 Angriff (arpreplay) von aireplay sehr ähnelt.
Problem:
ich bekomme diese Meldung beim Compilen:

In file included from send.h:15,
from main.c:1:
sniff.h:24: error: variably modified ‘pack’ at file scope

sniff.h sieht so aus:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <net/ethernet.h>
#include <arpa/inet.h>
#include <errno.h>

//----------------------------------------------------------------------------

void sniff();
void choosepack();

//----------------------------------------------------------------------------

int packsiz = 12000;
char pack[packsiz];

//----------------------------------------------------------------------------

void sniff() {
int sock;
//this is the raw socket we want to sinff from:
if((sock = socket(AF_INET, SOCK_PACKET, htons(0x3))) < 0) {
perror("Couldn't create a socket for sniffing!!!");
exit(EXIT_FAILURE);
}
//now we read from the socket:
read(sock, pack, packsiz);
}

//----------------------------------------------------------------------------

void choosepack() {
struct ether_header *eth = (struct ether_header*)pack;
struct iphdr *ip = (struct iphdr*)(pack + sizeof(struct ether_header));
struct tcphdr *tcp = (struct tcphdr*)(pack + sizeof(struct tcphdr) + sizeof(struct iphdr));
char *pay = (pack + sizeof(struct tcphdr) + sizeof(struct iphdr) + sizeof(struct tcphdr));
char yn[0];
while(1) {
memset(pack, '\0', packsiz);
sniff();
printf("SRC MAC: %x:%x:%x:%x:%x:%x\n", eth -> ether_shost[0], eth -> ether_shost[1], eth -> ether_shost[2], eth -> ether_shost[3], eth -> ether_shost[4], eth -> ether_shost[5]);
printf("DST MAC: %x:%x:%x:%x:%x:%x\n", eth -> ether_dhost[0], eth -> ether_dhost[1], eth -> ether_dhost[2], eth -> ether_dhost[3], eth -> ether_dhost[4], eth -> ether_dhost[5]);
printf("SRC IP: %s\n", inet_ntoa(*(struct in_addr*) &ip -> saddr)); //print the source IP
printf("DST IP: %s\n", inet_ntoa(*(struct in_addr*) &ip -> daddr)); //print the destination IP
printf("use packet? [y/n]");
fgets(yn,sizeof(yn),stdin);
if(strcmp(yn,"y") == 0) {
return;
}
}
}

//----------------------------------------------------------------------------


hoffe mir kann da einer Helfen :S

greez li0n

Apex
31.05.2010, 20:33
int packsiz = 12000;
char pack[packsiz];

Heißt es nicht

const int PACKSIZ 12000;
char pack[PACKSIZ];

?? Oder täusch ich mich?

AlterHacker
31.05.2010, 20:55
Hey

Yep. Array-Größen müssen fest Definiert sein. also entweder ein #define machen oder const int sollte auch noch gehen.
Falls du variable Arrays brauchst, dann nur mit nem pointer / malloc

MfG.

Apex
31.05.2010, 21:00
Gut, dann hab ich doch richtig gelegen. Hab mir gedacht, du brauchst vielleicht ein bisschen Hilfe im Bereich Pointer und hab dann 'n interessantes PDF Dokument gefunden:

http://www.sec.informatik.tu-darmstadt.de/pages/lehre/WS07-08/gdi3/folien/c-einfuehrung_m.pdf

Weiter unten stehen dann Beiträge zu Pointer, aber ob es dir hilft, weiß ich nicht gibt aber sicherlich bessere / gute "Tutorials" im Internet.

li0n
01.06.2010, 16:25
Ok dankeschön das mit den Arraygrößen war mir neu :)

//EDIT: Das mit dem const int arrysiz klappt auch nicht aber ich habe jetzt pack aeifach als pack[12000] definiert.