Skip to content

Commit f9a20fc

Browse files
committed
Fixed .peb helper to include instructions in list
1 parent b759b27 commit f9a20fc

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

Shellcodev/command.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,22 @@ static BOOL shelldev_command_shellcode(shell_t* sh, std::vector<std::string> par
6868
return TRUE;
6969
}
7070

71-
static BOOL shelldev_command_peb(shell_t* sh, std::vector<std::string> parts)
71+
static BOOL shelldev_command_peb(shell_t* sh, std::vector<std::string> parts, std::vector<asm_t>* assemblies)
7272
{
73+
std::string instructions;
7374
#ifdef _M_X64
7475
// xor eax, eax
7576
// mov rax, gs:[eax+0x60]
76-
unsigned char bytes[] = { 0x31, 0xc0, 0x65, 0x48, 0x8b, 0x40, 0x60 };
77+
// unsigned char bytes[] = { 0x31, 0xc0, 0x65, 0x48, 0x8b, 0x40, 0x60 };
78+
instructions = "xor eax, eax;mov rax, gs:[eax+0x60]";
7779
#elif defined(_M_IX86)
7880
// xor eax, eax
7981
// mov eax, fs:[eax+0x30]
80-
unsigned char bytes[] = { 0x31, 0xC0, 0x64, 0x8B, 0x40, 0x30 };
82+
// unsigned char bytes[] = { 0x31, 0xC0, 0x64, 0x8B, 0x40, 0x30 };
83+
instructions = "xor eax, eax;mov eax, fs:[eax+0x30]";
8184
#endif
82-
if (!shelldev_write_shellcode(sh, bytes, sizeof(bytes)))
83-
{
84-
shelldev_print_errors("Unable to allocate shellcode!");
85-
return TRUE;
86-
}
8785

88-
shelldev_debug_shellcode(sh);
89-
shelldev_print_registers(sh);
86+
shelldev_run_shellcode(sh, instructions, assemblies);
9087

9188
return TRUE;
9289
}
@@ -465,7 +462,7 @@ BOOL shelldev_run_command(shell_t* sh, std::string command, std::vector<asm_t>*
465462
else if (mainCmd == ".shellcode")
466463
return shelldev_command_shellcode(sh, parts);
467464
else if (mainCmd == ".peb")
468-
return shelldev_command_peb(sh, parts);
465+
return shelldev_command_peb(sh, parts, assemblies);
469466
else if (mainCmd == ".quit" || mainCmd == ".exit")
470467
ExitProcess(0);
471468
else

Shellcodev/eval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ BOOL shelldev_run_shellcode(shell_t* sh, std::vector<asm_t>* assemblies)
284284
}
285285

286286

287-
static BOOL shelldev_run_shellcode(shell_t* sh, std::string assembly, std::vector<asm_t>* assemblies)
287+
BOOL shelldev_run_shellcode(shell_t* sh, std::string assembly, std::vector<asm_t>* assemblies)
288288
{
289289
std::vector<std::string> instructions = split(assembly, ";");
290290
std::vector<unsigned char> data;

Shellcodev/repl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ void shelldev_debug_shellcode(shell_t* sh);
3838

3939
std::vector<std::string> shelldev_parse_string(std::string value);
4040
BOOL shelldev_run_shellcode(shell_t* sh, std::vector<asm_t>* assemblies);
41+
BOOL shelldev_run_shellcode(shell_t* sh, std::string assembly, std::vector<asm_t>* assemblies);
4142
BOOL shelldev_run_command(shell_t* sh, std::string command, std::vector<asm_t>* assemblies);
4243

4344
void shelldev_print_pids(shell_t* sh);

0 commit comments

Comments
 (0)