Explain how order clause can be exploited in Rails

后端 未结 2 1310
长情又很酷
长情又很酷 2021-01-27 08:33

I am having difficulty understanding how this section from this website on Rails SQL Injections works.

Taking advantage of SQL injection in ORDER BY clau

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-27 08:43

    If you are trying to determine the value of a field you know is in the table, but not being returned in the select you could iterate over it in the order by, until you get the value:

     ORDER BY CASE WHEN variableIdLikeToDiscover < 'N' then 1 else 0 end
    

    Then see whether it is greater than or less than 'N'. If it's less than, next you could try:

     ORDER BY CASE WHEN variableIdLikeToDiscover < 'F' then 1 else 0 end
    

    And so on and so forth until you have (eventually) determined the value.

提交回复
热议问题