second-order SQL injection ( ã»ã«ã³ããªã¼ãã¼SQLã¤ã³ã¸ã§ã¯ã·ã§ã³ )
é«æ¨å
çã®Blogããã
http://takagi-hiromitsu.jp/diary/20051231.html#p05
â¦ããã¾ãããªã³ã¯å
ã«ç§»åãã¦èªãã§ããã§çä»ããã»ããæ©ããã ãã©ã
ã¾ãä¸å¿ããã¯ãããããªã®ã§ãå¿
è¦ãªã¨ãããæ¸ãã¦ããã¾ãã£ã¦ãããå¼ç¨ãã¦ããã¾ãã
ãã¨ãã¢ããªã±ã¼ã·ã§ã³ã常ã«ã·ã³ã°ã«ã¯ãªã¼ããã¨ã¹ã±ã¼ããã¦ãã¦ããæ»æè ã¯ãªããããã¼ã¿ãã¼ã¹ä¸ã®ãã¼ã¿ããã®ã¢ããªã±ã¼ã·ã§ã³ã§åå©ç¨ãããã¨ãã«SQLãã¤ã³ã¸ã§ã¯ããããã¨ãã§ããã
Username: admin'--
Password: passwordä¾ãã°ãæ»æè ãã¢ããªã±ã¼ã·ã§ã³ã«ç»é²ãã¦ãã¦ã¼ã¶åãadmin'--ãããã¹ã¯ã¼ããpasswordãã®ã¦ã¼ã¶åãä½ã£ãã¨ãããã
ãã®ã¢ããªã±ã¼ã·ã§ã³ã¯ã·ã³ã°ã«ã¯ãªã¼ããæ£ããã¨ã¹ã±ã¼ããããã®ãããªINSERTæãä½ããããinsert into users values( 123, 'admin''--', 'password', 0xffff)
ãã®ã¢ããªã±ã¼ã·ã§ã³ããã¦ã¼ã¶ã«ãã®ãã¹ã¯ã¼ããå¤æ´ãããã¨ã許ãã¦ããã¨ãããã
æ°ãã¹ã¯ã¼ããã»ããããã¯ã¨ãªã¯ãããªæãã«ãªããããããªãã
sql = "update users set password = '" + newpassword + "' where
username = '" + rso("username") + "'"ã¦ã¼ã¶å admin'-- ãä¸ããããã¨ã以ä¸ã®ã¯ã¨ãªãçæããã
update users set password = 'password' where username = 'admin'--'
ãããã£ã¦æ»æè ã¯ãadmin'-- ã¨ããã¦ã¼ã¶ãç»é²ãããã¨ã«ãã£ã¦ãadmin ã®ãã¹ã¯ã¼ããèªç±ã«ã»ããã§ããã
ãã£ã¨â¦ã¾ããã¨ã¹ã±ã¼ãå¦çãå¿ããã ãã¸ã£ã³ãã¨ãããçªè¾¼ã¿ãé ã«æµ®ãã¶ãé«æ¨å
çãåãããã«çªã£è¾¼ã¾ãã¦ããã¾ããã
ã¨ã¯ãããä»äººæ§ã®ããã°ã©ã ããã§ãã¯ããéã«ã¯èæ
®ãã¦ãããããã¤ã³ãã®ä¸ã¤ãªã®ããããã¾ããã