8/19/2007

“以非特权用户身份运行eMule”是如何实现的

eMule的用户大概很少用到“选项/安全/以非特权用户身份运行eMule”,我试了下,它帮我生成了一个emule_secure用户,并且启动eMule之后查看windows任务管理器发现eMule是以这个emule_secure用户名运行的。

俺以前知道个命令行RunAs,但是这个RunAs每次运行都要俺输入密码,着实不便,而eMule只在选项里选选就能实现以其它用户身份运行,真是太酷了!

上google查了查,发现现在这种搞法很时尚,很多服务器程序都改为以非特权用户身份运行以增强安全性。

http://sourceforge.net/projects/emule 下载回emule0.45b的源代码,看了看,相关文件有两个:SecRunAsUser.cpp,SecRunAsUser.h,主要用的是Advapi32.dll里的CreateProcessWithLogonW:
typedef BOOL (WINAPI* TCreateProcessWithLogonW)(
LPCWSTR lpUsername, // user's name
LPCWSTR lpDomain, // user's domain
LPCWSTR lpPassword, // user's password
DWORD dwLogonFlags, // logon option
LPCWSTR lpApplicationName, // executable module name
LPWSTR lpCommandLine, // command-line string
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCWSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFOW lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInfo // process information
);


微软的MSDN有Knowledge Base:HOWTO: Start a Process as Another User from Visual Basic

俄国人有Delphi的例子,不懂俄语,大意好像是做一个rootkit以其它用户运行,http://forum.sources.ru/index.php?act=Print&client=printer&f=12&t=62774

没有评论: