~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to contrib/phishing/whitelist_test.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Phishing detection automated testing & tools.
 
3
 *
 
4
 *  Copyright (C) 2006 Torok Edvin <edwintorok@gmail.com>
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
19
 *  MA 02110-1301, USA.
 
20
 *
 
21
 */
 
22
#include <stdio.h>
 
23
#include <sys/time.h>
 
24
#include <time.h>
 
25
#include "whitelist.h"
 
26
void show_time(struct timeval tv1,struct timeval tv2)
 
27
{
 
28
        struct timeval diff;
 
29
        diff.tv_sec = tv2.tv_sec-tv1.tv_sec;
 
30
        diff.tv_usec = tv2.tv_usec-tv1.tv_usec;
 
31
        if(diff.tv_usec>0) {
 
32
                diff.tv_sec += diff.tv_usec/1000000;
 
33
                diff.tv_usec %= 1000000;
 
34
        }
 
35
        else {
 
36
                int x = diff.tv_usec/1000000;//<0
 
37
                diff.tv_sec += x-1;
 
38
                diff.tv_usec -= (x-1)*1000000;
 
39
        }
 
40
        printf("%d.%06d,",diff.tv_sec,diff.tv_usec);
 
41
}
 
42
int main(int argc,char* argv[])
 
43
{
 
44
        if(argc<2)
 
45
                return 1;
 
46
        FILE* f=fopen("whitelist.wdb","rb");
 
47
        init_whitelist();
 
48
        printf("%d,",load_whitelist(f));
 
49
        struct timeval tv0,tv01;
 
50
        gettimeofday(&tv0,NULL);
 
51
        build_whitelist();
 
52
        gettimeofday(&tv01,NULL);
 
53
        show_time(tv0,tv01);
 
54
        fclose(f);
 
55
        FILE* f2=fopen(argv[1],"rb");
 
56
        fseek(f2,0,SEEK_END);
 
57
        long p=ftell(f2);
 
58
        fseek(f2,0,SEEK_SET);
 
59
        char* x = malloc(p+1);
 
60
        if(fread(x,p,1,f2)!=1)
 
61
                return 2;
 
62
        x[p]=0;
 
63
        fclose(f2);
 
64
        struct timeval tv1,tv2,diff;
 
65
        gettimeofday(&tv1,NULL);
 
66
        int rc=whitelist_match(x,"test",0);
 
67
        gettimeofday(&tv2,NULL);
 
68
        show_time(tv1,tv2);
 
69
        printf("%d\n",rc);
 
70
        free(x);
 
71
        whitelist_done();
 
72
/*      const char* real = "http://pics.ebaystatic.com/";
 
73
        const char* display = "http://www.ebay.com/";
 
74
        printf("%d\n",whitelist_match(real,display,0));*/
 
75
        return 0;
 
76
}