SQL注入中的1=1

1<>1 的用處:

用於只取結構不取數據的場合,例如:
create table table_tem

引用塊內容

p tablespace tbs_temp as
select * from table_ori where 1<>1
建成一個與table_ori 結構相同的表table_temp,但是不要table_ori 裏的數據。
(除了表結構,其它結構也同理)

1=1用於動態SQL,例如:

lv_string = ‘select tbl_name,tbl_desc from tbl_test where 1=1 ‘+l_condition;
當用戶選擇了查詢的名稱’abc’時
l_condition =’and tbl_name = ”abc”’;
但是當用戶沒有選擇名稱查詢時l_condition就爲空串”這樣
lv_string = ‘select tbl_name,tbl_desc from tbl_test where 1=1 ‘,
運行也不會出錯,相當於沒有限制名稱條件。但是如果沒有1=1的條件,則
lv_string = ‘select tbl_name,tbl_desc from tbl_test where ‘;
這樣就會報錯。

SQL注入

select * from users where username=” or 1=1#’ and password=md5(”)
  語義分析:“#”在mysql中是註釋符,這樣井號後面的內容將被mysql視爲註釋內容,這樣就不會去執行了,換句話說,以下的兩句sql語句等價:
   select * from users where username=” or 1=1#’ and password=md5(”)
  等價於
   select * from users where username=” or 1=1
  因爲1=1永遠都是成立的,即where子句總是爲真,將該sql進一步簡化之後,等價如下select語句:
   select * from users

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章