无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 559|回复: 12
打印 上一主题 下一主题

[讨论] 简单粗暴的PE下Administrator用户登录

  [复制链接]
跳转到指定楼层
1#
发表于 5 天前 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 Bluebells 于 2025-1-27 21:04 编辑

红毛樱木 帖子"最简单粗暴的PE下SYSTEM用户切换Administrator用户"的分析和进一步讨论
一楼内容为分析, 二楼内容为进一步探讨, 且二楼末尾提供有示例 WinPE

  1. SERV -wait ProfSvc
  2. LOOP #1=1,
  3. {*
  4.     SERV ?&ProfSvcState ProfSvc
  5.     MSTR * &ProfSvcState=<3>&ProfSvcState
  6.     IFEX #%&ProfSvcState%=4,
  7.     {*
  8.         EXIT LOOP
  9.     }!  
  10.     {*
  11.         WAIT 200
  12.     }
  13. }
复制代码
这段代码是确保 ProfSvc 服务项的状态为 SERVICE_RUNNING (正在运行), 不然就进入死循环
  1. REGI --init --ak HKLM\SECURITY\SAM\Domains\Builtin\Aliases\Members\\,&&Members
  2. ENVI &AdminSID=
  3. FIND *<>&Members,
  4. {*
  5.     FORX *NL &Members,&Member,
  6.     {*
  7.         FIND *<>&Member,
  8.         {*
  9.             FIND $%&Member%<>S-1-5,
  10.             {*
  11.                 ENVI~ &AdminSID=&Member
  12.                 ENVI< &AdminSID=-500
  13.                 EXIT FORX
  14.             }
  15.         }
  16.     }
  17. }
复制代码
这段代码获取 Administrator 用户的 SID 字符串
  1. ENVI &MAX_PATH=260
  2. SET$ &pszProfilePath=*%&MAX_PATH% 0
  3. CALC &cchProfilePath=%&MAX_PATH%
  4. CALL $--qd --ret:&&CreateProfileRet Userenv.dll,CreateProfile,$%&AdminSID%,$Administrator,*&pszProfilePath,#%&cchProfilePath%
复制代码
这段代码是调用 Userenv.dll 的 CreateProfile 函数创建 Administrator 的用户配置文件

CreateProfile 函数有四个参数, 其中第一个参数是"用户的 SID" (第二个代码段获取)
在调用 CreateProfile 函数时, ProfSvc 服务项的状态必须为 SERVICE_RUNNING, 否则无法调用该函数 (第一个代码段就是前置条件之一)

简单地说, 只要成功调用 CreateProfile 函数以创建 Administrator 的用户配置文件, 然后再运行 tsdiscon.exe 即可让所有支持 Administrator 用户登录的 Nt6pe 从 SYSTEM 切换到 Administrator

评分

参与人数 1无忧币 +10 收起 理由
kuer + 10 赞一个!

查看全部评分

2#
 楼主| 发表于 5 天前 | 只看该作者
本帖最后由 Bluebells 于 2025-1-28 00:03 编辑

直接简单粗暴地让PE以Administrator用户登录
其实以 Administrator 用户登录的前提是"本地计算机加入到工作组", 如果本地计算机未加入到"工作组"时使用 tsdiscon.exe, 就会出现 "指定的域不存在,或无法联系", 并卡在此处
如何让本地计算机加入到工作组? 可以调用 Netapi32.dll 的 NetJoinDomain 函数
  1. CALL $Netapi32.dll,NetJoinDomain,,WORKGROUP,,,,1
复制代码
注意在调用 NetJoinDomain 函数时, LanmanWorkstation 服务项的状态必须为 SERVICE_RUNNING
如果我们使用注册表查看 LanmanWorkstation 服务项的 Start 的数据, 会发现其默认值为 2, 即 SERVICE_AUTO_START (自动启动)
由于服务项的启动优先级问题, LanmanWorkstation 服务项通常会比较慢启动, 所以在早期直接调用 NetJoinDomain 函数时, 经常会失败
PS: 有些 PE 会在注册表项 HKEY_LOCAL_MACHINE\SYSTEM\Setup\AllowStart 中添加 LanmanWorkstation 子项以让 LanmanWorkstation 服务项启动得更早, 然而这种方法并不靠谱

