mySql 注入攻擊


注入攻擊

  1.原理:

      a.只要是帶有參數的動態網頁且此網頁訪問了數據庫,那么就有可能存在SQL注入;

      b.字符串拼接和沒有判斷用戶輸入是否合法------>導致用戶可以玩填字游戲----->SQL注入攻擊會導致的數據庫安全風險包括:刷庫、拖庫、撞庫。

  2.簡單解決方法:

      預防字符串拼接---->可以使用變量綁定避免注入攻擊.

        以查詢語句為例:

 

      正確輸入名稱與密碼   

            name = "hello"  password = "wangergou"

            "select price from houses where name = %s and paswd = %s"%(name,password)

      非法輸入名稱與密碼

            name = "'' a' or 1=1 or ('1'='1' "  password = " 'abc') or '1'='1' "

            "select price from houses where name = %s and paswd = %s"%(name,password)

            "select price from houses where name =' a' or 1=1 or ('1'='1' and paswd = 'abc') or '1'='1' 

      解決方式:  "select price from houses where name = %s and paswd = %s",name,password    ----->Tornado 框架中使用的版本 

 

              

 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM