Imports System.Text.RegularExpressions
adlı namespace i projenize ekleyiniz...
Page_Load prosedürümüze aşağıdaki gibi bir kod yazalım...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
If Request.QueryString("id") = "" Then
Response.Redirect("Default.aspx")
Else
Dim a As String = guvenlik(Request.QueryString("id"))
AccessDataSource1.SelectCommand = "Select * from makaleler where makale_id=" + a
End If
End If
End Sub
Sonra Guvenlik adındaki fonksiyonumuzu ekleyelim...
Public Function guvenlik(ByVal degistir As String)
degistir = Regex.Replace(degistir, ",", "")
degistir = Regex.Replace(degistir, "/", "")
degistir = Regex.Replace(degistir, "\n", "")
degistir = Regex.Replace(degistir, "/?", "")
degistir = Regex.Replace(degistir, "/*", "")
degistir = Regex.Replace(degistir, "'", "")
degistir = Regex.Replace(degistir, "&", "")
degistir = Regex.Replace(degistir, "<", "")
degistir = Regex.Replace(degistir, ">", "")
degistir = Regex.Replace(degistir, "=", "")
degistir = Regex.Replace(degistir, "AND", "")
degistir = Regex.Replace(degistir, "OR", "")
degistir = Regex.Replace(degistir, "AS", "")
degistir = Regex.Replace(degistir, "LIKE", "")
degistir = Regex.Replace(degistir, "JOIN", "")
degistir = Regex.Replace(degistir, "UNION", "")
degistir = Regex.Replace(degistir, "UPDATE", "")
degistir = Regex.Replace(degistir, "SELECT", "")
degistir = Regex.Replace(degistir, "INSERT", "")
degistir = Regex.Replace(degistir, "CREATE", "")
degistir = Regex.Replace(degistir, "DELETE", "")
degistir = Regex.Replace(degistir, "DROP", "")
degistir = Regex.Replace(degistir, "ALTER", "")
degistir = Regex.Replace(degistir, "HAVING", "")
degistir = Regex.Replace(degistir, "GROUP", "")
degistir = Regex.Replace(degistir, "BY", "")
degistir = Regex.Replace(degistir, "BETWEEN", "")
degistir = Regex.Replace(degistir, "IN", "")
degistir = Regex.Replace(degistir, "INNER", "")
degistir = Regex.Replace(degistir, "JOIN", "")
degistir = Regex.Replace(degistir, "SUM", "")
degistir = Regex.Replace(degistir, "SET", "")
Return degistir
End Function
Bu kodları kullanarak tan sitenize makale.goster.aspx?id=1 OR 1=1 gibi sql injectionlardan korunmayı garantileyebilirsiniz.Yukarıdaki kodlarda değişik TSQL fonksiyonları ve kodlamaları ekleyerek geliştirebilirsiniz...
Bu kodlamayla sql injection asla yemeyeceksiniz.Bu kıyağımı unutmayın
adlı namespace i projenize ekleyiniz...
Page_Load prosedürümüze aşağıdaki gibi bir kod yazalım...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
If Request.QueryString("id") = "" Then
Response.Redirect("Default.aspx")
Else
Dim a As String = guvenlik(Request.QueryString("id"))
AccessDataSource1.SelectCommand = "Select * from makaleler where makale_id=" + a
End If
End If
End Sub
Sonra Guvenlik adındaki fonksiyonumuzu ekleyelim...
Public Function guvenlik(ByVal degistir As String)
degistir = Regex.Replace(degistir, ",", "")
degistir = Regex.Replace(degistir, "/", "")
degistir = Regex.Replace(degistir, "\n", "")
degistir = Regex.Replace(degistir, "/?", "")
degistir = Regex.Replace(degistir, "/*", "")
degistir = Regex.Replace(degistir, "'", "")
degistir = Regex.Replace(degistir, "&", "")
degistir = Regex.Replace(degistir, "<", "")
degistir = Regex.Replace(degistir, ">", "")
degistir = Regex.Replace(degistir, "=", "")
degistir = Regex.Replace(degistir, "AND", "")
degistir = Regex.Replace(degistir, "OR", "")
degistir = Regex.Replace(degistir, "AS", "")
degistir = Regex.Replace(degistir, "LIKE", "")
degistir = Regex.Replace(degistir, "JOIN", "")
degistir = Regex.Replace(degistir, "UNION", "")
degistir = Regex.Replace(degistir, "UPDATE", "")
degistir = Regex.Replace(degistir, "SELECT", "")
degistir = Regex.Replace(degistir, "INSERT", "")
degistir = Regex.Replace(degistir, "CREATE", "")
degistir = Regex.Replace(degistir, "DELETE", "")
degistir = Regex.Replace(degistir, "DROP", "")
degistir = Regex.Replace(degistir, "ALTER", "")
degistir = Regex.Replace(degistir, "HAVING", "")
degistir = Regex.Replace(degistir, "GROUP", "")
degistir = Regex.Replace(degistir, "BY", "")
degistir = Regex.Replace(degistir, "BETWEEN", "")
degistir = Regex.Replace(degistir, "IN", "")
degistir = Regex.Replace(degistir, "INNER", "")
degistir = Regex.Replace(degistir, "JOIN", "")
degistir = Regex.Replace(degistir, "SUM", "")
degistir = Regex.Replace(degistir, "SET", "")
Return degistir
End Function
Bu kodları kullanarak tan sitenize makale.goster.aspx?id=1 OR 1=1 gibi sql injectionlardan korunmayı garantileyebilirsiniz.Yukarıdaki kodlarda değişik TSQL fonksiyonları ve kodlamaları ekleyerek geliştirebilirsiniz...
Bu kodlamayla sql injection asla yemeyeceksiniz.Bu kıyağımı unutmayın
