ãã€ãŠãçãããã®ããã¬ã€ããããšã«æ±ºããã®ã§ãããã¹ãããŒã¹ã®ã³ã³ãã¥ãŒã¿ãŒãã«ããã¬ã€ã€ãŒãã£ããã²ãŒã ã§ããMUDã«ç®ãåããŸããã ç¹å®ã®ãµãŒããŒçšã«äœæãããå°çšã¯ã©ã€ã¢ã³ãã®å©ããåããŠãããã³telnetãä»ããŠããããåçã§ããŸãã
çŸåšååšãããµãŒããŒïŒhttps://www.bat.org/ïŒã®ãããããéžæãããšãWindowsçšã®æ¢å®ã®telnetã¯ã©ã€ã¢ã³ãã䜿çšããŠæŠè£ ãã...ãã£ããããŸããã ãããããã€ã³ãã¯ã²ãŒã å ã«ããã®ã§ã¯ãªããtelnet.exeããã®ã²ãŒã ãšå¯Ÿè©±ããæ¹æ³ã«ãããŸãã æ°ã¥ãã®ã¯æ²ããã§ãããå ¥åããæåïŒæååãããŸããŸãªã¢ã¯ã·ã§ã³ãªã©ïŒã®ããããã³ã³ãœãŒã«ç»é¢ã«è¡šç€ºãããŸããã§ããã ã¯ããã³ãã³ãã¯EnterããŒãæŒãããšã§éä¿¡ãããŸããããæå°éã®å¯Ÿè©±æ©èœããªãããããã®ãããªã²ãŒã ã¯äºå®äžäžå¯èœã«ãªããŸããïŒä»¥åã«å ¥åããæåãåé€ããã®ã¯ç¹ã«äžäŸ¿ã§ããã
èãçŽãããšãªããç§ã¯ãããš...ã䜿çšããŠåããµãŒããŒã«æ¥ç¶ããŠã¿ãããšã«ããŸãã... ãããŒ ïŒ å ¥åããæåã衚瀺ãããŸãïŒ
telnet.exeã§ãšã³ãŒãæ©èœããªãã®ã¯ãªãã§ããïŒ ãããä¿®æ£ããæ¹æ³ã¯ãããŸããïŒ ãããç解ããŸãããã
ããã»ã¹ãã©ã®ããã«é²ãã ãããããŠãã®çµæã¯ãã«ããã®äžã§èªã¿ãŸããã ãã®èšäºãèªãåã«ã以åã®èšäºãããç解ããŠããããšã匷ããå§ãããŸãã ããã§ã¯çç¥ãããå€ãã®ç¹ã«ã€ããŠæ¢ã«èª¬æããŠããŸãã
æåã®ã¹ãããã¯ã件åãååŸããããšã§ãã telnetã¯ã©ã€ã¢ã³ããã€ã³ã¹ããŒã«ãïŒWin-R-> appwiz.cpl-> Windowsã®æ©èœããªã³ãŸãã¯ãªãã«ãã->ãTelnetã¯ã©ã€ã¢ã³ããã®ç¢æã®æšªã«ãã§ãã¯ããŒã¯ãä»ãããOKããã¿ã³ãã¯ãªãã¯ããŸãïŒãå®è¡å¯èœãªtelnet.exeãã¡ã€ã«ããïŒ WINDIRïŒ \ System32 "ä»ã®ãã£ã¬ã¯ããªã«ã
次ã®ã¹ãããã¯ãå¿ èŠãªããŒã«ãæºåããããšã§ãã PE ToolsãšOllyDbgãããŠã³ããŒãããŸã ãããã¯ä»¥åã®èšäºã§äœåºŠãèšåããŸãããã䟿å©ãªãã£ã¬ã¯ããªã«å±éããŠãã ããã
次ã«ãæ¢çŽ¢ãããã€ããªã«å¯ŸããŠASLRãã¯ãããžãæå¹ã«ãªã£ãŠãããã©ãããç解ããå¿ èŠããããŸãã PEããŒã«ãèµ·åããAlt-1ãæŒããŠtelnet.exeãéžæããããªãã·ã§ã³ã®ããããŒããã¿ã³ãã¯ãªãã¯ããŸãã
ã¯ããASLRã¯æå¹ã§ãã ããããªãã«ããŸããã-0x8140ã0x8100ã«çœ®ãæããŠïŒããã以åã«èª¬æãããçç±ã§ã-ããšãã°ã ãããåç § ïŒããOKããã¿ã³ãã¯ãªãã¯ããŸãã
ããã§ã¯ãèãã¯äœã§ããïŒ ç§ãæåã«æãã€ããã®ã¯ãã¢ããªã±ãŒã·ã§ã³ãSetAPonsoleMode WinAPIé¢æ°ã䜿çšããŠãšã³ãŒãæ瀺çã«ãç¡å¹åãã§ããããšã§ãã OllyDbgã§ãã€ããªãéå§ããã¢ãžã¥ãŒã«éåŒã³åºãã®ãªã¹ããå«ããŠã£ã³ããŠãéãããã®é¢æ°ãžã®åŒã³åºããã¢ããªã±ãŒã·ã§ã³ã«å®éã«ååšããããšã確èªããŸãã
ãããã«ãã¬ãŒã¯ã眮ããF9ãæŒããŠããã¬ãŒã¯ãã€ã³ãã®1ã€ã§åæ¢ããŸãã
ã¹ã¿ãã¯ãŠã£ã³ããŠã®åŒæ°ãèŠãŠã¿ãŸãããã
ããã¥ã¡ã³ããèªãïŒ
ENABLE_ECHO_INPUT
0x0004
ReadFileé¢æ°ãŸãã¯ReadConsoleé¢æ°ã«ãã£ãŠèªã¿åãããæåã¯ãèªã¿åããããšãã«ã¢ã¯ãã£ããªç»é¢ãããã¡ãŒã«æžã蟌ãŸããŸãã ãã®ã¢ãŒãã¯ãENABLE_LINE_INPUTã¢ãŒããæå¹ã«ãªã£ãŠããå Žåã«ã®ã¿äœ¿çšã§ããŸã
å¿ èŠãªãã®ïŒ ãã ãããã£ãšç°¡åãªæ¹æ³ããããŸã-ãã®é¢æ°ãåŒã³åºããªãã§ãã ããïŒ
ã³ã³ãœãŒã«ãäœæããããšãENABLE_WINDOW_INPUTãé€ããã¹ãŠã®å ¥åã¢ãŒããããã©ã«ãã§æå¹ã«ãªããŸã
ãããã°ãåéããŸããããåŒã³åºããåæ¢ããŸã
ãšã³ãŒãåäœãããã©ããã確èªããŠãã ããã ããããçµæã¯ä»¥åãšåãã§ã-å ¥åããæåã¯ã³ã³ãœãŒã«ç»é¢ã«è¡šç€ºãããŸããã
ããŠãã²ãŒã ãååã®å ¥åãèŠæ±ããç¬éãåŸ ã¡ãŸããã
ãããã³OllyDbgã§F12ïŒäžæåæ¢ïŒãæŒããŸãã
ç§ãã¡ãä»ã©ãã«ããããç解ããããã«åšããèŠåãããšããå§ãããŸãã éå§ããã«ã¯ãAlt-KãæŒããŠã³ãŒã«ã¹ã¿ãã¯ãéããŸãã
ãã®ãããuser32.dllã®è žå ã®ã©ããã«ãã³ã°ã¢ããããŸãã user32.dllã«å°éããå Žæããã 0x0100D0D0ã«ããæãè¿ãããŠãŒã¶ãŒãã³ãŒãïŒã€ãŸããtelnetã¢ãžã¥ãŒã«ã«å±ããã³ãŒãïŒã«ãžã£ã³ãããŸãã
çµéšè±å¯ãªWindowséçºè ã¯ãéžæãããåœä»€GetMessageã®å®è¡æã«EDIã¬ãžã¹ã¿ã§æãå¯èœæ§ã®é«ãé¢æ°ã¢ãã¬ã¹ããã§ã«ç解ããŠããå¿ èŠããããŸãã ãããããããå人çã«ç¢ºèªããŸãããã ãã®ã¢ãã¬ã¹ã«ãã¬ãŒã¯ã眮ãããããã°ãåéããç®çã®å Žæã«å°éãããŸã§F9ãæŒããŸãã
ã芧ã®ãšãããããã¯å®éã«ã¯GetMessageã§ãã ãã®å Žåã®åé¡ã¯ããã®é¢æ°ãEnterããŒãæŒãåã«åŒã³åºããã³ãŒãã«å¶åŸ¡ãæ»ããªãããšã§ããã€ãŸãããšã³ãŒãšã¯ãŸã£ããé¢ä¿ãããŸããã
次ã«ããã®æç¹ã§ä»ã®ã¹ã¬ãããäœãããŠããã®ããèŠãŠã¿ãŸãããïŒãã¡ãããååšããå ŽåïŒã å床ãF9ã䜿çšããŠããã°ã©ã ãå®è¡ããF12ãæŒããŠãã¹ã¬ããããŠã£ã³ããŠãéããŸãïŒè¡šç€º->ã¹ã¬ããïŒïŒ
èµ€ã§åŒ·èª¿è¡šç€ºãããŠããïŒããã¯ä»èŠãã°ããã®çŸåšã®ã¹ã¬ããã§ãïŒä»¥å€ã¯ããããããCPUãŠã£ã³ããŠã§éãïŒã¹ã¬ãã-> CPUãŠã£ã³ããŠã§å¯Ÿå¿ããè¡ãå³ã¯ãªãã¯ïŒãåŒã³åºãã¹ã¿ãã¯ã確èªããŸãã 次ã®åŒã³åºãã¹ã¿ãã¯ã䜿çšããŠã¹ã¬ããã«æ³šæãåããå¿ èŠããããŸãã
ReadConsoleInputã¯ããã®ã±ãŒã¹ã§ã¯ãã§ã«ããèå³æ·±ãé¢æ°ã§ãã åŒã³åºãã«ãã¬ãŒã¯ãã€ã³ããèšå®ãããããã°ãåéãã... telnetãŠã£ã³ããŠã«ãã©ãŒã«ã¹ã移åãããã³ã«åæ¢ããŸãã
è¿ãã«ã¹ã€ãããããããšã«æ³šæããŠãã ãããã»ãšãã©ã®å Žåã察å¿ããã€ãã³ãã®ãã³ãã©ãŒã«ãžã£ã³ãããŸãã ãããã¬ã§å®è¡ããåŸããã©ãŒã«ã¹ãå€æŽãããå Žåãå¶åŸ¡ãããã©ã«ãã®ã±ãŒã¹ã«ç§»ãããããšãããããŸãã
OllyDbgã«ããã³ãŒãã®åæããå€æãããšãããã«ã¯å€ãã®ãªãã·ã§ã³ã¯ãããŸãã-ããã©ã«ãã®ã±ãŒã¹ã«å ããŠãã±ãŒã¹10ããã³1ããããŸããæåã®ã±ãŒã¹ã§ã¯ãããã€ãã®åœä»€ãå®è¡ããåŸãèæ ®ããããã©ã«ãã®ã±ãŒã¹ã«ãžã£ã³ãããŸãã ReadConsoleInputé¢æ°ã®åŒã³åºããããã¬ãŒã¯ãåé€ããŠãã±ãŒã¹1ã«ãã¬ãŒã¯ãå ¥ããŠã¿ãŸãããã
ãããã°ãåéããååã®å ¥åãæ±ããã¡ãã»ãŒãžã衚瀺ãããã®ãåŸ ã¡ãã1ããæŒããŠããã®ãŸãã«ã±ãŒã¹ãããã¯ã§åæ¢ããŸãã
ä»äœãã§ããŸããïŒ ããã§ãbat.orgãããšãã°smtp.gmail.comã«æ¥ç¶ããå Žåã®telnet.exeã®åäœã確èªã§ããããã«ãªããŸãããæãåºããšããšã³ãŒã¯æ£ããæ©èœããŠããŸããã ããã¬ãŒã¹ã®å®è¡ããŠã£ã³ããŠãéãïŒè¡šç€º->ãã¬ãŒã¹ã®å®è¡ïŒãå³ã¯ãªãã¯ããŠãããã¡ã€ã«ã«ãã°ããšããã¡ãã¥ãŒé ç®ãéžæãããã¡ã€ã«åãéžæããŠCtrl-F11ïŒãã¬ãŒã¹ã€ã³ïŒãæŒããŸãã ãã¬ãŒã¹åŸããã¡ã€ã«ãéãïŒããã¬ãŒã¹ã®å®è¡ããŠã£ã³ããŠãå³ã¯ãªãã¯->ãã°ãã¡ã€ã«ãéããïŒãsmtp.gmail.comïŒ25ã®å Žåãåãããšãè¡ããŸãïŒtelnetããŒããæ瀺çã«æå®ããå Žåã¯ãIPã¢ãã¬ã¹ãã¹ããŒã¹æåã䜿çšããŸããã€ãŸããã³ãã³ãã¯ãtelnet.exe smtp.gmail.com 25ãã®ããã«ãªããŸãã
åäœã®é¡èãªéãã¯ãã¢ãã¬ã¹0x0100A2F9ããå§ãŸããŸãã
bat.orgã®å Žå
ã¢ãã¬ã¹ã¹ã¬ããã³ãã³ãã ç»é²ãšã³ã¡ã³ã 0100AB9F 00002EA0 JNZ telnetã0100AED2 0100ABA5 00002EA0ãã¹ããã€ãPTR SSïŒ[EBP-24]ã3 0100ABA9 00002EA0 JE telnetã0100AED2 [...] 0100A2F7 00002EA0ãã¹ãEAXãEAX 0100A2F9 00002EA0 JNZã·ã§ãŒãtelnetã0100A304 0100A2FB 00002EA0ãã¹ããã€ãPTR DSïŒ[1010740]ã10 [...]
smtp.gmail.comã®å Žå
ã¢ãã¬ã¹ã¹ã¬ããã³ãã³ãã ç»é²ãšã³ã¡ã³ã 0100AB9F 00002EA0 JNZ telnetã0100AED2 0100ABA5 00002EA0ãã¹ããã€ãPTR SSïŒ[EBP-24]ã3 0100ABA9 00002EA0 JE telnetã0100AED2 [...] 0100A2F7 000031D4ãã¹ãEAXãEAX 0100A2F9 000031D4 JNZã·ã§ãŒãtelnetã0100A304 0100A304 000031D4 PUSH EDI; Arg4 = 01024CA0 [...]
telnet.exeãbat.orgãšéä¿¡ããå Žåã0x0100A304ãžã®ãžã£ã³ãã¯å®è¡ãããŸããã 0x0100A2F9ã®åœä»€ããç¡æ¡ä»¶ã«ãžã£ã³ãããŠã¿ãŸãããã ãããã°ãåéããtelnetã¢ãžã¥ãŒã«ã«ç§»åããŠCtrl-GãæŒãã衚瀺ããããŠã£ã³ããŠã«ã¢ãã¬ã¹0x0100A2F9ãå ¥åããEnterãæŒããŸãã ã¹ããŒã¹ããŒãæŒããŠã JNZåœä»€ãJMPã«çœ®ãæããŸãã
F9ããŒãæŒããTelnetãŠã£ã³ããŠã«ã1ããå ¥åããŠãææ¡ããããªãã·ã§ã³ã®ãããããéžæããããååãå ¥åããŠãã ãããå ¥åããèšå·ã衚瀺ãããŸãã
ãããã¬ã§å®è¡ãããšã SetConsoleCursorPositionãWriteConsoleOutputCharacterãªã©ã®WinAPIé¢æ°ã®åŒã³åºããè¡ãããã³ãŒããã©ã³ãã«å ¥ãããšãããããŸãã
ã§ã¯ãªãæ©ãããã«æ¥ãªãã£ãã®ã§ããïŒ ãžã£ã³ãã«ã€ããŠã®æ±ºå®ãäœã«äŸåããŠãããèŠãŠã¿ãŸãããïŒ
TEST EAXãEAXæäœã®çµæã«äŸåããåã®ã¹ã¯ãªãŒã³ã·ã§ããã«èŠãããããã«ãå€ã¯ã¢ãã¬ã¹0x01010754ããEAXã¬ãžã¹ã¿ãŒã«èœã¡ãŸããã ããŠãbat.orgã®å Žåã«ãŒãã§ãã£ãçç±ãç解ããŠã¿ãŸãããã
調ã¹ãããã«ãã¢ãã¬ã¹0x01010754ã«ããŒããŠã§ã¢ãã¬ãŒã¯ã¬ã³ãŒãã眮ãããšãææ¡ããŸãã ããã«ãžã£ã³ãããã«ã¯ã 0x0100A2BDã«ããåœä»€ãå³ã¯ãªãã¯->ãã³ãã§ãã©ããŒ->ã¡ã¢ãªã¢ãã¬ã¹ïŒ
æå®ãããã¢ãã¬ã¹ã®æåã®ãã€ããå³ã¯ãªãã¯->ãã¬ãŒã¯ãã€ã³ã->ããŒããŠã§ã¢ãæžã蟌ã¿-> Dwordã ãããã°ãåéãããŒããå«ãŸãããšãã«ã¢ãã¬ã¹0x01010754ãžã®æåŸã®åŒã³åºããèŠã€ããŸãã ãã®ã¢ããŒã«ã¯ãã¡ãã§ãïŒ
åŒã³åºãã¹ã¿ãã¯ãèŠãŠãããã§åŒã³åºãããå Žæããããã·ãŒãžã£ã«ãžã£ã³ããããšãåä¿¡ããŒã¿ã®åŸç¶ã®åæã䌎ãrecvé¢æ°ã®åŒã³åºãã衚瀺ãããŸãã
å®æ°0xFFã«æ³šæããŠãã ããã telnet ä»æ§ã«ãããšããã®ãã€ãã«ç¶ãã®ã¯ããã®ãããã³ã«ã§äœ¿çšãããã³ãã³ãã§ãã
以äžã¯ãå®çŸ©ãããTELNETã³ãã³ãã§ãã ãããã®ã³ãŒãã«æ³šæããŠãã ãã ãŸããã³ãŒãã·ãŒã±ã³ã¹ã¯ãããã«æå®ãããæå³ãæã¡ãŸã IACãå è¡ããŸãã ååã³ãŒãã®æå³ SE 240ãµãããŽã·ãšãŒã·ã§ã³ãã©ã¡ãŒã¿ã®çµããã NOP 241æäœãªãã ããŒã¿ããŒã¯242åæã®ããŒã¿ã¹ããªãŒã éšåã ããã¯åžžã«äŒŽãã¹ãã§ã TCPç·æ¥éç¥ã«ããã 243 NVTãã£ã©ã¯ã¿ãŒBRKã解é€ããŸãã å²ã蟌ã¿ããã»ã¹244æ©èœIPã åºåã®äžæ¢245é¢æ°AOã Are You There 246é¢æ°AYTã æå247ã®æ¶å»é¢æ°ECã æ¶å»è¡248é¢æ°ELã å ã«è¡ã249 GAã·ã°ãã«ã SB 250åŸã«ç¶ããã®ã 瀺ãããã®å¯äº€æž ãªãã·ã§ã³ã WILLïŒãªãã·ã§ã³ã³ãŒãïŒ251éå§ãåžæããããšã瀺ããŸã å®è¡ããŸãã¯ç¢ºèª ããªãã¯ä»æŒå¥ããŠããŸã 瀺ããããªãã·ã§ã³ã WO N'TïŒãªãã·ã§ã³ã³ãŒãïŒ252å®è¡ã®æåŠã瀺ããŸãã ãŸãã¯å®è¡ãç¶ãããšã 瀺ããããªãã·ã§ã³ã DOïŒãªãã·ã§ã³ã³ãŒãïŒ253 çžæãå®è¡ããããŸã㯠ããªããæåŸ ããŠããããšã®ç¢ºèª å®è¡ããçžæã 瀺ããããªãã·ã§ã³ã DO N'TïŒãªãã·ã§ã³ã³ãŒãïŒ254 çžæã®ããã©ãŒãã³ã¹ã®åæ¢ã ãŸãã¯ããªããããªãããšã®ç¢ºèª çžæãé·ãæåŸ ããŠãã å®è¡ããã«ã¯ã瀺ããããªãã·ã§ã³ã IAC 255ããŒã¿ãã€ã255ã
ã¹ã¿ãã¯ãèŠããšããé²ãããšããã³ãã³ãã瀺ããã€ãã·ãŒã±ã³ã¹0xFF 0xF9ã«çŽé¢ããŠããããšãããããŸãã ããã«é¢ããŠã¯ãMicrosoft Webãµã€ãã§æ¬¡ã®ããšãå ±åãããŠããŸãã
å ã®Telnetå®è£ ã¯ãããã©ã«ãã§åäºéåäœã«èšå®ãããŠããŸããã ã€ãŸããããŒã¿ãã©ãã£ãã¯ã¯äžåºŠã«äžæ¹åã«ããéä¿¡ã§ãããäžæ¹åã®ãã©ãã£ãã¯ã®çµããã瀺ãããã«ç¹å®ã®ã¢ã¯ã·ã§ã³ãå¿ èŠã§ããããã©ãã£ãã¯ã¯ããäžæ¹ã®æ¹åã«éå§ãããå¯èœæ§ããããŸãã [ããã¯ãã¢ããã¥ã¢ç¡ç·ããã³CBç¡ç·ãªãã¬ãŒã¿ãŒã«ããããã¬ãŒãããã³ããªãŒããŒãã®äœ¿çšã«äŒŒãŠããŸããïŒå ·äœçãªã¢ã¯ã·ã§ã³ã¯ãããŒã¿ã¹ããªãŒã ã«GAæåãå«ããããšã§ãã
äœããã®çç±ã§ãMicrosoft telnetã¯ã©ã€ã¢ã³ãã®å®è£ ã§ã¯ããã®ã³ãã³ãã¯0x01010754ã®å 容ããŒã以å€ã®å€ã«æ»ãããšãªããšã³ãŒã«åœ±é¿ããŸãã
ããã確èªããã«ã¯ãPythonã§å°ããªãµãŒããŒãäœæããŸãã
import socket, threading s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 1900)) s.listen(1) class daemon(threading.Thread): def __init__(self, (socket, address)): threading.Thread.__init__(self) self.socket = socket self.address = address def run(self): self.socket.send('Greetings!') while True: data = self.socket.recv(1024) if data[0] == '1': data = 'Response' elif data[0] == '2': data = bytearray() data.append(0xFF) data.append(0xF9) self.socket.send(data); self.socket.close() while True: daemon(s.accept()).start()
ãã®ãµãŒããŒãèµ·åããã³ãã³ããtelnet.exe 127.0.0.1 1900ãã䜿çšããŠæ¥ç¶ãããšãã³ãã³ãã2ãã«å¯ŸããçããåŸããããŸã§ãšã³ãŒãæ£ç¢ºã«æ©èœããããšãããããŸãã
ãæšæ¶ïŒ1Response1Response1Response1Response2ResponseResponseResponseResponseResponseResponse
ããããããã ãã§ã¯ãããŸããïŒ å®éãä»ã®ããŒã ãåæ§ã®åäœãããŠããŸãã ããšãã°ããæäœãªããã瀺ã0xFF 0xF1ã®ãã€ãã·ãŒã±ã³ã¹ã¯ãTelnetã¯ã©ã€ã¢ã³ãã®ãšã³ãŒãå®å šã«ãç¡å¹ãã«ããŸãã
ãã°ïŒ æ©èœïŒ 圌ãç¥ã£ãŠãã人ã äž»ãªããšã¯ãtelnet.exeã«MUDã§æ£ããã²ãŒã ãæããããšã§ãïŒ
ããšãã
ãã¡ããã解決çã¯ãŸã å®å šã§ã¯ãããŸããã ããšãã°ãBackspaceããŒãæŒããŠããã«ãŒãœã«ã®åã®æåã¯åé€ãããŸããïŒãã ãããŠãŒã¶ãŒãå ¥åããã³ãã³ãã®ãå éšãè¡šçŸã¯äºæ³ã©ããã«å€æŽãããŸãïŒã ã¯ããããã¯åãªãçŸå®¹äžã®ç¬éã§ãããææ ¢ããããšãã§ããŸããããã®èšäºãå§ããã®ã¯çŸå®¹äžã®äžäŸ¿ãã§ããããïŒ
ãæž èŽããããšãããããŸããããŸãããã®èšäºã誰ãã«åœ¹ç«ã€ããšãé¡ã£ãŠããŸãã