因此我们可以仿效 红毛 的代码, 确保 LanmanWorkstation 服务项的状态为 SERVICE_RUNNING (正在运行)
  1. SERV -wait LanmanWorkstation
  2. LOOP #1=1,
  3. {*
  4.     SERV ?&LWState LanmanWorkstation
  5.     MSTR * &LWState=<3>&LWState
  6.     IFEX #%&LWState%=4,
  7.     {*
  8.         EXIT LOOP
  9.     }!  
  10.     {*
  11.         WAIT 200
  12.     }
  13. }
复制代码
其实也可以调用 net.exe 命令行工具
  1. SERV ?&LWState LanmanWorkstation
  2. MSTR * &LWState=<3>&LWState
  3. IFEX #%&LWState%=4,! EXEC -wait -hide %SystemRoot%\System32\net.exe start LanmanWorkstation
复制代码
PS: 有些人可能想到还可以用 sc.exe 命令行工具, 但 sc start 命令执行完毕后(无错误输出)并不能确保目标服务项的状态为 SERVICE_RUNNING
其实有更简便的方式让本地计算机加入到工作组, 就是调用 PE 中自带的 wpeutil.exe 命令行工具
  1. EXEC -wait -hide %SystemRoot%\System32\wpeutil.exe InitializeNetwork
复制代码
使用 wpeutil.exe 初始化 PE 网络环境时, 它会确保 LanmanWorkstation 服务项的状态为 SERVICE_RUNNING, 并让本地计算机加入到工作组
由于不确定 wpeutil 在初始化目标 PE 的网络环境时是否会遇到阻塞, 所以这里仅仅提一下, 并不推荐


结论:
先让计算机成功加入到工作组, 然后成功调用 CreateProfile 函数创建 Administrator 用户配置文件, 再运行 tsdiscon.exe 即可让所有支持 Administrator 用户登录的 Nt6pe 以 Administrator 用户登录
  1. SERV -wait LanmanWorkstation
  2. LOOP #1=1,
  3. {*
  4.     SERV ?&LWState LanmanWorkstation
  5.     MSTR * &LWState=<3>&LWState
  6.     IFEX #%&LWState%=4,
  7.     {*
  8.         EXIT LOOP
  9.     }!
  10.     {*
  11.         WAIT 200
  12.     }
  13. }
  14. CALL $Netapi32.dll,NetJoinDomain,,WORKGROUP,,,,1

  15. SERV -wait ProfSvc
  16. LOOP #1=1,
  17. {*
  18.     SERV ?&ProfSvcState ProfSvc
  19.     MSTR * &ProfSvcState=<3>&ProfSvcState
  20.     IFEX #%&ProfSvcState%=4,
  21.     {*
  22.         EXIT LOOP
  23.     }!  
  24.     {*
  25.         WAIT 200
  26.     }
  27. }

  28. REGI --init --ak HKLM\SECURITY\SAM\Domains\Builtin\Aliases\Members\\,&&Members
  29. ENVI &AdminSID=
  30. FIND *<>&Members,
  31. {*
  32.     FORX *NL &Members,&Member,
  33.     {*
  34.         FIND *<>&Member,
  35.         {*
  36.             FIND $%&Member%<>S-1-5,
  37.             {*
  38.                 ENVI~ &AdminSID=&Member
  39.                 ENVI< &AdminSID=-500
  40.                 EXIT FORX
  41.             }
  42.         }
  43.     }
  44. }

  45. ENVI &MAX_PATH=260
  46. SET$ &pszProfilePath=*%&MAX_PATH% 0
  47. CALC &cchProfilePath=%&MAX_PATH%
  48. CALL $--qd --ret:&&CreateProfileRet Userenv.dll,CreateProfile,$%&AdminSID%,$Administrator,*&pszProfilePath,#%&cchProfilePath%

  49. REGI $HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\\DefaultUserName=Administrator
  50. REGI $HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\\Userinit=userinit.exe,Pecmd.exe MAIN -user %SystemRoot%\System32\pecmd.ini,
  51. REGI #HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\\EnableSIHostIntegration=0
  52. REGI #HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList\\Guest=0

  53. EXEC -wait %SystemRoot%\System32\tsdiscon.exe
复制代码

分享一个示例 WinPE, 其基于论坛 Lightning 老大的 WIN10PE_X64_19043.1237_Network 制作
下载地址: https://www.123684.com/s/RglEjv-vJ6Ph 提取码: ONHj

