aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorauth <[email protected]>2020-07-18 03:14:23 +0200
committerauth <[email protected]>2020-07-18 03:14:23 +0200
commit0a11963b4a510f212645c68fb92dd114ec2ce427 (patch)
tree9dc7c12f02e7096f7ea903882581b0bfd0b70373
parentRefactoring. (diff)
downloadloader-0a11963b4a510f212645c68fb92dd114ec2ce427.tar.xz
loader-0a11963b4a510f212645c68fb92dd114ec2ce427.zip
More placeholders and general plan.
-rw-r--r--client/src/client/client.h2
-rw-r--r--client/src/client/packet.h5
-rw-r--r--client/src/injection/mapper.h3
-rw-r--r--client/src/main.cpp10
-rw-r--r--server/src/image/pe.h40
-rw-r--r--server/src/main.cpp14
-rw-r--r--server/src/server/packet.h5
-rw-r--r--server/src/util/util.cpp4
8 files changed, 70 insertions, 13 deletions
diff --git a/client/src/client/client.h b/client/src/client/client.h
index 4239651..bdd7cf5 100644
--- a/client/src/client/client.h
+++ b/client/src/client/client.h
@@ -1,6 +1,7 @@
#pragma once
#include "../util/io.h"
#include "../util/events.h"
+#include "../injection/mapper.h"
#include "packet.h"
namespace tcp {
@@ -32,6 +33,7 @@ class client {
public:
int state;
+ mmap::data mapper_data;
std::string session_id;
event<packet_t&> receive_event;
diff --git a/client/src/client/packet.h b/client/src/client/packet.h
index e197bf0..fccd1a5 100644
--- a/client/src/client/packet.h
+++ b/client/src/client/packet.h
@@ -18,10 +18,7 @@ enum packet_id {
process_list,
ban,
game_select,
- image_req,
- image_resp,
- import_req,
- import_resp
+ image
};
struct packet_t {
diff --git a/client/src/injection/mapper.h b/client/src/injection/mapper.h
index ef06a9b..27541c4 100644
--- a/client/src/injection/mapper.h
+++ b/client/src/injection/mapper.h
@@ -2,9 +2,10 @@
namespace mmap {
- struct header {
+ struct data {
size_t image_size;
uint32_t entry;
uint32_t base;
+ std::string imports;
};
}; \ No newline at end of file
diff --git a/client/src/main.cpp b/client/src/main.cpp
index aac1c4f..4413a44 100644
--- a/client/src/main.cpp
+++ b/client/src/main.cpp
@@ -2,7 +2,6 @@
#include "util/io.h"
#include "client/client.h"
#include "shellcode/shellcode.h"
-#include "injection/mapper.h"
int main(int argc, char* argv[]) {
io::init();
@@ -75,12 +74,17 @@ int main(int argc, char* argv[]) {
if (res == tcp::login_result::login_success) {
client.state = tcp::client_state::logged_in;
-
-
io::logger->info("logged in.");
}
}
+ if (id == tcp::packet_id::game_select) {
+ /*auto pe = nlohmann::json::parse(message);
+
+
+ client.read_stream(client.mapper_data.imports);*/
+ }
+
if (id == tcp::packet_id::ban) {
io::logger->error(
"your computer is blacklisted, please contact a developer.");
diff --git a/server/src/image/pe.h b/server/src/image/pe.h
index 2199411..0256a8b 100644
--- a/server/src/image/pe.h
+++ b/server/src/image/pe.h
@@ -120,6 +120,44 @@ class image {
}
}
+ void copy(std::vector<char> &out) {
+ const auto nt = m_image->get_nt_headers();
+ const auto n = nt->file_header.num_sections;
+
+ out.resize(nt->optional_header.size_image);
+
+ for (auto &sec : m_sections) {
+ std::memcpy(&out[sec.va], &m_buffer[sec.rva], sec.size);
+ }
+ }
+
+ void relocate(std::vector<char> &image, uintptr_t base) {
+ const uint32_t delta =
+ base - m_image->get_nt_headers()->optional_header.image_base;
+ if (delta > 0) {
+ for (auto &[base_rva, entry] : m_relocs) {
+ if (entry.type == win::rel_based_high_low) {
+ *reinterpret_cast<uint32_t *>(image.data() + base_rva +
+ entry.offset) += delta;
+ }
+ }
+ }
+ }
+
+ void fix_imports(std::vector<char> &image, const std::string_view imports) {
+ if (!nlohmann::json::accept(imports.data())) {
+ io::logger->error("imports arent valid json!!");
+ return;
+ }
+
+ auto j = nlohmann::json::parse(imports.data());
+ for (auto &[mod, funcs] : m_imports) {
+ for (auto &func : funcs) {
+ *reinterpret_cast<uint32_t *>(image.data() + func.rva) = j[func.name];
+ }
+ }
+ }
+
const auto operator->() { return m_image; }
operator bool() const { return m_image != nullptr; }
@@ -138,4 +176,6 @@ class image {
}
};
+
+
}; // namespace pe \ No newline at end of file
diff --git a/server/src/main.cpp b/server/src/main.cpp
index 81de12e..fe0d602 100644
--- a/server/src/main.cpp
+++ b/server/src/main.cpp
@@ -169,6 +169,20 @@ int main(int argc, char* argv[]) {
}
}
+ if (id == tcp::packet_id::game_select) {
+ // select image
+ // set message to be pe header
+ // stream imports
+ // wait for client to send back a packet with allocation base and fixed imports
+ }
+
+ if (id == tcp::packet_id::image) {
+ // message contains allocation base
+ // fixed imports are streamed back/save them in a folder to see if anything went wrong
+ // stream back the fixed image
+ // set client status or just drop them
+ }
+
client.write(tcp::packet_t(message, tcp::packet_type::write, session));
});
diff --git a/server/src/server/packet.h b/server/src/server/packet.h
index 77bca7b..626d340 100644
--- a/server/src/server/packet.h
+++ b/server/src/server/packet.h
@@ -18,10 +18,7 @@ enum packet_id {
process_list,
ban,
game_select,
- image_req,
- image_resp,
- import_req,
- import_resp
+ image
};
struct packet_t {
diff --git a/server/src/util/util.cpp b/server/src/util/util.cpp
index 799663f..1cb6367 100644
--- a/server/src/util/util.cpp
+++ b/server/src/util/util.cpp
@@ -4,4 +4,6 @@
void util::to_lowercase(std::string &str) {
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
-} \ No newline at end of file
+}
+
+