forked from N1coc4colA/DA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibraryban.cpp
67 lines (55 loc) · 1.52 KB
/
libraryban.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
63
64
65
66
67
#include "libraryban.h"
#include <iostream>
#include <QProcess>
const QString proc_name = "ldd ";
LDA_BEGIN_NAMESPACE
LibraryBan::LibraryBan(QObject *parent) : QLibrary(parent), proc (new QProcess)
{
connect(proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
[=](int exitCode, QProcess::ExitStatus exitStatus){
if (exitStatus == QProcess::ExitStatus::NormalExit) {
this->parseOutput();
} else {
std::cout << "Library Ban Check ERROR: [readelf]: " << exitCode << std::endl;
Q_EMIT this->checkFailed();
}
});
}
LibraryBan::~LibraryBan()
{
proc->~QProcess();
this->QLibrary::~QLibrary();
}
void LibraryBan::checkLib()
{
proc->startDetached(proc_name + this->fileName());
}
void LibraryBan::parseOutput()
{
QString data = proc->readAll();
QStringList list = data.split("\n");
int i = 0;
m_ban = false;
while (i<list.length()) {
QString d = list.at(i).split("=>").at(0);
d.remove(" ");
int j = 0;
while (j<libsToBan.length()) {
if (d.contains(libsToBan.at(i))) {
m_ban = true;
j = libsToBan.length();
}
}
i++;
}
}
typedef AbstractPlugin* (*requestPlugin)();
AbstractPlugin *LibraryBan::loadPlugin()
{
if(this->load()) {
requestPlugin get = (requestPlugin)this->resolve("getPlugin");
return get();
}
return nullptr;
}
LDA_END_NAMESPACE