-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.cpp
More file actions
170 lines (145 loc) · 7.01 KB
/
Example.cpp
File metadata and controls
170 lines (145 loc) · 7.01 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#if LIBSERIALS_EXERELEASE
#include <Windows.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include "LibSerials/LibSerials.hpp"
static bool AttachConsoleAndEnableVT() {
if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
if (AllocConsole()) {
FILE* fpOut = nullptr;
FILE* fpIn = nullptr;
freopen_s(&fpOut, "CONOUT$", "w", stdout);
freopen_s(&fpIn, "CONIN$", "r", stdin);
if (!fpOut || !fpIn) return false;
}
}
else {
FILE* fpOut = nullptr;
FILE* fpIn = nullptr;
freopen_s(&fpOut, "CONOUT$", "w", stdout);
freopen_s(&fpIn, "CONIN$", "r", stdin);
if (!fpOut || !fpIn) return false;
}
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwMode = 0;
if (GetConsoleMode(hConsole, &dwMode)) {
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(hConsole, dwMode);
}
system("cls");
return true;
}
static void HexToRGB(const std::string& hex, int& r, int& g, int& b) {
std::stringstream ss;
ss << std::hex << hex.substr(0, 2); ss >> r; ss.clear();
ss << std::hex << hex.substr(2, 2); ss >> g; ss.clear();
ss << std::hex << hex.substr(4, 2); ss >> b;
}
static void BlendColor(int r1, int g1, int b1, int r2, int g2, int b2, float ratio, int& r, int& g, int& b) {
r = static_cast<int>(r1 + ratio * (r2 - r1));
g = static_cast<int>(g1 + ratio * (g2 - g1));
b = static_cast<int>(b1 + ratio * (b2 - b1));
}
static std::string Colorize(const std::string& text, const std::string& hexFrom, const std::string& hexTo = "") {
int r1, g1, b1, r2, g2, b2;
HexToRGB(hexFrom, r1, g1, b1);
if (hexTo.empty()) HexToRGB(hexFrom, r2, g2, b2); else HexToRGB(hexTo, r2, g2, b2);
int length = 0;
for (size_t i = 0; i < text.length(); ++i) {
if ((text[i] & 0xC0) != 0x80) ++length;
}
std::string coloredText;
int charIndex = 0;
for (size_t i = 0; i < text.length();) {
float ratio = (length > 1) ? (static_cast<float>(charIndex) / static_cast<float>(length - 1)) : 0.0f;
int r, g, b; BlendColor(r1, g1, b1, r2, g2, b2, ratio, r, g, b);
std::stringstream ss; ss << "\033[38;2;" << r << ";" << g << ";" << b << "m";
if ((text[i] & 0x80) == 0) { ss << text[i]; ++i; }
else if ((text[i] & 0xE0) == 0xC0) { ss << text[i] << text[i + 1]; i += 2; }
else if ((text[i] & 0xF0) == 0xE0) { ss << text[i] << text[i + 1] << text[i + 2]; i += 3; }
else if ((text[i] & 0xF8) == 0xF0) { ss << text[i] << text[i + 1] << text[i + 2] << text[i + 3]; i += 4; }
coloredText += ss.str();
++charIndex;
}
coloredText += "\033[0m";
return coloredText;
}
static void DebugUI() {
AttachConsoleAndEnableVT();
LibSerials::InitializeSerials();
auto hddSerials = LibSerials::HDD_Serials();
std::cout << Colorize(" [!] SSD/HDD\n", "ff2a00", "ff8c00");
for (int i = 0; i < (int)hddSerials.size(); i++)
std::cout << Colorize("[" + std::to_string(i) + "] ", "ff2a00", "ff8c00") + hddSerials[i] + "\n";
std::cout << Colorize("\n [!] Motherboard\n", "ff8c00", "62ff00");
std::cout << Colorize("[Manufacturer] ", "ff8c00", "62ff00") + LibSerials::Baseboard_Manufacturer() + "\n";
std::cout << Colorize("[Product] ", "ff8c00", "62ff00") + LibSerials::Baseboard_Product() + "\n";
std::cout << Colorize("[Serial] ", "ff8c00", "62ff00") + LibSerials::Baseboard_Serial() + "\n\n";
std::cout << Colorize(" [!] BIOS\n", "09ff00", "00eaff");
std::cout << Colorize("[Vendor] ", "09ff00", "00eaff") + LibSerials::BIOS_Vendor() + "\n";
std::cout << Colorize("[Version] ", "09ff00", "00eaff") + LibSerials::BIOS_Version() + "\n\n";
std::cout << Colorize(" [!] System\n", "00eaff", "0022ff");
std::cout << Colorize("[Manufacturer] ", "00eaff", "0022ff") + LibSerials::System_Manufacturer() + "\n";
std::cout << Colorize("[UUID] ", "00eaff", "0022ff") + LibSerials::System_UUID() + "\n";
std::cout << Colorize("[Family] ", "00eaff", "0022ff") + LibSerials::System_Family() + "\n\n";
std::cout << Colorize(" [!] Chassis\n", "6E11FF", "dd00ff");
std::cout << Colorize("[Manufacturer] ", "6E11FF", "dd00ff") + LibSerials::Chassis_Manufacturer() + "\n";
std::cout << Colorize("[Version] ", "6E11FF", "dd00ff") + LibSerials::Chassis_Version() + "\n";
std::cout << Colorize("[Serial] ", "6E11FF", "dd00ff") + LibSerials::Chassis_Serial() + "\n\n";
std::cout << Colorize(" [!] CPU\n", "dd00ff", "ff00ea");
std::cout << Colorize("[Name] ", "dd00ff", "ff00ea") + LibSerials::CPU_Product() + "\n";
std::cout << Colorize("[Serial] ", "dd00ff", "e600ff") + LibSerials::CPU_Serial() + "\n";
std::cout << Colorize("[Socket] ", "dd00ff", "e600ff") + LibSerials::CPU_Socket() + "\n";
std::cout << Colorize("[Cores] ", "dd00ff", "e600ff") + LibSerials::CPU_Cores() + "\n";
std::cout << Colorize("[Threads] ", "dd00ff", "e600ff") + LibSerials::CPU_Threads() + "\n";
std::cout << Colorize("[Clock] ", "dd00ff", "e600ff") + LibSerials::CPU_ClockSpeed() + " MHz\n\n";
std::cout << Colorize(" [!] TPM\n", "00ff88", "00ffcc");
if (LibSerials::TPM_Present()) {
std::cout << Colorize("[Vendor] ", "00ff88", "00ffcc") + LibSerials::TPM_Vendor() + "\n";
std::cout << Colorize("[Spec] ", "00ff88", "00ffcc") + LibSerials::TPM_SpecVersion() + "\n";
std::cout << Colorize("[Firmware] ", "00ff88", "00ffcc") + LibSerials::TPM_FirmwareVersion() + "\n\n";
} else {
std::cout << Colorize("[Status] ", "00ff88", "00ffcc") + "Not Present\n\n";
}
size_t slotCount = LibSerials::Slot_Count();
if (slotCount > 0) {
std::cout << Colorize(" [!] System Slots\n", "ffaa00", "ffdd00");
for (size_t i = 0; i < slotCount; i++)
std::cout << Colorize("[" + std::to_string(i) + "] ", "ffaa00", "ffdd00") + LibSerials::Slot_Designation(i) + " (Type: " + LibSerials::Slot_Type(i) + ")\n";
std::cout << "\n";
}
size_t cacheCount = LibSerials::Cache_Count();
if (cacheCount > 0) {
std::cout << Colorize(" [!] Cache\n", "8800ff", "aa44ff");
for (size_t i = 0; i < cacheCount; i++)
std::cout << Colorize("[" + std::to_string(i) + "] ", "8800ff", "aa44ff") + LibSerials::Cache_Designation(i) + "\n";
std::cout << "\n";
}
size_t batteryCount = LibSerials::Battery_Count();
if (batteryCount > 0) {
std::cout << Colorize(" [!] Battery\n", "00ccff", "0088ff");
for (size_t i = 0; i < batteryCount; i++)
std::cout << Colorize("[" + std::to_string(i) + "] ", "00ccff", "0088ff") + LibSerials::Battery_Location(i) + " - " + LibSerials::Battery_Manufacturer(i) + "\n";
std::cout << "\n";
}
std::cout << Colorize(" [!] GPU\n", "ff6600", "ff9900");
std::cout << Colorize("[Name] ", "ff6600", "ff9900") + LibSerials::GPU_Name() + "\n\n";
auto macAddresses = LibSerials::MACAddress_List();
std::cout << Colorize(" [!] MAC Address\n", "e600ff", "ff0000");
for (int i = 0; i < (int)macAddresses.size(); i++)
std::cout << Colorize("[" + std::to_string(i) + "] ", "f520c3", "fa202f") + macAddresses[i] + "\n";
std::string hwid = LibSerials::System_HWID();
std::cout << Colorize("\n[*] HWID: " + hwid, "ff2a00", "ff8c00") << std::endl;
std::cout << Colorize("[*] github.com/MagmaMCNet/LibSerials", "2e2e2e") << std::endl;
LibSerials::FreeSerials();
std::cin.ignore();
FreeConsole();
}
int main() {
DebugUI();
return 0;
}
#endif