回复

使用道具 举报

3#
 楼主| 发表于 5 天前 | 只看该作者
本帖最后由 Bluebells 于 2025-1-27 20:58 编辑

支持 Administrator 用户登录的 WinPE 的依赖文件
  1. \Windows\System32\activeds.dll
  2. \Windows\System32\adsldpc.dll
  3. \Windows\System32\AuthExt.dll
  4. \Windows\System32\batmeter.dll
  5. \Windows\System32\BCP47mrm.dll
  6. \Windows\System32\certca.dll
  7. \Windows\System32\certcli.dll
  8. \Windows\System32\CredProvCommonCore.dll
  9. \Windows\System32\CredProv2faHelper.dll
  10. \Windows\System32\CredProvDataModel.dll
  11. \Windows\System32\credprovhost.dll
  12. \Windows\System32\credprovs.dll
  13. \Windows\System32\credprovslegacy.dll
  14. \Windows\System32\dfscli.dll
  15. \Windows\System32\DiagnosticDataSettings.dll
  16. \Windows\System32\Faultrep.dll
  17. \Windows\System32\FontGlyphAnimator.dll
  18. \Windows\System32\gpsvc.dll
  19. \Windows\System32\imageres.dll
  20. \Windows\System32\InputHost.dll
  21. \Windows\System32\InputSwitch.dll
  22. \Windows\System32\joinutil.dll
  23. \Windows\System32\logoncli.dll
  24. \Windows\System32\LogonController.dll
  25. \Windows\System32\LogonUI.exe
  26. \Windows\System32\MrmCoreR.dll
  27. \Windows\System32\msiltcfg.dll
  28. \Windows\System32\netjoin.dll
  29. \Windows\System32\ninput.dll
  30. \Windows\System32\nlaapi.dll
  31. \Windows\System32\pfclient.dll
  32. \Windows\System32\profapi.dll
  33. \Windows\System32\profext.dll
  34. \Windows\System32\profsvc.dll
  35. \Windows\System32\profsvcext.dll
  36. \Windows\System32\samcli.dll
  37. \Windows\System32\seclogon.dll
  38. \Windows\System32\SensApi.dll
  39. \Windows\System32\SettingSyncCore.dll
  40. \Windows\System32\shacct.dll
  41. \Windows\System32\shsvcs.dll
  42. \Windows\System32\TextInputFramework.dll
  43. \Windows\System32\threadpoolwinrt.dll
  44. \Windows\System32\tsdiscon.exe
  45. \Windows\System32\umpdc.dll
  46. \Windows\System32\userinit.exe
  47. \Windows\System32\usermgr.dll
  48. \Windows\System32\usermgrcli.dll
  49. \Windows\System32\UserMgrProxy.dll
  50. \Windows\System32\wer.dll
  51. \Windows\System32\weretw.dll
  52. \Windows\System32\WerFault.exe
  53. \Windows\System32\wersvc.dll
  54. \Windows\System32\whoami.exe
  55. \Windows\System32\winbio.dll
  56. \Windows\System32\wincorlib.dll
  57. \Windows\System32\WindowManagementAPI.dll
  58. \Windows\System32\Windows.ApplicationModel.dll
  59. \Windows\System32\Windows.Globalization.Fontgroups.dll
  60. \Windows\System32\Windows.Internal.UI.Logon.ProxyStub.dll
  61. \Windows\System32\Windows.System.RemoteDesktop.dll
  62. \Windows\System32\Windows.UI.CredDialogController.dll
  63. \Windows\System32\Windows.UI.dll
  64. \Windows\System32\Windows.UI.Immersive.dll
  65. \Windows\System32\Windows.UI.Logon.dll
  66. \Windows\System32\Windows.UI.Xaml.dll
  67. \Windows\System32\Windows.UI.Xaml.Controls.dll
  68. \Windows\System32\Windows.UI.Xaml.Resources.*.dll
  69. \Windows\System32\Windows.UI.XamlHost.dll
  70. \Windows\System32\wmiclnt.dll
  71. \Windows\System32\en-US\adsldpc.dll.mui
  72. \Windows\System32\en-US\gpsvc.dll.mui
  73. \Windows\System32\en-US\imageres.dll.mui
  74. \Windows\System32\en-US\netjoin.dll.mui
  75. \Windows\System32\en-US\Ninput.dll.mui
  76. \Windows\System32\en-US\SettingSyncCore.dll.mui
  77. \Windows\System32\en-US\tsdiscon.exe.mui
  78. \Windows\System32\en-US\whoami.exe.mui
  79. \Windows\System32\en-US\Windows.UI.dll.mui
  80. \Windows\System32\en-US\Windows.UI.Xaml.Controls.dll.mui
  81. \Windows\System32\en-US\windows.ui.xaml.dll.mui
  82. \Windows\System32\zh-CN\activeds.dll.mui
  83. \Windows\System32\zh-CN\AuthExt.dll.mui
  84. \Windows\System32\zh-CN\batmeter.dll.mui
  85. \Windows\System32\zh-CN\certca.dll.mui
  86. \Windows\System32\zh-CN\certcli.dll.mui
  87. \Windows\System32\zh-CN\CredProv2faHelper.dll.mui
  88. \Windows\System32\zh-CN\credprovhost.dll.mui
  89. \Windows\System32\zh-CN\credprovs.dll.mui
  90. \Windows\System32\zh-CN\credprovslegacy.dll.mui
  91. \Windows\System32\zh-CN\faultrep.dll.mui
  92. \Windows\System32\zh-CN\gpsvc.dll.mui
  93. \Windows\System32\zh-CN\InputSwitch.dll.mui
  94. \Windows\System32\zh-CN\LogonController.dll.mui
  95. \Windows\System32\zh-CN\netjoin.dll.mui
  96. \Windows\System32\zh-CN\profext.dll.mui
  97. \Windows\System32\zh-CN\profsvc.dll.mui
  98. \Windows\System32\zh-CN\seclogon.dll.mui
  99. \Windows\System32\zh-CN\shsvcs.dll.mui
  100. \Windows\System32\zh-CN\tsdiscon.exe.mui
  101. \Windows\System32\zh-CN\userinit.exe.mui
  102. \Windows\System32\zh-CN\usermgr.dll.mui
  103. \Windows\System32\zh-CN\wer.dll.mui
  104. \Windows\System32\zh-CN\WerFault.exe.mui
  105. \Windows\System32\zh-CN\wersvc.dll.mui
  106. \Windows\System32\zh-CN\whoami.exe.mui
  107. \Windows\System32\zh-CN\winbio.dll.mui
  108. \Windows\System32\zh-CN\Windows.ApplicationModel.dll.mui
  109. \Windows\System32\zh-CN\Windows.UI.CredDialogController.dll.mui
  110. \Windows\System32\zh-CN\Windows.UI.Immersive.dll.mui
  111. \Windows\System32\zh-CN\Windows.UI.Xaml.Controls.dll.mui
  112. \Windows\System32\zh-CN\windows.ui.xaml.dll.mui
  113. \Windows\SystemResources\batmeter.dll.mun
  114. \Windows\SystemResources\imageres.dll.mun
  115. \Windows\SystemResources\shsvcs.dll.mun
  116. \Windows\SystemResources\Windows.UI.Immersive.dll.mun
  117. \Windows\SystemResources\Windows.UI.Logon
