Giter Site home page Giter Site logo

rustattack's Introduction

Rust Attack

image

This repository is inspired by different Rust repositories in order to define my own Offensive Windows Rust cheatsheet and weapons. The entire project has been developed and compiled on a Linux machine.

Index

Examples

1 - DLLs

You can find 3 different projects inside 01_DLLs/

$ ls 01_DLLs
code_execution  msgbox  shellcode_CreateRemoteThread  shellcode_CreateThread

1.1 - MsgBox

Launch a simple Windows prompt.

$ cd /01_DLLs/msgbox
$ ls
Cargo.toml  src
$ cargo build --target x86_64-pc-windows-gnu --lib --release

This generate a .dll file with the export function exec. It is located at: target/x86_64-pc-windows-gnu/release/

$ ls
build  deps  examples  incremental  libmsgbox_dll.dll.a  msgbox_dll.d  msgbox_dll.dll

image

For execute it in Windows:

C:\>rundll32 msgbox_dll.dll,exec

image

1.2 - Code Execution

Execute commands from a new cmd process.

$ cd 01_DLLs/code_execution
$ ls
Cargo.toml  src
$ cargo build --target x86_64-pc-windows-gnu --lib --release

This generate a .dll file with the export function exec. It is located at: target/x86_64-pc-windows-gnu/release/

$ ls
build  code_execution_dll.d  code_execution_dll.dll  deps  examples  incremental  libcode_execution_dll.dll.a

image

For execute it in Windows:

C:\>rundll32 code_execution_dll.dll,exec

image

Customization

To change the purpose and/or command execution of the DLL, open lib.rs modify the following line and recompile:

let output = Command::new("cmd").args(&["/C", "calc.exe"]).output().expect("failed to execute process");

1.3 - Shellcode - CreateRemoteThread method

[NO AV DETECTION (DEFENDER, ESET, FSECURE, MCAFEE, CORTEX) - 15/02/2022]

Launch a shellcode inside a especific process. This example execute a shellcode generated by msfvenom which launch calc.exe.

$ cd 01_DLLs/shellcode_CreateRemoteThread
$ ls
Cargo.toml  src
$ cargo build --target x86_64-pc-windows-gnu --lib --release

This generate a .dll file with the export function exec. It is located at: target/x86_64-pc-windows-gnu/release/

$ ls
build  deps  examples  incremental  libshellcodeshellcode_create_remote_thread_dll.dll.a  shellcode_create_remote_thread_dll.d  shellcode_create_remote_thread_dll.dll

For execute it in Windows:

C:\>rundll32 shellcode_create_remote_thread_dll.dll,exec <process_name>

If the process name is not specified, the shellcode is injected into the explorer.exe process by default.

image

AV DETECTIONS (with Covenant Grunt shellcode)

image

Customization

To change the purpose and/or shellcode of the DLL, open lib.rs modify the following line and recompile:

let shellcode:[u8;276] = [0xfc, 0x48, ... <blablabla>];

In addition, if you want to change default process for inject the shellcode, you can edit the following line in lib.rs and recompile:

let mut processname = "explorer.exe";

1.4 - Shellcode - CreateThread method

[NO AV DETECTION (DEFENDER, ESET, FSECURE, MCAFEE, CORTEX) - 15/02/2022]

Launch a shellcode inside the current process. This example execute a shellcode generated by msfvenom which launch calc.exe.

$ cd 01_DLLs/shellcode_CreateThread
$ ls
Cargo.toml  src
$ cargo build --target x86_64-pc-windows-gnu --lib --release

This generate a .dll file with the export function exec. It is located at: target/x86_64-pc-windows-gnu/release/

$ ls
build  deps  examples  incremental  libshellcode_createThread_dll.dll.a  shellcode_createThread_dll.d  shellcode_createThread_dll.dll

image

For execute it in Windows:

C:\>rundll32 shellcode_createThread_dll.dll,exec

image

Customization

To change the purpose and/or shellcode of the DLL, open lib.rs modify the following line and recompile:

let shellcode:[u8;276] = [0xfc, 0x48, ... <blablabla>];

NOTE: you must specify shellcode length.

2 - Executables

2.1 - MsgBox

Launch a simple Windows prompt.

$ cd /02_EXEs/msgbox
$ ls
Cargo.toml  src
$ cargo build --target x86_64-pc-windows-gnu --release

This generate a .exe file. It is located at: target/x86_64-pc-windows-gnu/release/

$ ls
build  deps  examples  incremental  msgbox_exe.d  msgbox_exe.exe

For execute it in Windows:

C:\>msgbox_exe.exe

2.2 - Code Execution

Execute commands from a new cmd process.

$ cd 02_EXEs/code_execution
$ ls
Cargo.toml  src
$ cargo build --target x86_64-pc-windows-gnu --release

This generate a .exe file. It is located at: target/x86_64-pc-windows-gnu/release/

$ ls
build  code_execution_exe.d  code_execution_exe.exe  deps  examples  incremental

For execute it in Windows:

C:\>code_execution_exe.exe
Customization

To change the purpose and/or command execution of the EXE, open main.rs modify the following line and recompile:

let output = Command::new("cmd").args(&["/C", "calc.exe"]).output().expect("failed to execute process");

2.3 - Shellcode - CreateRemoteThread method

[NO AV DETECTION (DEFENDER, ESET, FSECURE, MCAFEE, CORTEX) - 15/02/2022]

Launch a shellcode inside a especific process. This example execute a shellcode generated by msfvenom which launch calc.exe.

$ cd 02_EXEs/shellcode_CreateRemoteThread
$ ls
Cargo.toml  src
$ cargo build --target x86_64-pc-windows-gnu --release

This generate a .exe file. It is located at: target/x86_64-pc-windows-gnu/release/

$ ls
build  deps  examples  incremental  shellcode_create_remote_thread_exe.d  shellcode_create_remote_thread_exe.exe

For execute it in Windows:

C:\>shellcode_create_remote_thread_exe.exe <process_name>

If the process name is not specified, the shellcode is injected into the explorer.exe process by default.

AV DETECTIONS (with Covenant Grunt shellcode)

image

Customization

To change the purpose and/or shellcode of the DLL, open main.rs modify the following line and recompile:

let shellcode:[u8;276] = [0xfc, 0x48, ... <blablabla>];

In addition, if you want to change default process for inject the shellcode, you can edit the following line in main.rs and recompile:

let mut processname = "explorer.exe";

2.4 - Shellcode - CreateThread method

[NO AV DETECTION (DEFENDER, ESET, FSECURE, MCAFEE, CORTEX) - 15/02/2022]

Launch a shellcode inside the current process. This example execute a shellcode generated by msfvenom which launch calc.exe.

$ cd 02_EXEs/shellcode_CreateThread
$ ls
Cargo.toml  src
$ cargo build --target x86_64-pc-windows-gnu --release

This generate a .exe file. It is located at: target/x86_64-pc-windows-gnu/release/

$ ls
build  deps  examples  incremental  shellcode_createThread_exe.d  shellcode_createThread_exe.exe

For execute it in Windows:

C:\>shellcode_createThread_exe.exe
Customization

To change the purpose and/or shellcode of the DLL, open main.rs modify the following line and recompile:

let shellcode:[u8;276] = [0xfc, 0x48, ... <blablabla>];

NOTE: you must specify shellcode length.

To-DO

  • AMSI Bypass
  • ETW Bypass
  • ETW Patch
  • OpSec
  • Hell'sGate Rust Implementation

Other Rust Projects

Interesting links for other offensive Rust project:

rustattack's People

Contributors

oliv4s avatar

Stargazers

DAssemblerxXBin3ryNinj! avatar b4r0n avatar MrTux avatar

Watchers

MrTux avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.