Difference between revisions of "Anri-chan/Source/natematch.c"
From SDA Knowledge Base
(written 20 may 2006 by djgrenola) |
(No difference)
|
Revision as of 17:25, 7 October 2008
#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; }