黑客风云——风云网络
设为首页 加入收藏 我要投稿 网站地图

您现在的位置: 黑客风云 >> 黑客文章 >> 黑客入门 >> 电脑新手 >> 正文
·没有路由密码权限时的鸽08-23·上网安全 Vista自我防范10-11
·让濒临崩溃的Windows XP10-11·有备无患,快速自制救急10-11
·要你好看!Windows看图工10-11·空间赞助网提供不同类型10-11
·讨论net.exe和net1.exe的10-10·让3389远程桌面传输更通10-10
·巧妙入侵渗透赌博站10-10·Aspx空间扫权限工具10-10
·Windows2003最新提权工具10-10·易淘乐提供100M免费全能10-10
·系统开机密码忘了不着急10-09·中意网络提供免费100M免10-09
·与众不同 Windows XP开始10-08·让桌面图标翻跟斗 在XP上10-08
·上海宽元站长资助计划-提10-08·个性化Windows XP的任务10-07
·趣盘提供3G免费网络硬盘10-07·秀山热线提供200MB免费全10-07
·一次艰辛的提权过程10-06·成功入侵IT大卖场的渗透10-06
·mysqlhack- MYSQL利用工10-06·lanker一句话PHP后门客户10-06
·WIXI提供3G免费多媒体网10-06·新人网络提供100M/ftp免10-06
·如何利用QQ带来高流量10-05·UuShare提供免费网络文件10-05
[推荐]命令行下建立虚拟目录
        ★★★★★

命令行下建立虚拟目录

文章整理发布:黑客风云 文章来源:www.05112.com 更新时间:2006-11-25 10:24:06
很久,很久没有和大家聊天了,很想大家的。见面先就给大家送个小礼吧。其实也不是什么好东西。
在研究和学习中进步,没有研究,没有深入的去了解,就没有进步。认真的学习态度+穷追不舍+十万个为什么。
得到的结果就是成就!
好了,屁话放了太多了。明白的人,不看上面的话都明白。不明白的人,看了也许永远也不会明白。

系统中有个VBS也可以实现这样的功能的。不过我认为,如果在台虚拟主机中,存在多个网站的情况下。
建立虚拟目录,也只能在第一个默认的站点中。一般情况下虚拟主机默认是关掉的。也就是你建好了,通过HTTP也不能访问。
从MSDN中,我找到了一些相关的技术资料,写了个小工具。可以建立在其它站点中。这里看来说起来有点混乱。

我举例给大家说说吧。
拿个虚拟主机的 Internet 信息服务中的列表给大家看看就明白了

+默认 web 站点(已停止)
+管理 web 站点(已停止)
+163.com
+263.com
+363.com

好,上面大家看到了,有三个站点是开放的。而前面那个默认的已经被关闭了。
这时,我们用VBS建立虚拟目录,是建立在默认的站点中,而站点被停止了,所以建立成功后,也不能访问。
比如:我们怎么能在263.com这个站中,建立一个目录,比如:VDIR,通过http://www.163.com/VDIR就可以访问了呢?
通过查找资料,我得到了,在建立的时候,允许指定一个序号,比如:1..N

1 : 表示,在默认的站点中,然后按着这个顺序来,而363.com对应的序号就是5.
明白了这个道理后,用程序来实现这个功能就比较简单了。当然,你会说,那么我想在263.com这个站中,建立。
但是我不知道,这个站对应的序号是多少,对于这个问题,我们只能从序号3开始一直往下建立,(1,2对应的是前面默认的)
当建立一个后,可以读出他的配置信息,返回给大家。建一个后,你就明白是不是建立在你想要建的那个站中,如果不是。
也可以把他删掉。再增加序号。:)(有没有一个工具,可以在命令行下,实现把所有的主机站点信息,比如:名称,对应目录之类的列出来?原理差不多,你看完代码应该会写了)

以下是代码:
program VDir;

{$APPTYPE CONSOLE}

uses
ActiveX,SysUtils,ComObj;
Var
VName,
VPath,
Vattrib : String;

createVpath : Boolean;
WebIndex : integer;

Procedure ShowHelp;
Begin
WriteLn('=========== VDir by CYFD! ============');
WriteLn('');
WriteLn('Useag:'+ParamStr(0)+' <-n:VName> <-p:VPath> <-i:WebIndex> <-c:CmdType> [-r:Vattrib]');
WriteLn('');
WriteLn('Sample:'+ParamStr(0)+' -n:yfd -p:c:\ -i:1 -c:1 -r:0,1,3');
WriteLn('');
WriteLn(' CmdType :');
WriteLn(' 1 : create');
WriteLn(' 0 : delete');
WriteLn(' Vattrib :');
WriteLn(' 0 : AccessScript');
WriteLn(' 1 : AccessRead');
WriteLn(' 2 : AccessWrite');
WriteLn(' 3 : AccessExecute');
WriteLn(' 4 : EnableDirBrowsing');
End;

