1 /* 2 * $Id: nmap_compat.h,v 1.1 2002/12/07 20:45:43 skyper Exp $ 3 * 4 * Make THCrut process nmap-of-fingerprint files. 5 * We use a slightly more performant algorithm to load the strings 6 * into memory. 7 */ 8 9 #ifndef __THCRUT_NMAP_COMPAT_H__ 10 #define __THCRUT_NMAP_COMPAT_H__ 1 11 12 #include <sys/types.h> 13 14 #define NMAP_HASH_SIZE (113) 15 #define NMAP_DF_ISNOTSET(item) ((item)->df & 0x1) 16 #define NMAP_DF_ISSET(item) ((item)->df & 0x2) 17 18 #define NMAP_DF_SET_ISNOTSET(item) ((item)->df |= 0x1) 19 #define NMAP_DF_SET_ISSET(item) ((item)->df |= 0x2) 20 21 #define NMAP_FP_TONE "\003\003\012\001\002\004\001\011\010\012\077\077\077\077\000\000\000\000\000\000" 22 #define NMAP_FP_TONE_LEN 20 23 24 /* 25 * All in HBO 26 */ 27 struct _nmap_osfp_TONE 28 { 29 struct _nmap_osfp_TONE *next; 30 unsigned long ops:30; /* 10 ops */ 31 unsigned long df:2; 32 unsigned short wsize; /* windows size */ 33 unsigned long ofs_string; 34 unsigned long class; 35 }; 36 37 /* 38 * HASH shall be the (wsize ^ var) % HASH_SIZE 39 */ 40 struct _nmap_osfp 41 { 42 char *strings; 43 struct _nmap_osfp_TONE *hash_tone[NMAP_HASH_SIZE]; 44 }; 45 46 /* 47 * This is the evil shit. 48 * We check a test-1-entry from the DB if the value match against 49 * it. 50 * 51 * Decoded is it: 52 * if (tone->wsize != wsize) 53 * continue; 54 * if (tone->ops != ops) 55 * continue; 56 * if ((df) && (NMAP_DF_ISSET(tone))) 57 * return tone; 58 * if ((!df) && NMAP_DF_ISNOTSET(tone)) 59 * return tone; 60 */ 61 #define NMAP_TONE_MATCH(tone, mywsize, mydf, myops) ((tone)->wsize != mywsize?0: (tone)->ops != myops?0:(mydf) && NMAP_DF_ISSET(tone)?1:(!mydf) && NMAP_DF_ISNOTSET(tone)?1:0) 62 63 long NMAP_class2long(const char *input); 64 int NMAP_load_fp(struct _nmap_osfp *osfp, char *file); 65 struct _nmap_osfp_TONE *NMAP_lookup(struct _nmap_osfp *osfp, unsigned short wsize, char df, unsigned long ops); 66 unsigned long NMAP_tcpops2ops(char *opstr, unsigned char *buf, size_t len); 67 char * NMAP_long2class(char *dst, long val); 68 69 #endif /* !__THCRUT_NMAP_COMPAT_H__ */ 70 71