-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,432 additions
and
1,195 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <obfuscator/context.hpp> | ||
|
||
namespace obfuscator | ||
{ | ||
bool analyze(Context& ctx, bool verbose = false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
#include <deque> | ||
#include <zasm/zasm.hpp> | ||
|
||
namespace obfuscator | ||
{ | ||
|
||
std::string formatFlagsMask(uint32_t mask); | ||
std::string formatRegsMask(uint64_t mask); | ||
std::vector<zasm::x86::Gp> maskToRegs(uint64_t mask); | ||
uint32_t regMask(const zasm::Reg& reg); | ||
|
||
struct InstructionData | ||
{ | ||
uint64_t address = 0; | ||
zasm::InstructionDetail detail = {}; | ||
zasm::InstrCPUFlags flagsModified = 0; | ||
zasm::InstrCPUFlags flagsTested = 0; | ||
uint32_t regsWritten = 0; | ||
uint32_t regsRead = 0; | ||
|
||
zasm::InstrCPUFlags flagsLive = 0; | ||
uint32_t regsLive = 0; | ||
}; | ||
|
||
struct Context | ||
{ | ||
zasm::Program& program; | ||
|
||
explicit Context(zasm::Program& program) : program(program) | ||
{ | ||
} | ||
|
||
InstructionData* addInstructionData( | ||
zasm::Node* node, uint64_t address, zasm::MachineMode mode, const zasm::InstructionDetail& detail | ||
); | ||
|
||
private: | ||
std::deque<InstructionData> instructionDataPool; | ||
}; | ||
|
||
} // namespace obfuscator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <obfuscator/context.hpp> | ||
|
||
namespace obfuscator | ||
{ | ||
bool disassemble(Context& ctx, const uint64_t functionStart, const std::vector<uint8_t>& code, bool verbose = false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include <cstring> | ||
#include <cstdio> | ||
#include <cerrno> | ||
|
||
// NOTE: These are source-compatible stubs for some MSVC-specific functions. | ||
|
||
#ifndef _WIN32 | ||
template <size_t Count, class... Args> int sprintf_s(char (&Dest)[Count], const char* fmt, Args... args) | ||
{ | ||
return snprintf(Dest, Count, fmt, args...); | ||
} | ||
|
||
inline size_t strcpy_s(char* dst, size_t size, const char* src) | ||
{ | ||
return strlcpy(dst, src, size); | ||
} | ||
|
||
inline int fopen_s(FILE** fp, const char* filename, const char* mode) | ||
{ | ||
*fp = fopen(filename, mode); | ||
return errno; | ||
} | ||
|
||
static void __debugbreak() | ||
{ | ||
__builtin_debugtrap(); | ||
} | ||
#endif // _WIN32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <obfuscator/context.hpp> | ||
|
||
namespace obfuscator | ||
{ | ||
bool obfuscate(Context& ctx); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <vector> | ||
#include <span> | ||
#include <string_view> | ||
|
||
namespace obfuscator | ||
{ | ||
bool loadFile(const std::string& path, std::vector<uint8_t>& data); | ||
bool findFunction(const std::span<uint8_t>& pe, std::string_view name, uint64_t& address, std::vector<uint8_t>& code); | ||
} // namespace obfuscator |
Oops, something went wrong.