Procedure ParseParam(Str : String);
var
tStr : String;
Begin
tStr := lowercase(Copy(Str,1,3));
if tStr='-n:' then
VName := Copy(Str,4,Length(Str));
if tStr='-p:' then
VPath := Copy(Str,4,Length(Str));
if tStr='-c:' then
createVpath := StrToIntDef(Copy(Str,4,Length(Str)),1) = 1;
if tStr='-r:' then
Vattrib := Copy(Str,4,Length(Str));
if tStr='-i:' then
WebIndex := StrToIntDef(Copy(Str,4,Length(Str)),1);

End;

Function GetStrForSpace(SourceStr :String ; JGZF:char ; Index:integer):String;
var
Pchar1 : pchar;
i , count : integer;
cStr : string;
begin
Count := 0;
Pchar1 := pchar(SourceStr);
cStr := '';
for i:=0 to length(Pchar1)-1 do begin
if pchar1 = JGZF then
begin
Count := Count + 1;
if Count = Index then begin
break;
end;
end
else if Count = Index -1 then cStr := cStr + pchar1;
end;
Result := cStr;
end;

procedure createVDir(Vdirpath:string);
var
WebSite, WebServer, WebRoot, VDir,Binds: Variant;
BindStr : String;
begin
Try
WebSite := createOleObject('IISNamespace');
WebSite := WebSite.GetObject('IIsWebService', 'localhost/w3svc');
WebServer := WebSite.GetObject('IIsWebServer', IntTostr(WebIndex));

// 这里的WebIndex就是你要建立的序号.

WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root');

if createVpath then Begin
VDir := WebRoot.create('IIsWebVirtualDir', VName);
Vdir.AccessScript := pos(',0,',Vattrib) >0;
VDir.AccessRead := pos(',1,',Vattrib) >0;
VDir.AccessWrite := pos(',2,',Vattrib) >0;
VDir.AccessExecute := pos(',3,',Vattrib) >0;
VDir.EnableDirBrowsing := pos(',4,',Vattrib) >0;

// 以上几行是为你建立的目录设访问权限。可写,可读,可执行,可流览...

VDir.Path :=VDirPath;
VDir.SetInfo;

Binds := WebServer.ServerBindings;
BindStr := Binds[0]+':';
WriteLn('');
WriteLn('Result :');
WriteLn('');
WriteLn('IP : '+ GetStrForSpace(BindStr,':',1));
WriteLn('Port : '+ GetStrForSpace(BindStr,':',2));
WriteLn('HostName : '+ GetStrForSpace(BindStr,':',3));
WriteLn('');
WriteLN('Path Is: ' + WebRoot.Path);
WriteLN('Index IS: ' + IntTostr(WebIndex));
WriteLn('Comment : ' + WebServer.ServerComment);

// 上面几行就是得到站点的一些信息,IP,端口,主机名,路径,等等..

WriteLn('');
WriteLn('create success.');
End
Else Begin
WebRoot.delete('IIsWebVirtualDir', VName);
Writeln('delete Success.');
End;
Except
WriteLn('Fail.');
End;

end;

Var
i : integer;
begin

coinitialize(nil);
if ParamCount <4 then Begin
ShowHelp;
Exit;
End;

For i:=1 to ParamCount do
ParseParam(Paramstr(i));

if (ParamCount = 5) and (Vattrib ='') then Begin
ShowHelp;
Exit;
End;
Vattrib := ','+Vattrib+',';
createVDir(VPath);

{ TODO -oUser -cConsole Main : insert code here }

end.
代码可以用COPY到记事本中,然后保存为VDIR.DPR 文件,用DELPHI打开编译一下就行了。

使用方法:
我要在默认站点(序号为1)中建立一个,可读,可写,可注浏览的目录,名称为: yfd 路径为c:
那么这么使用:

D:VDir.exe -n:yfd -p:c: -i:1 -c:1 -r:1,2,4

程序帮助显示:
Useag:VDir.exe <-n:VName> <-p:VPath> <-i:WebIndex> <-c:CmdType> [-r:Vattrib]

Sample:D:VDir.exe -n:yfd -p:c: -i:1 -c:1 -r:0,1,3

CmdType :
1 : create
0 : delete
Vattrib :

0 : AccessScript (脚本访问)
1 : AccessRead (可读)
2 : AccessWrite (可写)
3 : AccessExecute (可执行)
4 : EnableDirBrowsing (可浏览)

-n: 建立的目录名称

-P: 建立的目录路径

-i: 序号

-c: (1表示建立,0表示删除)

-r: (当选择建立的时候,请输入他相应的访问权限值,删除的时候可以不写).

返回结果:

D:>VDir.exe -n:yfd -p:c: -i:1 -c:1 -r:1,2,4

Result :

IP : 127.0.0.1
Port : 80
HostName :

Path Is: E:ScriptWEBTEST
Index IS: 1
Comment : 默认 Web 站点
create success.
文章录入:cainiaowang    责任编辑:cainiaowang 
【字体:
Copyright @2006 黑客风云 ●业务联系:QQ 联系怪人 联系奇人 Email:给怪人发邮件 给奇人发邮件
ICP备案:冀06009886