Can I use RSA Secure Id programmatically for use in Test Automation?

I have a requirement when I need to enter a secure identifier from an RSA token during login authentication, and then run an automation test.

Is it possible to programmatically access the value of the RSA marker through any api or in any other way so that the test thread is fully automated?

+9
security rsa automation
source share
4 answers

We automated our vpn login that uses the rsa and Cisco AnyConnect security identifiers by completing the following steps:

1) Open the secure rsa identifier programmatically the way you want

2) Run the following .ps1

#Source http://www.lazywinadmin.com/2010/06/powershell-get-clipboard-set-clipboard.html function Get-ClipBoard { Add-Type -AssemblyName System.Windows.Forms $tb = New-Object System.Windows.Forms.TextBox $tb.Multiline = $true $tb.Paste() $tb.Text } # end Source http://www.lazywinadmin.com/2010/06/powershell-get-clipboard-set-clipboard.html $wshell = New-Object -ComObject wscript.shell; $wshell.AppActivate('the name')#Here you need to write the name that appears on the left top corner of the rsa secure id window Sleep 1 $wshell.SendKeys('{TAB}') $wshell.SendKeys('~') $a = Get-ClipBoard #Source http://www.cze.cz #This script is tested with "Cisco AnyConnect Secure Mobility Client version 3.0.5080″ #Please change following variables [string]$CiscoVPNHost = 'the vpn you are trying to connect' [string]$Login = 'your user' [string]$Password = $a #Please check if file exists on following paths [string]$vpncliAbsolutePath = 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe' [string]$vpnuiAbsolutePath = 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe' #**************************************************************************** #**** Please do not modify code below unless you know what you are doing **** #**************************************************************************** Add-Type -AssemblyName System.Windows.Forms -ErrorAction Stop #Set foreground window function #This function is called in VPNConnect Add-Type @' using System; using System.Runtime.InteropServices; public class Win { [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetForegroundWindow(IntPtr hWnd); } '@ -ErrorAction Stop #quickly start VPN #This function is called later in the code Function VPNConnect() { Start-Process -FilePath $vpncliAbsolutePath -ArgumentList "connect $CiscoVPNHost" $counter = 0; $h = 0; while($counter++ -lt 1000 -and $h -eq 0) { sleep -m 10 $h = (Get-Process vpncli).MainWindowHandle } #if it takes more than 10 seconds then display message if($h -eq 0){echo "Could not start VPNUI it takes too long."} else{[void] [Win]::SetForegroundWindow($h)} } #Terminate all vpnui processes. Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq "vpnui") {$Id = $_.Id; Stop-Process $Id; echo "Process vpnui with id: $Id was stopped"}} #Terminate all vpncli processes. Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq "vpncli") {$Id = $_.Id; Stop-Process $Id; echo "Process vpncli with id: $Id was stopped"}} #Disconnect from VPN echo "Trying to terminate remaining vpn connections" start-Process -FilePath $vpncliAbsolutePath -ArgumentList 'disconnect' -wait #Connect to VPN echo "Connecting to VPN address '$CiscoVPNHost' as user '$Login'." VPNConnect #Write login and password [System.Windows.Forms.SendKeys]::SendWait("$Login{Enter}") [System.Windows.Forms.SendKeys]::SendWait("$Password{Enter}") #Start vpnui start-Process -FilePath $vpnuiAbsolutePath #Wait for keydown #echo "Press any key to continue …" #try{$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")}catch{} #Exit 

Now you need to install vpn and user on the script above.

+2
source share

You need to indicate which token you are using.

There are several options here:

  • hardware token
  • software token application (Mac OS, Windows, iOS, Android, Windows Mobile and some 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 a hardware token, you will need to use some kind of camera and read the pixels of the received image (I can not help you)

Software token is simpler.

I recently created a small command line tool that can execute, enter a PIN code and read the password generated in the token application. I cannot send you a tool (a property of my company), but I can give you some tips on what you need to do to create your own application that will do the same.

But first you need to say if you use a software token or not.


OK Since you have a software token, I will describe what my application does to automatically connect to a VPN.

1) you need your software token to configure this before.
In addition, this VPN client must also be configured, and the connection must be listed in the list of available connections.
When it is configured, you can make your automatic VPN connection.
We have a software token similar to this: https://ssl.seagate.com/ssl/docs/soft_token_install_instructions.html
Our VPN client looks something like this: http://wireless-setup.wsu.edu/msIPSEC.html

2) After setting up all the tools, you can start the VPN connection.

You must be prepared for a deep investigation. The RSA guys worked very hard to make it impossible; this is what we do here.
They do not use conventional controls. They created their own control, which I do not have spec for.

I did this using the C ++ and WIN32 API functions. This is my recipe.

a) reading parameters passed to the program

b) check the parameters I have a number of parameters, such as the PIN code, the connection number for the installation, the command to start when the connection is established, etc. They can be hard-coded, but to be flexible, I can pass them from the command line.

c) check for token use [EnumWindows]
Token app can have 2 top-level windows [the one you enter the PIN, and the password code]
If I find that both windows are open, I close the application and restart it.
You can try sending WM_CLOSE message to close the application. I simulate the action of users to click the close button "X"

 //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 run it, I use the CreateProcess function.
When you restart the application or open only one window, you can enter the PIN code.

d) Enter PIN

I imitate users with the left mouse button on the output window WM_LBUTTONDOWN, WM_LBUTTONUP.
I get in touch using WM_CHAR.
After entering, click "OK" using WM_LBUTTONDOWN, WM_LBUTTONUP.
Upon completion, you should open a password window.

e) Read access code
To get the access code, I use the Copy from token button. This button Copy data to the clipboard.
We simulate clicking this button: WM_LBUTTONDOWN, WM_LBUTTONUP
And read the data from the 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(); 

You now have a password ready for use in the CISCO VPN client.
Please let me know if this makes sense to you.
If so, and your application works up to this point, let me know and I will give instructions for working with the VPN client.

If you need more detailed instructions for the above steps, please let me know.

+1
source share

I read this thread looking for an automated solution for step "1) Programmatically open rsa secure id the way you want." I am looking for a solution that does the following in Win10.

  1. Run the SecurID.exe program saved in the path "C: \ Program Files (x86) \ RSA SecurID Software Token"
  2. Enter PIN
  3. press enter
  4. Click the "Copy" button in the frame of SecurID.exe. This copies the one-time session password to the clipboard.
  5. Close SecurID.exe

Preferably, I like to run it as native Java or powershell code, a perl script, or an exe file. I found a solution for auto-hotkeys, but don't use it. Any help or pointer is much appreciated.

0
source share

One idea is to record a pair of clock / token pairs and start the clock for your program and play the recording. In fact, if you have the ability to make a watch, you really only need one pair.

(I did not say that it was a GOOD idea.)

Good luck, / Bob Brian

-2
source share

All Articles