From:
Http://www.siteweavercms.cn/Item/113.aspx
Because the stored procedure has a + number connection SQL statement for string connection, this causes the possibility of SQL injection.
The following is an example:
Pr_usermanage_users_batchmove
Create procedure [DBO]. [pr_usermanage_users_batchmove]
(
@ Usertype Int = 1,
@ Groupid nvarchar (500) = '',
@ Userid nvarchar (4000) = '',
@ Username nvarchar (255) = '',
@ Startuserid Int = 0,
@ Enduserid Int = 0,
@ Batchusergroupid nvarchar (500) =''
)
As
Begin
Set nocount off
If (@ usertype = 1)
Begin
Exec ('Update pe_users set groupid = '+ @ groupid + 'where userid in (' + @ userid + ')')
End
Else if (@ usertype = 2)
Begin
Exec ('Update pe_users set groupid = '+ @ groupid + 'where username in (''' + @ username + ''')')
End
Else if (@ usertype = 3)
Begin
Exec ('Update pe_users set groupid = '+ @ groupid + 'where userid between' + @ startuserid +' and '+ @ enduserid)
End
Else if (@ usertype = 4)
Begin
Exec ('Update pe_users set groupid = '+ @ groupid + 'where groupid in (' + @ batchusergroupid + ')')
End
End
It can be seen that the user name is directly put into the query without filtering.
Call place:
Public bool movebyusername ( string username, int groupid) { parameters parmsforusers = new parameters (); parmsforusers. addinparameter ("@ usertype", dbtype . int32 , 2); parmsforusers. addinparameter ("@ username", dbtype . string , username); parmsforusers. addinparameter ("@ groupid", dbtype . int32 , groupid); Return dbhelper . executeproc ("pr_usermanage_users_batchmove", parmsforusers);} exploitation process:
User Management, batch movement specify the user name and add SQL Injection statements here
"/"Application Server Error in Program .
the quotation marks after the string 'jax ') are incomplete. There Is A syntax error near 'jax. Note: An error occurred while executing the current Web request. Check the stack trace information for details about the error and the source of the error in Code . exception details: the quotation marks after system. Data. sqlclient. sqlexception: String 'jax ')' are incomplete. 'jannock') 'is near a syntax error. |
solution: because you do not pay attention to the call, this may cause danger. Therefore, stored procedures similar to this type should be written outside the program, it is easy to filter and discover, and should not be written in the stored procedure. |