2014-05-01ãã1ã¶æéã®è¨äºä¸è¦§
ã¹ã¿ãã¯ãããã¡ãªã¼ãã¼ããã¼ãå©ç¨ãã¦ã¹ã¿ãã¯ä¸ã®ã·ã§ã«ã³ã¼ãã«ã¸ã£ã³ãããã«ã¯åãã£ã¦ã·ã§ã«ã³ã¼ããç½®ããã¦ããã¢ãã¬ã¹ãç¥ãå¿ è¦ãããããASLRãæå¹ãªå ´åã¹ã¿ãã¯é åã®ãã¼ã¹ã¢ãã¬ã¹ãã©ã³ãã åããã¦ãã¾ãã ããããã®ãããªå ´åã§ãâ¦
ã¢ã»ã³ããªå½ä»¤ï¼asmï¼ã¨æ©æ¢°èªï¼opcodeï¼ãç¸äºã«å¤æããæ¹æ³ã®ã¡ã¢ã GNU Binutilsã使ã asmããopcodeã«å¤æããã«ã¯ãasã³ãã³ãã使ãã $ echo jmp esp | as -msyntax=intel -mnaked-reg -aln -o /dev/null 1 0000 FFE4 jmp esp ããã§ã-msyntax=inâ¦
ããã¾ã§ã®ã¨ã³ããªã§ã¯ããããã¡ãªã¼ãã¼ããã¼ãªã©ã«ããèµ·åãããã·ã§ã«ã¯ãã¼ã«ã«ã®ç«¯æ«ããæä½ãã¦ããã ããããªã¢ã¼ããããããã¯ã¼ã¯è¶ãã«æä½ããã«ã¯ãã·ã§ã«ã®æ¨æºå ¥åºåããããã¯ã¼ã¯ã½ã±ããã«ç¹ãå¤ãã¦ããå¿ è¦ãããã ããã§ã¯ããâ¦
ããã¼ããªã¼ãã¼ããã¼ã«ããGOT overwriteããã£ã¦ã¿ããã§ã¯ããã°ã©ã ä¸ã«ã¦å®ç¾©ããæ§é ä½ãå©ç¨ãã¦ãã¼ããªã¼ãã¼ããã¼ãè¡ã£ãã ããã«é¢é£ãã¦ãC++ã«ããã¦ä»®æ³é¢æ°ãã¡ã³ãé¢æ°ã«æã¤ã¯ã©ã¹ãå©ç¨ããã¨ããã¼ããªã¼ãã¼ããã¼ã«ããä»»æã®ã¢ãâ¦
ä¸ã¤åã®ã¨ã³ããªã§ã¯ãã¼ããªã¼ãã¼ããã¼ãå©ç¨ããGOT overwriteãè¡ããã¸ã£ã³ãæeaxã¬ã¸ã¹ã¿ã«ãããã¡ã®ã¢ãã¬ã¹ãå ¥ã£ã¦ãããã¨ãå©ç¨ãããã¨ã«ããStack pivotãè¡ã£ãã ãããããã®ãããªã©ã¤ãã©ãªé¢æ°å¼ã³åºããè¦ã¤ãããªãå ´åãããããâ¦
ä¸ã¤åã®ã¨ã³ããªã§ã¯ãã¼ããªã¼ãã¼ããã¼ãå©ç¨ããGOT overwriteã«ããã·ã§ã«ã³ã¼ãã®å®è¡ãè¡ã£ãããDEPãæå¹ãªå ´åãã¼ãé åã«ç½®ããã·ã§ã«ã³ã¼ããå®è¡ãããã¨ã¯ã§ããªããªãã ã¹ã¿ãã¯ãããã¡ãªã¼ãã¼ããã¼ã«ããã¦DEPãåé¿ããæ¹æ³ã«ã¯Returâ¦
ããã°ã©ã ã®å®è¡æã«ãã¼ã¿ãç½®ãããå ´æã«ã¯ã¹ã¿ãã¯ã¨ãã¼ãããããã¹ã¿ãã¯ã¨åæ§ãã¼ãã«ã¤ãã¦ããããã¡ãªã¼ãã¼ããã¼ãèµ·ããããã ãã¼ãé åã§èµ·ãããããã¡ãªã¼ãã¼ããã¼ã¯ãHeap-based buffer overflowãããã¯Heap overflowã¨å¼ã°ããã â¦
Red HatãCentOSãªã©ãExec-Shieldã¨å¼ã°ããã»ãã¥ãªãã£ã¢ã¸ã¥ã¼ã«ãå©ç¨ããã¦ããOSã«ã¯ãASCII-armorã¨å¼ã°ããã»ãã¥ãªãã£æ©æ§ãåå¨ããã ããã§ã¯ãASCII-armorã®åä½ã確èªããReturn-to-strcpyãReturn-to-pltã¨å¼ã°ããæ¹æ³ã«ããã·ã§ã«èµ·åãâ¦
ãã使ããããªãã®ã®è¦æ¸ã å®è¡ãã¡ã¤ã«ãæå®ãã¦èµ·åãã $ gdb a.out 次ã®ããã«ãªãã·ã§ã³ãæå®ããã¨ã ã©ã¤ã»ã³ã¹è¡¨ç¤ºãåºããªã ã¢ã»ã³ããªã³ã¼ããIntelå½¢å¼ã§è¡¨ç¤ºãã åæ¢ãããã³ã«ç´å¾ã®å½ä»¤ã表示ãã ããã«ã§ããã $ gdb -q -ex 'set disâ¦
ASLRãæå¹ãªå ´åãã¹ã¿ãã¯é åã»ãã¼ãé åãå ±æã©ã¤ãã©ãªãç½®ãããã¢ãã¬ã¹ã¯ä¸å®ã®ç¯å²ã®ä¸ã§ã©ã³ãã ã«æ±ºããããã ä¸æ¹ãå®è¡ãã¡ã¤ã«ãã®ãã®ãç½®ãããã¢ãã¬ã¹ã¯åºæ¬çã«ã¯åºå®ã§ããããPIE (Position-Independent Executables) ã¨ãªãããã«â¦