web安全概述-SQL注入總結

Web 安全概要

  • 第三方內容:廣告插件·mochup
  • web前端框架:jQuery/Bootstrap/HTML5
  • Web應用:BBS/CMS/BLOG
  • Web開發框架:Django/Rails/ThinkPHP
  • Web服務器語言:PHP/JSP/.NET
  • Web容器:Apache/IIS/Nginx/Tomcat
  • 存儲:數據庫存儲/內存存儲/文件存儲
  • 操做系統:Linux/Windows

什麼是注入漏洞

注入漏洞攻擊的本質,web應用程序沒有對過濾用戶輸入*,直接把用戶輸入的惡意數據當代碼執行。php

兩個條件

用戶可以控制輸入
本來程序要執行的代碼,拼接了用戶輸入的數據
複製代碼

注入類型

SQL注入: 攻擊者把sql代碼命令插入到web表單的輸入域或頁面請求的查詢字符串,欺騙數據庫服務器執行惡意的sql命令
命令注入:後端爲過濾掉惡意數據,代碼當系統命令執行。
代碼注入:通常出如今不安全使用某些函數
        文件包含
        反序列化漏洞
LAAP注入:用於訪問網絡中目錄服務,經常使用在Active Directory
XML注入:
        XXE注入:引用外部實體時,經過構造惡意代碼內容,致使讀取任意文件執行系統命令,探測內網端口,攻擊內網網站等危害。
        xpath注入:與sql注入相似,xpath解析自己對url,表單中提交的代碼未做嚴格限制,致使惡意代碼能夠直接解析
        XQuery注入
JSON注入:輕量級的數據交換格式,主要利用特殊字符注入JSON中,形成解析失敗。
jsonp注入:回調函數未做嚴格的檢測和過濾
複製代碼

SQL注入過程

SQL注入危害

繞過登陸驗證:使用萬能密碼登陸網站後臺
獲取敏感數據:獲取網站管理員帳號 密碼等
文件操做系統:列目錄,獲取,寫入文件等
註冊表操做: 讀寫刪
執行系統命令:遠程執行系統命令
複製代碼

SQL 注入分類

數字型注入:輸入的參數爲整數 如ID age page 
字符型注入:輸入的參數爲字符型?字符型注入通常要使用單引號來閉合
搜索型注入:指對數據進行搜索時沒過濾搜索參數
複製代碼

SQL注入緣由

1.不正確的處理轉義字符(寬字節注入)
2.不正確的處理類型(報錯泄露信息)
3.不正確的處理聯合查詢
4.不正確的處理錯誤信息(報錯泄露信息)
5.不正確的處理屢次提交(二次注入)
6.後臺存在問題:無過濾或者編碼用戶數據  數據庫能夠拼接用戶傳遞的惡意代碼
7.錯誤處理不當
8不安全的數據庫配置:默認帳號     權限 
複製代碼

SQL注入過程

1.判斷是否存在注入點
2.判斷字段長度
3.判斷字段回顯位置
4.判斷數據庫信息
5.查找數據庫名
6.查找數據庫表
7.查找數據庫中全部字段
8.猜解帳號密碼
9.登陸管理員後臺
複製代碼

SQL注入能夠作什麼

1.讀取修改數據庫中的內容  
2.脫庫   
3讀取建立文件  
4函數備份寫入webshell,讀取數據庫文件 
5繞過密碼驗證登陸後臺  
6經過存儲過程執行系統命令和操做註冊表
複製代碼

常見url注入點(hack)

