Skip to content

Instantly share code, notes, and snippets.

@xorl
Created September 29, 2012 07:02
Show Gist options
  • Save xorl/3803395 to your computer and use it in GitHub Desktop.
Save xorl/3803395 to your computer and use it in GitHub Desktop.
#!/bin/sh
###############################################
# Original by unl0cker
# V.1
# Remade by Xorl for sanity reasons :P
# For MAC's Only.
###############################################
TEST="ssh xorl@$1"
##### Courtesy of rhcp #####
function scp {
set password dottie
set ipaddr [lrange $argv 0 0]
set file [lrange $argv 1 1]
set location [lrange $argv 2 2]
set timeout -1
# now connect to remote UNIX box (ipaddr) with given script to execute
spawn scp $file root@$ipaddr:$location
match_max 100000
# Look for passwod prompt
expect "*?assword:*"
# Send password aka $password
send -- "$password\r"
# send blank line (\r) to make sure we get back to gui
send -- "\r"
expect eof
}
#####First we copy over the applications #####
read -p "Starting script are you sure you want to continue? <yes/no>"
if [ "$REPLY" = "yes" ]; then
echo -e "SSH Keygen will now generate a key so we don't get prompted for a password the whole time.\n"
echo -e "Just keep pressing enter (leave passphrase blank for now.)";
if [ ! -e ~/.ssh/id_rsa.pub ]
ssh-keygen -t rsa
scp(); -rp anySIM.app $1:/Applications
scp(); -rp sleep ls rm mv bbupdater $1:/usr/bin
scp(); -rp lockdownd device_private_key.pem device_public_key.pem data_ark.plist $1:/
$TEST "mkdir /private/var/root/.ssh/ && chmod 700 /private/var/root/.ssh/ && touch /private/var/root/.ssh/authorized_keys2"
scp(); -rp ~/.ssh/id_rsa.pub $1:/private/var/root/.ssh/
$TEST "chmod 644 /private/var/root/.ssh/authorized_keys2"
$TEST "cat /private/var/root/id_rsa.pub >> /private/var/root/.ssh/authorized_keys2"
echo -e "Now you shouldn't have to type the password anymore!\n"
set password dottie
expect "*?assword:*"
send -- "$password\r"
expect eof
fi
else
echo "Exiting stage 2!";
exit 0;
fi
##### Now we Do the Remote Calls #####
read -p "Continue with stage 2? <yes/no>"
if [ "$REPLY" = "yes" ]; then
$TEST launchctl unload -w /System/Library/LaunchDaemons/com.apple.SpringBoard.plist
$TEST launchctl load -w /System/Library/LaunchDaemons/com.apple.SpringBoard.plist
echo "\----------------------------------------------";
echo "Time to run anySIM. Go ahead and run anySIM";
echo "Ignore the \'unlock commands failed\' error";
echo "After anySIM is done type yes to continue";
echo "The final stages will finish the rest of";
echo "the processes that need to be done.";
echo "\----------------------------------------------";
else
echo "Exiting stage 2!";
exit 0;
fi
##### Fix com center and Clean Up #####
read -p "Continue with stage 3? <yes/no>"
if [ "$REPLY" = "yes" ]; then
$TEST launchctl unload -w /System/Library/LaunchDaemons/com.apple.CommCenter.plist
echo "Swaping lockdownd and fixing youtube...\n"
$TEST rm -rf /Applications/anySIM.app
$TEST rm /usr/libexec/lockdownd
$TEST mv /lockdownd /usr/libexec/
$TEST mv /device_private_key.pem /private/var/root/Library/Lockdown/
$TEST mv /device_public_key.pem /private/var/root/Library/Lockdown/
$TEST mv /data_ark.plist /private/var/root/Library/Lockdown/
$TEST rm -rf /private/var/root/Library/Lockdown/activation_records/*
##### Running bbupdater #####
echo "Done swaping files. Running bbupdater...\n"
$TEST bbupdater -v
echo "Bringing CommCenter back up...\n"
else
echo "Exiting stage3!";
exit 0;
fi
read -p "Continue with stage 4 and clean out files? <yes/no>"
if [ "$REPLY" = "yes" ]; then
$TEST launchctl load -w /System/Library/LaunchDaemons/com.apple.CommCenter.plist
##### Just finish the cleaning #####
echo "Cleaning up used files...\n";
$TEST rm /usr/bin/mv
$TEST rm /usr/bin/bbupdater
$TEST rm /usr/bin/sleep
$TEST rm /usr/bin/ls
$TEST rm /usr/bin/stage2
$TEST rm /usr/bin/stage3
$TEST rm /usr/bin/rm
echo "Finished, you can now restart the phone.";
echo "We should be good to go at this point.";
echo "Enjoy your new unlocked iPhone!";
echo "Xorl & unl0cker";
else
echo "Exiting Stage 4!";
exit 0;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment