| 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 | #include <stdlib.h> |
| 33 | |
| 34 | #include "ophstat.h" |
| 35 | /*-------------------------------------------------------------------------*/ |
| 36 | ophstat_t *ophstat_alloc(void) { |
| 37 | ophstat_t *stat = (ophstat_t*)malloc(sizeof(ophstat_t)); |
| 38 | int i; |
| 39 | |
| 40 | for (i=0; i<16; i++) { |
| 41 | stat->length[i] = 0; |
| 42 | stat->category[i] = 0; |
| 43 | } |
| 44 | stat->time = list_alloc(); |
| 45 | |
| 46 | ophstat_reset(stat); |
| 47 | |
| 48 | return stat; |
| 49 | } |
| 50 | /*-------------------------------------------------------------------------*/ |
| 51 | void ophstat_free(ophstat_t *stat) { |
| 52 | list_free(stat->time); |
| 53 | free(stat); |
| 54 | } |
| 55 | /*-------------------------------------------------------------------------*/ |
| 56 | void ophstat_add(ophstat_t *stat1, ophstat_t *stat2) { |
| 57 | stat1->hredux += stat2->hredux; |
| 58 | stat1->prefix += stat2->prefix; |
| 59 | stat1->postfix += stat2->postfix; |
| 60 | stat1->start += stat2->start; |
| 61 | stat1->fseek_idx += stat2->fseek_idx; |
| 62 | stat1->fseek_end += stat2->fseek_end; |
| 63 | stat1->fseek_srt += stat2->fseek_srt; |
| 64 | stat1->falarm += stat2->falarm; |
| 65 | stat1->falarm_hredux += stat2->falarm_hredux; |
| 66 | stat1->match_table += stat2->match_table; |
| 67 | stat1->match_bforce += stat2->match_bforce; |
| 68 | } |
| 69 | /*-------------------------------------------------------------------------*/ |
| 70 | void ophstat_reset(ophstat_t *stat) { |
| 71 | stat->hredux = 0; |
| 72 | stat->prefix = 0; |
| 73 | stat->postfix = 0; |
| 74 | stat->start = 0; |
| 75 | stat->fseek_idx = 0; |
| 76 | stat->fseek_end = 0; |
| 77 | stat->fseek_srt = 0; |
| 78 | stat->falarm = 0; |
| 79 | stat->falarm_hredux = 0; |
| 80 | stat->match_table = 0; |
| 81 | stat->match_bforce = 0; |
| 82 | |
| 83 | } |