NewsInfo.asp?id=
otherinfo.asp?id=
info.asp?id=
news_show.asp?id=
showhf.asp?id=
detailshow.asp?ID=
CompHonorBig.asp?id=
EnCompHonorBig.asp?id=
Google dorks sql injection:
NewsInfo.asp?id=
Show.asp?Id=
intitle:山西學校 inurl:asp?=
inurl: (asp?=10) inurl: (php?=10)
inurl:Article_Print.asp?
inurl:ManageLogin.asp
inurl:Offer.php?idf=
inurl:Opinions.php?id=
inurlage.php?id=
inurlop.php?id=
inurlost.php?id=
inurlrod_info.php?id=
inurlroduct-item.php?id=
inurlroduct.php?id=
inurlroduct_ranges_view.php?ID=
inurlroductdetail.php?id=
inurlroductinfo.php?id=
inurlroduit.php?id=
inurl:Profile_view.php?id=
inurl:Publications.php?id=
inurl:Stray-Questions-View.php?num=
inurl:aboutbook.php?id=
inurl:ages.php?id=
inurl:announce.php?id=
inurl:art.php?idm=
inurl:article.php?ID=
inurl:articleshow.asp?articleid=10
inurl:artikelinfo.php?id=
inurl:asp
inurl:asp?id=
inurl:avd_start.php?avd=
inurl:band_info.php?id=
inurl:buy.php?category=
inurl:category.php?id=
inurl:channel_id=
inurl:chappies.php?id=
inurl:clanek.php4?id=
inurl:clubpage.php?id=
inurl:collectionitem.php?id=
inurl:communique_detail.php?id=
inurl:curriculum.php?id=
inurl:declaration_more.php?decl_id=
inurl:detail.php?ID=
inurl:download.php?id=
inurl:downloads_info.php?id=
inurl:event.php?id=
inurl:faq2.php?id=
inurl:fellows.php?id=
inurl:fiche_spectacle.php?id=
inurl:forum_bds.php?num=
inurl:galeri_info.php?l=
inurl:gallery.php?id=
inurl:game.php?id=
inurl:games.php?id=
inurl:historialeer.php?num=
inurl:hosting_info.php?id=
inurl:humor.php?id=
inurl:index.php?=
inurl:index.php?id=
inurl:index2.php?option=
inurl:iniziativa.php?in=
inurl:item_id=
inurl:kategorie.php4?id=
inurl:labels.php?id=
inurl:loadpsb.php?id=
inurl:look.php?ID=
inurl:main.php?id=
inurl:material.php?id=
inurl:memberInfo.php?id=
inurl:news-full.php?id=
inurl:news.php?id=
inurl:newsDetail.php?id=
inurl:news_Article.asp?Class_ID=
inurl:news_display.php?getid=
inurl:news_view.php?id=
inurl:newscat.php?id=
inurl:newsid=
inurl:newsitem.php?num=
inurl:newsone.php?id=
inurl:newsticker_info.php?idn=
inurl:ray.php?id=
inurl:read.php?id=
inurl:readnews.php?id=
inurl:reagir.php?num=
inurl:releases.php?id=
inurl:review.php?id=
inurl:rub.php?idr=
inurl:rubp.php?idr=
inurl:rubrika.php?idr=
inurl:section.php?id=
inurl:select_biblio.php?id=
inurl:sem.php3?id=
inurl:shop.php?do=part&id=
inurl:shop_category.php?id=
inurl:shopping.php?id=
inurl:show.php?id=
inurl:show_an.php?id=
inurl:showimg.php?id=
inurl:shredder-categories.php?id=
inurl:spr.php?id=
inurl:staff_id=
inurl:story.php?id=
inurl:sw_comment.php?id=
inurl:tekst.php?idt=
inurl:theme.php?id=
inurl:title.php?id=
inurl:top10.php?cat=
inurl:tradeCategory.php?id=
inurl:trainers.php?id=
inurl:transcript.php?id=
inurl:view.php?id=
inurl:view_faq.php?id=
inurl:view_product.php?id=
inurl:viewapp.php?id=
inurl:viewphoto.php?id=
inurl:viewshowdetail.php?id=
inurl:website.php?id=
inurlage.php?file=
inurlageid=
inurlages.php?id=
inurlarticipant.php?id=
inurlerson.php?id=
inurllay_old.php?id=
inurlreview.php?id=
inurlrod_detail.php?id=
inurlroduct-item.php?id=
inurlroductinfo.php?id=
inurl:news_Article.asp?Class_ID=
showproduct.asp?id=
showproduct.asp?id=99前端

隱祕注入點

1. 僞靜態
2. Cookie
3. key值注入
4. Limit OrderBy注入
5. Json格式注入
6. 二次注入
7. 編碼加密輸入點
8.referer注入
9.UA注入
10.XFF頭注入
11.GBK繞過(%df%27)
複製代碼

防護sql注入

1.UniOn SLeCT(大小寫) /*uniOn*/%09/*sElecT*/(註釋符)Unio%n Selec%t  

2.addslashes()  
addslashes(\$query="SELECT * FROM users WHERE id=\$id AND user='\$username'");  
sql語句就是\\"SELECT * FROM users WHERE id='\$id' AND user='\$username'\\"

3.hemlspecialchars() (默認ent_compat) + ent_quotes->  
\$quert="select * from users where id='\$id" and user='\$username'";  
把 < 和 > 轉換爲實體經常使用於防止瀏覽器將其用做 HTML 元素。  

4.參數化查詢->PDO模塊  

5.對於數字型能夠用intval()函數轉換  

6.對於字符型用1-4方法以及mysql_escape_string()函數轉義特殊字符,關閉magic_quoes_gpc配置  
複製代碼

sql手工注入命令

1.order by N  超出字段數會報錯 

2.union select 1,2,3......聯合查詢 用來判斷顯位以及猜解列數(結合系統函數來爆數據庫信息)  
(1) unio select schema_name from information_schema.schemata limit 1,2查看全部數據庫  

(2) information_schema.tables查看錶名  

(3) load_file(file_name):讀取文件並將文件內容按照字符串格式返回  
前提條件:  
                    1.文件位置必須在服務器上,擁有文件路徑以及file特權  
                    2.文件必須可讀取,文件容量必須小於max_allowed_paket字節  
                    3.文件必須存在  
3.exists(select...)  函數來猜解表名   
4.OR 1=1   OR 1=2   AND 1=1  AND 1=2  
複製代碼

SQL注入漏洞方式

1.識別數據庫
2盲跟蹤 (不一樣數據庫sql語句的差別如@@version 和version() web應用技術)
3非忙跟蹤(報錯 直接查詢)mysql

SQL盲注分類

布爾盲注:布爾值爲真時頁面返回正常,布爾值爲假頁面不返回數據
時間盲注:延時爲0頁面返回正常,大於設定時間頁面返回(sleep/benchmark()函數)
報錯盲注:利用頁面報錯信息(floor  EXtractvalue  Updatexml EXP )
複製代碼
相關文章
相關標籤/搜索