Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

551 lines
12 KiB

  1. <?XML version="1.0" ?>
  2. <package>
  3. <comment>
  4. HKLM,%WINLOGON%,DefaultDomainName,%REG_SZ%,%BVTDOMAIN% --- ???
  5. HKLM,%WINLOGON%,DefaultUserName,%REG_SZ%,%BVTUSER%
  6. HKLM,%WINLOGON%,DefaultPassword,%REG_SZ%,%BVTPASSWORD%
  7. HKLM,%WINLOGON%,AutoAdminLogon,%REG_SZ%,1
  8. HKLM,%WINLOGON%,ForceAutoLogon,%REG_SZ%,1
  9. HKLM,%WINLOGON%,passwordexpirywarning,%REG_DWORD%,0
  10. passwordexpirywarning ???
  11. </comment>
  12. <job>
  13. <resource id="keys">
  14. DefaultUserName
  15. DefaultPassword
  16. DefaultDomainName
  17. AutoAdminLogon
  18. ForceAutoLogon
  19. </resource>
  20. <resource id="domainname">ntdev</resource>
  21. <resource id="domainuser">winbld</resource>
  22. <resource id="regpath">HKLM\SOFTWARE\Microsoft\WINDOWS NT\CurrentVersion\Winlogon</resource>
  23. <resource id="Usage">
  24. Name:
  25. %SELF%
  26. Manipulating the REGISTRY providing automatic logon
  27. Usage:
  28. %SELF% -h -d -u:%USER% -p:%PASS% -y:%DOMAIN% -a:%AUTO% -c
  29. Where
  30. -h show this message
  31. -d enable debugging
  32. -y domain. Default is %DOMAINNAME%
  33. -u username. Default is "%DOMAINUSER%"
  34. -p password. No default
  35. -a Set AutoAdminLogon Feature. Only executed if explicitly set
  36. -c Clean the keys known to %SELF%. Default keys are: %KEYS%
  37. </resource>
  38. <script language="VBScript">
  39. <![CDATA[
  40. Function ReadResource(sPresId)
  41. On Error resume next
  42. Dim WshShell
  43. Set WshShell = CreateObject("WScript.Shell")
  44. Dim sPRes, asRes, uRes, tsRes
  45. sPREs = GetResource(sPresId)
  46. If Err.number <> 0 Then
  47. Wscript.echo err.number & " " & err.description
  48. ' The Error description are not informative when failed getresource
  49. IF Err.number = 7 Then
  50. Wscript.echo chr(9) & "Null resource: " & _
  51. sPresId
  52. End If
  53. IF Err.number = 5 Then
  54. Wscript.echo chr(9) & "Undefined resource: " & _
  55. sPresId
  56. End If
  57. Wscript.quit
  58. End If
  59. asRes = Split(WshShell.ExpandEnvironmentStrings(sPRes), VBNEWLINE)
  60. Set ures = CreateObject("Scripting.Dictionary")
  61. For Each tsRes in asRes
  62. If 0 <> Len(tsRes) Then
  63. uRes(tsRes) = 1
  64. End If
  65. Next
  66. Dim tResource
  67. tResource = uRes.Keys
  68. If uBound(tResource) = 0 Then
  69. ReadResource = tResource(0)
  70. Else
  71. ReadResource = tResource
  72. End If
  73. Set WshShell = Nothing
  74. Set uRes = Nothing
  75. End Function
  76. ]]>
  77. </script>
  78. <script language="VBScript">
  79. <![CDATA[
  80. sub showUsage
  81. Const VBEXPECTED = 5
  82. on error resume next
  83. Dim oGenRplaceVarNamXp
  84. Dim oExRplaceVarNamXp
  85. Dim aoRplaceMatches, oMatch, sMatch, sLabel, sResource
  86. Set oGenRplaceVarNamXp = new RegExp
  87. Set oExRplaceVarNamXp = new RegExp
  88. With oGenRplaceVarNamXp
  89. .Global = True
  90. .IgnoreCase = True
  91. .Pattern = "%\w+%"
  92. End With
  93. With oExRplaceVarNamXp
  94. .Global = True
  95. .IgnoreCase = True
  96. .Pattern = "%\w+%"
  97. End With
  98. Dim sLine,asTest
  99. asTest = ReadResource("Usage")
  100. For Each sLine in asTest
  101. sLine = Replace(sLine, "%SELF%", WScript.ScriptName,1,10)
  102. Set aoRplaceMatches = oGenRplaceVarNamXp.Execute(sLine)
  103. For Each oMatch in aoRplaceMatches
  104. sMatch = oMatch.value
  105. sMatch = UCase(Mid(sMatch, 2, Len(sMatch)-2))
  106. sLabel = LCase(sMatch)
  107. Err.clear
  108. sResource = GetResource(sLabel)
  109. If err = 0 Then
  110. sMatch = sResource
  111. ElseIf err = VBEXPECTED Then
  112. sMatch = "<" & sMatch & ">"
  113. Else
  114. Raise Err
  115. End If
  116. oExRplaceVarNamXp.Pattern = oMatch.value
  117. sLine = oExRplaceVarNamXp.Replace(sLine, sMatch)
  118. Next
  119. WScript.echo sLine
  120. Next
  121. WScript.Quit(0)
  122. End sub
  123. ]]>
  124. </script>
  125. <script language="VBScript">
  126. <![CDATA[
  127. option explicit
  128. Public Function reQuoteObjArgs(objArgs)
  129. Dim sLabelVar, sFoundLabel, sArgsDictionary, sArg, oArgs, nArg
  130. Dim poQuotedCheckRegEx, poStringCheckRegEx, psQuotedCheckPt
  131. Dim sConcatArgs, aRepArgs, spBadQuotedPart, spGoodQuotedPart, apQuoted
  132. sConcatArgs = join(objArgs, " ")
  133. psQuotedCheckPt = "\'[^\']+\'"
  134. Set poQuotedCheckRegEx = New RegExp
  135. With poQuotedCheckRegEx
  136. .Global = True
  137. .IgnoreCase = True
  138. .Pattern = psQuotedCheckPt
  139. End with
  140. Set poStringCheckRegEx = New RegExp
  141. With poQuotedCheckRegEx
  142. .Global = True
  143. .IgnoreCase = True
  144. .Pattern = psQuotedCheckPt
  145. End with
  146. If True = poQuotedCheckRegEx.Test(sConcatArgs) Then
  147. Set apQuoted = poQuotedCheckRegEx.Execute(sConcatArgs)
  148. For each spBadQuotedPart in apQuoted
  149. spGoodQuotedPart = Replace(spBadQuotedPart," ", "0x20", 1, 1000)
  150. spGoodQuotedPart = Mid(spGoodQuotedPart,2, Len(spGoodQuotedPart) -2 )
  151. poStringCheckRegEx.Pattern = Replace(spBadQuotedPart, "\", "\\", 1 ,100)
  152. sConcatArgs = poStringCheckRegEx.Replace(sConcatArgs, spGoodQuotedPart)
  153. Next
  154. aRepArgs = Split(sConcatArgs, " ")
  155. oArgs = Array()
  156. Redim oArgs (ubound(aRepArgs) + 1)
  157. For nArg = 0 To ubound(aRepArgs)
  158. oArgs(nArg) = Replace(aRepArgs(nArg), "0x20", " ", 1, 100)
  159. Next
  160. reQuoteObjArgs = oArgs
  161. Else
  162. reQuoteObjArgs = objArgs
  163. End If
  164. End Function
  165. Public Sub GetParams(sFlags, sVarNames, objArgs)
  166. Dim sLabelVar, sFoundLabel, sArgsDictionary
  167. Dim poKnownSwitchRegEx, psMaskKnownSwitch, nArg, mma, nma, nextlen, objargsnamed
  168. Dim aFlags, aVarNames ' Arrays to split the sFlags and sVarNames
  169. Set poKnownSwitchRegEx = New RegExp
  170. Set sArgsDictionary = CreateObject("Scripting.Dictionary")
  171. psMaskKnownSwitch = "[-/]\w+:?\b"
  172. poKnownSwitchRegEx.Global = True
  173. poKnownSwitchRegEx.IgnoreCase = True
  174. poKnownSwitchRegEx.Pattern = psMaskKnownSwitch
  175. If 0 = ubound(objArgs) Then
  176. Exit Sub
  177. End If
  178. For nArg = 0 to uBound(objArgs)
  179. If True = poKnownSwitchRegEx.Test(objArgs(nArg)) Then
  180. Set mmA = poKnownSwitchRegEx.Execute(objArgs(nArg))
  181. If mma.Count <> 1 Then
  182. WScript.echo "Bad RegExp Count"
  183. Err.Raise (1937)
  184. Else
  185. For each nma in mma
  186. NextLen = nma.FirstIndex + nma.Length
  187. sFoundLabel = CStr(Mid(objArgs(nArg), _
  188. 2 + nma.FirstIndex, _
  189. nma.Length - 1))
  190. ' This is not If Right(sFoundLabel,1) = ":" Then
  191. ' required sFoundLabel = Left(sFoundLabel, len(sFoundLabel) - 1 )
  192. ' End If
  193. If NextLen <> len(objArgs(nArg)) Then
  194. sLabelVar = CStr(Mid(objArgs(nArg),NextLen + 1 ))
  195. Else
  196. sLabelVar = CInt(True)
  197. End If
  198. sArgsDictionary.add sFoundLabel, sLabelVar
  199. Next
  200. End If
  201. End If
  202. Next
  203. aFlags = split(sFlags)
  204. aVarNames = split(sVarNames)
  205. If Ubound(aFlags) <> Ubound(aVarNames) Then
  206. Exit Sub
  207. End If
  208. Dim tnCnt
  209. For tnCnt = 0 to Ubound(aFlags)
  210. If sArgsDictionary.Exists(aFlags(tnCnt)) Then
  211. FeedVar sArgsDictionary(aFlags(tnCnt)), aVarNames(tnCnt)
  212. End If
  213. Next
  214. Set sArgsDictionary = Nothing
  215. Set poKnownSwitchRegEx = Nothing
  216. End Sub
  217. Private Sub FeedVar(sLabelVar, sLabel)
  218. If VarType(sLabelVar) <> vbString Then
  219. If VarType(sLabelVar) = VBBoolean Then
  220. Execute(sLabel & "= CBool(" & sLabelVar & ")")
  221. Else
  222. Execute(sLabel & "=" & sLabelVar)
  223. End If
  224. Else
  225. Execute(sLabel & "=" & """" & sLabelVar & """" )
  226. End If
  227. End Sub
  228. ]]>
  229. </script>
  230. <script language="VBScript">
  231. <![CDATA[
  232. Public Function sURLDecoded (sTestPassInputv)
  233. Dim oHexBackDict, sOutPut
  234. Set oHexBackDict = CreateObject("Scripting.Dictionary")
  235. For nCnt = 32 To 64
  236. sOutPut = "%" & Hex(nCnt)
  237. oHexBackDict.Add sOutPut, Chr(nCnt)
  238. Next
  239. ''For Each sOutPut in oHexBackDict.Keys
  240. ''
  241. '' WScript.echo sOutPut & " -> " & oHexBackDict(sOutPut)
  242. ''
  243. ''Next
  244. For Each sOutPut in oHexBackDict.Keys
  245. sTestPassInputv = Replace(sTestPassInputv, sOutPut, oHexBackDict(sOutPut), 1, 1000)
  246. Next
  247. sURLDecoded = sTestPassInputv
  248. End Function
  249. ]]>
  250. </script>
  251. <script language="VBScript">
  252. <![CDATA[
  253. option explicit
  254. Dim opShell
  255. Dim sRegPathDir, oKeyList, aKeys, nCnt, sKey
  256. Dim spDomainUser, spDomainName
  257. Dim Help, Debug, siDomainUser, siDomainName, siPassword, sBClean
  258. Dim apCopyArgs, nRawArg
  259. Dim sTestPassInputv
  260. ''sTestPassInputv="v%21%202lar%40e"
  261. ''WScript.echo sURLDecoded(sTestPassInputv)
  262. ''WScript.quit
  263. sRegPathDir = CStr(GetResource("regpath"))
  264. aKeys = ReadResource("keys")
  265. Set opShell = WScript.CreateObject("WScript.Shell")
  266. apCopyArgs = Array()
  267. Redim apCopyArgs (Wscript.arguments.Count)
  268. For nRawArg = 0 to Wscript.arguments.Count - 1
  269. apCopyArgs(nRawArg) = Wscript.arguments(nRawArg)
  270. Next
  271. apCopyArgs = reQuoteObjArgs(apCopyArgs)
  272. Call GetParams("h d u: y: p: c", _
  273. "Help Debug siDomainUser siDomainName siPassword sbClean", _
  274. apCopyArgs)
  275. if Help <> "" Then
  276. ShowUsage
  277. End If
  278. Set oKeyList = CreateObject("Scripting.Dictionary")
  279. For nCnt = 0 to UBound(aKeys)
  280. oKeyList.add aKeys(nCnt), ""
  281. '' create keys but leave them undefined
  282. Next
  283. If "" <> siDomainUser Then
  284. oKeyList("DefaultUserName") = siDomainUser
  285. End If
  286. If "" <> siDomainName Then
  287. oKeyList("DefaultDomainName") = siDomainName
  288. End If
  289. If "" <> siPassword Then
  290. oKeyList("DefaultPassword") = sURLDecoded(siPassword)
  291. oKeyList("AutoAdminLogon") = "1"
  292. oKeyList("ForceAutoLogon") = "1"
  293. End If
  294. If True = sbClean Then
  295. oKeyList("ForceAutoLogon") = "0"
  296. oKeyList("AutoAdminLogon") = "0"
  297. For Each sKey in oKeyList.Keys
  298. If Debug Then
  299. WScript.echo sKey & "=" & oKeyList(sKey)
  300. End If
  301. Next
  302. End If
  303. If True = sbClean Then
  304. For Each sKey in oKeyList.Keys
  305. on error resume next
  306. err.clear
  307. If "" = oKeyList(sKey) Then
  308. opShell.RegWrite sRegPathDir & "\" & sKey, oKeyList(sKey) ,"REG_SZ"
  309. opShell.RegDelete sRegPathDir & "\" & sKey
  310. If Debug Then
  311. WScript.Echo sRegPathDir & "\" & sKey & " deleted"
  312. End If
  313. Else
  314. opShell.RegWrite sRegPathDir & "\" & sKey, oKeyList(sKey) ,"REG_SZ"
  315. If Debug Then
  316. WScript.Echo opShell.RegRead(sRegPathDir & "\" & sKey)
  317. End If
  318. End If
  319. Next
  320. Else
  321. For Each sKey in oKeyList.Keys
  322. If "" <> oKeyList(sKey) Then
  323. If Debug Then
  324. WScript.echo "Set " & sKey & " = " & oKeyList(sKey)
  325. End If
  326. opShell.RegWrite sRegPathDir & "\" & sKey, oKeyList(sKey) ,"REG_SZ"
  327. WScript.Echo sKey & "=" & opShell.RegRead(sRegPathDir & "\" & sKey)
  328. End If
  329. Next
  330. opShell.RegWrite sRegPathDir & "\" & "passwordexpirywarning", 0, "REG_DWORD"
  331. If Debug Then
  332. WScript.Echo "passwordexpirywarning=" & _
  333. opShell.RegRead(sRegPathDir & "\" & "passwordexpirywarning")
  334. End If
  335. End If
  336. Set opShell = nothing
  337. WScript.quit(0)
  338. ]]>
  339. </script>
  340. </job>
  341. </package>