![pas customization - cpm terminal plugins overview03定制終端插件概述_第1頁](http://file4.renrendoc.com/view7/M00/0B/31/wKhkGWcGtgaAMlE2AAAwGZFn4So171.jpg)
![pas customization - cpm terminal plugins overview03定制終端插件概述_第2頁](http://file4.renrendoc.com/view7/M00/0B/31/wKhkGWcGtgaAMlE2AAAwGZFn4So1712.jpg)
![pas customization - cpm terminal plugins overview03定制終端插件概述_第3頁](http://file4.renrendoc.com/view7/M00/0B/31/wKhkGWcGtgaAMlE2AAAwGZFn4So1713.jpg)
![pas customization - cpm terminal plugins overview03定制終端插件概述_第4頁](http://file4.renrendoc.com/view7/M00/0B/31/wKhkGWcGtgaAMlE2AAAwGZFn4So1714.jpg)
![pas customization - cpm terminal plugins overview03定制終端插件概述_第5頁](http://file4.renrendoc.com/view7/M00/0B/31/wKhkGWcGtgaAMlE2AAAwGZFn4So1715.jpg)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
pascustomizationIntroductiontoCPMTerminalPluginsBytheendofthissessionyouwillbeableto:DescribethebasicfunctionalityofastatemachineDescribeastatemachinecompiledasProcessandPromptsfilesReverseEngineeranexistingCPMTerminalpluginLessonObjectives2reviewPMTerminalandTPCarethetwopluginenginesresponsibleformanagingcredentialsinTerminalbasedDevices.PMTerminalandTPCexecutethelogicinpluginsthatarecompiledastwofiles:TheProcessfileThePromptsfilePMTerminalandTPCREVIEWANewPMTerminalorTPCprocessisspawnedbytheCPMwhenitneedstoperformanActionCPMprovidestheenginewiththefollowing:CPMActionNon-SensitiveInformationSensitiveInformationTheinformationprovidedbyCPMtothepluginenginecanbeusedasparametersintheflowPMTerminal.exe/TPCCPMIPAddressUsernameLogonReconcilePortProcessPromptsNon-SensitiveInformation<VerifyPass><Logon><ChangePass><PreReconcoilePass><ReconcilePass>CPMAction<pmpass><pmnewpass><pmextrapass1><pmextrapass3>SensitiveInformationManagingterminalbaseddevicesreviewThestatemachinePMTerminalandTPCrunasastatemachine,simulatinghumanbehavior(usingamodulecalledExpect).Astatemachinestartsataninitialstate,andmovesfromstatetostateaccordingtoconditionsthataremetuntilitreachesafinalstate.ThePromptsandProcess
files
describetheStateMachine,whichisusedtodescribetheprocessofchanging,verifyingandreconcilingapasswordonaspecificdeviceDevelopingCPMTerminalpluginsmanuallyrequiresmanuallycreatingthestatemachine,i.e.–manuallycreatingtheProcessandPrompts
filesStateMachineTheProcessFiledefinesStatesandTransitions.Statesdefinetheactionsperformedtoenterastate.TransitionsdefinewheretomoveinthestatemachineonceaConditionhasbeenmet.ThePromptsFiledefinestheConditions.Whenthepluginruns,theenginematchestheconditionstotheoutput(prompts)
itreceivedfromthetargetmachine.Processfile:[states]Login=(spawn)telnet.exe<address>SendUsername=<username>SendPassword=<pmpass>InvalidLogon=FAIL(badusernameorpassword,8001).END[transitions]#CurrentState Condition NextStateLogin, Username, SendUsernameSendUsername, Password, SendPasswordSendPassword, StandardPrompt, ENDSendPassword, AccessDenied, InvalidLogonPromptsfile:[conditions]Username=username:Password=password:StandardPrompt=#AccessDenied=AccessdeniedProcessandpromptsfilesProcessandPromptsFiles(Flow)LoginSendUsernameUsernameSendPasswordPasswordInvalidLogonAccessDeniedStandardPromptEND(spawn)telnet.exe<address><username><pmpass>Processfile:[states]Login=(spawn)telnet.exe<address>SendUsername=<username>SendPassword=<pmpass>InvalidLogon=FAIL(badusernameorpassword,8001).END[transitions]#CurrentState Condition NextStateLogin, Username, SendUsernameSendUsername, Password, SendPasswordSendPassword, StandardPrompt, ENDSendPassword, AccessDenied, InvalidLogonPromptsfile:[conditions]Username=username:Password=password:StandardPrompt=#AccessDenied=Accessdenied[Conditions]PlinkStoreKey=Storekeyincache|AreyousureyouwantLogin=loginas:|login[States]StartSSH=(spawn)bin\\Plink.exe<address>-ssh-P<port>StoreKeyInCache=yLogonUser=<username>[Transitions]StartSSH, PlinkStoreKey, StoreKeyInCacheStartSSH, Login, LogonUserStoreKeyInCache, Login, LogonUserBranchLogin(If…Then…Else)If$prompt="Login:"Then sendkeys($password)ElseIf$prompt="Storekeyincache" sendkeys("y")EndIf[Conditions]IsRoot=(expression)[stringequal-nocase"<username>""root"]IsAdmin=(expression)[stringequal-nocase"<username>""admin"]IsSupport=(expression)[stringequal-nocase"<username>""support"][States]CheckUserTypeSendAdminUID=<username>SendSupportUID=<username>SendExtra1UID=<extrapass1\username>[Transitions]CheckUserType, IsAdmin, SendAdminUIDCheckUserType, IsSupport, SendSupportUIDCheckUserType, IsRoot, SendExtra1UIDBranchLogic(Select…Case)SELECTCASE$type="Admin" sendkeys(<username>) …CASE$type="Support" sendkeys(<username>) …CASE$type="Root" sendkeys(<extrapass1/username>) …ENDSELECT[Conditions]GetOutput=(.*)(.*)[States]Command=uname–n-oSetOutput=(script)set$hostname“$output_match(1,string)”;set$osname“$output_match(2,string)”;[Transitions]Command, GetOutput,SetOutputCaptureOutputandSetaVariable$hostname=“Blackhole”$osname=“GNU/Linux”CommandsyntaxInthissectionwewillcoverthecommandsyntaxforusingthefollowinginCPMTerminalplugins:ParametersVariablesExpressionsTCLCommandsparametersCredentialsandotherpropertiesfromthetargetandlinkedaccountscanbeusedasparametersintheflow.Propertiescanbebroughtfromthefollowinglocation:TargetAccountLinkedAccountTargetAccountPlatform(AdditionalPolicySettings)ChangePass=passwd<username>
Inthisexample,thecommand"passwd"issenttothetargetmachinewiththeusernametakenfromthetargetaccount.SendPass=<pmpass>
Inthisexample,thecurrentpasswordofthetargetaccountissenttothetargetmachine.LoginExtraUser=<extrapass1\username>
Inthisexample,theusernameofthefirstlinkedaccount(commonlyusedasalogonaccount)issenttothetargetmachine.StartSession=(spawn)bin\\plink.exe<address>-SSH-P<port>
Inthisexample,anSSHconnectionisestablishedusingtheaddressandporttakenfromthetargetaccount.Iftheportisnotsetinthetargetaccount,itistakenfromtheplatform.variablesYoucanuselocalvariablesduringtherunofthepluginTosetavariableuseSET.ToupdateavariableuseSETorAPPENDTouseavariable,Referencethevariablebyappendingthe
$
charactertothenameofthevariableInit=(script)setcurr_pass"<pmpass>";
InitVerifyLogon=(script)setcurr_pass"<pmnewpass>";
Inthisexample,thevariablecurr_passissetintwodifferentways:Whenreachingthe
Init
state,itissettothecurrentpasswordofthetargetaccountWhenreachingthe
InitVerifyLogon
state,itissettothenewpasswordofthetargetaccountLoginPass=$curr_pass
Inthisexample,thevariablecurr_passissenttothetargetmachine.Whilethepluginisrunning,thispasswordcanbesettothetargetaccount’scurrentornewpasswordoreventooneofthelinkedaccount’spasswords,dependingontheuserthatisusedtologontothetarget.Theseexamplesareusefulforreusingtheloginflow.Oncefortheinitiallogon,andasecondforrunningaverifyafterthepasswordwaschanged.expressionsBooleanexpressionscanalsobeusedasconditionswithintheplugincode.Expressionscaninclude:StringcomparisonIntegercomparisonBooleanconstantsBooleanoperations:ActionIsVerify=(expression)[stringequal-nocase"<action>""verifypass"]ThisexpressionchecksthattheactioncurrentlyrunningisVerify,bycomparingthebuilt-inparameter<action>andtheconstantstringverifypassIsVerifyLogon=(expression)$VerifyLogon==1Thisexpressionusesintegercomparisontovalidatethatthevariable$VerifyLogon,whichispreviouslysettoavalueusingasetcommand,isnowset1.TRUE=(expression)true
Thisexpressionsetsaconditionthatisalwaystrueusingthekeywordtrue.Inthesameway,youcancreateaconditionthatisalwaysfalseusingthekeywordfalse.!(Expression)Not(ExpressionA)&&(ExpressionB)And(ExpressionA)||(ExpressionB)OrActionIsNotVerify=!(expression)[stringequal-nocase"<action>""verifypass"]Thisexpressionchecksthattheactioncurrentlyrunningisnot
Verify.Usingastringcompressionofthebuiltinparameter<action>andtheconstantstring"verifypass"andtheoperator"!"TclcommandsTCLisaDynamicProgrammingLanguage.TCLcommandscanbeusedintheplugintoworkwithvariables,manipulatestrings,performarithmeticoperationsandmore.AsPMTerminalwaswritteninTCL,itsupportsTCLcommandsnatively.Althoughwrittenin.NET,TPCalsosupportsallTCLcommandsforbackwardcompatibility(fromv11).SomeexamplesofcommonlyusedTCLcommandsSyntaxFunctionCommandSet<Variable><Value>ReadandwritevariablesSetappend<Variable><Value>AppendtovariableAppendstringlength<input>ReturnsthenumberofcharactersinastringStringlengthlogout=(script)closeClosetheconnectiontothetargetCloseYoucanfindallsupportedTCLcommandsinthislocation:ProcessFileInthissectionwewillcovertheProcessFilewhichcontainsfivesections:StatesTransitionsCPMParametersValidationParametersDebugInformationStatesareactionsthatparticipateintheprocess:sendtoremote(default)spawnscriptsendtoremote-Thisactiondefinestheinformationtosendtotheremotemachine.Itisthemostcommonaction,soitdoesnotrequireakeyword.spawn-Thisactiondefinestheclientapplicationwhichwillbeusedtoconnecttotheremotemachine(plink,telnet,python)script-ThisactiondefinesavalidTCLscriptthatisevaluatedduringruntimewhentheactionisperformed.Multipleactionscanbeperformedinasinglestateusingthe
;
(semicolon)separator
[states]#InitializationInit=(script)setVerifyLogon0;setcurr_pass"<pmpass>";#LoginsequenceCheckProtocol=StartSessionSSH=(spawn)bin\\plink.exe<address>-ssh-P<port>StartSessionTelnet=(spawn)telnet<address><port>StoreKeyInCache=yCheckExtraPass=LoginExtraUser=<extrapass1\username>LoginExtraPass=<pmextrapass1>SwitchUser=su-<username>SwitchPass=$curr_pass...#FinalstateEND#FailurestatesFailUnableToConnect=FAIL(Firstlogin-Unabletoconnecttomachine.Checkmachineaddressandport,8000)FailTARGETInvalidUsernameOrPassword=FAIL(Invalidusernameorbadpassword,2114)StatesTherearetwospecialstatesthatwillendtheplugin:ENDFailureScenariosEND-Thisstatesetsthesuccessfulreturnfromtheplugin.Whenreachingthisstate,thepluginreturnsareturncode0(success)tothe
CPM
andtheenduser.Youmustnamethisstate“END”.FAIL–ThisactionsetsthereturncodeandmessagethatarereturnedtotheCPMandtheenduserThefailuremessagewillbewrittentothescreenandlog.Theerrorcodewillbeusedasthereturnedcode(allowingCPMtotakenecessaryaction,e.g.–reconcile).
[states]#InitializationInit=(script)setVerifyLogon0;setcurr_pass"<pmpass>";#LoginsequenceCheckProtocol=StartSessionSSH=(spawn)bin\\plink.exe<address>-ssh-P<port>StartSessionTelnet=(spawn)telnet<address><port>StoreKeyInCache=yCheckExtraPass=LoginExtraUser=<extrapass1\username>LoginExtraPass=<pmextrapass1>SwitchUser=su-<username>SwitchPass=$curr_pass...#FinalstateEND#FailurestatesFailUnableToConnect=FAIL(Firstlogin-Unabletoconnecttomachine.Checkmachineaddressandport,8000)FailTARGETInvalidUsernameOrPassword=FAIL(Invalidusernameorbadpassword,2114)EndstateandfailurescenariosTransitionsdefinetheflowoftheprocess.Eachtransitionismadeupofthreeparameterscalleda
triple,whichareseparatedbycommasThefirstelementisthelogicalnameofthecurrentstate,thesecondelementisthecondition,andthethirdelementisthenextstate.
[transitions]#CurrentState Condition NextStateLogin, Username, SendUsernameSendUsername, Password, SendPasswordSendPassword, StandardPrompt,ENDSendPassword, AccessDenied, InvalidLogonTransitionsPMTerminalandTPCcanbeinstructedtovalidatetheexistenceofmandatoryparametersintheplatformbeforethepluginisexecuted.Inthisexample,theusernameofthelogonaccount(extrapass1)isrequiredonlyifalogonaccountisattached.Thisischeckedbymakingsurethatthelogonaccount’spasswordisnotempty
[CPMParametersValidation]username,source=FILE,Mandatory=yesaddress, source=FILE,Mandatory=yesprotocol,source=FILE,Mandatory=yesport,source=FILE,Mandatory=yesextrapass1\username,source=FILE,Mandatory=![stringequal-nocase"<pmextrapass1>"""]CPMParametersValidationPromptTimeout-Thetimeoutinsecondstowaitforaprompt.Whenthistimeoutexpires,theplug-inwillfail.SendSlow/SendHuman-Therateatwhichinformationissenttotheremotemachine.Stty-enableordisablepropertiesoftheterminal.Note:whenTPCisperformingtheaction,onlythePromptTimeoutparameterisparsed(astheconnectionismadebytheNET.SSHlibraryandnotplink). [parameters]PromptTimeout=60#SendSlow=1.001#SendHuman=.1.31.052#Stty-validvaluesareoneormoreof:echo,raw,cooked,-echo,-raw,-cooked#Stty=ParametersDebugInformation(PMTerminal)Userscansetavarietyofparameterstocontroldifferentaspectsofdebuggingtheplugin.Logswillbewrittento<cpmfolder>/logs/thirdparty
[DebugInformation]DebugLogFullParsingInfo=noDebugLogFullExecutionInfo=noDebugLogDetailBuiltInActions=noExpectLog=yesConsoleOutput=no*****************************************************************2017/07/0216:26:40(58414670)STATE:StartSessionSSH*****************************************************************FATALERROR:expect:does"FATALERROR:"(spawn_idexp4)matchregularexpression"FATALERROR:|Unabletoopenconnection:|Couldnotopenconnectiontothehost"?yesexpect:setexpect_out(0,string)"FATALERROR:"expect:setexpect_out(spawn_id)"exp4"expect:setexpect_out(buffer)"FATALER*****************************************************************2017/07/0216:27:03(58436840)STATE:FailUnableToConnect**************************************************************ExpectLogexample:DebugInformation(TPC)TPCcreatesonlyonedebuglogwhichwillbewrittento<cpmfolder>/logs/thirdpartySwitchinganyoftheparametersinthissectiontoyeswillturnondebug.Alternative–inthePVWA,turnonDebug
parameterfromthefollowinglocation:TargetAccountPlatform
>
AutomaticPasswordManagement
>
AdditionalPolicySettings[DebugInformation]DebugLogFullParsingInfo=noDebugLogFullExecutionInfo=noDebugLogDetailBuiltInActions=noExpectLog=yesConsoleOutput=no13/11/201902:34:29.011|Info->a7::c->*****************************************************************13/11/201902:34:29.011|Info->a7::c-> CheckAction13/11/201902:34:29.011|Info->a7::c->*****************************************************************13/11/201902:34:29.011|Info->bp::c->START13/11/201902:34:29.011|Info->bp::c->AnalyzingnextstatecandidateIsVerifyLogon13/11/201902:34:29.026|Info->bp::c->AnalyzingnextstatecandidateActionIsRecOrPreRec13/11/201902:34:29.026|Info->bp::c->AnalyzingnextstatecandidateActionIsVerify13/11/201902:34:29.026|Info->bp::c->Expression(expression)[stringequal-nocase"<action>""verifypass"]isTRUE,continuingtonextstateCheckExtraPass113/11/201902:34:29.026|Info->bp::c->END13/11/201902:34:29.026|Info->a7::c->*****************************************************************13/11/201902:34:29.026|Info->a7::c-> CheckExtraPass113/11/201902:34:29.026|Info->a7::c->*******************************************************************************************************************************TPCdebugLogexample:InthissectionwewillcoverthePromptsFilewhich
containsthreetypesofconditions:SimplePrompts(complex)PromptsExpressions
PromptsFileSimplepromptsareconditionswherethevalueofthereturnedpromptsiscomparedtotext.Regularexpressionscannotbeused.Simplepromptshavethefollowingformat:Name=(simpleprompt)Prompt
Simpleprompts[conditions]#StandardpromptsStandardPrompt=\n.*\$?$|.*\#?$|.*\>?$|.*\%?$|.*\]?$#LoginsequenceLogin=loginas:|login:Password=Password:|Enterthepasswordfor.*PasswordExpired=Passwordfor<username>expired.|ChooseanewpasswordInvalidLogin=Youenteredaninvalidloginnameorpassword|password:PlinkStoreKey=Storekeyincache#CheckprotocolProtocolIsSSH=(expression)[stringequal-nocase"<protocol>"ssh]ProtocolIsTelnet=(expression)[stringequal-nocase"<protocol>"telnet]ExtraPassExists=(expression)<pmmaxextrapassindex>==1ExtraPassNotExists=(expression)<pmmaxextrapassindex>==0EOF=(simpleprompt)eofTRUE=(expression)trueComplexPromptsarepromptsthatincluderegularexpressions.Astheyaremostcommonlyused,nokeywordisrequired.Alistofregularexpressionscanbecomparedinasingleconditionsusing'|'betweentheregexexpressionsUseabackslash(‘\’)beforespecialcharacters.Regularexpressionscanbetestedonline:
(Complex)Prompts[conditions]#StandardpromptsStandardPrompt=\n.*\$?$|.*\#?$|.*\>?$|.*\%?$|.*\]?$#LoginsequenceLogin=loginas:|login:Password=Password:|Enterthepasswordfor.*PasswordExpired=Passwordfor<username>expired.|ChooseanewpasswordInvalidLogin=Youenteredaninvalidloginnameorpassword|password:PlinkStoreKey=Storekeyincache#CheckprotocolProtocolIsSSH=(expression)[stringequal-nocase"<protocol>"ssh]ProtocolIsTelnet=(expression)[stringequal-nocase"<protocol>"telnet]ExtraPassExists=(expression)<pmmaxextrapassindex>==1ExtraPassNotExists=(expression)<pmmaxextrapassindex>==0EOF=(simpleprompt)eofTRUE=(expression)trueExpressionsareconditional(Boolean)expressions.Expressionshavethefollowingformat:Name=(expression)expression
Canbeusedtocomparestringsornumbers
expressions[conditions]#StandardpromptsStandardPrompt=\n.*\$?$|.*\#?$|.*\>?$|.*\%?$|.*\]?$#LoginsequenceLogin=loginas:|login:Password=Password:|Enterthepasswordfor.*PasswordExpired=Passwordfor<username>expired.|ChooseanewpasswordInvalidLogin=Youenteredaninvalidloginnameorpassword|password:PlinkStoreKey=Storekeyincache#CheckprotocolProtocolIsSSH=(expression)[stringequal-nocase"<protocol>"ssh]ProtocolIsTelnet=(expression)[stringequal-nocase"<protocol>"telnet]ExtraPassExists=(expression)<pmmaxextrapassindex>==1ExtraPassNotExists=(expression)<pmmaxextrapassindex>==0EOF=(simpleprompt)eofTRUE=(expression)trueReverseengineeraplugin
(os390)CheckProtocolInitsetVerifyLogon0;setcurr_pass"<pmpass>";ProtocolIsSSHStartSessionSSHConnectionFailedFailUnableToConnect(spawn)bin\\plink.exe<address>-ssh-P<port>(expression)[stringequal-nocase"<protocol>"ssh]LoginLogin=loginas:|login:CheckExtraPassStoreKeyInCache=yPlinkStoreKeyLoginTRUE=(expression)trueExistsDoesNotExistLoginExtraUserLoginUser<username><extrapass1\username>PasswordLoginExtraPass<pmextrapass1>PasswordExpiredFAILExpiredExtraPasswordFAILInvalidCurrPassword1InvalidLoginStandardPromptSwitchUsersu-<username>PasswordSwitchPass$curr_passStandardPromptVerifySwitchEcho\$LOGNAMEFailInvalidCurrPassword3SuWrongPasswordCheckAction2StandardPromptPasswordExpiredCheckIDCheckAction1C
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度人工智能產(chǎn)品供應(yīng)合同范本
- 2025年度租賃房屋租賃保證金合同范本
- 2025年度居民與香港居民離婚登記跨國財產(chǎn)分割服務(wù)合同
- 2025年兼職翻譯工作合同范本
- 2025年度護理專業(yè)實習實訓基地合作與支持合同
- 2025年度家政服務(wù)與家庭保潔與環(huán)保服務(wù)合同參考
- 2025年臨時工聘用合同范文(2篇)
- 2025年二手店鋪轉(zhuǎn)讓合同協(xié)議樣本(三篇)
- 2025年度綠色環(huán)保材料進出口代理購銷合同細則
- 2025年度健身中心健身教練職業(yè)發(fā)展計劃合同
- 體育館改造裝修工程施工組織設(shè)計
- 137案例黑色三分鐘生死一瞬間事故案例文字版
- 山東省德州市德城區(qū)2023-2024學年八年級下學期期末考試數(shù)學試卷(含答案)
- 【魔鏡洞察】2024藥食同源保健品滋補品行業(yè)分析報告
- 醫(yī)院運營管理案例-北大國際醫(yī)院-利用精益管理提升患者體驗
- 2024-2030年中國潤滑油行業(yè)發(fā)展趨勢與投資戰(zhàn)略研究報告
- 《洗煤廠工藝》課件
- 鋼結(jié)構(gòu)工程施工(第五版) 課件 2項目四 高強度螺栓
- 機票預訂行業(yè)營銷策略方案
- 大學生就業(yè)指導(高等院校學生學習就業(yè)指導課程)全套教學課件
- 謝爾塔拉露天煤礦變更環(huán)評
評論
0/150
提交評論