批處理修改本地安全策略中的:拒絕從網(wǎng)絡(luò)訪問計(jì)算機(jī),將里面的Guest刪除。
echo [Version]>mm.inf
echo signature="$CHICAGO$">>mm.inf
echo Revision=1>>mm.inf
echo [Privilege Rights]>>mm.inf
echo SeDenyNetworkLogonRight =>>mm.inf
secedit /configure /db mm.sdb /cfg mm.inf
del mm.inf /q
del mm.sdb /q
pause
參考:
http://www.cnblogs.com/SummerRain/archive/2011/04/10/2011246.html
以下是原文:
在窗口界面下訪問組策略用gpedit.msc
命令行下用secedit.exe。
secedit命令語法:
secedit /analyze
secedit /configure
secedit /export
secedit /validate
secedit /refreshpolicy
5個命令的功能分別是分析組策略、配置組策略、導(dǎo)出組策略、驗(yàn)證模板語法和更新組策略。其中secedit /refreshpolicy 在XP/2003下被gpupdate代替。這些命令具體的語法自己在命令行下查看就知道了。
與訪問注冊表只需reg文件不同的是,訪問組策略除了要有個模板文件(還是inf),還需要一個安全數(shù)據(jù)庫文件(sdb)。要修改組策略,必須先將模板導(dǎo)入安全數(shù)據(jù)庫,再通過應(yīng)用安全數(shù)據(jù)庫來刷新組策略。來看個例子:
假設(shè)我要將密碼長度最小值設(shè)置為6,并啟用“密碼必須符合復(fù)雜性要求”,那么先寫這么一個模板:
[version]
signature="$CHICAGO$"
[System Access]
MinimumPasswordLength = 6
PasswordComplexity = 1
保存為gp.inf,然后導(dǎo)入:
secedit /configure /db gp.sdb /cfg gp.inf /quiet
這個命令執(zhí)行完成后,將在當(dāng)前目錄產(chǎn)生一個gp.sdb,它是“中間產(chǎn)品”,你可以刪除它。
/quiet參數(shù)表示“安靜模式”,不產(chǎn)生日志。但根據(jù)我的試驗(yàn),在2000sp4下該參數(shù)似乎不起作用,XP下正常。日志總是保存在%windir%\security\logs\scesrv.log。你也可以自己指定日志以便隨后刪除它。比如:
secedit /configure /db gp.sdb /cfg gp.inf /log gp.log
del gp.*
另外,在導(dǎo)入模板前,還可以先分析語法是否正確:
secedit /validate gp.inf
那么,如何知道具體的語法呢?當(dāng)然到MSDN里找啦。也有偷懶的辦法,因?yàn)橄到y(tǒng)自帶了一些安全模板,在%windir%\security\templates目錄下。打開這些模板,基本上包含了常用的安全設(shè)置語法,一看就懂。
再舉個例子——關(guān)閉所有的“審核策略”。(它所審核的事件將記錄在事件查看器的“安全性”里)。
echo版:
echo [version] >1.inf
echo signature="$CHICAGO$" >>1.inf
echo [Event Audit] >>1.inf
echo AuditSystemEvents=0 >>1.inf
echo AuditObjectAccess=0 >>1.inf
echo AuditPrivilegeUse=0 >>1.inf
echo AuditPolicyChange=0 >>1.inf
echo AuditAccountManage=0 >>1.inf
echo AuditProcessTracking=0 >>1.inf
echo AuditDSAccess=0 >>1.inf
echo AuditAccountLogon=0 >>1.inf
echo AuditLogonEvents=0 >>1.inf
secedit /configure /db 1.sdb /cfg 1.inf /log 1.log /quiet
del 1.*
也許有人會說:組策略不是保存在注冊表中嗎,為什么不直接修改注冊表?因?yàn)椴皇撬械慕M策略都保存在注冊表中。比如“審核策略”就不是。你可以用 regsnap比較修改該策略前后注冊表的變化。我測試的結(jié)果是什么都沒有改變。只有“管理模板”這一部分是完全基于注冊表的。而且,知道了具體位置,用哪個方法都不復(fù)雜。
比如,XP和2003的“本地策略”-》“安全選項(xiàng)”增加了一個“本地帳戶的共享和安全模式”策略。XP下默認(rèn)的設(shè)置是“僅來賓”。這就是為什么用管理員帳號連接XP的ipc$仍然只有Guest權(quán)限的原因。可以通過導(dǎo)入reg文件修改它為“經(jīng)典”:
echo Windows Registry Editor Version 5.00 >1.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>1.reg
echo "forceguest"=dword:00000000 >>1.reg
regedit /s 1.reg
del 1.reg
而相應(yīng)的用inf,應(yīng)該是:
echo [version] >1.inf
echo signature="$CHICAGO$" >>1.inf
echo [Registry Values] >>1.inf
echo MACHINE\System\CurrentControlSet\Control\Lsa\ForceGuest=4,0 >>1.inf
secedit /configure /db 1.sdb /cfg 1.inf /log 1.log
del 1.*
關(guān)于命令行下讀取組策略的問題。
系統(tǒng)默認(rèn)的安全數(shù)據(jù)庫位于%windir%\security\database\secedit.sdb,將它導(dǎo)出至inf文件:
secedit /export /cfg gp.inf /log 1.log
沒有用/db參數(shù)指定數(shù)據(jù)庫就是采用默認(rèn)的。然后查看gp.inf。
不過,這樣得到的只是組策略的一部分(即“Windows設(shè)置”)。而且,某個策略如果未配置,是不會被導(dǎo)出的。比如“重命名系統(tǒng)管理員帳戶”,只有被定義了才會在inf文件中出現(xiàn)NewAdministratorName="xxx"。對于無法導(dǎo)出的其他的組策略只有通過訪問注冊表來獲得了。
此辦法在XP和2003下無效——可以導(dǎo)出但內(nèi)容基本是空的。原因不明。根據(jù)官方的資料,XP和2003顯示組策略用RSoP(組策略結(jié)果集)。相應(yīng)的命令行工具是gpresult。但是,它獲得的是在系統(tǒng)啟動時被附加(來自域)的組策略,單機(jī)測試結(jié)果還是“空”。所以,如果想知道某些組策略是否被設(shè)置,只有先寫一個inf,再用secedit /analyze,然后查看日志了
組策略的計(jì)算機(jī)安全策略
可以使用secedit,具體幫助參考secedit /?
其它內(nèi)容,一般都存在與注冊表,只要修改注冊表就可以了,具體內(nèi)容參考 *.adm文件(windows\inf或\windows\system32\GroupPolicy\Adm下)
注冊表可以使用 regedit -s yourreg.reg 來導(dǎo)入自己定義的值
secedit /export /cfg gp.inf /log 1.log
導(dǎo)出文件內(nèi)容示例:
=====================gp.inf================================
[Unicode]
Unicode=yes
[System Access]
MinimumPasswordAge = 0
MaximumPasswordAge = 42
MinimumPasswordLength = 6
PasswordComplexity = 0
PasswordHistorySize = 0
LockoutBadCount = 6
ResetLockoutCount = 30
LockoutDuration = 30
RequireLogonToChangePassword = 0
ForceLogoffWhenHourExpire = 0
NewAdministratorName = "Administrator"
NewGuestName = "Guest"
ClearTextPassword = 0
LSAAnonymousNameLookup = 0
EnableAdminAccount = 1
EnableGuestAccount = 0
[Event Audit]
AuditSystemEvents = 0
AuditLogonEvents = 1
AuditObjectAccess = 0
AuditPrivilegeUse = 0
AuditPolicyChange = 0
AuditAccountManage = 0
AuditProcessTracking = 0
AuditDSAccess = 0
AuditAccountLogon = 1
[Version]
signature="$CHICAGO$"
Revision=1
[Registry Values]
MACHINE\Software\Microsoft\Driver Signing\Policy=3,1
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Setup\RecoveryConsole\SecurityLevel=4,0
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Setup\RecoveryConsole\SetCommand=4,0
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AllocateCDRoms=1,"0"
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AllocateDASD=1,"0"
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AllocateFloppies=1,"0"
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\CachedLogonsCount=1,"10"
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ForceUnlockLogon=4,0
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\PasswordExpiryWarning=4,14
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ScRemoveOption=1,"0"
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableCAD=4,0
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\DontDisplayLastUserName=4,0
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\LegalNoticeText=7,
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ScForceOption=4,0
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ShutdownWithoutLogon=4,0
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\UndockWithoutLogon=4,1
MACHINE\Software\Policies\Microsoft\Windows\Safer\CodeIdentifiers\AuthenticodeEnabled=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\AuditBaseObjects=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\CrashOnAuditFail=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\DisableDomainCreds=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\EveryoneIncludesAnonymous=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\ForceGuest=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\FullPrivilegeAuditing=3,0
MACHINE\System\CurrentControlSet\Control\Lsa\LimitBlankPasswordUse=4,1
MACHINE\System\CurrentControlSet\Control\Lsa\LmCompatibilityLevel=4,2
MACHINE\System\CurrentControlSet\Control\Lsa\MSV1_0\NTLMMinClientSec=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\MSV1_0\NTLMMinServerSec=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\NoDefaultAdminOwner=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\NoLMHash=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\RestrictAnonymous=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\RestrictAnonymousSAM=4,1
MACHINE\System\CurrentControlSet\Control\Print\Providers\LanMan Print Services\Servers\AddPrinterDrivers=4,1
MACHINE\System\CurrentControlSet\Control\SecurePipeServers\Winreg\AllowedExactPaths\Machine=7,System\CurrentControlSet\Control\ProductOptions,System\CurrentControlSet\Control\Server Applications,Software\Microsoft\Windows NT\CurrentVersion
MACHINE\System\CurrentControlSet\Control\SecurePipeServers\Winreg\AllowedPaths\Machine=7,System\CurrentControlSet\Control\Print\Printers,System\CurrentControlSet\Services\Eventlog,Software\Microsoft\OLAP Server,Software\Microsoft\Windows NT\CurrentVersion\Print,Software\Microsoft\Windows NT\CurrentVersion\Windows,System\CurrentControlSet\Control\ContentIndex,System\CurrentControlSet\Control\Terminal Server,System\CurrentControlSet\Control\Terminal Server\UserConfig,System\CurrentControlSet\Control\Terminal Server\DefaultUserConfiguration,Software\Microsoft\Windows NT\CurrentVersion\Perflib,System\CurrentControlSet\Services\SysmonLog
MACHINE\System\CurrentControlSet\Control\Session Manager\Kernel\ObCaseInsensitive=4,1
MACHINE\System\CurrentControlSet\Control\Session Manager\ProtectionMode=4,1
MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\optional=7,Posix
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\AutoDisconnect=4,15
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\EnableForcedLogOff=4,1
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\EnableSecuritySignature=4,0
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes=7,COMNAP,COMNODE,SQL\QUERY,SPOOLSS,NETLOGON,LSARPC,SAMR,BROWSER
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\NullSessionShares=7,COMCFG,DFS$
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\RequireSecuritySignature=4,0
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\RestrictNullSessAccess=4,1
MACHINE\System\CurrentControlSet\Services\LanmanWorkstation\Parameters\EnablePlainTextPassword=4,0
MACHINE\System\CurrentControlSet\Services\LanmanWorkstation\Parameters\EnableSecuritySignature=4,1
MACHINE\System\CurrentControlSet\Services\LanmanWorkstation\Parameters\RequireSecuritySignature=4,0
MACHINE\System\CurrentControlSet\Services\LDAP\LDAPClientIntegrity=4,1
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\DisablePasswordChange=4,0
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\MaximumPasswordAge=4,30
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\RequireSignOrSeal=4,1
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\RequireStrongKey=4,0
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\SealSecureChannel=4,1
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\SignSecureChannel=4,1
[Privilege Rights]
SeNetworkLogonRight = S-1-1-0,S-1-5-32-544,S-1-5-32-545,S-1-5-32-547,S-1-5-32-551
SeBackupPrivilege = S-1-5-32-544,S-1-5-32-551
SeChangeNotifyPrivilege = S-1-1-0,S-1-5-32-544,S-1-5-32-545,S-1-5-32-547,S-1-5-32-551
SeSystemtimePrivilege = S-1-5-19,S-1-5-32-544,*S-1-5-32-547
SeCreatePagefilePrivilege = *S-1-5-32-544
SeDebugPrivilege = *S-1-5-32-544
SeRemoteShutdownPrivilege = S-1-5-32-544
SeAuditPrivilege = S-1-5-19,S-1-5-20
SeIncreaseQuotaPrivilege = S-1-5-19,S-1-5-20,S-1-5-32-544
SeIncreaseBasePriorityPrivilege = *S-1-5-32-544
SeLoadDriverPrivilege = *S-1-5-32-544
SeBatchLogonRight = S-1-5-19,SUPPORT_388945a0
SeServiceLogonRight = S-1-5-20
SeInteractiveLogonRight = S-1-5-32-544,S-1-5-32-545,S-1-5-32-547,S-1-5-32-551
SeSecurityPrivilege = *S-1-5-32-544
SeSystemEnvironmentPrivilege = *S-1-5-32-544
SeProfileSingleProcessPrivilege = S-1-5-32-544,S-1-5-32-547
SeSystemProfilePrivilege = S-1-5-32-544
SeAssignPrimaryTokenPrivilege = S-1-5-19,S-1-5-20
SeRestorePrivilege = S-1-5-32-544,S-1-5-32-551
SeShutdownPrivilege = S-1-5-32-544,S-1-5-32-547,S-1-5-32-551
SeTakeOwnershipPrivilege = *S-1-5-32-544
SeDenyNetworkLogonRight = SUPPORT_388945a0
SeDenyInteractiveLogonRight = SUPPORT_388945a0
SeUndockPrivilege = S-1-5-32-544,S-1-5-32-547
SeManageVolumePrivilege = *S-1-5-32-544
SeRemoteInteractiveLogonRight = S-1-5-32-544,S-1-5-32-555
SeImpersonatePrivilege = S-1-5-32-544,S-1-5-6
SeCreateGlobalPrivilege = S-1-5-32-544,S-1-5-6
以下內(nèi)容轉(zhuǎn)自:
http://soft.aizhan.com/wzzx/67174.html
[Privilege Rights]這一組就是本地策略里的用戶權(quán)利指派
,下面是一些與用戶登陸有關(guān)的項(xiàng):
sedenyinteractivelogonright 拒絕從本地登陸
sedenynetworklogonright 拒絕從網(wǎng)絡(luò)訪問這臺計(jì)算機(jī)
sedenyservicelogonright 拒絕作為服務(wù)登陸
sedenybatchlogonright 拒絕作為批處理作業(yè)登陸
seinteractivelogonright 在本地登陸
senetworklogonright 從網(wǎng)絡(luò)訪問此計(jì)算機(jī)
seservicelogonright 作為服務(wù)登陸
sebatchlogonright 作為批處理作業(yè)登陸
每一項(xiàng)后面的值是用戶或用戶組的SID號,每個用戶的SID號用逗號隔開,要知道用戶的SID號可以用getsid.exe這個工具。注意,拒絕的優(yōu)先級最高。以前總是有人發(fā)現(xiàn),得到了一個用戶的密碼,想登陸上去卻發(fā)現(xiàn)此用戶不允許交互式登陸。現(xiàn)在就可以用此方法來更改安全策略,至于怎么改就不在本文的討論范圍了。