无忧启动论坛
标题:
简单粗暴的PE下Administrator用户登录
[打印本页]
作者:
Bluebells
时间:
2025-1-27 19:52
标题:
简单粗暴的PE下Administrator用户登录
本帖最后由 Bluebells 于 2025-1-27 21:04 编辑
对
红毛樱木
帖子"
最简单粗暴的PE下SYSTEM用户切换Administrator用户
"的分析和进一步讨论
一楼内容为分析, 二楼内容为进一步探讨, 且二楼末尾提供有示例 WinPE
SERV -wait ProfSvc
LOOP #1=1,
{*
SERV ?&ProfSvcState ProfSvc
MSTR * &ProfSvcState=<3>&ProfSvcState
IFEX #%&ProfSvcState%=4,
{*
EXIT LOOP
}!
{*
WAIT 200
}
}
复制代码
这段代码是确保 ProfSvc 服务项的状态为 SERVICE_RUNNING (正在运行), 不然就进入死循环
REGI --init --ak HKLM\SECURITY\SAM\Domains\Builtin\Aliases\Members\\,&&Members
ENVI &AdminSID=
FIND *<>&Members,
{*
FORX *NL &Members,&Member,
{*
FIND *<>&Member,
{*
FIND $%&Member%<>S-1-5,
{*
ENVI~ &AdminSID=&Member
ENVI< &AdminSID=-500
EXIT FORX
}
}
}
}
复制代码
这段代码获取 Administrator 用户的 SID 字符串
ENVI &MAX_PATH=260
SET$ &pszProfilePath=*%&MAX_PATH% 0
CALC &cchProfilePath=%&MAX_PATH%
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
作者:
Bluebells
时间:
2025-1-27 19:52
本帖最后由 Bluebells 于 2025-1-28 00:03 编辑
直接简单粗暴地让PE以Administrator用户登录
其实以 Administrator 用户登录的前提是"本地计算机加入到工作组", 如果本地计算机未加入到"工作组"时使用 tsdiscon.exe, 就会出现 "指定的域不存在,或无法联系", 并卡在此处
如何让本地计算机加入到工作组? 可以调用 Netapi32.dll 的 NetJoinDomain 函数
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 (正在运行)
SERV -wait LanmanWorkstation
LOOP #1=1,
{*
SERV ?&LWState LanmanWorkstation
MSTR * &LWState=<3>&LWState
IFEX #%&LWState%=4,
{*
EXIT LOOP
}!
{*
WAIT 200
}
}
复制代码
其实也可以调用 net.exe 命令行工具
SERV ?&LWState LanmanWorkstation
MSTR * &LWState=<3>&LWState
IFEX #%&LWState%=4,! EXEC -wait -hide %SystemRoot%\System32\net.exe start LanmanWorkstation
复制代码
PS: 有些人可能想到还可以用 sc.exe 命令行工具, 但 sc start 命令执行完毕后(无错误输出)并不能确保目标服务项的状态为 SERVICE_RUNNING
其实有更简便的方式让本地计算机加入到工作组, 就是调用 PE 中自带的 wpeutil.exe 命令行工具
EXEC -wait -hide %SystemRoot%\System32\wpeutil.exe InitializeNetwork
复制代码
使用 wpeutil.exe 初始化 PE 网络环境时, 它会确保 LanmanWorkstation 服务项的状态为 SERVICE_RUNNING, 并让本地计算机加入到工作组
由于不确定 wpeutil 在初始化目标 PE 的网络环境时是否会遇到阻塞, 所以这里仅仅提一下, 并不推荐
结论:
先让计算机成功加入到工作组, 然后成功调用 CreateProfile 函数创建 Administrator 用户配置文件, 再运行 tsdiscon.exe 即可让所有支持 Administrator 用户登录的 Nt6pe 以 Administrator 用户登录
SERV -wait LanmanWorkstation
LOOP #1=1,
{*
SERV ?&LWState LanmanWorkstation
MSTR * &LWState=<3>&LWState
IFEX #%&LWState%=4,
{*
EXIT LOOP
}!
{*
WAIT 200
}
}
CALL $Netapi32.dll,NetJoinDomain,,WORKGROUP,,,,1
SERV -wait ProfSvc
LOOP #1=1,
{*
SERV ?&ProfSvcState ProfSvc
MSTR * &ProfSvcState=<3>&ProfSvcState
IFEX #%&ProfSvcState%=4,
{*
EXIT LOOP
}!
{*
WAIT 200
}
}
REGI --init --ak HKLM\SECURITY\SAM\Domains\Builtin\Aliases\Members\\,&&Members
ENVI &AdminSID=
FIND *<>&Members,
{*
FORX *NL &Members,&Member,
{*
FIND *<>&Member,
{*
FIND $%&Member%<>S-1-5,
{*
ENVI~ &AdminSID=&Member
ENVI< &AdminSID=-500
EXIT FORX
}
}
}
}
ENVI &MAX_PATH=260
SET$ &pszProfilePath=*%&MAX_PATH% 0
CALC &cchProfilePath=%&MAX_PATH%
CALL $--qd --ret:&&CreateProfileRet Userenv.dll,CreateProfile,$%&AdminSID%,$Administrator,*&pszProfilePath,#%&cchProfilePath%
REGI $HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\\DefaultUserName=Administrator
REGI $HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\\Userinit=userinit.exe,Pecmd.exe MAIN -user %SystemRoot%\System32\pecmd.ini,
REGI #HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\\EnableSIHostIntegration=0
REGI #HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList\\Guest=0
EXEC -wait %SystemRoot%\System32\tsdiscon.exe
复制代码
分享一个示例 WinPE, 其基于论坛
Lightning
老大的
WIN10PE_X64_19043.1237_Network
制作
下载地址:
https://www.123684.com/s/RglEjv-vJ6Ph
提取码: ONHj
作者:
Bluebells
时间:
2025-1-27 19:52
本帖最后由 Bluebells 于 2025-1-27 20:58 编辑
支持 Administrator 用户登录的 WinPE 的依赖文件
\Windows\System32\activeds.dll
\Windows\System32\adsldpc.dll
\Windows\System32\AuthExt.dll
\Windows\System32\batmeter.dll
\Windows\System32\BCP47mrm.dll
\Windows\System32\certca.dll
\Windows\System32\certcli.dll
\Windows\System32\CredProvCommonCore.dll
\Windows\System32\CredProv2faHelper.dll
\Windows\System32\CredProvDataModel.dll
\Windows\System32\credprovhost.dll
\Windows\System32\credprovs.dll
\Windows\System32\credprovslegacy.dll
\Windows\System32\dfscli.dll
\Windows\System32\DiagnosticDataSettings.dll
\Windows\System32\Faultrep.dll
\Windows\System32\FontGlyphAnimator.dll
\Windows\System32\gpsvc.dll
\Windows\System32\imageres.dll
\Windows\System32\InputHost.dll
\Windows\System32\InputSwitch.dll
\Windows\System32\joinutil.dll
\Windows\System32\logoncli.dll
\Windows\System32\LogonController.dll
\Windows\System32\LogonUI.exe
\Windows\System32\MrmCoreR.dll
\Windows\System32\msiltcfg.dll
\Windows\System32\netjoin.dll
\Windows\System32\ninput.dll
\Windows\System32\nlaapi.dll
\Windows\System32\pfclient.dll
\Windows\System32\profapi.dll
\Windows\System32\profext.dll
\Windows\System32\profsvc.dll
\Windows\System32\profsvcext.dll
\Windows\System32\samcli.dll
\Windows\System32\seclogon.dll
\Windows\System32\SensApi.dll
\Windows\System32\SettingSyncCore.dll
\Windows\System32\shacct.dll
\Windows\System32\shsvcs.dll
\Windows\System32\TextInputFramework.dll
\Windows\System32\threadpoolwinrt.dll
\Windows\System32\tsdiscon.exe
\Windows\System32\umpdc.dll
\Windows\System32\userinit.exe
\Windows\System32\usermgr.dll
\Windows\System32\usermgrcli.dll
\Windows\System32\UserMgrProxy.dll
\Windows\System32\wer.dll
\Windows\System32\weretw.dll
\Windows\System32\WerFault.exe
\Windows\System32\wersvc.dll
\Windows\System32\whoami.exe
\Windows\System32\winbio.dll
\Windows\System32\wincorlib.dll
\Windows\System32\WindowManagementAPI.dll
\Windows\System32\Windows.ApplicationModel.dll
\Windows\System32\Windows.Globalization.Fontgroups.dll
\Windows\System32\Windows.Internal.UI.Logon.ProxyStub.dll
\Windows\System32\Windows.System.RemoteDesktop.dll
\Windows\System32\Windows.UI.CredDialogController.dll
\Windows\System32\Windows.UI.dll
\Windows\System32\Windows.UI.Immersive.dll
\Windows\System32\Windows.UI.Logon.dll
\Windows\System32\Windows.UI.Xaml.dll
\Windows\System32\Windows.UI.Xaml.Controls.dll
\Windows\System32\Windows.UI.Xaml.Resources.*.dll
\Windows\System32\Windows.UI.XamlHost.dll
\Windows\System32\wmiclnt.dll
\Windows\System32\en-US\adsldpc.dll.mui
\Windows\System32\en-US\gpsvc.dll.mui
\Windows\System32\en-US\imageres.dll.mui
\Windows\System32\en-US\netjoin.dll.mui
\Windows\System32\en-US\Ninput.dll.mui
\Windows\System32\en-US\SettingSyncCore.dll.mui
\Windows\System32\en-US\tsdiscon.exe.mui
\Windows\System32\en-US\whoami.exe.mui
\Windows\System32\en-US\Windows.UI.dll.mui
\Windows\System32\en-US\Windows.UI.Xaml.Controls.dll.mui
\Windows\System32\en-US\windows.ui.xaml.dll.mui
\Windows\System32\zh-CN\activeds.dll.mui
\Windows\System32\zh-CN\AuthExt.dll.mui
\Windows\System32\zh-CN\batmeter.dll.mui
\Windows\System32\zh-CN\certca.dll.mui
\Windows\System32\zh-CN\certcli.dll.mui
\Windows\System32\zh-CN\CredProv2faHelper.dll.mui
\Windows\System32\zh-CN\credprovhost.dll.mui
\Windows\System32\zh-CN\credprovs.dll.mui
\Windows\System32\zh-CN\credprovslegacy.dll.mui
\Windows\System32\zh-CN\faultrep.dll.mui
\Windows\System32\zh-CN\gpsvc.dll.mui
\Windows\System32\zh-CN\InputSwitch.dll.mui
\Windows\System32\zh-CN\LogonController.dll.mui
\Windows\System32\zh-CN\netjoin.dll.mui
\Windows\System32\zh-CN\profext.dll.mui
\Windows\System32\zh-CN\profsvc.dll.mui
\Windows\System32\zh-CN\seclogon.dll.mui
\Windows\System32\zh-CN\shsvcs.dll.mui
\Windows\System32\zh-CN\tsdiscon.exe.mui
\Windows\System32\zh-CN\userinit.exe.mui
\Windows\System32\zh-CN\usermgr.dll.mui
\Windows\System32\zh-CN\wer.dll.mui
\Windows\System32\zh-CN\WerFault.exe.mui
\Windows\System32\zh-CN\wersvc.dll.mui
\Windows\System32\zh-CN\whoami.exe.mui
\Windows\System32\zh-CN\winbio.dll.mui
\Windows\System32\zh-CN\Windows.ApplicationModel.dll.mui
\Windows\System32\zh-CN\Windows.UI.CredDialogController.dll.mui
\Windows\System32\zh-CN\Windows.UI.Immersive.dll.mui
\Windows\System32\zh-CN\Windows.UI.Xaml.Controls.dll.mui
\Windows\System32\zh-CN\windows.ui.xaml.dll.mui
\Windows\SystemResources\batmeter.dll.mun
\Windows\SystemResources\imageres.dll.mun
\Windows\SystemResources\shsvcs.dll.mun
\Windows\SystemResources\Windows.UI.Immersive.dll.mun
\Windows\SystemResources\Windows.UI.Logon
复制代码
PS: imageres.dll 文件必须使用 Windows 系统中的完整库文件, 而不能使用 WinRE(或 WinPE) 中的精简库文件
以下文件可能会提高 PE 以 Administrator 用户登录的兼容性?
\Windows\System32\AppResolver.dll
\Windows\System32\wbadmin.exe
\Windows\System32\webservices.dll
\Windows\System32\werdiagcontroller.dll
\Windows\System32\Windows.Devices.Midi.dll
\Windows\System32\windowsperformancerecordercontrol.dll
\Windows\System32\winhttpcom.dll
\Windows\System32\wuceffects.dll
\Windows\System32\en-US\wbadmin.exe.mui
\Windows\System32\zh-CN\AppResolver.dll.mui
\Windows\System32\zh-CN\wbadmin.exe.mui
\Windows\System32\zh-CN\webservices.dll.mui
复制代码
支持 Administrator 用户登录的 PE 好像需要 DWM 组件支持?
\Windows\System32\d2d1.dll
\Windows\System32\d3d10warp.dll
\Windows\System32\D3DCompiler_47.dll
\Windows\System32\DXCore.dll
\Windows\System32\zh-CN\d2d1.dll.mui
\Windows\System32\CoreMessaging.dll
\Windows\System32\CoreUIComponents.dll
\Windows\System32\dcomp.dll
\Windows\System32\dwm.exe
\Windows\System32\dwmcore.dll
\Windows\System32\dwmghost.dll
\Windows\System32\dwminit.dll
\Windows\System32\dwmredir.dll
\Windows\System32\hotplug.dll
\Windows\System32\ISM.dll
\Windows\System32\rmclient.dll
\Windows\System32\themecpl.dll
\Windows\System32\themeservice.dll
\Windows\System32\themeui.dll
\Windows\System32\twinapi.appcore.dll
\Windows\System32\twinui.dll
\Windows\System32\ubpm.dll
\Windows\System32\uDWM.dll
\Windows\System32\wdi.dll
\Windows\System32\Windows.Gaming.Input.dll
\Windows\System32\Windows.UI.Immersive.dll
\Windows\System32\en-US\Windows.Gaming.Input.dll.mui
\Windows\System32\zh-CN\dwm.exe.mui
\Windows\System32\zh-CN\dwmcore.dll.mui
\Windows\System32\zh-CN\dwminit.dll.mui
\Windows\System32\zh-CN\dwmredir.dll.mui
\Windows\System32\zh-CN\hotplug.dll.mui
\Windows\System32\zh-CN\themecpl.dll.mui
\Windows\System32\zh-CN\themeservice.dll.mui
\Windows\System32\zh-CN\themeui.dll.mui
\Windows\System32\zh-CN\twinapi.appcore.dll.mui
\Windows\System32\zh-CN\twinui.dll.mui
\Windows\System32\zh-CN\ubpm.dll.mui
\Windows\System32\zh-CN\uDWM.dll.mui
\Windows\System32\zh-CN\wdi.dll.mui
\Windows\System32\zh-CN\Windows.UI.Immersive.dll.mui
\Windows\SystemResources\dwmcore.dll.mun
\Windows\SystemResources\themecpl.dll.mun
\Windows\SystemResources\themeui.dll.mun
\Windows\SystemResources\twinui.dll.mun
\Windows\SystemResources\Windows.UI.Immersive.dll.mun
复制代码
作者:
Bluebells
时间:
2025-1-27 19:53
请勿占楼, 待编辑
作者:
呆萌鼠
时间:
2025-1-27 20:01
应该非常不错的,制作自己的双用户的PE的一直是我想作的,有时间制作PE时候这个是必备的,十分感谢大佬分享!
作者:
martin313
时间:
2025-1-27 20:04
呆萌鼠 发表于 2025-1-27 20:01
应该非常不错的,制作自己的双用户的PE的一直是我想作的,有时间制作PE时候这个是必备的,十分感谢大佬分享 ...
制作自己的双用户的PE,这几天我刚刚折腾出来
http://bbs.wuyou.net/forum.php?m ... p;extra=&page=6
作者:
小灰兔
时间:
2025-1-27 20:17
感谢分享
作者:
youxia1220
时间:
2025-1-27 22:14
谢谢分享
作者:
yc2428
时间:
2025-1-27 23:38
谢谢分享
作者:
chairmansu
时间:
2025-1-29 13:45
谢谢分享
作者:
cena
时间:
2025-1-30 23:35
感谢分享
作者:
lm8dir
时间:
2025-2-8 16:58
楼主说的很简单,但是我看一点都不简单。
欢迎光临 无忧启动论坛 (http://bbs.wuyou.net/)
Powered by Discuz! X3.3