|
|
2#

楼主 |
发表于 2007-8-28 17:41:24
|
只看该作者
德国人制作补丁 批处理a
@echo offclsrem Copyright (C) 2003-05 Ansgar Wiechers & Torsten Mannrem Contact: admin@ntsvcfg.deremrem This program is free software; you can redistribute it and/or modify it underrem the terms of the GNU General Public License as published by the Free Software Foundation;rem either version 2 of the License, or (at your option) any later version.rem This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;rem without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.rem See the GNU General Public License for more details.remrem You should have received a copy of the GNU General Public License along with this program;rem if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,rem MA 02111-1307, USA.echo.REM Tested on ... WinXP_SP2REM Always basic XP64 SupportREM Modifications to BITS service (cause of v5 WindowsUpdate) - #discharged#REM Additional notices corresponding to DHCP issueREM Variables problems during RESTORE_DEFAULT usage fixedREM SMBDEVICEENABLED Restore Bug fixedREM Mod_history-09-27-2005**11-08-2005**11-29-2005**12-07-2005**12-18-2005setlocalREM *** INIT_VARS ***set CHK_SVC=YESset XPSP2=FALSEset SERVER=FALSEset NT_SERVER_CHK=TRUE:STARTecho "svc2kXp.cmd" v2.2_build7b (18.12.2005), published under GNU GPLecho ================================================================set find=%SystemRoot%\System32\find.exeset regedit=%SystemRoot%\regedit.exeif not exist "%find%" goto :NOFINDif not exist "%regedit%" goto :NOREGEDITif not "%1" == "%*" goto :SYNTAXif /I "%1"=="/?" goto :HELPif /I "%1"=="/help" goto :HELPif /I "%1"=="-h" goto :HELPif /I "%1"=="--help" goto :HELPif /I "%1"=="-?" goto :HELPif /I "%1"=="--?" goto :HELPif /I "%1"=="/fix" goto :FIXgoto :VERSION:SYNTAXecho.echo.echo !!Syntax error!!echo ________________echo Es kann nur ein oder kein Parameter angegeben werden.echo.echo Only one or no parameter allowed.goto UIT:HELPecho.echo -= Hilfe =-echo Parameter:echo /lan.......Einige Dienste fuer LAN-Betrieb werden nicht veraendert.echo /std.......Schliesst alle Ports, einige Dienste bleiben unveraendert.echo /all.......Setzt alle Vorschlaege nach www.ntsvcfg.de um (hardening).echo /restore...Nimmt die zuletzt vorgenommenen Aenderungen zurueck.echo /reLAN.....Reaktiviert Dienste, die fuer LAN-Betrieb benoetigt werden.echo /default...Setzt alle Diensteinstellungen auf urspr黱gliche Werte zur點k.echo.echo Parameters:echo /lan.......Some services needed for LAN-usage stay unchanged!echo /std.......Closes all Ports, but some services stay unchangedecho /all.......Changes all issues recommended by www.ntsvcfg.de ("hardening")echo /restore...Undo last changes.echo /reLAN.....Reactivates services required for LAN.echo /default...Restoring factory service settings (before first time usage)echo.echo example: svc2kxp.cmd /allecho.set /P CHS= [Press "G" for GNU GPL informations or "Q" for quit]?if /I "%CHS%"=="G" goto :GNU_GPLif /I "%CHS%"=="Q" goto UIT_EXTCLSgoto :HELP:GNU_GPLCLSecho Informations about GNU-General Public License for "svc2kxp.cmd"echo ===============================================================echo.echo Copyright (C) 2003-05 Ansgar Wiechers, Torsten Mannecho Contact: admin@ntsvcfg.deecho.echo This program is free software; you can redistribute it and/or modify it underecho the terms of the GNU General Public License as published by the Free Softwareecho Foundation; either version 2 of the License, or (at your option) any laterecho version. This program is distributed in the hope that it will be useful, butecho WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY orecho FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for moreecho details.echo.echo You should have received a copy of the GNU General Public License along withecho this program; if not, write to the:echo.echo Free Software Foundation, Inc.echo 59 Temple Place, Suite 330echo Boston, MA 02111-1307, USA.echo.set /P CHS= [Press "H" for help or "Q" for quit]?CLSif /I "%CHS%"=="H" goto :HELPif /I "%CHS%"=="Q" goto UIT_EXTgoto GNU_GPL:VERSIONecho Checking system version ...if /I "%NT_SERVER_CHK%"=="FALSE" goto :SKIP_NT_SERVER_CHKREM Checking for running server version "%regedit%" /e "%TEMP%\~svr.txt" "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions" type "%TEMP%\~svr.txt"|"%find%" /i "Server" >NUL if not errorlevel 1 set SERVER=TRUE type "%TEMP%\~svr.txt"|"%find%" /i "LanMan" >NUL if not errorlevel 1 set SERVER=TRUE if exist "%TEMP%\~svr.txt" del /F /Q "%TEMP%\~svr.txt" if /I "%SERVER%"=="TRUE" goto :NTSERVER:SKIP_NT_SERVER_CHKver | "%find%" /i "Windows 2000" > nulif not errorlevel 1 goto :OS2Kver | "%find%" /i "Windows XP" > nulif not errorlevel 1 goto :OSXPver | "%find%" /i "Microsoft Windows [Version 5.2.3790]" > nulif not errorlevel 1 goto :OSXP64echo !!Failed!!echo __________echo.echo Dieses Script ist nur unter Windows 2000 oder XP lauffaehig!echo.echo This script works only on Windows 2000/XP machines!echo.goto UIT:NOFINDecho.echo !!Failed!!echo __________echo.echo Leider konnte folgende Datei nicht gefunden werden:echo.echo Sorry, but following file is missing:echo.echo.echo # %SystemRoot%\System32\FIND.EXEecho.echo.goto UIT:NOREGEDITecho.echo !!Failed!!echo __________echo.echo Leider konnte folgende Datei nicht gefunden werden:echo.echo Sorry, but following file is missing:echo.echo.echo # %SystemRoot%\REGEDIT.EXEecho.echo.goto UIT:NTSERVERecho.echo !!Failed!!echo __________echo.echo Dieses Script unterstuetzt keine NT Server Versionen!echo.echo This script doesn't support NT server versions!echo.goto UIT:OS2Krem Specific OS Detection Iset SYSTEM=2krem Testing for XP ServicePacks "%regedit%" /e "%TEMP%\~svclist.txt" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 4" >NUL if errorlevel==1 ( type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 3" >NUL if errorlevel==1 ( type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 2" >NUL if errorlevel==1 ( type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 1" >NUL if errorlevel==1 ( echo !Windows 2000 [no or unknown Service Pack] detected! goto NO_2KSP ) echo !Windows 2000 [Service Pack 1] detected! goto :NO_2KSP ) echo !Windows 2000 [Service Pack 2] detected! goto :NO_2KSP ) echo !Windows 2000 [Service Pack 3] detected! goto :NO_2KSP ) echo !Windows 2000 [Service Pack 4] detected! goto :NO_2KSP:NO_2kSPif exist "%TEMP%\~svclist.txt" del /F /Q "%TEMP%\~svclist.txt"goto :CONTINUE:OSXPrem Specific OS detection IIset SYSTEM=xprem Testing for XP ServicePack 2 "%regedit%" /e "%TEMP%\~svclist.txt" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 2" >NUL if errorlevel==1 ( type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 1" >NUL if errorlevel==1 ( SET XPSP2=FALSE echo !Windows XP [no or unknown Service Pack] detected! goto NO_XPSP ) SET XPSP2=FALSE echo !Windows XP [Service Pack 1] detected! goto :NO_XPSP ) SET XPSP2=TRUE echo !Windows XP [ServicePack 2] detected! goto :NO_XPSP:OSXP64rem Specific OS detection IIset SYSTEM=xprem Testing for XP ServicePack 2 "%regedit%" /e "%TEMP%\~svclist.txt" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 2" >NUL if errorlevel==1 ( type "%TEMP%\~svclist.txt"|"%find%" /i "Service Pack 1" >NUL if errorlevel==1 ( SET XPSP2=FALSE echo !EXPERIMENTAL! Windows XP64 [no or unknown Service Pack] detected! goto NO_XPSP ) SET XPSP2=FALSE echo !EXPERIMENTAL! Windows XP64 [Service Pack 1] detected! goto :NO_XPSP ) SET XPSP2=TRUE echo !EXPERIMENTAL! Windows XP64 [ServicePack 2] detected! goto :NO_XPSP:NO_XPSPif exist "%TEMP%\~svclist.txt" del /F /Q "%TEMP%\~svclist.txt"goto :CONTINUE:CONTINUEREM Creating subdirectory "ntsvcfg" in userprofile if necessaryif not exist "%USERPROFILE%\ntsvcfg\*.*" mkdir "%USERPROFILE%\ntsvcfg"REM Moving old script backup files to ...\%USERNAME%\ntsvcfg : if exist "%USERPROFILE%\dcom.reg" move /Y "%USERPROFILE%\dcom.reg" "%USERPROFILE%\ntsvcfg\dcom.reg" if exist "%USERPROFILE%\dcomp.reg" move /Y "%USERPROFILE%\dcomp.reg" "%USERPROFILE%\ntsvcfg\dcomp.reg" if exist "%USERPROFILE%\services.reg" move /Y "%USERPROFILE%\services.reg" "%USERPROFILE%\ntsvcfg\services.reg" if exist "%USERPROFILE%\current_services_config.reg" move /Y "%USERPROFILE%\current_services_config.reg" "%USERPROFILE%\ntsvcfg\current_services_config.reg" if exist "%USERPROFILE%\smb.reg" move /Y "%USERPROFILE%\smb.reg" "%USERPROFILE%\ntsvcfg\smb.reg" if exist "%USERPROFILE%\FPRINT.REF" move /Y "%USERPROFILE%\FPRINT.REF" "%USERPROFILE%\ntsvcfg\FPRINT.REF" if exist "%USERPROFILE%\handler_aim.reg" move /Y "%USERPROFILE%\handler_aim.reg" "%USERPROFILE%\ntsvcfg\handler_aim.reg" if exist "%USERPROFILE%\handler_gopher.reg" move /Y "%USERPROFILE%\handler_gopher.reg" "%USERPROFILE%\ntsvcfg\handler_gopher.reg" if exist "%USERPROFILE%\handler_telnet.reg" move /Y "%USERPROFILE%\handler_telnet.reg" "%USERPROFILE%\ntsvcfg\handler_telnet.reg" if exist "%USERPROFILE%\services.reg.default" move /Y "%USERPROFILE%\services.reg.default" "%USERPROFILE%\ntsvcfg\services.reg.default" if exist "%USERPROFILE%\dcom.reg.default" move /Y "%USERPROFILE%\dcom.reg.default" "%USERPROFILE%\ntsvcfg\dcom.reg.default" if exist "%USERPROFILE%\dcomp.reg.default" move /Y "%USERPROFILE%\dcomp.reg.default" "%USERPROFILE%\ntsvcfg\dcomp.reg.default" if exist "%USERPROFILE%\smb.reg.default" move /Y "%USERPROFILE%\smb.reg.default" "%USERPROFILE%\ntsvcfg\smb.reg.default" if exist "%USERPROFILE%\handler_aim.reg.default" move /Y "%USERPROFILE%\handler_aim.reg.default" "%USERPROFILE%\ntsvcfg\handler_aim.reg.default" if exist "%USERPROFILE%\handler_gopher.reg.default" move /Y "%USERPROFILE%\handler_gopher.reg.default" "%USERPROFILE%\ntsvcfg\handler_gopher.reg.default" if exist "%USERPROFILE%\handler_telnet.reg.default" move /Y "%USERPROFILE%\handler_telnet.reg.default" "%USERPROFILE%\ntsvcfg\handler_telnet.reg.default"REM *****Declarations*****set SELECT="no"set SVC_BAK=%USERPROFILE%\ntsvcfg\services.regset SVC_SAV=%USERPROFILE%\ntsvcfg\current_services_config.regset DCOM_BAK=%USERPROFILE%\ntsvcfg\dcom.regset DCOMP_BAK=%USERPROFILE%\ntsvcfg\dcomp.regset SMB_BAK=%USERPROFILE%\ntsvcfg\smb.regset DCOM_TMP=%TEMP%\dcomoff.regset DCOMP_TMP=%TEMP%\dcompoff.regset SMB_TMP=%TEMP%\smboff.regset FPRINT=%USERPROFILE%\ntsvcfg\FPRINT.REFset HANDLER1=%USERPROFILE%\ntsvcfg\handler_aim.regset HANDLER2=%USERPROFILE%\ntsvcfg\handler_gopher.regset HANDLER3=%USERPROFILE%\ntsvcfg\handler_telnet.regset NB_TMP=%TEMP%\nb_off.vbsset srctmp=%USERPROFILE%\ntsvcfg\~srcreate.vbsset DHCP_CHANGES="YES"REM *****Options*****set SCHEDULER_ENABLED=NOset UseXPSysRestore=YESset RESTORE=NOset SVC_MOD=NOset USE_FPRINT=YESset Deactivate_NetBIOS=YESset RESTORE_MODE=2REM *****APP_PATHs******set NET=%SystemRoot%\system32\net.exeset SC=%SystemRoot%\system32\sc.exeset FC=%SystemRoot%\system32\fc.exeset IPCONFIG=%SystemRoot%\system32\ipconfig.exeecho Checking available permissions: [local], please wait ..."%net%" user "%USERNAME%" 2> nul | "%find%" /i "admin" | "%find%" /i /v "name" > nulif errorlevel 1 ( echo " " " : [domain], please wait ... "%net%" user "%USERNAME%" /domain 2> nul | "%find%" /i "admin" | "%find%" /i /v "name" > nul if errorlevel 1 ( echo. echo Failed! echo __________ echo Leider verfuegen Sie nicht ueber die erforderlichen Rechte! echo Melden Sie sich bitte als Administrator an. echo. echo Sorry but you don't have the permissions required for this task. echo Please login as Administrator. echo. goto :END ) )set IMPORT_OLD_FILES=FALSErem searching for sc.exeif not exist "%FPRINT%" echo Checking for presence of SC.EXE ..."%sc%" qc > nul 2>&1if errorlevel 1 ( echo !!Failed!! echo __________ echo Die notwendige Datei SC.EXE konnte leider nicht unter echo [%SystemRoot%\SYSTEM32\] gefunden werden. echo Bitte laden Sie sich diese Datei von der unten genannten Adresse herunter: echo. echo SC.EXE couldn't be found in [%SystemRoot%\SYSTEM32\]. echo Please download it from following location: echo. echo. echo -= ftp://ftp.microsoft.com/reskit/win2000/sc.zip =- echo. echo Self-installing SC.EXE echo ====================== echo svx2kxp.cmd kann versuchen, die notwendige Datei selbst zu installieren. echo Hierzu benoetigen Sie eine bestehende Internetverbindung. echo. echo svc2kxp.cmd may try to download the required file SC.EXE itself if an echo active internet connection exists. goto :SC_DOWNLOAD )if /I "%1"=="/all" ( set SELECT="/all" goto :SKIP_MENUE )if /I "%1"=="/relan" ( set SELECT="/relan" goto :SKIP_MENUE )if /I "%1"=="/std" ( set SELECT="/std" goto :SKIP_MENUE )if /I "%1"=="/default" goto :RESTORE_DEFAULTSrem checking for modified servicesif /I %CHK_SVC%==YES ( if /I %USE_FPRINT%==YES ( if exist "%FPRINT%" ( rem Creating fingerprint of current service settings... if exist "%USERPROFILE%\ntsvcfg\svc2cmp.sav" del /F /Q "%USERPROFILE%\ntsvcfg\svc2cmp.sav" "%sc%" query type= service state= all bufsize= 8192 | %FIND% "SERVICE_NAME" >%TEMP%\~svclist.txt for /F "tokens=1*" %%a in (%TEMP%\~svclist.txt) do ( echo %%b >>"%USERPROFILE%\ntsvcfg\svc2cmp.sav" "%sc%" query "%%b" | %FIND% "STATE" >>"%USERPROFILE%\ntsvcfg\svc2cmp.sav" "%sc%" qc "%%b" | %FIND% "DISPLAY_NAME" >>"%USERPROFILE%\ntsvcfg\svc2cmp.sav" "%SC%" qc "%%b" | %FIND% "START_TYPE" >>"%USERPROFILE%\ntsvcfg\svc2cmp.sav" echo. >> "%USERPROFILE%\ntsvcfg\svc2cmp.sav" ) del "%TEMP%\~svclist.txt" "%FC%" "%FPRINT%" "%USERPROFILE%\ntsvcfg\svc2cmp.sav" >NUL if errorlevel 1 goto IFF goto OK IFF echo Checking for modified services ... failed-services maybe modified! [E]valuate set SVC_MOD=YES goto :MOD_END :OK echo Checking for modified services ... OK set SVC_MOD=NO if exist "%USERPROFILE%\ntsvcfg\svc2cmp.sav" del /F /Q "%USERPROFILE%\ntsvcfg\svc2cmp.sav" goto :MOD_END :MOD_END REM ) ) )set CHK_SVC=NOif /I "%1"=="/restore" goto :RESTORE:MENUEif /I "%1"=="/lan" goto :SKIP_MENUEecho.echo -= Auswahl / Overview =-echo.echo Bitte waehlen sie einen Punkt aus, den sie ausfuehren moechten:echo.echo (1) LAN: Einige Dienste fuer LAN-Betrieb werden nicht veraendert.echo (2) Standard: Schliesst alle Ports, aber einige Dienste bleiben unveraendert.echo (3) ALL: Setzt alle Vorschlaege nach www.ntsvcfg.de um (hardening).echo (4) Restore: Nimmt die zuletzt vorgenommenen Aenderungen zurueck.echo ______________________________________________________________________________echo.echo Please choose one task you want to do:echo.echo (1) LAN: Some services needed for LAN-usage stay unchangedecho (2) Standard: Close ports but some services stay unchangedecho (3) ALL: Making all changes described at www.ntsvcfg.de (hardening)echo (4) restore: Restores last changes made.echo.set /P CHS= Bitte waehlen Sie/Please choose: [1],[2],[3],[4], [M]ore options or [Q]uit?if /I "%CHS%"=="1" ( set SELECT="/lan" goto :SKIP_MENUE )if /I "%CHS%"=="2" ( set SELECT="/std" goto :SKIP_MENUE )if /I "%CHS%"=="3" ( set SELECT="/all" goto :SKIP_MENUE )if /I "%CHS%"=="4" goto :RESTOREif /I "%CHS%"=="R" goto :RESTOREif /I "%CHS%"=="M" goto :MORE_OPTIONSif /I "%SVC_MOD%"=="YES" if /I "%CHS%"=="E" goto :EVALUATE_SERVICESif /I "%CHS%"=="G" goto :CREATING_NEW_FINGERPRINTif /I "%CHS%"=="Q" goto UITclsgoto :START:SKIP_MENUErem Checking if old restorefiles exists.rem if it is so old files will be restored before new changesif not exist "%SVC_BAK%" goto :NO_RESTOREif /I %RESTORE_MODE%==3 goto :NO_RESTOREif /I %RESTORE_MODE%==4 goto :NO_RESTOREset RESTORE=YESecho.echo _______________________________________________________________________echo.echo [Selected Restore Mode: %RESTORE_MODE%]echo.echo # Achtung: Alte Sicherungsdateien gefunden!echo.echo "Svc2kXp.cmd" wurde schon einmal ausgefuehrt. Damit neue Aenderungenecho korrekt durchgefuehrt werden koennen, werden die Sicherungsdateienecho eingespielt.echo.echo.echo Attention: old restore-files found!echo.echo This program runs not for the first time. To apply all new changesecho correctly old restore files will used to get an definite state.echo.echo.echo # Starting restore ...goto RESTORE_EXT:NO_RESTORErem query if taskplaner should runif /I "%SYSTEM%"=="2k" goto :SKIP_SQUERYif /I "%SYSTEM%"=="xp" ( if /I %SELECT%=="" goto :SKIP_SQUERY if /I %SELECT%=="/all" goto :SKIP_SQUERY if /I %XPSP2%==True ( set SCHEDULER_ENABLED=YES goto :SKIP_SQUERY ) )echo.echo.echo Rueckfrage / Queryecho ==================echo.echo Soll der Dienst "Taskplaner" beendet werden?echo.echo Wenn sie zeitgesteuerten Aufgaben [z.B. Antiviren-Updates] oder die automati-echo sche Erstellung von Systemwiederherstellungspunkten nicht benoetigen, drueckenecho Sie eine BELIEBIGE TASTE, um auch Port 135 [RPC] sowie Port 1025 [Taskplaner]echo zu schliessen [empfohlen!]. Andernfalls druecken Sie "N"!echo.echo.echo Should the "scheduler service" be disabled?echo.echo If you have time-controlled tasks [i.e. AV-Updates] or you will not setecho automatic system restore points press ANY KEY TO CONTINUE to close port 135echo [RPC] and port 1025 [scheduler] instantly. Otherwise press "N"echo ___________________________________________echo.set /P UNDO= Taskplaner beenden - Close scheduler [y/n]?if /I "%UNDO%"=="n" set SCHEDULER_ENABLED=YES
[[i] 本帖最后由 cnn_5454 于 2007-8-29 12:07 PM 编辑 [/i]] |
|