-
Notifications
You must be signed in to change notification settings - Fork 16
/
nvd.cpp
62 lines (59 loc) · 2.56 KB
/
nvd.cpp
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
/*
nvd.cpp
DetExploit program file related to NVD.
DetExploit (https://github.com/moppoi5168/DetExploit)
Licensed by GPL License
*/
#include "detexploit.hpp"
std::map<std::string, std::string> nvd_download_vulndata(HANDLE hStdout) {
std::string Url = "";
std::string str = "";
std::vector<std::string> tmp;
std::map<std::string, std::string> product_dict;
std::cout << NVD_DOWNLOAD_INTRO << std::endl;
for (int y = 2010; y < 2020; y++) {
Url = "https://raw.githubusercontent.com/moppoi5168/VulnData/cf6e0e47cf14ee8866c7ddbd1bd9fb226779a3da/NVD-DETEXPLOIT/NVDVULN_";
Url += std::to_string(y);
Url += ".detexploit";
URLDownloadToFile(0, Url.c_str(), _T("nvd_temp.xml"), 0, 0);
std::ifstream ifs("nvd_temp.xml");
while (getline(ifs, str)) {
tmp = split(str, "/,/,/,/");
try {
product_dict[tmp[0]] = tmp[1];
} catch (...) {
continue;
}
}
}
std::cout << NVD_DOWNLOAD_SUCCESS << std::endl;
std::cout << "===========================================================" << std::endl;
return product_dict;
}
std::map<std::string, VulnInfo> nvd_scan(std::map<std::string, std::string> nvd_vulndata, std::map<std::string, std::string> installed) {
std::map<std::string, VulnInfo> resultdict;
std::string level = "";
VulnInfo vinfo;
for (auto fit = nvd_vulndata.begin(); fit != nvd_vulndata.end(); fit++) {
for (auto nit = installed.begin(); nit != installed.end(); nit++) {
if ((*fit).first == (*nit).first && (*fit).second == (*nit).second) {
level = determine_severity(NVD, "NOEXT");
vinfo.version = (*fit).second;
vinfo.is_edb = true;
vinfo.is_jvn = false;
vinfo.is_nvd = false;
vinfo.is_winupd = false;
vinfo.severity = level;
resultdict[(*fit).first] = vinfo;
std::cout << "===========================================================" << std::endl;
std::cout << DETECT_ALERT << std::endl;
std::cout << APP_NAME << (*fit).first << " >>" << std::endl;
std::cout << APP_VERSION << (*fit).second << " >>" << std::endl;
std::cout << DETECT_USING_NVD << std::endl;
std::cout << OBJECT_LEVEL << level << " >>" << std::endl;
std::cout << "===========================================================" << std::endl;
}
}
}
return resultdict;
}