- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
02-25-2019 10:00 PM
#AutoIt3Wrapper_UseX64=n
#include <BlockInputEx.au3>
#include <IE.au3>
#Include <Array.au3>
#Include <Chrome.au3>
Opt("MustDeclareVars", 1)
AutoItSetOption("WinTitleMatchMode", 3) ; EXACT_MATCH!
;============================================================
; PSM AutoIt Dispatcher Skeleton
; ------------------------------
;
; Use this skeleton to create your own
; connection components integrated with the PSM.
; Areas you may want to modify are marked
; with the string "CHANGE_ME".
;
; Created : April 2013
; Cyber-Ark Software Ltd.
;============================================================
#include "PSMGenericClientWrapper.au3"
#include <IE.au3>
;=======================================
; Consts & Globals
;=======================================
Global Const $DISPATCHER_NAME = "PSMPolicyBuilderWebDispatcher" ; CHANGE_ME
Global Const $CLIENT_EXECUTABLE = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ; CHANGE_ME
Global Const $ERROR_MESSAGE_TITLE = "PSM " & $DISPATCHER_NAME & " Dispatcher error message"
Global Const $LOG_MESSAGE_PREFIX = $DISPATCHER_NAME & " Dispatcher - "
Global $TargetUsername
Global $TargetPassword
Global $TargetAddress
Global $ConnectionClientPID = 0
Global $oIE
Global $ochrome
Global $oChrome2
Global $oChrome3
Global $oForm
Global $oSubmit
Global $oUsername_3
Global $oPassword_3
;=======================================
; Code
;=======================================
Exit Main()
;=======================================
; Main
;=======================================
Func Main()
; Init PSM Dispatcher utils wrapper
ToolTip ("Initializing...")
if (PSMGenericClient_Init() <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
LogWrite("successfully initialized Dispatcher Utils Wrapper")
; Get the dispatcher parameters
FetchSessionProperties()
LogWrite("mapping local drives")
if (PSMGenericClient_MapTSDrives() <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
LogWrite("starting client application")
ToolTip ("Starting " & $DISPATCHER_NAME & "...")
;_ChromeStartup($TargetAddress) ; commented by Aniket
;$ConnectionClientPID=wingetprocess("") ; commented by Aniket
; added by aniket
Local $oChrome = _ChromeStartup($TargetAddress) ;added by Aniket
_ChromeDocWaitForReadyStateCompleted() ;added by Aniket
Sleep(500) ;added by Aniket
$ConnectionClientPID=WinGetProcess(_ChromeDocGetTitle(2)) ;added by Aniket
if ($ConnectionClientPID == 0) Then
Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error))
EndIf
;Send PID to PSM as early as possible so recording/monitoring can begin
LogWrite("sending PID to PSM")
if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
;till here
;For handling SSL Certificate Error If Any
;-------------------------------------
Local $sText = _IEBodyReadHTML($oIE)
;--------------------------------------
if StringRegExp($sText,"There is a problem with this website's security certificate.") = 1 Then
_IELinkClickByText($oIE, "Continue to this website (not recommended).")
tooltip("Continue to untrusted website")
EndIf
if WinExists("Certificate Error: Navigation Blocked - Windows Internet Explorer") Then
_IELinkClickByText($oIE, "Continue to this website (not recommended).")
tooltip("Continue to untrusted website by wintitle")
EndIf
; ------------------
; Handle login here! ; CHANGE_ME
; ------------------
;--------------------------------------
_BlockInputEx(1);
tooltip("Opening CMS_Samsung WebPage. It May Take Time Pleae Wait")
_BlockInputEx(0);
sleep(5000)
_BlockInputEx(0);
WinWaitActive("CCM [[2405] - Google Chrome")
sleep(5000)
Send($TargetUsername)
Send("{TAB}")
sleep(1000)
Send($TargetPassword,1)
Send("{Enter}")
_BlockInputEx(0);
_BlockInputEx(0);
; Terminate PSM Dispatcher utils wrapper
;LogWrite("Terminating Dispatcher Utils Wrapper")
;PSMGenericClient_Term()
Return $PSM_ERROR_SUCCESS
EndFunc
_BlockInputEx(0);
;==================================
; Functions
;==================================
; #FUNCTION# ====================================================================================================================
; Name...........: Error
; Description ...: An exception handler - displays an error message and terminates the dispatcher
; Parameters ....: $ErrorMessage - Error message to display
; $Code - [Optional] Exit error code
; ===============================================================================================================================
Func Error($ErrorMessage, $Code = -1)
; If the dispatcher utils DLL was already initialized, write an error log message and terminate the wrapper
if (PSMGenericClient_IsInitialized()) Then
LogWrite($ErrorMessage, True)
PSMGenericClient_Term()
EndIf
Local $MessageFlags = BitOr(0, 16, 262144) ; 0=OK button, 16=Stop-sign icon, 262144=MsgBox has top-most attribute set
MsgBox($MessageFlags, $ERROR_MESSAGE_TITLE, $ErrorMessage)
; If the connection component was already invoked, terminate it
if ($ConnectionClientPID <> 0) Then
ProcessClose($ConnectionClientPID)
$ConnectionClientPID = 0
EndIf
Exit $Code
EndFunc
; #FUNCTION# ====================================================================================================================
; Name...........: LogWrite
; Description ...: Write a PSMWinSCPDispatcher log message to standard PSM log file
; Parameters ....: $sMessage - [IN] The message to write
; $LogLevel - [Optional] [IN] Defined if the message should be handled as an error message or as a trace messge
; Return values .: $PSM_ERROR_SUCCESS - Success, otherwise error - Use PSMGenericClient_PSMGetLastErrorString for details.
; ===============================================================================================================================
Func LogWrite($sMessage, $LogLevel = $LOG_LEVEL_TRACE)
Return PSMGenericClient_LogWrite($LOG_MESSAGE_PREFIX & $sMessage, $LogLevel)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name...........: PSMGenericClient_GetSessionProperty
; Description ...: Fetches properties required for the session
; Parameters ....: None
; Return values .: None
; ===============================================================================================================================
Func FetchSessionProperties() ; CHANGE_ME
if (PSMGenericClient_GetSessionProperty("Username", $TargetUsername) <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
if (PSMGenericClient_GetSessionProperty("Password", $TargetPassword) <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
if (PSMGenericClient_GetSessionProperty("Address", $TargetAddress) <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
EndFunc
_BlockInputEx(0);
02-25-2019 11:10 PM
Hi,
Please use CyberArk Chrome connection components .
If you use "send" parameters to send username and password for any dispatcher then it will type password in clear text which will be audit issue.
02-25-2019 11:10 PM
Hi,
Please use CyberArk Chrome connection components .
If you use "send" parameters to send username and password for any dispatcher then it will type password in clear text which will be audit issue.
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

