çšèªé¶
Mayhem ããã³ãã®ããã¥ã¡ã³ãã§ã¯ããªãã¿ããªãçšèªã䜿ãããŠãã (ãããã¯ããªãã¿ãããçšèªããªãã¿ã®ãªã䜿ãæ¹ããããŠãã) ãããããŸããã以äžã«çšèªã®å®çŸ©ãç°¡åã«èª¬æããŸãã
ã¢ããªã±ãŒã·ã§ã³¶
ã¢ããªã±ãŒã·ã§ã³ã®å®çŸ©ã¯ãŠãŒã¶ãŒã«ãã£ãŠç°ãªããŸããã³ã³ããã¹ãã«ãã£ãŠã¯ãããŠã§ãã¢ããªãã®ããã« 1 ã€ã®ç®çãéæããããã«äœ¿çšããããœãããŠã§ã¢ã®éåãæããŸããMayhem ã§ã¯ãã¢ããªã±ãŒã·ã§ã³ãšã¯ "httpd" ã "/bin/ls" ã®ãããªåäžã®ããã°ã©ã ã§ããMayhem ã¯ã¢ããªã±ãŒã·ã§ã³ããã€ããªãå®è¡ãã¡ã€ã«ãšããçšèªãåãæå³ã§äœ¿çšãããŸãã
ããã€ã㢠ãã¹ã¶
ããã€ã㢠ãã¹ãã¯ãããŸããŸãªå ¥åå€ã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ãå®è¡ããå ¥åã®å€åã«äŒŽã£ãŠã©ã®ããã«ããã°ã©ã ãããŒãã³ãŒã ã«ãã¬ããžãã¢ããªã±ãŒã·ã§ã³ã®çµäºæ¹æ³ãç°ãªããã芳å¯ããŸããç°åžžãªèŠ³æž¬çµæãéžå¥ãããåäœãè匱æ§ã§ãããã©ãããå€æãããŸãã
å¶åŸ¡ãã㌠ã°ã©ã (CFG)¶
å¶åŸ¡ãã㌠ã°ã©ã (CFG) ãšã¯ãã¹ããŒãã¡ã³ããããŒããšããå¶åŸ¡ã®é·ç§»ãå¯èœãª 2 ã€ã®ããŒãã®éã«ãšããžãååšããæåã°ã©ãã§ãã
äŸåé¢ä¿¶
ã¢ããªã±ãŒã·ã§ã³ã®äŸåé¢ä¿ã«ã¯ãã¢ããªã±ãŒã·ã§ã³ã®å®è¡ã«å¿
èŠãªã©ã€ãã©ãªãæ§æãã¡ã€ã«ãå«ãŸããŸããldd /usr/bin/program
ã«ãã£ãŠãªã¹ããããã©ã€ãã©ãªããNGINX ã® nginx.conf
ãã¡ã€ã«ãªã©ãäŸåé¢ä¿ã®äŸã§ãã
åç解æ¶
åç解æã¯ãã¿ãŒã²ãã ããã°ã©ã ãå®éã®å
¥åãåŠçããã®ãã¢ãã¿ãŒããŸããããšãã°ãããã°ã©ã 㧠valgrind
ãå®è¡ããã®ã¯ãã¡ã¢ãª ãšã©ãŒã調ã¹ãåç解æã® 1 çš®ã§ãã
å®è¡å¯èœããã°ã©ã ¶
å®è¡ãã¡ã€ã«ã¯ãMayhem ã§ã¯ã¢ããªã±ãŒã·ã§ã³ãŸãã¯ãã€ããªãšãåŒã°ãããã£ã¹ã¯äžã®åäžã®ãã·ã³å®è¡å¯èœããã°ã©ã ã§ããC/C++ãGoãRust ãé¡äŒŒã®èšèªã§æžãããå®è¡ãã¡ã€ã«ã«ã³ã³ãã€ã«ããããã®ã Mayhem ã«é©åããŸããå®è¡ãã¡ã€ã«ã¯ã©ã€ãã©ãªãæ§æãã¡ã€ã«ãªã©ã®å€éšäŸåé¢ä¿ã«äŸåããŠããå ŽåããããŸããçŸæç¹ã§ã¯ãMayhem 㯠PythonãJavascriptãbash ãªã©ã®ã€ã³ã¿ãŒããªã¿ãŒèšèªã§æžãããããã°ã©ã ã解æã§ããŸããã
ã«ããŒããããšã㞶
Mayhem ã¯ãå¶åŸ¡ãã㌠ã°ã©ãã®ããã€ã®ãšããžãå®è¡ãããããèšæž¬ãããšããž ã«ãã¬ããž ã¡ããªã¯ã¹ã䜿çšããŸããããæ£åŒã«ã¯ãããã°ã©ã ã®åã¹ããŒãã¡ã³ããããŒããšããå¶åŸ¡ãã㌠ã°ã©ããèæ ®ãã2 ã€ã®ããŒãéã«å¯èœãªå¶åŸ¡ãããŒãããå Žåã«ã ãããŒããæ¥ç¶ãããŸãããšããž ã«ãã¬ããžã¯ããã¹ã ã¹ã€ãŒãã«ãã£ãŠæ€èšŒããããšããžã®æ°ãèšæž¬ããŸãã
ãã¡ãžã³ã°¶
ãã¡ãžã³ã°ã¯éžæãããå
¥åå€ A
ãå€åãããŠæ°ããå
¥åå€ B
ãäœæããå
¥åå€ B
ã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ãå®è¡ããŸããããã¡ãžã³ã°ããšããçšèªã¯ãäžè¬çã«ã¯ Bart Miller ã«ããé èªãšãããŠããŸãã
Mayhem ã¯ããŒããã©ãªãª ãã¡ã¶ãŒã§ããé«ãã¬ãã«ã§ã¯ããã¡ãžã³ã°ææ³ã¯æ¬¡ã®ããã«åé¡ã§ããŸãã
- ãã©ãã¯ããã¯ã¹ææ³: ããã°ã©ã èªäœã®ç¥èãªãã«ãéåžžã¯ã©ã³ãã ã«å
¥åãå€åãããŸãã Linux ã®
zzuff
ããã°ã©ã ã¯ããã©ãã¯ããã¯ã¹ ãã¡ã¶ãŒã®äŸã§ãã - ãã¯ã€ãããã¯ã¹ ãã¡ã¶ãŒ: ããã°ã©ã ã®æ
å ±ã䜿çšããŠå
¥åå€
A
ããå ¥åå€B
ã掟çãããŸãã Mayhem ã«ã¯ã·ã³ããªãã¯å®è¡ã«åºã¥ããã¯ã€ãããã¯ã¹ ãã¡ã¶ãŒãå«ãŸããŠããŸããã·ã³ããªãã¯å®è¡ã¯ã圢åŒã³ã³ãã¥ãŒã¿ãŒ ãµã€ãšã³ã¹ææ³ã䜿çšããå ¥åå€A
ã«å¯ŸããŠããã°ã©ã ãã©ã®ããã«å®è¡ãããããã¢ãã«åããŠæ°ããå ¥åå€B
ã掟çãããããã°ã©ã 解æææ³ã§ãã - ã°ã¬ãŒããã¯ã¹ ãã¡ã¶ãŒ: ã€ã³ã¹ãã¥ã«ã¡ã³ããŒã·ã§ã³ã䜿çšããŠæ°ããå
¥åå€ã掟çãããŸãã
afl
ãã¡ã¶ãŒã¯ã°ã¬ãŒããã¯ã¹ ãã¡ã¶ãŒã§ããMayhem ã«ã¯ã°ã¬ãŒããã¯ã¹ ãã¡ã¶ãŒãå«ãŸããŠããŸãã - ããŒããã©ãªãª ãã¡ã¶ãŒ: äžèšã®ãã¡ãžã³ã°ææ³ãã€ã³ããªãžã§ã³ãã«çµã¿åãããŠã«ãã¬ããžãæ倧åããŸãã
ããŒã㹶
ããŒãã¹ã¯ããã¹ã察象å®è¡ãã¡ã€ã«å ã®ã¿ãŒã²ãããšãããç¹å®ã«ãŒãã³ãåŒã³åºãæ°ããã³ãŒãããŠãŒã¶ãŒãè¿œå ããããšã§äœæãããŸãã
ãµã³ãã«:
OpenSSL ã® fuzz ãã£ã¬ã¯ããªã«ããã€ãã®ããŒãã¹ãå®çŸ©ãããŠããŸãã
Mayhemfile¶
Mayhem ã®æ§æãã¡ã€ã«ã§ãã
mCoders¶
Mayhem ã®ãŠãŒã¶ãŒãšã¯ãã¢ããªã±ãŒã·ã§ã³ ã»ãã¥ãªãã£ãdev(sec)opsãè匱æ§èª¿æ»ãå質ä¿èšŒãªã©ã®ããã¯ã°ã©ãŠã³ãã«ãããããããœãããŠã§ã¢ã®å質åäžã«é¢å¿ãæã€ãã¹ãŠã®äººãæããŸãã
ãã¬ãã£ã ãã¹ã¶
誀ã£ãåäœãŸãã¯æãŸãããªãåäœãæ€èšŒãããã¹ãã§ãããããžãã£ã ãã¹ãã®å察èªã§ãããã¬ãã£ã ãã¹ãã¯ãã¿ãŒã²ããã«èª€ã£ã圢åŒã®å ¥åå€ãæå®ãããå Žåãäºæããªãåäœãããªãããšãä¿èšŒããŸããããšãã°ãæ°å€ããŒãµãŒãæ°å€ã§ã¯ãªãæååå ¥åå€ãã°ã¬ãŒã¹ãã«ã«åŠçã§ããããšãä¿èšŒããã®ã¯ããã¬ãã£ã ãã¹ãã® 1 çš®ã«ãªãã§ãããã
ãã¹ãå®è¡æ°¶
ããã°ã©ã ã«å¯ŸããŠç°ãªãå ¥åå€ã§å®è¡ãããç¹°ãè¿ãã®ç·æ°ã§ãã
Note
ãã¹ãŠã®ç¹°ãè¿ããæ°ãããã¹ã ã±ãŒã¹ã«ã€ãªããããã§ã¯ãããŸãããæ°ãããšããž ã«ãã¬ããžãç¹å®ãããã¹ã ã±ãŒã¹ã ããä¿åããããããããã¯æåŸ ãããåäœã§ããããšãã°ããã¹ãå®è¡æ°ã 60M ã ã£ãå Žåãå°ãªããšã 6000 äžåã®å ¥åå€ã®ãã¥ãŒããŒã·ã§ã³ãè©Šã¿ãããã¿ãŒã²ããã«éä¿¡ãããããšãæå³ããŸãã
çµç¹¶
çµç¹ã¯ãMayhem ã§ãŠãŒã¶ãŒ (ãããã£ãŠã©ã³ãžã®ã¢ã¯ã»ã¹) ã管çããéã®æäžäœã®æ§é ã§ããçµç¹ã«ã¯ã¡ã³ããŒããããžã§ã¯ããããŒã ãå«ããããšãã§ããŸãã
çµç¹ãªãŒã㌶
çµç¹ã®ç®¡çè æš©éãæã€ãŠãŒã¶ãŒ ã¡ã³ããŒã§ããçµç¹ãªãŒããŒã§ãããŠãŒã¶ãŒã¯ãçµç¹å ã®ã¡ã³ããŒããã³ããŒã ã管çã§ããŸãã
çµç¹ã¡ã³ã㌶
çµç¹ã®ã¡ã³ããŒãšããŠãªã¹ãããããŠãŒã¶ãŒ ã¢ã«ãŠã³ãã§ãããŠãŒã¶ãŒãçµç¹å ã§ã©ã³ãéå§ããã«ã¯ããã®çµç¹ã®ã¡ã³ããŒã§ãªããã°ãªããŸãããã©ã³ãéå§ãããåã«ãåãŠãŒã¶ãŒã® API ããŒã¯ã³ãšçµç¹ã¡ã³ããŒã®ãªã¹ããç §åãããŸãããŠãŒã¶ãŒã¯è€æ°ã®çµç¹ã®ã¡ã³ããŒã«ãªãããšãã§ããŸãã
ããã±ãŒãž¶
ããã±ãŒãžã¯ãã¢ããªã±ãŒã·ã§ã³å®è¡ã«å¿
èŠãª chroot ç°å¢å
šäœã« Mayhem ãã©ã¡ãŒã¿ãŒãæå®ãã Mayhemfile
æ§æãã¡ã€ã«ãå ãããã®ã§ãã å
žåçãªããã±ãŒãžã«ã¯ä»¥äžãå«ãŸããŸãã
- ãã¡ãº ã¿ãŒã²ããã® Mayhem ã©ã³ãæ§æãã
Mayhemfile
- ãã¡ãº ã¿ãŒã²ããã®ãã¹ã ã±ãŒã¹ã®éåãå«ããã¹ã ãã©ã«ããŒ
- ã¢ããªã±ãŒã·ã§ã³ãŸãã¯ã³ã³ãã€ã«æžã¿ãã€ããªã®å®è¡ã«å¿ èŠãªã¢ããªã±ãŒã·ã§ã³åºæã®ã©ã€ãã©ãªããã³ã¢ããªã±ãŒã·ã§ã³åºæã®æ§æãã¡ã€ã«ãå«ã chroot ç°å¢
Note
çŸåšãããã±ãŒãžãšã¯ãDocker ã€ã¡ãŒãžãŸã㯠Docker ã䜿çšããªããŠãŒã¶ãŒã®ããã® chroot
ç°å¢ãå«ãç·åçãªæŠå¿µã§ããMayhem ããã±ãŒãžã®ç®çã¯ãåæ£ãã¡ãžã³ã°ã®ããã®å®å
šãªã©ã³ã¿ã€ã ç°å¢ãæå®ããããšã§ãã
ããžãã£ã ãã¹ã¶
ããžãã£ã ãã¹ãã¯ãããã°ã©ã ãžã®å ¥åå€ãšããŠæå¹ãªããŒã¿ãéä¿¡ããæåŸ ãããçµæãã©ããããã§ãã¯ãããã¹ãã® 1 çš®ã§ãã
ããŒããã©ãªãªè§£æ¶
解æã®ã·ã°ããã£ã®ã¿ã€ããåãè€æ°ã®ã¿ã€ãã®è§£æãå®è¡ããããšã§ããããšãã°ãã·ã³ããªãã¯å®è¡ãšãã¡ãžã³ã°ã¯ãäž¡æ¹ãšãããã°ã©ã ãšã·ãŒãå ¥åå€ãåãåããæ°ãããã¹ã ã±ãŒã¹ãåºåããŸããã·ã³ããªãã¯å®è¡ãšãã¡ãžã³ã°ã¯ãããŒããã©ãªãªè§£æãšããŠåæã«å®è¡ã§ããŸãã
ãããžã§ã¯ã¶
ãããžã§ã¯ãã¯ã解æ察象ã¿ãŒã²ããã®ã³ã¬ã¯ã·ã§ã³ã§ãããŠãŒã¶ãŒã¯ãããžã§ã¯ãã«å«ããã¿ãŒã²ããã決å®ã§ããŸãããããããã¿ãŒã³ã¯ã1 ã€ã®æ¯èŒç倧ããªã¢ããªã±ãŒã·ã§ã³ã®ããã®ã¿ãŒã²ããããã¹ãŠ 1 ã€ã®ãããžã§ã¯ãã«å ¥ãããšãããã®ã§ãã
ãããžã§ã¯ã ã³ã³ããªãã¥ãŒã¿ãŒ¶
ãããžã§ã¯ãã«è¿œå ãããèªã¿åããæžã蟌ã¿ã管çã¢ã¯ã»ã¹æš©ã®ãããããä»äžããããŠãŒã¶ãŒãŸãã¯ããŒã ã¢ã«ãŠã³ãã§ãã管çæš©éãæã€ã³ã³ããªãã¥ãŒã¿ãŒã ãããããžã§ã¯ããåé€ã§ããŸããä»»æã®ãŠãŒã¶ãŒ ã¢ã«ãŠã³ãããããžã§ã¯ããäœæã§ããŸãã
ã©ã³¶
Mayhem ãåæ£ã¯ã©ã¹ã¿ãŒå ã§ã¢ããªã±ãŒã·ã§ã³ã®ãã¡ãº ãã¹ããå®è¡ãã Mayhem ã©ã³ã§ã (ãžã§ããšãåŒã°ããŸã)ã
ã¿ãŒã²ãã¶
ã¿ãŒã²ããã¯ãã³ã³ãã€ã«æžã¿ã®ã¢ããªã±ãŒã·ã§ã³ãšãããå®è¡ããããã®ã³ãã³ã ã©ã€ã³ã§ãã
ããšãã°ãOpenSSL ãã³ã³ãã€ã«ãããšãopenssl
å®è¡ãã¡ã€ã«ãçæãããŸãã次ã®äŸã§ã¯ã1 ã€å®è¡ãã¡ã€ã«ã«å¯Ÿã㊠3 ã€ã®ç°ãªãã¿ãŒã²ããããããŸããã·ã³ãã« @@
ã¯ããã¡ãžã³ã°ã«äœ¿çšãããã¡ã€ã«ãè¡šããŸãã
openssl cms -cmsout -inform DER -in @@
openssl sha @@
openssl seed -in @@ -out /tmp/file2 -k foobar
ããŒã ¶
ããŒã ã¯ãè€æ°ã®ãŠãŒã¶ãŒ ã¢ã«ãŠã³ãã 1 ã€ã®ãŠãããã«ãŸãšããŠãããŒã å ã®ãã¹ãŠã®ãŠãŒã¶ãŒã«ããŒããã·ã§ã³ãå²ãåœãŠãããã®æ段ã§ãã
ãã¹ã ã±ãŒã¹¶
ãã¹ã ã±ãŒã¹ã¯ãããã°ã©ã ãŸãã¯ã·ã¹ãã ã®åäœãäºæããªãå ¥åå€ããã³æªæã®ããå ¥åå€ã«å¯Ÿããã¬ãžãªãšã³ã¹ãæ€èšŒããããã«çæãããããã°ã©ã ãŸãã¯ã·ã¹ãã ã«äžããããç¹å®ã®å ¥åå€ãŸãã¯ããŒã¿ãæããŸããéåžžããã¡ãžã³ã° ãã¹ã ã±ãŒã¹ã«ã¯ãæœåšçãªè匱æ§ãåŒãèµ·ãããããœãããŠã§ã¢ã®ãã°ãæããã«ããããã«ã誀ã£ã圢åŒã®ããŒã¿ãäºæããªãããŒã¿ãå«ãŸããŸãã
ãã¹ã ã«ãã¬ã㞶
ãã¹ã ã«ãã¬ããžã¯ã³ãŒã ã«ãã¬ããžãšãåŒã°ããå€åãããå ¥åãã¹ã ã±ãŒã¹ã䜿çšãããã¡ãžã³ã°ã§ãããã°ã©ã ãæ§æããã³ãŒããã©ã®çšåºŠå®è¡ãããããèšæž¬ããŸãã
ããšãã°ãå ¥åæååãèªã¿åãããã°ã©ã ããããšããŸããããã°ã©ã ã«ãã¹ã ã±ãŒã¹ "welcome" ãäžãããããšãããã°ã©ã 㯠"hello!" ãšåºåããä»ã®å Žåã¯å¥ã®åŠçãè¡ããŸãã
ãã®ããã°ã©ã ãå¶åŸ¡ãã㌠ã°ã©ããšããŠèããŠã¿ããšãå ¥åãã¹ã ã±ãŒã¹ã«åºã¥ããŠå®è¡ãããå¯èœæ§ããããã¹ãè€æ°ããããšãããããŸãã
graph TD
1[1 - input] -- if input == 'welcome' --> 2[2 - print 'hello!'];
1 -- else --> 3;
2-->3[3 - do something];
ãã®ããã°ã©ã ã®ã«ãã¬ããžã¯ã次ã®ã«ããŽãªã«åé¡ã§ããŸãã
- ããŒã ã«ãã¬ããž: ã°ã©ãã®åããŒããå®è¡ãããã¹ã ãã¹ã®éçŽãè¡šããŸããããŒã ã«ãã¬ããžã¯åããŒããå®è¡ãããããšã ããèŠæ±ããããŒãéã®ãã¹ãå®è¡ããããã©ããã¯åããŸãããããšãã°ããã¹ã ãã¹ [1, 2, 3] ã¯ãã¹ãŠã®ããŒãã«å°éããããèŠä»¶ {1, 2, 3} ãæºãããŸãã
- ãã¹ãèŠä»¶ = {1, 2, 3}
-
ãã¹ã ãã¹:
- [1, 2, 3]
-
ãšããž ã«ãã¬ããžã°ã©ãã®åãŠããŒã¯ãªç·ãã€ãŸããšããžãå®è¡ãããã¹ã ãã¹ã®éçŽãè¡šããŸãããšããž ã«ãã¬ããžã¯ã2 ã€ã®ããŒãéã®ãã¹ãŠã®ãã¹ãå®è¡ãããããšãèŠæ±ãããããäžèšã®ããŒã ã«ãã¬ããžã®ãã¹ã ãã¹ã§ã¯ååã§ã¯ãããŸãããããŒã 1 ãš 3 ãçŽæ¥ã€ãªããšããžãã«ããŒããã«ã¯ãè¿œå ã®ãã¹ã ãã¹ [1, 3] ãå¿ èŠã§ãã
- ãã¹ãèŠä»¶ = {(1, 2), (1, 3), (2, 3)}
-
ãã¹ã ãã¹:
- [1, 2, 3]
- [1, 3]
-
å®å šãã¹ ã«ãã¬ããžããã°ã©ã äžã®ãã¹ãŠã®ç·ç¶ã®ãã¹ãå°ãªããšã 1 åã¯å®è¡ããããã¹ã ãã¹ãè¡šããŸãã
- ãã¹ã ãã¹åèš:
- [1, 2, 3]
- [1, 3]
Info
ããã°ã©ã ã®å¶åŸ¡ãã㌠ã°ã©ãäžã®ã«ãŒããèæ ®ãããšãå®å šãã¹ ã«ãã¬ããžã¯ãšããž ã«ãã¬ããžãšã¯ç°ãªãå ŽåããããŸããã«ãã¬ããžè§£æã®è©³çŽ°ã«ã€ããŠã¯ãã¡ããåç §ããŠãã ããã
ãã®ãããã¿ãŒã²ãã ããã°ã©ã ããã¡ãžã³ã°ããéãMayhem ã¯ããã°ã©ã ã®å¶åŸ¡ãããŒã«æ²¿ã£ãããŸããŸãªãã¹ã ãã¹ãå®è¡ã§ãããããã©ã³ãã ãªå ¥åãã¹ã ã±ãŒã¹ãçæããŸãããã®åŸãã«ããŒããããšããžãªã©ã®ããŒã¿ã远跡ãã以éã®ã«ãã¬ããžè§£æã«äœ¿çšã§ããã«ãã¬ããž ãã¡ã€ã«ãçæããŸãã
ãã¹ã ã¹ã€ãŒã¶
ãã¹ã ã¹ã€ãŒãã¯ãããã°ã©ã ãŸãã¯ã·ã¹ãã ã®å ç¢æ§ãšã»ãã¥ãªãã£ãè©äŸ¡ããããã«ããŸãšããŠå®è¡ãããããæå³ããããã¹ã ã±ãŒã¹ã®ã³ã¬ã¯ã·ã§ã³ãŸãã¯ã»ãããæããŸãããã¡ãžã³ã° ãã¹ã ã¹ã€ãŒãã¯è€æ°ã®ãã¹ã ã±ãŒã¹ãããªããããããã®ãã¹ã ã±ãŒã¹ã¯ãã³ãŒã ã«ãã¬ããžãæ倧åããæœåšçãªè匱æ§ããœãããŠã§ã¢ã®æ¬ é¥ãæ€åºããããšãç®çãšããããŸããŸãªå ¥åå€ããã³ããŒã¿ã®ããªãšãŒã·ã§ã³ãå«ãã§ããŸãã
ãã¹ã ã¹ã€ãŒã ãµã€ãº¶
Mayhem ã«ãã£ãŠçºèŠããããããããä»ãšéè€ããªãã³ãŒã ã«ãã¬ããžã«å¯äžãããã¹ã ã±ãŒã¹ã®æ°ã§ãã
Note
ãããã®ãã¹ã ã±ãŒã¹ã®ãããããåé€ãããšããã§ã«çºèŠãããæ©èœã®äžéšãæ€èšŒãããªããªããŸãã