LINUX.ORG.RU

Вот есть программа, но...


0

0

*** CUT HERE *** begin-base64 644 dupkill.c.gz H4sICPPqkj8AA2R1cGtpbGwuYwC1Vm1v2zYQ/hz9ikuKrpKr2HK3FUHSZOgy pwjmJJ6bANu6TKAlyiIsU5pEJU4L//fdkZJsWW0xYJs+WDLJe+65dw56Vg9u Y1FAkIYc8P1uMu5bvYH1TMggKXHtTSJkuRpIriKRKJ7347PW5kxkfw3Mq71V qFCktGQ9C3kkJIcf7y7eX/4+glfed0eWNRgosUSdEh5jEcSgYg4ZCxZcIRlZ iJDnPISwzBIRMMXBzpKygCEUPIAlW/WdBven6c3k9vJqBEPLKlFyLlEwSeUc SINis4R/8FZDD5/7k60jRZzmqCwPhq/tZjGIWQ69WRm5SE1BwqWDMoViSgTw kAqkJLhdqLwMFKDRfsxkmHDoxS6J9mBZzB3rkwWgdzOe52lu0+JJvRZyFE+f Kkk7Njt8JZQ9xO+1ZZHmJRPSpg+WzwO34tXDPw81PO4Rr7LQ8m0L0IAPlb/v 9fbnGLflGne0lxtHohtwPYZTDRLkHKNS2+C5MLnwL69Ht5WZEdj7sWPtkbNi 96AjceAYOGNAhVlw5S8xEVECLie/+Oc3k9/8ydvzn0e3bp09G/xK9A14bT01 Sq0iTD9Zey09SCQkHTrKFa6LMCfWXgcY6NlCJ1mNvFc8CoV5a9PqkhcFm3Nf PWXcRljHgU+VbMAKDtfjq/fv/NF0ejM9tvZwI8pyjF+EujDPcxcOpjzg4gH9 rRMGKkB4Hv4hD1wU2TO5MyfjijkeMmpONNoMWS2Q07ZKdOBV5bxjIlMBmBIj DF9Bb1l5hGDNjoYl8/A85gLumwJZHp5l7ClJWejiZ8gU801t0EFdyadb5YYy 92ZLRLYHp6eAQrSNvl1mGKLAqTjRMxgAS5L0EXMtYEnVBQrsCHlazuPmWCdX HngeikBRKDU9bZkItbu00PWF//b8fDTB9MEMvb4bjyvCa/3LE/QTEjT8z7ok D5vWQnT/BREwZAhulwo9VTIchHmaaa97q+e/GlbPQ2goVdmAB1xaczs+7Ri3 8XE7NtC19eT/8PO2cSwIeKb+K/M6hVq7eacTVNwP2pViDq/rgsFBwspEfaE0 7+RCpo+yqUkq8n1kugO5pmazpmmGzVV38q83/JyrMpfg6Y4/wDlM0YE0gvPp eUFvrAk4OpwJVWsu+oCjud2Z0Vu+ieur71/TeEOki4TNjyFmhR6qehdmnEsc rMusVDz8AS6lUAIVPEHEMFE0MA2UBs6vz2IeeAb2ii34FmKEbYqheKGIsUbQ 83GJx/wGx6Y1M7F2iJMTSKV0YaF9RYC21PpAYlTRIPx4+ZJqT7c13LJbIA5I 7UojujCiCxQ9wtdG0GRLAN/AcLNk8LwVD2dHR9++8sbwJ505O4OhiY+OZlVF 2yLmTHPE2vxuYiGpwrSFtPNZpw6ruJPkXRbSFYdBXkopTFQBx4u5Fc2eFC/0 RPf6fWy6h8N7wEyqEsjSZ0qNEJJgH290XCPgRC+TEEOPftbhFh/xiErhI8/T PkxyfkhAFmRpoQ7x1hXiqVQTsFPJXxQ6YRK+5FI5dDvE2wx6eokgRA6vbvhT WBCVMiBBKFLAbDVq5QtFmkMEQgs0SWzuCd4g4U6XEV8xAj+2utcNM3i8sSmh qqJo8vrohYjr2Ycvl65ncxU7sH8Ko5uLJrhG3viEUtGmngI7QjqC6/o2QSKI kuZiLiRLSMoxs9jGk52y28LuUHebdKmfr90uP1caZupiQnqrqHrGTblop+gL VjevHK16pwK1pbvFhao7xbXJX5uUU8bJewfLhmjcN/Vx5NSJXbWwDlPT0KZm lyKPDYI62heyud3W/um1XDuuYmC3pZ2t8Hjj6qJnritr62/HvtE79QwAAA== ==== *** END CUT ***

Говорят её надо через uudecode ковертануть, у меня не получается... Может у кого нить получится... Спасибо...

anonymous

Сорри, не форматировалась как нужно....