复制代码
PS: imageres.dll 文件必须使用 Windows 系统中的完整库文件, 而不能使用 WinRE(或 WinPE) 中的精简库文件

以下文件可能会提高 PE 以 Administrator 用户登录的兼容性?
  1. \Windows\System32\AppResolver.dll
  2. \Windows\System32\wbadmin.exe
  3. \Windows\System32\webservices.dll
  4. \Windows\System32\werdiagcontroller.dll
  5. \Windows\System32\Windows.Devices.Midi.dll
  6. \Windows\System32\windowsperformancerecordercontrol.dll
  7. \Windows\System32\winhttpcom.dll
  8. \Windows\System32\wuceffects.dll
  9. \Windows\System32\en-US\wbadmin.exe.mui
  10. \Windows\System32\zh-CN\AppResolver.dll.mui
  11. \Windows\System32\zh-CN\wbadmin.exe.mui
  12. \Windows\System32\zh-CN\webservices.dll.mui
复制代码
支持 Administrator 用户登录的 PE 好像需要 DWM 组件支持?
  1. \Windows\System32\d2d1.dll
  2. \Windows\System32\d3d10warp.dll
  3. \Windows\System32\D3DCompiler_47.dll
  4. \Windows\System32\DXCore.dll
  5. \Windows\System32\zh-CN\d2d1.dll.mui

  6. \Windows\System32\CoreMessaging.dll
  7. \Windows\System32\CoreUIComponents.dll
  8. \Windows\System32\dcomp.dll
  9. \Windows\System32\dwm.exe
  10. \Windows\System32\dwmcore.dll
  11. \Windows\System32\dwmghost.dll
  12. \Windows\System32\dwminit.dll
  13. \Windows\System32\dwmredir.dll
  14. \Windows\System32\hotplug.dll
  15. \Windows\System32\ISM.dll
  16. \Windows\System32\rmclient.dll
  17. \Windows\System32\themecpl.dll
  18. \Windows\System32\themeservice.dll
  19. \Windows\System32\themeui.dll
  20. \Windows\System32\twinapi.appcore.dll
  21. \Windows\System32\twinui.dll
  22. \Windows\System32\ubpm.dll
  23. \Windows\System32\uDWM.dll
  24. \Windows\System32\wdi.dll
  25. \Windows\System32\Windows.Gaming.Input.dll
  26. \Windows\System32\Windows.UI.Immersive.dll
  27. \Windows\System32\en-US\Windows.Gaming.Input.dll.mui
  28. \Windows\System32\zh-CN\dwm.exe.mui
  29. \Windows\System32\zh-CN\dwmcore.dll.mui
  30. \Windows\System32\zh-CN\dwminit.dll.mui
  31. \Windows\System32\zh-CN\dwmredir.dll.mui
  32. \Windows\System32\zh-CN\hotplug.dll.mui
  33. \Windows\System32\zh-CN\themecpl.dll.mui
  34. \Windows\System32\zh-CN\themeservice.dll.mui
  35. \Windows\System32\zh-CN\themeui.dll.mui
  36. \Windows\System32\zh-CN\twinapi.appcore.dll.mui
  37. \Windows\System32\zh-CN\twinui.dll.mui
  38. \Windows\System32\zh-CN\ubpm.dll.mui
  39. \Windows\System32\zh-CN\uDWM.dll.mui
  40. \Windows\System32\zh-CN\wdi.dll.mui
  41. \Windows\System32\zh-CN\Windows.UI.Immersive.dll.mui
  42. \Windows\SystemResources\dwmcore.dll.mun
  43. \Windows\SystemResources\themecpl.dll.mun
  44. \Windows\SystemResources\themeui.dll.mun
  45. \Windows\SystemResources\twinui.dll.mun
  46. \Windows\SystemResources\Windows.UI.Immersive.dll.mun
