~ubuntu-branches/ubuntu/trusty/xprobe/trusty

« back to all changes in this revision

Viewing changes to src/os_matrix.h

  • Committer: Bazaar Package Importer
  • Author(s): Richard Atterer
  • Date: 2005-02-22 22:54:24 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050222225424-6cqy8rr45pkna819
Tags: 0.2.2-1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* $Id: os_matrix.h,v 1.5 2005/02/08 20:00:35 mederchik Exp $ */
 
3
/*
 
4
** Copyright (C) 2001 Fyodor Yarochkin <fygrave@tigerteam.net>,
 
5
**                    Ofir Arkin       <ofir@sys-security.com>
 
6
**
 
7
** This program is free software; you can redistribute it and/or modify
 
8
** it under the terms of the GNU General Public License as published by
 
9
** the Free Software Foundation; either version 2 of the License, or
 
10
** (at your option) any later version.
 
11
**
 
12
**
 
13
** This program is distributed in the hope that it will be useful,
 
14
** but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
** GNU General Public License for more details.
 
17
**
 
18
** You should have received a copy of the GNU General Public License
 
19
** along with this program; if not, write to the Free Software
 
20
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
21
*/
 
22
 
 
23
#ifndef OS_MATRIX_H
 
24
#define OS_MATRIX_H
 
25
 
 
26
#include "xprobe.h"
 
27
/*
 
28
#include <string>
 
29
#include <map>
 
30
#include <vector>
 
31
#include <algorithm>
 
32
*/
 
33
 
 
34
using namespace std;
 
35
 
 
36
#define XPROBE_MATCH_NO             0
 
37
#define XPROBE_MATCH_PROBABLY_NO    1
 
38
#define XPROBE_MATCH_PROBABLY_YES   2
 
39
#define XPROBE_MATCH_YES            3
 
40
 
 
41
class OS_Name {
 
42
    private:
 
43
        map <int, string> osid_name;
 
44
        int id_count;
 
45
    public:
 
46
        OS_Name(void);
 
47
        const string osid2str(int);
 
48
        const char *osid2char(int id) {
 
49
             string s = osid2str(id);
 
50
             return (s.c_str());
 
51
        }
 
52
        int add_os(string &os_name);
 
53
        int find_os(string &os_name);
 
54
        void list_oses(void);
 
55
        int get_osnum(void) { return id_count; }
 
56
};
 
57
               
 
58
 
 
59
class OS_Vector {
 
60
 
 
61
    private:
 
62
        int os_id;
 
63
        /* we may need this later: map<int, int> mod_score; */
 
64
        int total;
 
65
 
 
66
    public:
 
67
        OS_Vector(int);
 
68
        void add_result(int, int);
 
69
        int get_total(void) { return total; }
 
70
        int get_os_id(void) { return os_id; }
 
71
        friend bool os_vector_compare(const OS_Vector &, const OS_Vector &);
 
72
};
 
73
 
 
74
 
 
75
class OS_Matrix {
 
76
    private:
 
77
        vector <OS_Vector> osid_vec;
 
78
        int xp_loaded_mods;
 
79
        int find_os_id(int);
 
80
    
 
81
    public:
 
82
        OS_Matrix(int);
 
83
        virtual ~OS_Matrix(void);
 
84
        void add_result(int, int, int, int times = 1);
 
85
        /* returns top num scored OS id */
 
86
        int get_top(int);
 
87
        /* returns given os_id score */
 
88
        int get_score(int);
 
89
        /* returns maximum possible score --> max score by number of
 
90
         * tests */
 
91
        int get_max_score(void);
 
92
        /* returns given os_id score in percent */
 
93
        int get_prcnt_score(int);
 
94
};
 
95
 
 
96
#endif /* INTERFACE_H */
 
97