| 1 | /* |
| 2 | * |
| 3 | * Ophcrack is a Lanmanager/NTLM hash cracker based on the faster time-memory |
| 4 | * trade-off using rainbow tables. |
| 5 | * |
| 6 | * Created with the help of: Maxime Mueller, Luca Wullschleger, Claude |
| 7 | * Hochreutiner, Andreas Huber and Etienne Dysli. |
| 8 | * |
| 9 | * Copyright (c) 2008 Philippe Oechslin, Cedric Tissieres, Bertrand Mesot |
| 10 | * |
| 11 | * Ophcrack is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * Ophcrack is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with Ophcrack; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | * |
| 25 | * This program is released under the GPL with the additional exemption |
| 26 | * that compiling, linking, and/or using OpenSSL is allowed. |
| 27 | * |
| 28 | * |
| 29 | * |
| 30 | * |
| 31 | */ |
| 32 | #ifndef MISC_H |
| 33 | #define MISC_H |
| 34 | |
| 35 | #include <stdio.h> |
| 36 | #include <stdint.h> |
| 37 | #include <config.h> |
| 38 | |
| 39 | #include "bswap.h" |
| 40 | |
| 41 | #define MY_MAX(a,b) ((a)>(b)?(a):(b)) |
| 42 | #define MY_MIN(a,b) ((a)<(b)?(a):(b)) |
| 43 | |
| 44 | #define my_setbit(x,pos) x | (1 << pos); |
| 45 | #define my_getbit(x,pos) (x & (1 << pos)) ? 1 : 0 |
| 46 | |
| 47 | /** Maximum size of the buffers. */ |
| 48 | |
| 49 | #define STR_BUFF_SIZE 512 |
| 50 | |
| 51 | /** Maximum length of a password. */ |
| 52 | |
| 53 | #define MAX_PWD_LEN 50 |
| 54 | |
| 55 | /* Endianness conversion */ |
| 56 | |
| 57 | #ifdef WORDS_BIGENDIAN |
| 58 | # define ftohl64(x) __bswap_64 (x) /**< File (f) to host (h) int64. */ |
| 59 | # define ftohl(x) __bswap_32 (x) /**< File (f) to host (h) int32. */ |
| 60 | # define ftohs(x) __bswap_16 (x) /**< File (f) to host (h) short. */ |
| 61 | #else |
| 62 | # define ftohl64(x) (x) /**< File (f) to host (h) int64. */ |
| 63 | # define ftohl(x) (x) /**< File (f) to host (h) int32. */ |
| 64 | # define ftohs(x) (x) /**< File (f) to host (h) short. */ |
| 65 | #endif |
| 66 | |
| 67 | #ifdef __cplusplus |
| 68 | extern "C" { |
| 69 | #endif |
| 70 | |
| 71 | typedef unsigned char uchar_t; |
| 72 | |
| 73 | #if defined WIN32 || defined sun |
| 74 | char *strsep(char** stringp, const char* delim); |
| 75 | #endif |
| 76 | |
| 77 | uint64_t find_freeram(void); |
| 78 | void convert_to_colon(uchar_t *input); |
| 79 | void convert_from_colon(uchar_t *input); |
| 80 | void wincp1252_to_ascii(uchar_t *str); |
| 81 | void fprintf_hex(FILE *file, char *str, int len); |
| 82 | int categorize_password(char *pwd); |
| 83 | const char *category_string(int category); |
| 84 | |
| 85 | #ifdef __cplusplus |
| 86 | } |
| 87 | #endif |
| 88 | #endif |