复制代码

回复

使用道具 举报

4#
 楼主| 发表于 5 天前 | 只看该作者
请勿占楼, 待编辑
回复

使用道具 举报

5#
发表于 5 天前 | 只看该作者
应该非常不错的,制作自己的双用户的PE的一直是我想作的,有时间制作PE时候这个是必备的,十分感谢大佬分享!

点评

制作自己的双用户的PE,这几天我刚刚折腾出来 http://bbs.wuyou.net/forum.php?mod=viewthread&tid=439445&extra=&page=6  详情 回复 发表于 5 天前
回复

使用道具 举报

6#
发表于 5 天前 | 只看该作者
呆萌鼠 发表于 2025-1-27 20:01
应该非常不错的,制作自己的双用户的PE的一直是我想作的,有时间制作PE时候这个是必备的,十分感谢大佬分享 ...

制作自己的双用户的PE,这几天我刚刚折腾出来

http://bbs.wuyou.net/forum.php?m ... p;extra=&page=6

点评

十分感谢分享!  发表于 5 天前
回复

使用道具 举报

7#
发表于 5 天前 | 只看该作者
感谢分享
回复

使用道具 举报

8#
发表于 5 天前 | 只看该作者
谢谢分享
回复

使用道具 举报

9#
发表于 5 天前 | 只看该作者
谢谢分享
回复

使用道具 举报

10#
发表于 3 天前 | 只看该作者

谢谢分享
回复

使用道具 举报

11#
发表于 前天 23:35 | 只看该作者
感谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2025-2-1 23:45

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表