Skip to content

Instantly share code, notes, and snippets.

@kevinberny
Last active May 4, 2023 10:58
Show Gist options
  • Save kevinberny/8546336 to your computer and use it in GitHub Desktop.
Save kevinberny/8546336 to your computer and use it in GitHub Desktop.
Mac OS X AppleScript to automate RSA SecurID pin & Cisco AnyConnect client connection. Leverages keychain. Cobbled together from several other previous postings
set the clipboard to ""
set appname to "SecurID"
set thePin to RsaTokenPin()
activate application appname
do shell script "networksetup -setairportpower en0 on"
tell application appname
activate
tell application "System Events"
keystroke thePin -- type the pin number
key code 36 -- return key
delay 0.75 -- wait for token appear
key code 48 -- press tab
key code 49 -- space (to hit the copy button)
end tell
end tell
delay 0.5 -- wait
quit application appname
on RsaTokenPin()
return (do shell script "security -q find-generic-password -gl rsatoken 2>&1 | egrep '^password' | awk -F\\\" '{print $2}'")
end RsaTokenPin
tell application "Cisco AnyConnect Secure Mobility Client"
activate
end tell
repeat until application "Cisco AnyConnect Secure Mobility Client" is running
delay 1
end repeat
tell application "System Events"
repeat until (window 1 of process "Cisco AnyConnect Secure Mobility Client" exists)
delay 1
end repeat
click button "Connect" of window 1 of application process "Cisco AnyConnect Secure Mobility Client"
repeat until (window 2 of process "Cisco AnyConnect Secure Mobility Client" exists)
delay 1
end repeat
tell process "Cisco AnyConnect Secure Mobility Client"
keystroke "v" using {command down}
delay 1
keystroke return
-- click button "OK"
end tell
(* repeat until (window 1 of process "Cisco AnyConnect Secure Mobility Client" exists)
delay 1
end repeat
click button "Accept" of window 1 of application process "Cisco AnyConnect Secure Mobility Client"
*)
delay 8
keystroke return
end tell
@degreecy
Copy link

degreecy commented Dec 8, 2017

Any ideas how to adapt for MobilePass ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment