Skip to content

Commit 9a48981

Browse files
doxxdoxx
doxx
authored and
doxx
committed
Modified fileless exe method by providing Windows DLL files that can be wrapped using C#. Updated README.
1 parent 8faa670 commit 9a48981

File tree

5 files changed

+48
-77
lines changed

5 files changed

+48
-77
lines changed

Makefile

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
.PHONY: all clean build-all checksums
1+
.PHONY: all clean build-all checksums build-dll
22

33
# Define platforms and output settings
44
OUTPUT_DIR=bin
55

6-
all: build-all checksums
6+
all: build-all build-dll checksums
77

88
build-all:
99
mkdir -p $(OUTPUT_DIR)
@@ -27,6 +27,28 @@ build-all:
2727
GOOS=windows GOARCH=amd64 go build -o $(OUTPUT_DIR)/darkflare-client-windows-amd64.exe client/main.go
2828
GOOS=windows GOARCH=amd64 go build -o $(OUTPUT_DIR)/darkflare-server-windows-amd64.exe server/main.go
2929

30+
# New target for DLL builds
31+
build-dll:
32+
mkdir -p $(OUTPUT_DIR)/dll
33+
# Windows AMD64 DLL
34+
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 \
35+
CC="x86_64-w64-mingw32-gcc" \
36+
CGO_CFLAGS="-I/opt/homebrew/Cellar/mingw-w64/12.0.0_1/toolchain-x86_64/x86_64-w64-mingw32/include" \
37+
CGO_LDFLAGS="-L/opt/homebrew/Cellar/mingw-w64/12.0.0_1/toolchain-x86_64/x86_64-w64-mingw32/lib" \
38+
go build --buildmode=c-shared \
39+
-ldflags="-s -w" \
40+
-o $(OUTPUT_DIR)/dll/darkflare-client-windows-amd64.dll \
41+
client/main.go
42+
# Windows 386 DLL
43+
CGO_ENABLED=1 GOOS=windows GOARCH=386 \
44+
CC="i686-w64-mingw32-gcc" \
45+
CGO_CFLAGS="-I/opt/homebrew/Cellar/mingw-w64/12.0.0_1/toolchain-i686/i686-w64-mingw32/include" \
46+
CGO_LDFLAGS="-L/opt/homebrew/Cellar/mingw-w64/12.0.0_1/toolchain-i686/i686-w64-mingw32/lib" \
47+
go build --buildmode=c-shared \
48+
-ldflags="-s -w" \
49+
-o $(OUTPUT_DIR)/dll/darkflare-client-windows-386.dll \
50+
client/main.go
51+
3052
checksums:
3153
cd $(OUTPUT_DIR) && \
3254
echo "# DarkFlare Binary Checksums" > checksums.txt && \
@@ -35,10 +57,10 @@ checksums:
3557
( \
3658
if command -v sha256sum >/dev/null 2>&1; then \
3759
echo "Using sha256sum" && \
38-
sha256sum * >> checksums.txt; \
60+
find . -type f ! -name checksums.txt -exec sha256sum {} \; >> checksums.txt; \
3961
else \
4062
echo "Using shasum" && \
41-
shasum -a 256 * >> checksums.txt; \
63+
find . -type f ! -name checksums.txt -exec shasum -a 256 {} \; >> checksums.txt; \
4264
fi \
4365
)
4466

README.md

