You need to specify what kind of token you use.
There are number of choices here I heard of:
- hardware token
- software token application (Mac OS, Windows, iOS, Android, Windows Mobile, and few others)
- web browser token
Please check this link for more details:
http://www.emc.com/security/rsa-securid/rsa-securid-software-authenticators.htm#!offerings_for_web_browsers
With hardware token you will need to use some kind of camera and read pixels of the image taken (I will not be able to help you there)
Software token is simpler.
I have recently created small command line tool that is able to execute, enter PIN, and read Passcode generated in the token application.
I cannot send you the tool (property of my company), but I can give you some tips what you need to do to create your own application that will do the same stuff.
But first you need to tell me whether you use software token or not.
OK.
Since you have software token I'll describe what my app do to automatically connect to VPN.
1) you need to have your software token configured prior doing this.
On top of that VPN client will need to be also configured, and connection must be listed on available connection list.
When it is configured you can do your auto VPN Connection.
We have software token similar to this one:
https://ssl.seagate.com/ssl/docs/soft_token_install_instructions.html
Our VPN Client looks looks something like this one:
http://wireless-setup.wsu.edu/msIPSEC.html
2) Once all tools are configured you can start your VPN connection.
You need to be prepared to do deep investigation.
Guys from RSA worked really hard to make it impossible this what we are doing here.
They don't use ordinary controls. They have created their own controls I do not have
spec for.
I have done it using C++ and WIN32 API functions. This is my recipe.
a) read parameters passed to the program
b) validate the parameters
I have number of params like PIN, connection number to establish, Command to run when connection is established etc. They can be hardcoded of course but to be flexible I can pass them from command line.
c) check for token application [EnumWindows]
Token app can have 2 top level windows [The one you enter PIN, and the one with passcode]
If I detect both windows opened I close the app and restart it.
You can try sending Message WM_CLOSE to close the app. I simulate users action to press "X" close button
//restore it <if minimized>
SendMessage(hwndTokenApplicationPinWindow,WM_SYSCOMMAND,SC_RESTORE,NULL);
//close the app
SendMessage(hwndTokenApplicationPinWindow,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(223,14));
SendMessage(hwndTokenApplicationPinWindow, WM_LBUTTONUP,0,MAKELPARAM(223,14));
To start it I use CreateProcess function.
When you restart the app or you had only one window opened, you can now enter PIN.
d) Enter PIN
I simulate users left click on pin window WM_LBUTTONDOWN, WM_LBUTTONUP.
I enter the pin using WM_CHAR.
Once entered, click OK button using WM_LBUTTONDOWN, WM_LBUTTONUP.
Once completed you should have Passcode window displayed.
e) Read passcode
To get the passcode I use Copy button from the token. This button Copy data to clipboard.
We simulate pressing this button: WM_LBUTTONDOWN, WM_LBUTTONUP
And read data from clipboard:
BOOL InvalidData = FALSE;
OpenClipboard(NULL);
HANDLE clip0 = GetClipboardData(CF_UNICODETEXT);
wchar_t* p=(wchar_t*)GlobalLock(clip0);
if(wcslen(p) == MaxPasscodeSize-1)
wcscpy_s(currentPasscode,MaxPasscodeSize,p);
else if(wcslen(p) != MaxPasscodeSize-1 && wcslen(p) != 0)
{
wprintf(L"Error: Passcode in clipboard is invalid\n");
InvalidData = TRUE;
}
GlobalUnlock(clip0);
CloseClipboard();
Now you have Passcode ready to be used in the CISCO VPN Client.
Please let me know if it make any sense to you.
If it does, and you your app works up to this point please let me know and I'll pass instruction to deal with VPN client.
If you need more detailed instruction for the steps above please let me know.