Difference between revisions of "Anri-chan/Source/natematch.c"
From SDA Knowledge Base
(written 20 may 2006 by djgrenola) |
|||
Line 1: | Line 1: | ||
<pre><nowiki> | <pre><nowiki> | ||
+ | #written 20 May 2006 by DJ Grenola | ||
+ | |||
#include <stdio.h> | #include <stdio.h> | ||
#include <strings.h> | #include <strings.h> | ||
Line 27: | Line 29: | ||
if (match) | if (match) | ||
printf ("Matched byte string at offset 0x%0x (%u).\n", offset, offset); | printf ("Matched byte string at offset 0x%0x (%u).\n", offset, offset); | ||
− | offset++ | + | offset++; |
} | } | ||
return 0; | return 0; | ||
} | } | ||
</nowiki></pre> | </nowiki></pre> |
Latest revision as of 17:26, 7 October 2008
#written 20 May 2006 by DJ Grenola #include <stdio.h> #include <strings.h> #define NEEDLELEN 16 int main (void) { unsigned int i; unsigned char match; unsigned int offset=0; int j; char needle[] = { 0x00, 0x00, 0x01, 0xba, 0x44, 0x00, 0x04, 0x00, 0x04, 0x01, 0x01, 0x89, 0xc3, 0xf8, 0x00, 0x00 }; char buf[NEEDLELEN]; bzero(buf,NEEDLELEN); while ((j=getchar())!=EOF) { for (i=0;i<NEEDLELEN-1;i++) buf[i]=buf[i+1]; buf[i]=j; match=1; for (i=0;i<NEEDLELEN;i++) { if (needle[i] != buf[i]) match=0; } if (match) printf ("Matched byte string at offset 0x%0x (%u).\n", offset, offset); offset++; } return 0; }