Lines changed: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -295,72 +295,20 @@ Then simply:
295295
ssh remote-server
296296
```
297297

298+
## 🔒 Windows Fileless Execution
298299

299-
## 🧙 Fileless Execution
300-
301-
DarkFlare supports fileless execution on Windows systems using PowerShell, allowing you to run the client without saving any files to disk. This is particularly useful in restricted environments where:
302-
- You don't have write permissions to the local system
303-
- Security policies prevent executing downloaded binaries
304-
- You need to leave no traces on the filesystem
305-
- You want to run the client without installation or cleanup
306-
307-
### PowerShell Memory Execution
308-
Save this as `memory-exec.ps1` or download from examples/:
309-
```powershell
310-
# See examples/memory-exec.ps1 in the repository
311-
param (
312-
[Parameter(Mandatory=$true)]
313-
[string]$t,
314-
[Parameter(Mandatory=$true)]
315-
[string]$d,
316-
[Parameter(Mandatory=$false)]
317-
[string]$l = "stdin:stdout",
318-
[Parameter(Mandatory=$false)]
319-
[string]$p
320-
)
321-
322-
$url = "https://github.com/doxx/darkflare/releases/latest/download/darkflare-client-windows-amd64.exe"
323-
$webClient = New-Object System.Net.WebClient
324-
$bytes = $webClient.DownloadData($url)
325-
$assembly = [System.Reflection.Assembly]::Load($bytes)
326-
$args = @("-l", $l, "-t", $t, "-d", $d)
327-
if ($p) { $args += @("-p", $p) }
328-
$assembly.EntryPoint.Invoke($null, @(,[string[]]$args))
329-
```
300+
For scenarios requiring fileless operation on Windows systems, DarkFlare provides DLL variants that can be loaded directly into memory:
330301

331-
### Usage Examples
302+
Location: `bin/dll/`
303+
- `darkflare-client-windows-386.dll` (32-bit)
304+
- `darkflare-client-windows-amd64.dll` (64-bit)
332305

333-
1. Direct SSH connection using ProxyCommand:
334-
```bash
335-
ssh -o ProxyCommand="powershell -ExecutionPolicy Bypass -File memory-exec.ps1 -t cdn.example.com -d localhost:22" user@remote
336-
```
306+
These DLLs can be embedded within C# or C++ applications for memory-only execution, making them suitable for situations where disk writes need to be avoided.
337307

338-
2. One-liner for immediate execution (no script file needed):
339-
```powershell
340-
$script = (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/doxx/darkflare/main/examples/memory-exec.ps1');
341-
powershell -Command $script -t cdn.example.com -d localhost:22
342-
```
308+
For implementation details and examples, see:
309+
- [Embedding Golang Tools in C#/C++](https://medium.com/@shantanukhande/red-team-how-to-embed-golang-tools-in-c-e269bf33876a)
343310

344-
3. With a SOCKS5 proxy:
345-
```powershell
346-
powershell -ExecutionPolicy Bypass -File memory-exec.ps1 -t cdn.example.com -d localhost:22 -p socks5://proxy:1080
347-
```
348-
349-
### Benefits
350-
- **No Installation Required**: Run directly from memory without installing
351-
- **No Filesystem Traces**: Leaves no artifacts on the local system
352-
- **Bypass Restrictions**: Works in environments with strict file execution policies
353-
- **Easy Cleanup**: No files to remove after use
354-
- **Latest Version**: Always downloads the latest release
355-
- **Portable**: Can be run from any PowerShell prompt with internet access
356-
357-
### Security Considerations
358-
- Only download from trusted sources over HTTPS
359-
- Consider adding checksum verification for enhanced security
360-
- Be aware that some security software may detect/block memory execution
361-
- Use only in environments where you have permission to do so
362-
- The binary is still downloaded, just not saved to disk
363-
- Network administrators may still see the download traffic
311+
⚠️ Note: This feature should only be used in legitimate testing scenarios with proper authorization.
364312

365313
## 📖 Command Line Reference
366314

bin/checksums.txt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# DarkFlare Binary Checksums
2-
# Generated: Mon Dec 23 17:06:48 UTC 2024
2+
# Generated: Tue Jan 7 15:20:19 UTC 2025
33

4-
77b1046247f2ad10c0674197a71f4b2c5cc1e09dd9e02630dee8db5e106786d9 checksums.txt
5-
14705381b2991a46ecfe71682b3e0ff8e4189aab025a8b345d29f018ba514710 darkflare-client-darwin-amd64
6-
d6d7711419853958e955b500fcc3e1a212cf4c8e69ba9b8d1426c04a7a275e91 darkflare-client-darwin-arm64
7-
a377734c31105f0178a1f6ec2c2e1d91116c5aeba9bbfc79c7cdbdfe070ff685 darkflare-client-linux-amd64
8-
530aba39b34abdcf44b95f6eb1797f95e6484edaa1e790d6777138f7f8f7cbb9 darkflare-client-linux-arm64
9-
89baf3b59620b321cc888a6a7e5e8d04b2544c6dd1d4350289f0cba06a157367 darkflare-client-windows-amd64.exe
10-
cdf29af875438dbb991398f4331290299acb2676ba3e2cd93a945a1f67fde6f7 darkflare-server-darwin-amd64
11-
c7da08b1666b8adf1fc1f3bd6aba70b1c0a671903b8350d0a449316fa7384229 darkflare-server-darwin-arm64
12-
5baabce34c6460ab34e521d810d273a15214478ac28ddc5173e97508b4553e08 darkflare-server-linux-amd64
13-
adc8509157eec206a35521bd4350348b0b91be03a0ec154a80ef919973adf49a darkflare-server-linux-arm64
14-
894b84c82a4a750b71446301820535edf142552ff18f49983a368fb99c52ad81 darkflare-server-windows-amd64.exe
4+
c7da08b1666b8adf1fc1f3bd6aba70b1c0a671903b8350d0a449316fa7384229 ./darkflare-server-darwin-arm64
5+
894b84c82a4a750b71446301820535edf142552ff18f49983a368fb99c52ad81 ./darkflare-server-windows-amd64.exe
6+
d6d7711419853958e955b500fcc3e1a212cf4c8e69ba9b8d1426c04a7a275e91 ./darkflare-client-darwin-arm64
7+
89baf3b59620b321cc888a6a7e5e8d04b2544c6dd1d4350289f0cba06a157367 ./darkflare-client-windows-amd64.exe
8+
adc8509157eec206a35521bd4350348b0b91be03a0ec154a80ef919973adf49a ./darkflare-server-linux-arm64
9+
530aba39b34abdcf44b95f6eb1797f95e6484edaa1e790d6777138f7f8f7cbb9 ./darkflare-client-linux-arm64
10+
5baabce34c6460ab34e521d810d273a15214478ac28ddc5173e97508b4553e08 ./darkflare-server-linux-amd64
11+
cdf29af875438dbb991398f4331290299acb2676ba3e2cd93a945a1f67fde6f7 ./darkflare-server-darwin-amd64
12+
14705381b2991a46ecfe71682b3e0ff8e4189aab025a8b345d29f018ba514710 ./darkflare-client-darwin-amd64
13+
55d66950ba24f831185b239bcd5d3b10472de5f905944a9b172f1b90a04cde4a ./dll/darkflare-client-windows-amd64.dll
14+
ae697bb86934dc7788edbb72fb5089c75403be9b1b9da4cc8cfad8dcbabf8011 ./dll/darkflare-client-windows-386.dll
15+
a377734c31105f0178a1f6ec2c2e1d91116c5aeba9bbfc79c7cdbdfe070ff685 ./darkflare-client-linux-amd64
4.97 MB
Binary file not shown.
5.19 MB
Binary file not shown.

0 commit comments

Comments
 (0)