aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorauth12 <[email protected]>2020-07-19 11:46:24 -0700
committerauth12 <[email protected]>2020-07-19 11:46:24 -0700
commita4117f05f70fc20a05dc6b454db77447a0c8300b (patch)
treef8eab7a7bae237ad697feecfae26b17bab91b16e
parentAdded asmjit. (diff)
parentMore placeholders and general plan. (diff)
downloadloader-a4117f05f70fc20a05dc6b454db77447a0c8300b.tar.xz
loader-a4117f05f70fc20a05dc6b454db77447a0c8300b.zip
Merge branch 'master' into windows
-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 f4769d4..3a888fb 100644
--- a/client/src/client/client.h
+++ b/client/src/client/client.h
@@ -4,6 +4,7 @@
#include "../util/io.h"
#include "../util/events.h"
+#include "../injection/mapper.h"
#include "packet.h"
namespace tcp {
@@ -35,6 +36,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 4a47e01..f67ecf1 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 6350179..df3f6e8 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
+}
+
+