*** CUT HERE ***
begin-base64 644 dupkill.c.gz
H4sICPPqkj8AA2R1cGtpbGwuYwC1Vm1v2zYQ/hz9ikuKrpKr2HK3FUHSZOgy
pwjmJJ6bANu6TKAlyiIsU5pEJU4L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gvPp
eUFvrAk4OpwJVWsu+oCjud2Z0Vu+ieur71/TeEOki4TNjyFmhR6qehdmnEsc
rMusVDz8AS6lUAIVPEHEMFE0MA2UBs6vz2IeeAb2ii34FmKEbYqheKGIsUbQ
83GJx/wGx6Y1M7F2iJMTSKV0YaF9RYC21PpAYlTRIPx4+ZJqT7c13LJbIA5I
7UojujCiCxQ9wtdG0GRLAN/AcLNk8LwVD2dHR9++8sbwJ505O4OhiY+OZlVF
2yLmTHPE2vxuYiGpwrSFtPNZpw6ruJPkXRbSFYdBXkopTFQBx4u5Fc2eFC/0
RPf6fWy6h8N7wEyqEsjSZ0qNEJJgH290XCPgRC+TEEOPftbhFh/xiErhI8/T
PkxyfkhAFmRpoQ7x1hXiqVQTsFPJXxQ6YRK+5FI5dDvE2wx6eokgRA6vbvhT
WBCVMiBBKFLAbDVq5QtFmkMEQgs0SWzuCd4g4U6XEV8xAj+2utcNM3i8sSmh
qqJo8vrohYjr2Ycvl65ncxU7sH8Ko5uLJrhG3viEUtGmngI7QjqC6/o2QSKI
kuZiLiRLSMoxs9jGk52y28LuUHebdKmfr90uP1caZupiQnqrqHrGTblop+gL
VjevHK16pwK1pbvFhao7xbXJX5uUU8bJewfLhmjcN/Vx5NSJXbWwDlPT0KZm
lyKPDYI62heyud3W/um1XDuuYmC3pZ2t8Hjj6qJnritr62/HvtE79QwAAA==
====
*** END CUT ***

anonymous
()
Ответ на: комментарий от anonymous

/*
* This code is GPL.
*/
#include <linux/netfilter.h>
#include <libipq/libipq.h>
#include <stdio.h>

#define BUFSIZE 2048

//time in which the packet considered duplicate (plus 1 sec max.)
#define DROPTIME 1

unsigned long timetable[0x10000];

unsigned short crc16(unsigned char *buf, int len);

static void die(struct ipq_handle *h,char* msg)
{
   ipq_perror(msg);
   ipq_destroy_handle(h);
   exit(1);
}

int main(int argc, char **argv)
{
   int status;
   unsigned char buf[BUFSIZE];
   struct ipq_handle *h;
   unsigned short crc;
   unsigned long time;

   h = ipq_create_handle(0, PF_INET);
   if (!h)
	die(h,"ipq_create_handle");

   status = ipq_set_mode(h, IPQ_COPY_PACKET, BUFSIZE);
   if (status < 0)
	die(h,"ipq_set_mode");

   do{
	status = ipq_read(h, buf, BUFSIZE, 0);
	if (status < 0)
	     die(h,"ipq_read");

	switch (ipq_message_type(buf)) {
	     case NLMSG_ERROR:
		  fprintf(stderr, "Received error message %d\n",
			  ipq_get_msgerr(buf));
		  break;


	     case IPQM_PACKET: {
		  ipq_packet_msg_t *m = ipq_get_packet(buf);

		  crc = crc16(m->payload,m->data_len);
		  time = timetable[crc];
		  if(0 == m->timestamp_sec) {
		      // allow local packets through
		      status = ipq_set_verdict(h, m->packet_id,
					   NF_ACCEPT, 0, NULL);
		  }
		  else if( time >= m->timestamp_sec-DROPTIME ) {

		      status = ipq_set_verdict(h, m->packet_id,
					       NF_DROP, 0, NULL);
		      printf("drop crc 0x%X time %d timestamp %d\n",crc,time,m->timestamp_sec);
		  }
		  else {
		      timetable[crc] = m->timestamp_sec;
		      status = ipq_set_verdict(h, m->packet_id,
					   NF_ACCEPT, 0, NULL);
		      printf("accept crc 0x%X time %d timestamp %d\n",crc,time,m->timestamp_sec);
		  }
		  if (status < 0)
		       die(h,"ipq_set_verdict");
		  break;
	     }

	     default:
		  fprintf(stderr, "Unknown message type!\n");
		  break;
	}
   } while (1);

   ipq_destroy_handle(h);
   return 0;
}

/* Table of CRCs of all 8-bit messages. */
unsigned long crc_table[256];

/* Flag: has the table been computed? Initially false. */
int crc_table_computed = 0;

/* Make the table for a fast CRC. */
void make_crc_table(void)
{
  unsigned long c;
  int n, k;

  for (n = 0; n < 256; n++) {
    c = (unsigned long) n;
    for (k = 0; k < 8; k++) {
      if (c & 1) {
        c = 0xedb88320L ^ (c >> 1);
      } else {
        c = c >> 1;
      }
    }
    crc_table[n] = c;
  }
  crc_table_computed = 1;
}

/*
   Update a running crc with the bytes buf[0..len-1] and return
 the updated crc. The crc should be initialized to zero. Pre- and
 post-conditioning (one's complement) is performed within this
 function so it shouldn't be done by the caller. Usage example:

   unsigned long crc = 0L;

   while (read_buffer(buffer, length) != EOF) {
     crc = update_crc(crc, buffer, length);
   }
   if (crc != original_crc) error();
*/
unsigned long update_crc(unsigned long crc,
                unsigned char *buf, int len)
{
  unsigned long c = crc ^ 0xffffffffL;
  int n;

  if (!crc_table_computed)
    make_crc_table();
  for (n = 0; n < len; n++) {
    c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
  }
  return c ^ 0xffffffffL;
}

/* Return the CRC of the bytes buf[0..len-1]. */
unsigned short crc16(unsigned char *buf, int len)
{
  return (unsigned short)update_crc(0L, buf, len);
}

josephson ★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.