-
Notifications
You must be signed in to change notification settings - Fork 30
/
ServiceRegexMatcher.h
78 lines (64 loc) · 1.57 KB
/
ServiceRegexMatcher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include "Stdafx.h"
#include "BannerProcessor.h"
#include <string>
#include <boost/regex.hpp>
/*!
* Represents a service identifier entry.
*/
struct ServiceRegex
{
/*!
* Regular expression to match against service banner.
*/
boost::regex regex;
/*!
* CPE name of the matched service.
*/
std::string cpe;
/*!
* Product name of the matched service.
*/
std::string product;
/*!
* Version number of the matched service.
*/
std::string version;
};
/*!
* Implements a bulk regular expression matcher against service banners.
*/
class ServiceRegexMatcher : public BannerProcessor
{
public:
/*!
* Processes the specified service banner.
*
* \param banner Service banner.
* \param processVendor Whether to process vendor level patches appended to the end of the version
* number. This removes the patch level from the CPE version and appends it to
* the end via a semicolon separator.
*
* \return Matching CPE entries.
*/
std::vector<std::string> Scan(const std::string& banner, bool processVendor = true) override;
/*!
* Gets the regular expressions.
*
* \return List of regular expressions.
*/
static std::vector<ServiceRegex> GetRegexes();
/*!
* Frees up the resources allocated during the lifetime of this instance.
*/
~ServiceRegexMatcher() override;
private:
/*!
* List of regular expressions with their associated product info.
*/
static std::vector<ServiceRegex> regexes;
/*!
* Loads the regex database from external file.
*/
static void loadRegexes();
};