|
|
@ -9,13 +9,15 @@
|
|
|
|
#include "Obfuscator.h"
|
|
|
|
#include "Obfuscator.h"
|
|
|
|
#include "Random.h"
|
|
|
|
#include "Random.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "VirtualMachine.h"
|
|
|
|
|
|
|
|
|
|
|
|
__declspec(dllexport) VOID CvInit()
|
|
|
|
__declspec(dllexport) VOID CvInit()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XedTablesInit();
|
|
|
|
XedTablesInit();
|
|
|
|
srand(time(NULL));
|
|
|
|
srand(time(NULL));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__declspec(dllexport) PVOID CvDriverFunctionObfuscate(PVOID Code, ULONG CodeSize, PULONG OutSize, ULONG BranchCount, FLOAT MaxBranchSizePercentage)
|
|
|
|
__declspec(dllexport) PVOID CvDriverFunctionObfuscate(PVOID Code, UINT CodeSize, PUINT OutSize, UINT BranchCount, FLOAT MaxBranchSizePercentage)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//trip 0xCC alignment at end of code
|
|
|
|
//trip 0xCC alignment at end of code
|
|
|
|
while (((PUCHAR)Code)[CodeSize - 1] == 0xCC)
|
|
|
|
while (((PUCHAR)Code)[CodeSize - 1] == 0xCC)
|
|
|
@ -49,7 +51,7 @@ __declspec(dllexport) PVOID CvDriverFunctionObfuscate(PVOID Code, ULONG CodeSize
|
|
|
|
Obf.RandomizeSpaceBetweenBranches = TRUE;
|
|
|
|
Obf.RandomizeSpaceBetweenBranches = TRUE;
|
|
|
|
Obf.BranchRemainingInstructions = TRUE;
|
|
|
|
Obf.BranchRemainingInstructions = TRUE;
|
|
|
|
Obf.BranchChance = 75;
|
|
|
|
Obf.BranchChance = 75;
|
|
|
|
ULONG BranchesMade = */
|
|
|
|
UINT BranchesMade = */
|
|
|
|
|
|
|
|
|
|
|
|
while (BranchCount)
|
|
|
|
while (BranchCount)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -70,7 +72,7 @@ __declspec(dllexport) VOID CvDeleteCode(PVOID Code)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID PrintByteArr(PVOID Buff, ULONG BufSize)
|
|
|
|
VOID PrintByteArr(PVOID Buff, UINT BufSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < BufSize; i++)
|
|
|
|
for (uint32_t i = 0; i < BufSize; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -78,7 +80,7 @@ VOID PrintByteArr(PVOID Buff, ULONG BufSize)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PVOID MakeExecutableBuffer(PVOID Buffer, ULONG BufferSize)
|
|
|
|
PVOID MakeExecutableBuffer(PVOID Buffer, UINT BufferSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PVOID ExecBuffer = VirtualAlloc(nullptr, BufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
|
|
|
PVOID ExecBuffer = VirtualAlloc(nullptr, BufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
|
|
|
if (!ExecBuffer)
|
|
|
|
if (!ExecBuffer)
|
|
|
@ -90,7 +92,7 @@ PVOID MakeExecutableBuffer(PVOID Buffer, ULONG BufferSize)
|
|
|
|
return ExecBuffer;
|
|
|
|
return ExecBuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID PutToFile(PVOID Buffer, ULONG BufferSize)
|
|
|
|
VOID PutToFile(PVOID Buffer, UINT BufferSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::ofstream fout;
|
|
|
|
std::ofstream fout;
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -100,12 +102,12 @@ VOID PutToFile(PVOID Buffer, ULONG BufferSize)
|
|
|
|
fout.close();
|
|
|
|
fout.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ULONG64 TestShelcode(ULONG64 v1, ULONG64 v2, ULONG64 v3, ULONG64 v4)
|
|
|
|
UINT64 TestShelcode(UINT64 v1, UINT64 v2, UINT64 v3, UINT64 v4)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (v4 == 0)
|
|
|
|
if (v4 == 0)
|
|
|
|
v4 = 2;
|
|
|
|
v4 = 2;
|
|
|
|
|
|
|
|
|
|
|
|
ULONG64 Value = 1;
|
|
|
|
UINT64 Value = 1;
|
|
|
|
for (int i = 1; i <= v1; i++)
|
|
|
|
for (int i = 1; i <= v1; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Value *= i;
|
|
|
|
Value *= i;
|
|
|
@ -117,7 +119,7 @@ ULONG64 TestShelcode(ULONG64 v1, ULONG64 v2, ULONG64 v3, ULONG64 v4)
|
|
|
|
return Value;
|
|
|
|
return Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ULONG64 Nextfunction(ULONG64 v1)
|
|
|
|
UINT64 Nextfunction(UINT64 v1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return v1 + 1;
|
|
|
|
return v1 + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -139,7 +141,7 @@ UCHAR TestBuffer[] = {
|
|
|
|
0x48, 0x87, 0x04, 0x24,
|
|
|
|
0x48, 0x87, 0x04, 0x24,
|
|
|
|
0xC3,
|
|
|
|
0xC3,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
ULONG TestBufferSize = sizeof(TestBuffer);
|
|
|
|
UINT TestBufferSize = sizeof(TestBuffer);
|
|
|
|
|
|
|
|
|
|
|
|
UCHAR meme1[] = {
|
|
|
|
UCHAR meme1[] = {
|
|
|
|
0x31, 0xc0,
|
|
|
|
0x31, 0xc0,
|
|
|
@ -182,56 +184,69 @@ UCHAR IsEvenCode[]{
|
|
|
|
0xC3,
|
|
|
|
0xC3,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//EXTERN_C ULONG64 RetNum(ULONG64 Num);
|
|
|
|
//EXTERN_C UINT64 RetNum(UINT64 Num);
|
|
|
|
//EXTERN_C BOOL IsEven(ULONG64 Num);
|
|
|
|
//EXTERN_C BOOL IsEven(UINT64 Num);
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XedGlobalInit();
|
|
|
|
XedGlobalInit();
|
|
|
|
srand(time(NULL));
|
|
|
|
srand(time(NULL));
|
|
|
|
UCHAR TestCode[] = { 0x48, 0x8B, 0x84, 0xD1, 0xF0, 0x06, 0x00, 0x00 }; // { 0x48, 0x89, 0xC8 };
|
|
|
|
|
|
|
|
XED_DECODED_INST DecodedInst;
|
|
|
|
UINT OutSize = 0;
|
|
|
|
XedDecodedInstZeroSetMode(&DecodedInst, &XedGlobalMachineState);
|
|
|
|
PUCHAR Output = VmHandlerIRegLoadMem_BISO(VM_IREG_2, VM_OPSIZE_2, &OutSize); // VmHandlerPrologue(8, &OutSize);
|
|
|
|
//XedDecodedInstZero(&DecodedInst);
|
|
|
|
if (Output && OutSize)
|
|
|
|
//XedDecodedInstSetMode(&DecodedInst, XED_MACHINE_MODE_LONG_64, XED_ADDRESS_WIDTH_64b);
|
|
|
|
|
|
|
|
XED_ERROR_ENUM Err = XedDecode(&DecodedInst, TestCode, sizeof(TestCode));
|
|
|
|
|
|
|
|
if (Err != XED_ERROR_NONE)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("Failed to decode.\n");
|
|
|
|
PrintByteArr(Output, OutSize);
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XED_ICLASS_ENUM IClass = XedDecodedInstGetIClass(&DecodedInst);
|
|
|
|
printf("\n");
|
|
|
|
printf("IClass: %s\n", XedIClassEnumToString(IClass));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (UINT i = 0; i < VM_IREG_COUNT; i++)
|
|
|
|
|
|
|
|
|
|
|
|
CONST xed_inst_t* Inst = XedDecodedInstInst(&DecodedInst);
|
|
|
|
|
|
|
|
ULONG OperandCount = XedDecodedInstNumOperands(&DecodedInst);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (ULONG i = 0; i < OperandCount; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CONST xed_operand_t* Operand = XedInstOperand(Inst, i);
|
|
|
|
printf("IReg: %u, %s %s %s %s\n", i, XedRegEnumToString(VmIRegToXReg((VM_IREG_ENUM)i, VM_OPSIZE_1)), XedRegEnumToString(VmIRegToXReg((VM_IREG_ENUM)i, VM_OPSIZE_2)), XedRegEnumToString(VmIRegToXReg((VM_IREG_ENUM)i, VM_OPSIZE_4)), XedRegEnumToString(VmIRegToXReg((VM_IREG_ENUM)i, VM_OPSIZE_8)));
|
|
|
|
xed_operand_enum_t OperandName = XedOperandName(Operand);
|
|
|
|
|
|
|
|
printf("Operand Name: %s\n", XedOperandEnumToString(OperandName));
|
|
|
|
|
|
|
|
if (XedOperandIsRegister(OperandName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
xed_reg_enum_t RegEnum = XedDecodedInstGetReg(&DecodedInst, OperandName);
|
|
|
|
|
|
|
|
printf("Reg: %s\n", XedRegEnumToString(RegEnum));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperandName == XED_OPERAND_MEM0 || OperandName == XED_OPERAND_MEM1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ULONG MemOpIndex = OperandName - XED_OPERAND_MEM0;
|
|
|
|
|
|
|
|
printf("MemOpIdx: %u\n", MemOpIndex);
|
|
|
|
|
|
|
|
printf("Base Reg: %s\n", XedRegEnumToString(XedDecodedInstGetBaseReg(&DecodedInst, MemOpIndex)));
|
|
|
|
|
|
|
|
printf("Index Reg: %s\n", XedRegEnumToString(XedDecodedInstGetIndexReg(&DecodedInst, MemOpIndex)));
|
|
|
|
|
|
|
|
printf("Scale: %u\n", xed_decoded_inst_get_scale(&DecodedInst, MemOpIndex));
|
|
|
|
|
|
|
|
printf("Disp: %llu\n", xed_decoded_inst_get_memory_displacement(&DecodedInst, MemOpIndex));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Reg2: %s %s %s %s\n", XedRegEnumToString(VmGetRegOfSize(XED_REG_R15, VM_OPSIZE_1)), XedRegEnumToString(VmGetRegOfSize(XED_REG_R15, VM_OPSIZE_2)), XedRegEnumToString(VmGetRegOfSize(XED_REG_R15, VM_OPSIZE_4)), XedRegEnumToString(VmGetRegOfSize(XED_REG_R15, VM_OPSIZE_8)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//UCHAR TestCode[] = { 0x48, 0x8B, 0x84, 0xD1, 0xF0, 0x06, 0x00, 0x00 }; // { 0x48, 0x89, 0xC8 };
|
|
|
|
|
|
|
|
//XED_DECODED_INST DecodedInst;
|
|
|
|
|
|
|
|
//XedDecodedInstZeroSetMode(&DecodedInst, &XedGlobalMachineState);
|
|
|
|
|
|
|
|
//XED_ERROR_ENUM Err = XedDecode(&DecodedInst, TestCode, sizeof(TestCode));
|
|
|
|
|
|
|
|
//if (Err != XED_ERROR_NONE)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// printf("Failed to decode.\n");
|
|
|
|
|
|
|
|
// system("pause");
|
|
|
|
|
|
|
|
// return -1;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//XED_ICLASS_ENUM IClass = XedDecodedInstGetIClass(&DecodedInst);
|
|
|
|
|
|
|
|
//printf("IClass: %s\n", XedIClassEnumToString(IClass));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//CONST xed_inst_t* Inst = XedDecodedInstInst(&DecodedInst);
|
|
|
|
|
|
|
|
//UINT OperandCount = XedDecodedInstNumOperands(&DecodedInst);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//for (UINT i = 0; i < OperandCount; i++)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// CONST xed_operand_t* Operand = XedInstOperand(Inst, i);
|
|
|
|
|
|
|
|
// xed_operand_enum_t OperandName = XedOperandName(Operand);
|
|
|
|
|
|
|
|
// printf("Operand Name: %s\n", XedOperandEnumToString(OperandName));
|
|
|
|
|
|
|
|
// if (XedOperandIsRegister(OperandName))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// xed_reg_enum_t RegEnum = XedDecodedInstGetReg(&DecodedInst, OperandName);
|
|
|
|
|
|
|
|
// printf("Reg: %s\n", XedRegEnumToString(RegEnum));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (OperandName == XED_OPERAND_MEM0 || OperandName == XED_OPERAND_MEM1)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// UINT MemOpIndex = OperandName - XED_OPERAND_MEM0;
|
|
|
|
|
|
|
|
// printf("MemOpIdx: %u\n", MemOpIndex);
|
|
|
|
|
|
|
|
// printf("Base Reg: %s\n", XedRegEnumToString(XedDecodedInstGetBaseReg(&DecodedInst, MemOpIndex)));
|
|
|
|
|
|
|
|
// printf("Index Reg: %s\n", XedRegEnumToString(XedDecodedInstGetIndexReg(&DecodedInst, MemOpIndex)));
|
|
|
|
|
|
|
|
// printf("Scale: %u\n", XedDecodedInstGetScale(&DecodedInst, MemOpIndex));
|
|
|
|
|
|
|
|
// printf("Disp: %llu\n", XedDecodedInstGetMemoryDisplacement(&DecodedInst, MemOpIndex));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//xed_operand_values_t* Operands = xed_decoded_inst_operands(&DecodedInst);
|
|
|
|
//xed_operand_values_t* Operands = xed_decoded_inst_operands(&DecodedInst);
|
|
|
|
//printf("Operand Count %u\n", OperandCount);
|
|
|
|
//printf("Operand Count %u\n", OperandCount);
|
|
|
@ -246,9 +261,9 @@ int main()
|
|
|
|
|
|
|
|
|
|
|
|
//CvInit();
|
|
|
|
//CvInit();
|
|
|
|
|
|
|
|
|
|
|
|
////ULONG Delta = (*((PULONG)((PUCHAR)TestShelcode + 1))) + 5;
|
|
|
|
////UINT Delta = (*((PUINT)((PUCHAR)TestShelcode + 1))) + 5;
|
|
|
|
////printf("Delta: %X\n", Delta);
|
|
|
|
////printf("Delta: %X\n", Delta);
|
|
|
|
//PVOID ActualFunction = TestShelcode; // (PVOID)((ULONG64)TestShelcode + Delta);
|
|
|
|
//PVOID ActualFunction = TestShelcode; // (PVOID)((UINT64)TestShelcode + Delta);
|
|
|
|
|
|
|
|
|
|
|
|
//printf("%llu %llu %llu %llu\n", TestShelcode(1, 2, 3, 4), TestShelcode(20, 20, 20, 4), TestShelcode(50, 50, 50, 0), Nextfunction(12));
|
|
|
|
//printf("%llu %llu %llu %llu\n", TestShelcode(1, 2, 3, 4), TestShelcode(20, 20, 20, 4), TestShelcode(50, 50, 50, 0), Nextfunction(12));
|
|
|
|
//system("pause");
|
|
|
|
//system("pause");
|
|
|
@ -286,7 +301,7 @@ int main()
|
|
|
|
//ObfGenerateOpaqueBranches(&Obf, &RetNumBlock);
|
|
|
|
//ObfGenerateOpaqueBranches(&Obf, &RetNumBlock);
|
|
|
|
|
|
|
|
|
|
|
|
//printf("Assembling %u %u", NcCountInstructions(&RetNumBlock), NcCalcBlockSizeInBytes(&RetNumBlock));
|
|
|
|
//printf("Assembling %u %u", NcCountInstructions(&RetNumBlock), NcCalcBlockSizeInBytes(&RetNumBlock));
|
|
|
|
//ULONG AsmSize;
|
|
|
|
//UINT AsmSize;
|
|
|
|
//PVOID Asm = NcAssemble(&RetNumBlock, &AsmSize);
|
|
|
|
//PVOID Asm = NcAssemble(&RetNumBlock, &AsmSize);
|
|
|
|
//if (!Asm)
|
|
|
|
//if (!Asm)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
@ -297,7 +312,7 @@ int main()
|
|
|
|
//PutToFile(Asm, AsmSize);
|
|
|
|
//PutToFile(Asm, AsmSize);
|
|
|
|
//system("pause");
|
|
|
|
//system("pause");
|
|
|
|
|
|
|
|
|
|
|
|
/*ULONG AsmSize;
|
|
|
|
/*UINT AsmSize;
|
|
|
|
PVOID Asm = CvDriverFunctionObfuscate(MemeBlock, 110, &AsmSize, 5, 0.5);
|
|
|
|
PVOID Asm = CvDriverFunctionObfuscate(MemeBlock, 110, &AsmSize, 5, 0.5);
|
|
|
|
if (!Asm)
|
|
|
|
if (!Asm)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -308,7 +323,7 @@ int main()
|
|
|
|
PutToFile(Asm, AsmSize);
|
|
|
|
PutToFile(Asm, AsmSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef ULONG64(*FnTestShelcode)(ULONG64, ULONG64, ULONG64, ULONG64);
|
|
|
|
typedef UINT64(*FnTestShelcode)(UINT64, UINT64, UINT64, UINT64);
|
|
|
|
PVOID Exec = NULL;
|
|
|
|
PVOID Exec = NULL;
|
|
|
|
Exec = MakeExecutableBuffer(Asm, AsmSize);
|
|
|
|
Exec = MakeExecutableBuffer(Asm, AsmSize);
|
|
|
|
if (!Exec)
|
|
|
|
if (!Exec)
|
|
|
@ -321,7 +336,7 @@ int main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*PVOID Exec = MakeExecutableBuffer(Asm, AsmSize);
|
|
|
|
/*PVOID Exec = MakeExecutableBuffer(Asm, AsmSize);
|
|
|
|
typedef ULONG64(*FnRetNum)(ULONG Num);
|
|
|
|
typedef UINT64(*FnRetNum)(UINT Num);
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n\nSize: %u Obfuscated: %llu Original: %llu\n\n", NcCountInstructions(&RetNumBlock), ((FnRetNum)Exec)(1776), ((FnRetNum)Exec)(1776));
|
|
|
|
printf("\n\nSize: %u Obfuscated: %llu Original: %llu\n\n", NcCountInstructions(&RetNumBlock), ((FnRetNum)Exec)(1776), ((FnRetNum)Exec)(1776));
|
|
|
|
NcDeleteBlock(&RetNumBlock);
|
|
|
|
NcDeleteBlock(&RetNumBlock);
|
|
|
@ -339,15 +354,15 @@ int main()
|
|
|
|
ObfObfuscate(&Obf, &Block);
|
|
|
|
ObfObfuscate(&Obf, &Block);
|
|
|
|
NcDebugPrint(&Block);
|
|
|
|
NcDebugPrint(&Block);
|
|
|
|
|
|
|
|
|
|
|
|
ULONG ByteSize = NcCalcBlockSizeInBytes(&Block);
|
|
|
|
UINT ByteSize = NcCalcBlockSizeInBytes(&Block);
|
|
|
|
ULONG InstSize = NcCountInstructions(&Block);
|
|
|
|
UINT InstSize = NcCountInstructions(&Block);
|
|
|
|
|
|
|
|
|
|
|
|
printf("Bytes: %u, Insts: %u, FlagsMeme: %u.\n", ByteSize, InstSize, Obf.Flags);
|
|
|
|
printf("Bytes: %u, Insts: %u, FlagsMeme: %u.\n", ByteSize, InstSize, Obf.Flags);
|
|
|
|
|
|
|
|
|
|
|
|
ULONG AsmSize;
|
|
|
|
UINT AsmSize;
|
|
|
|
PVOID Asm = NcAssemble(&Block, &AsmSize);
|
|
|
|
PVOID Asm = NcAssemble(&Block, &AsmSize);
|
|
|
|
PVOID Exec = MakeExecutableBuffer(Asm, AsmSize);
|
|
|
|
PVOID Exec = MakeExecutableBuffer(Asm, AsmSize);
|
|
|
|
typedef ULONG(*FnGetFour)();
|
|
|
|
typedef UINT(*FnGetFour)();
|
|
|
|
printf("numba is: %u size is %u\n\n", ((FnGetFour)Exec)(), AsmSize);
|
|
|
|
printf("numba is: %u size is %u\n\n", ((FnGetFour)Exec)(), AsmSize);
|
|
|
|
PutToFile(Asm, AsmSize);*/
|
|
|
|
PutToFile(Asm, AsmSize);*/
|
|
|
|
|
|
|
|
|
|
|
@ -371,14 +386,14 @@ int main()
|
|
|
|
///*Pre->Start = Return1776;
|
|
|
|
///*Pre->Start = Return1776;
|
|
|
|
//Pre->End = Return1776;*/
|
|
|
|
//Pre->End = Return1776;*/
|
|
|
|
|
|
|
|
|
|
|
|
//for (ULONG i = 0; i < Return1776->RawDataSize; i++)
|
|
|
|
//for (UINT i = 0; i < Return1776->RawDataSize; i++)
|
|
|
|
// Return1776->RawData[i] = (UCHAR)rand();
|
|
|
|
// Return1776->RawData[i] = (UCHAR)rand();
|
|
|
|
//for (ULONG i = 0; i < RetInst->RawDataSize; i++)
|
|
|
|
//for (UINT i = 0; i < RetInst->RawDataSize; i++)
|
|
|
|
// RetInst->RawData[i] = (UCHAR)rand();
|
|
|
|
// RetInst->RawData[i] = (UCHAR)rand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ULONG AsmLen;
|
|
|
|
//UINT AsmLen;
|
|
|
|
//PVOID Asm = NcAssemble(Pre1, &AsmLen);
|
|
|
|
//PVOID Asm = NcAssemble(Pre1, &AsmLen);
|
|
|
|
//PUCHAR Tb = (PUCHAR)Asm;
|
|
|
|
//PUCHAR Tb = (PUCHAR)Asm;
|
|
|
|
//for (uint32_t i = 0; i < AsmLen; i++)
|
|
|
|
//for (uint32_t i = 0; i < AsmLen; i++)
|
|
|
@ -388,7 +403,7 @@ int main()
|
|
|
|
|
|
|
|
|
|
|
|
//system("pause");
|
|
|
|
//system("pause");
|
|
|
|
|
|
|
|
|
|
|
|
//typedef ULONG64(*FnGet1776)();
|
|
|
|
//typedef UINT64(*FnGet1776)();
|
|
|
|
//FnGet1776 ExecBuffer = (FnGet1776)MakeExecutableBuffer(Asm, AsmLen);
|
|
|
|
//FnGet1776 ExecBuffer = (FnGet1776)MakeExecutableBuffer(Asm, AsmLen);
|
|
|
|
//if (ExecBuffer)
|
|
|
|
//if (ExecBuffer)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
@ -411,7 +426,7 @@ int main()
|
|
|
|
PNATIVE_CODE_LINK NewLink = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST, meme1, sizeof(meme1));
|
|
|
|
PNATIVE_CODE_LINK NewLink = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST, meme1, sizeof(meme1));
|
|
|
|
|
|
|
|
|
|
|
|
NcInsertLinkBefore(Block.End->Prev->Prev->Prev->Prev, NewLink);
|
|
|
|
NcInsertLinkBefore(Block.End->Prev->Prev->Prev->Prev, NewLink);
|
|
|
|
ULONG AssembledSize;
|
|
|
|
UINT AssembledSize;
|
|
|
|
PVOID AssembledBlock = NcAssemble(&Block, &AssembledSize);
|
|
|
|
PVOID AssembledBlock = NcAssemble(&Block, &AssembledSize);
|
|
|
|
if (!AssembledBlock || !AssembledSize)
|
|
|
|
if (!AssembledBlock || !AssembledSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|