Guest User

Untitled

a guest
Nov 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. Subroutine CS_SETSTATION_HOOK(flag,station)
  2.  
  3. Declare Function GetCommandLine, InList
  4. CommandLine = GetCommandLine()
  5.  
  6. TrustedStations = "SERVER1,SERVER2,ADMINSTATION"
  7. TrustedAccounts = "ADMIN1,ADMIN2,DEV3"
  8.  
  9. *Get the command line arguments used to launch oinsight.exe
  10. CmdArgs = GetCommandLine()
  11.  
  12. Token = '/DV=' ;*Look for this command like argument
  13. TokenLen = Len(Token)
  14.  
  15. CommandLineDVValue = '' ;* If found, store cmd arg value here
  16.  
  17. *Index and IndexC are not available at this point in launch.
  18. *Loop through all characters in the command line arguments
  19. CharCount = Len(CmdArgs)
  20. For i = 1 To CharCount
  21.  
  22. *Does this section match the argument we are searching for?
  23. If CmdArgs[i,TokenLen] EQ Token Then
  24. *Found the parameter
  25.  
  26. *Parameter value starts here:
  27. TokenValuePos = i + TokenLen
  28.  
  29. *Find the value and length of parameter
  30. TokenValue = ''
  31. TokenValueLen = ''
  32.  
  33. For j = TokenValuePos To CharCount
  34. *Now find the end of the value
  35.  
  36. If CmdArgs[j,1] EQ ' ' Then
  37. *This is the first space after the beginning of the parm value
  38. *so it must be the end of the value
  39. TokenValueLen = j - TokenValuePos
  40. j = CharCount ;* Break the loop
  41. End
  42.  
  43. Next j
  44.  
  45. If TokenValue EQ '' And TokenValueLen EQ '' Then
  46. *Didn't find an end value to the token so maybe it was the last position
  47. *in the command line arguments and has no ending space character
  48. TokenValueLen = (CharCount - TokenValuePos) + 1
  49.  
  50. End
  51.  
  52. TokenValue = CmdArgs[TokenValuePos, TokenValueLen]
  53.  
  54. *Drop any quotes protecting the UN value
  55. Swap "'" With '' In TokenValue
  56. Swap '"' With '' In TokenValue
  57.  
  58. CommandLineDVValue = TokenValue
  59.  
  60. i = CharCount ;* Break out of parent loop
  61. End
  62.  
  63. Next i
  64.  
  65. Token = '/UN=' ;*Look for this command like argument
  66. TokenLen = Len(Token)
  67.  
  68. CommandLineUNValue = '' ;* If found, store cmd arg value here
  69.  
  70. *Index and IndexC are not available at this point in launch.
  71. *Loop through all characters in the command line arguments
  72. CharCount = Len(CmdArgs)
  73. For i = 1 To CharCount
  74.  
  75. *Does this section match the argument we are searching for?
  76. If CmdArgs[i,TokenLen] EQ Token Then
  77. *Found the parameter
  78.  
  79. *Parameter value starts here:
  80. TokenValuePos = i + TokenLen
  81.  
  82. *Find the value and length of parameter
  83. TokenValue = ''
  84. TokenValueLen = ''
  85.  
  86. For j = TokenValuePos To CharCount
  87. *Now find the end of the value
  88.  
  89. SingleChar = CmdArgs[j,1]
  90. If SingleChar EQ ' ' Then
  91. *This is the first space after the beginning of the parm value
  92. *so it must be the end of the value
  93. TokenValueLen = j - TokenValuePos
  94. j = CharCount ;* Break the loop
  95. End
  96.  
  97. Next j
  98.  
  99. If TokenValue EQ '' And TokenValueLen EQ '' Then
  100.  
  101. *Didn't find an end value to the token so maybe it was the last position
  102. *in the command line arguments and has no ending space character
  103. TokenValueLen = (CharCount - TokenValuePos) + 1
  104.  
  105. End
  106.  
  107. TokenValue = CmdArgs[TokenValuePos, TokenValueLen]
  108.  
  109. *Drop any quotes protecting the UN value
  110. Swap "'" With '' In TokenValue
  111. Swap '"' With '' In TokenValue
  112.  
  113. CommandLineUNValue = TokenValue
  114.  
  115. i = CharCount ;* Break out of parent loop
  116. End
  117.  
  118. Next i
  119.  
  120. CommandLineUNValue = Trim(CommandLineUNValue)
  121.  
  122. *
  123. * At this point the program didn't terminate so we aren't on a trusted station
  124. *
  125.  
  126. If InList(TrustedAccounts,CommandLineUNValue,',') Then
  127. *The account is trusted even if we aren't on a trusted station
  128. Return
  129. End
  130.  
  131. *
  132. * Account is not trusted nor is the staion.
  133. * Must use the correct command line arguments
  134. *
  135.  
  136. If CommandLineUNValue EQ '' Or CommandLineDVValue NE '0' Then
  137. *No user specified on command line so don't allow run or
  138. *Run mode was not specified.
  139. *In other words, only allow user to run OI with command line arguments and DV=0
  140. isRestricted = 1
  141. End Else
  142. isRestricted = 0
  143. End
  144.  
  145.  
  146. If isRestricted Then
  147. Call Msg(@Window, 'Command line not correct for account')
  148. Call Utility("DESTROY", "SYSTEM")
  149. End
  150.  
  151.  
  152. Return
Add Comment
Please, Sign In to add comment