GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: 调整目录结构,兼容Pro版(模块版) · VVeakee/SKRoot-linuxKernelRoot@c2a9b1e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • patch_kernel_root/analyze
    • base_func.h
  • testRoot/jni/kernel_root_kit/core
    • rootkit_simple_encryptor.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎patch_kernel_root/analyze/base_func.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/base_func.h
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ static auto hex2bytes(uint8_t* hex, uint8_t* str) -> void {
5555
str[i / 2] = ((high > 9 ? high - 7 : high) << 4) + (low > 9 ? low - 7 : low);
5656
}
5757
}
58-
static std::string bytes2hex(const unsigned char* input, size_t length) {
5958

59+
static std::string bytes2hex(const unsigned char* input, size_t length) {
60+
static const char HEX[16] = {
61+
'0', '1', '2', '3',
62+
'4', '5', '6', '7',
63+
'8', '9', 'a', 'b',
64+
'c', 'd', 'e', 'f'
65+
};
6066
std::string str;
6167
str.reserve(length << 1);
6268
for (size_t i = 0; i < length; ++i) {
Collapse file

‎testRoot/jni/kernel_root_kit/core/rootkit_simple_encryptor.h‎

Copy file name to clipboardExpand all lines: testRoot/jni/kernel_root_kit/core/rootkit_simple_encryptor.h
+37-10Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
#include <chrono>
77
#include <stdexcept>
88
namespace {
9-
static const std::string ALPHABET =
9+
static const std::string alphabet62 =
1010
"0123456789"
1111
"abcdefghijklmnopqrstuvwxyz"
1212
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
13-
static const int M = (int)ALPHABET.size(); // 62
13+
static const int BASE62 = (int)alphabet62.size(); // 62
1414

1515
static int random_index() {
1616
static std::mt19937 rng(
1717
(unsigned)std::chrono::steady_clock::now().time_since_epoch().count()
1818
);
19-
std::uniform_int_distribution<int> dist(0, M - 1);
19+
std::uniform_int_distribution<int> dist(0, BASE62 - 1);
2020
return dist(rng);
2121
}
2222

2323
static int idx_of(char c) {
24-
auto pos = ALPHABET.find(c);
24+
auto pos = alphabet62.find(c);
2525
if (pos == std::string::npos) {
2626
throw std::invalid_argument(std::string("Invalid char: ") + c);
2727
}
@@ -36,14 +36,14 @@ static std::string simple_encrypt(const std::string& plain) {
3636
throw std::invalid_argument("Plaintext cannot be empty");
3737
}
3838
int ki = random_index();
39-
char key = ALPHABET[ki];
39+
char key = alphabet62[ki];
4040
std::string cipher;
4141
cipher.reserve(N + 1);
4242
cipher.push_back(key);
4343
for (size_t i = 0; i < N; ++i) {
4444
int pi = idx_of(plain[i]);
45-
int ci = (pi + ki + (int)i) % M;
46-
cipher.push_back(ALPHABET[ci]);
45+
int ci = (pi + ki + (int)i) % BASE62;
46+
cipher.push_back(alphabet62[ci]);
4747
}
4848
return cipher;
4949
}
@@ -63,9 +63,36 @@ static std::string simple_decrypt(const std::string& cipher) {
6363

6464
for (size_t i = 0; i < N; ++i) {
6565
int ci = idx_of(cipher[i + 1]);
66-
int pi = (ci - ki - (int)i) % M;
67-
if (pi < 0) pi += M;
68-
plain.push_back(ALPHABET[pi]);
66+
int pi = (ci - ki - (int)i) % BASE62;
67+
if (pi < 0) pi += BASE62;
68+
plain.push_back(alphabet62[pi]);
6969
}
7070
return plain;
71+
}
72+
73+
static std::string to_base62(std::size_t num) {
74+
if (num == 0) {
75+
return std::string(1, alphabet62[0]);
76+
}
77+
std::string s;
78+
while (num > 0) {
79+
int rem = static_cast<int>(num % BASE62);
80+
s.push_back(alphabet62[rem]);
81+
num /= BASE62;
82+
}
83+
std::reverse(s.begin(), s.end());
84+
return s;
85+
}
86+
87+
static std::size_t from_base62(const std::string& s) {
88+
std::size_t val = 0;
89+
for (char c : s) {
90+
std::size_t idx = alphabet62.find(c);
91+
if (idx == std::string::npos) {
92+
throw std::invalid_argument(
93+
std::string("Invalid character in base62 string: ") + c);
94+
}
95+
val = val * BASE62 + idx;
96+
}
97+
return val;
7198
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.