其余所有的盘都只给于administrators和system用户的完全控制权限,删除其他所有用户并替换子目录。
d:\test(用户网站目录)继承现有属性并增加app_test_user和iis_test_user完全控制的权限并替换子目录。
以后每增加一个网站都以此类推。
但是,至此,system.io还是对c:\windows又读取权限的,(怀疑network servers用户属于users组,但是好多服务都要使用users组来执行的,所以不能把c:\windwos去掉users组的读取权限)但必须知道系统路径,有两种方案解决。
1、 再安装系统的时候使用无人值守安装,更换c:\windows默认安装路径,如更改为c:\testtest(要符合dos的命名规则,不能超过8个字符)。这个是必需的
2、 以下位置具有指派给 iis_wpg 的权限:
%windir%\help\iishelp\common – 读取
%windir%\iis temporary compressed files – 列出、读取、写入
%windir%\system32\inetsrv\asp compiled template – 读取
inetpub\wwwroot(或内容目录)- 读取、执行
此外,iis_wpg 还具有以下用户权限:
忽略遍历检查(sechangenotifyprivilege)
作为批处理作业登录(sebatchlogonright)
从网络访问此计算机(senetworklogonright)
当然两种方法结合起来算是最安全的方案,一般使用第一种方案已经算是很安全的,毕竟是用一个webshell来猜测8位字符的目录还是需要花费时间的。使用防火墙很容易就能察觉出来,并加以控制。
第二种可能根据所安装软件不同还要相应增加目录的读取权限,详细情况要根据软件来确定。
如果主机用户比较多,这将是一个相当大的劳动量,推荐使用程序来解决问题,下面给出网上不常见的针对iis应用程序池操作的代码和针对iis虚拟目录的操作代码。
操作iis应用程序池
| using system; using system.directoryservices; using system.reflection; namespace adsi1 { /// /// small class containing methods to configure iis. /// class configiis { /// /// the main entry point for the application. /// [stathread] //主程序入口,可以选择用哪些,我为了方便,全部功能都写上去了。 static void main(string[] args) { string apppoolname = "myapppool"; string newvdir1 = "myvdir"; directoryentry newvdir = createvdir(newvdir1); createapppool(apppoolname); assignapppool(newvdir, apppoolname); configapppool("stop",apppoolname); } //创建虚拟目录 static directoryentry createvdir (string vdirname) { directoryentry newvdir; directoryentry root=new directoryentry("iis://localhost/w3svc/1/root"); newvdir=root.children.add(vdirname, "iiswebvirtualdir"); newvdir.properties["path"][0]= "c:\\inetpub\\wwwroot"; newvdir.properties["accessscript"][0] = true; newvdir.commitchanges(); return newvdir; } //创建新的应用程序池。 static void createapppool(string apppoolname) { directoryentry newpool; directoryentry apppools=new directoryentry("iis://localhost/w3svc/apppools"); newpool=apppools.children.add(apppoolname, "iisapplicationpool"); newpool.commitchanges(); } static void assignapppool(directoryentry newvdir, string apppoolname) { object[] param={0, apppoolname, true}; newvdir.invoke("appcreate3", param); } //method是管理应用程序池的方法,有三种start、stop、recycle,而apppoolname是应用程序池名称 static void configapppool(string method,string apppoolname) { directoryentry apppool = new directoryentry("iis://localhost/w3svc/apppools"); directoryentry findpool = apppool.children.find(apppoolname,iisapplicationpool"); findpool.invoke(method,null); apppool.commitchanges(); apppool.close(); } //应用程序池的列表 static void apppoollist() { directoryentry apppool = new directoryentry("iis://localhost/w3svc/apppools"); foreach(directoryentry a in apppool.children) { console.writeline(a.name); } } private void vdirtoapppool() { directroryentry vd = new directoryentry("iis://localhost/w3svc/1/root/ccc"); console.writeline(vd.properties["apppoolid"].value.tostring()); } } } |
iis6操作的例子
|
using system;
本文关键:ASP.NET虚拟主机安全漏洞解决方案
相关方案
|