AlpacaHack Round 8 (Rev) ã® write-up
AlpacaHack Round 8 (Rev) ã«åå ãã¦ã3 å解ã㦠12/316 ä½ã§ããã
æ¯ãè¿ã
masking tape
ã¨ãããããã¤ããªãè½ã¨ãã¦ãã¦å®è¡ãã¾ãã ããããæ 度ã¯æ¬å½ã«çµãã£ã¦ãããã§ãããã¾ãéå¶ãä¿¡ãã¦å®è¡ãã¡ããã¾ãï¼ä»®æ³ç°å¢ãªã®ã§ä¸å¿å¤§ä¸å¤«ãªã¯ããä¸å¿ï¼ã
% ./masking-tape #> usage: ./masking-tape <input> % ./masking-tape a #> wrong
ä½ããã®æ£ãã <input>
ãå¯è¶ãã¨ãã話ã£ã½ããæãã¾ãã
ã¨ãããã r2
(radareorg/radare2) ã使ã£ã¦è¦ã¦ã¿ãã¨ãstrcmp
ã§ãªã«ããæ¯è¼ãã¦ãããããªã®ã§ãå¼æ°ãè¦ã¦ã¿ã¾ã*1ã
// hook-a.c #include <stdio.h> int strcmp(char const* s1, char const* s2) { printf("'%s' <=> '%s'\n", s1, s2); return 0; }
ããã
% gcc-14 --shared -o hook-a.so hook-a.c
ãããã¦
% LD_PRELOAD=./hook-a.so ./masking-tape a | xxd #> 00000000: 2708 2303 0313 0313 0301 2331 1311 c803 '.#.......#1.... #> 00000010: c803 1301 c813 1303 1313 1113 2327 203c ............#' < #> 00000020: 3d3e 2027 0327 0a27 0240 8008 0808 c8c8 => '.'.'.@...... #> 00000030: 8088 0880 8832 0832 8080 8032 0880 0808 .....2.2...2.... #> 00000040: 4888 80c8 2720 3c3d 3e20 2708 270a 636f H...' <=> '.'.co #> 00000050: 6e67 7261 747a 0a ngratz.
ãããå°ãéãã§ã¿ã¾ãã
% LD_PRELOAD=./hook-a.so ./masking-tape ab | xxd #> 00000000: 2708 2303 0313 0313 0301 2331 1311 c803 '.#.......#1.... #> 00000010: c803 1301 c813 1303 1313 1113 2327 203c ............#' < #> 00000020: 3d3e 2027 0313 270a 2702 4080 0808 08c8 => '..'.'.@..... #> 00000030: c880 8808 8088 3208 3280 8080 3208 8008 ......2.2...2... #> 00000040: 0848 8880 c827 203c 3d3e 2027 0827 0a63 .H...' <=> '.'.c #> 00000050: 6f6e 6772 6174 7a0a ongratz. % LD_PRELOAD=./hook-a.so ./masking-tape Al | xxd #> 00000000: 2708 2303 0313 0313 0301 2331 1311 c803 '.#.......#1.... #> 00000010: c803 1301 c813 1303 1313 1113 2327 203c ............#' < #> 00000020: 3d3e 2027 0823 270a 2702 4080 0808 08c8 => '.#'.'.@..... #> 00000030: c880 8808 8088 3208 3280 8080 3208 8008 ......2.2...2... #> 00000040: 0848 8880 c827 203c 3d3e 2027 0240 270a .H...' <=> '.@'. #> 00000050: 636f 6e67 7261 747a 0a congratz.
1 æå追å ãããã¨ã«å³è¾ºã伸ã³ãã伸ã³ãªãã£ãããããï¼ ãªããã®ããã·ã¥çãªæ©æ§ãå ¥ã£ã¦ã¦ãäºæ³ããã®ã¯å¤§å¤ããã ã¨ãããã左辺㯠28 bytes ãªã®ã§ã28 bytes ç¨åº¦ã®ãã©ã°ãçãã«ãªãããæã
ãããã試ãã¦ããã¨ãbyte ãã¨ã«å¹²æ¸ããªããããªã®ã§ãã¨ãããã 1 byte ãã¤æ±ºãã¦ããã°ããããããªã®ã§ãããã solver ãæ¸ãã¾ãã
from pwn import * target1 = ( "\x08\x23\x03\x03\x13\x03\x13\x03\x01\x23\x31\x13\x11\xC8" "\x03\xC8\x03\x13\x01\xC8\x13\x13\x03\x13\x13\x11\x13\x23" ) target2 = ( "\x02\x40\x80\x08\x08\x08\xC8\xC8\x80\x88\x08\x80\x88\x32" "\x08\x32\x80\x80\x80\x32\x08\x80\x08\x08\x48\x88\x80\xC8" ) context.log_level = "error" def escape(s): return s.replace("'", r"'\''") flag = "" for i in range(len(target1)): for c in range(ord(" "), ord("~") + 1): c = chr(c) p = process( f"LD_PRELOAD=./hook.-aso ./masking-tape '{escape(flag + c)}'", shell=True ) recv1 = p.recvline()[:-1] recv2 = p.recvline()[:-1] p.close() expected1, actual1 = recv1[: len(target1)], recv1[len(target1) :] expected2, actual2 = recv2[: len(target2)], recv2[len(target2) :] if ( len(actual1) == len(actual2) == i + 1 and expected1[: i + 1] == actual1 and expected2[: i + 1] == actual2 ): flag += c break else: exit(1) print(flag)
% python3 solve-a.py
#> Alpaca{********************}
ãã¼ã ã
hidden
ãããã¨ããããå®è¡ã
% ./hidden #> usage: ./hidden <input> % ./hidden a #> wrong
ãããã£ãã¨åãæããã
ä»å㯠memcmp
ã§æ¯è¼ãã¦ããã¿ããã§ãï¼
ãªã«ãã GDB ã main
ãè¦ã¤ãã¦ãããªãã¿ããã§å°ã£ãã
(gdb) b main Function "main" not defined. Make breakpoint pending on future shared library load? (y or [n]) n
r2
çã«ã¯ s main
ã¨ããã§ããã®ã§ãä½ããã®ãã¨ããã¦é ããã¦ããã®ã§ãããããã¨ãããã puts
ãå¼ãã§ããç®æã§æ¢ããããã¦ã¿ã¾ãã
(gdb) b puts Breakpoint 1 at 0x10b0 (gdb) r a Starting program: /mnt/hidden a warning: Error disabling address space randomization: Operation not permitted [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, __GI__IO_puts (str=0x555555556020 "wrong") at ./libio/ioputs.c:33 warning: 33 ./libio/ioputs.c: No such file or directory (gdb) bt #0 __GI__IO_puts (str=0x555555556020 "wrong") at ./libio/ioputs.c:33 #1 0x0000555555555545 in ?? () #2 0x00007ffff7dc23b8 in __libc_start_call_main (main=main@entry=0x5555555553e1, argc=argc@entry=2, argv=argv@entry=0x7fffffffed18) at ../sysdeps/nptl/libc_start_call_main.h:58 #3 0x00007ffff7dc247b in __libc_start_main_impl (main=0x5555555553e1, argc=2, argv=0x7fffffffed18, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffed08) at ../csu/libc-start.c:360 #4 0x0000555555555145 in ?? () (gdb) x/10i 0x0000555555555545 0x555555555545: mov $0x0,%eax 0x55555555554a: mov -0x18(%rbp),%rdx 0x55555555554e: sub %fs:0x28,%rdx 0x555555555557: je 0x55555555555e 0x555555555559: call 0x5555555550d0 <__stack_chk_fail@plt> 0x55555555555e: mov -0x8(%rbp),%rbx 0x555555555562: leave 0x555555555563: ret 0x555555555564: endbr64 0x555555555568: sub $0x8,%rsp
ãªã«ãã r2
ã§è¦ã main
ã£ã½ãå½ä»¤ãè¦ã¤ãã£ãã®ã§ä¸æ¦æºè¶³ãã¢ãã¬ã¹ã®ä¸ 1.5 byte ãä¸è´ãã¦ãã¾ããã
ã¨ããããã¾ãä¼¼ããããªãã¨ããã£ã¦ã¿ã¾ãã
// hook-b.c #include <stdio.h> int memcmp(void const* s1, void const* s2, size_t n) { printf("memcmp(%p, %p, %zu)\n", s1, s2, n); for (size_t i = 0; i < n; ++i) { printf("[%zu]: %#04x %#04x\n", i, *((unsigned char*)s1 + i), *((unsigned char*)s2 + i)); } return 0; }
% LD_PRELOAD=./hook-b.so ./hidden a #> memcmp(0x5555555592a0, 0x555555558040, 108) #> [0]: 0xfc 0xdc #> [1]: 0xea 0x86 #> [2]: 0x6a 0x1a #> [3]: 0xfb 0x9a #> [4]: 0000 0xdd #> [5]: 0000 0x93 #> [6]: 0000 0x9b #> [7]: 0000 0x35 #: #> [104]: 0000 0xb0 #> [105]: 0000 0xa2 #> [106]: 0000 0x99 #> [107]: 0000 0x91 #> congratz
ãããçµå±ããã·ã¥ããããã®ãéãã¦ä¸è´ããã°ããã§ã¨ããã¨ããæãã£ã½ãï¼
% LD_PRELOAD=./hook-b.so ./hidden Alpaca{ #> memcmp(0x5555555592a0, 0x555555558040, 108) #> [0]: 0xdc 0xdc #> [1]: 0x86 0x86 #> [2]: 0x1a 0x1a #> [3]: 0x9a 0x9a #> [4]: 0xdd 0xdd #> [5]: 0x93 0x93 #> [6]: 0x9b 0x9b #> [7]: 0x41 0x35 #> [8]: 0000 0xd3
ããã£ã½ããããã®ã§ãããã£ã½ã solver ãæ¸ãã¾ãã
from pwn import * target = ( b"\xDC\x86\x1A\x9A\xDD\x93\x9B\x35\xD3\x74\xDA\xEE\xE8\x5A\x3C\xC5" b"\x1C\x64\x33\x47\xD2\x3B\x28\xF3\xCC\x5A\x48\x8B\x74\x0C\x4B\x87" b"\x38\xD6\x80\x40\x51\xE6\x4A\x27\xA1\x73\x52\x0F\x93\x06\x54\x3D" b"\x65\x13\xFB\xC8\x65\xAF\xD2\x67\xB3\x09\xEF\x7D\x23\xA6\x76\xE5" b"\x13\x10\x13\xFF\x34\x8D\xAE\xD0\x9C\x2C\x4D\xF3\xA1\xBC\x46\x2F" b"\x98\x87\xB6\x57\x1A\xA2\x17\xF1\xF0\xE5\xB0\xBA\x9B\x6D\xB5\xA7" b"\xAC\x6A\x5E\xAC\xE8\xF6\x90\xD8\xB0\xA2\x99\x91" ) context.log_level = "error" def escape(s): return s.replace("'", r"'\''") flag = "" for i in range(len(target)): for c in range(ord(" "), ord("~") + 1): c = chr(c) p = process(f"LD_PRELOAD=./hook-b.so ./hidden '{escape(flag + c)}'", shell=True) recv = p.recvline()[:-1] p.close() if target[: len(flag) + 1] == recv[: len(flag) + 1]: print(c, end="", flush=True) flag += c break else: exit(1) print()
% python3 solve-b.py
#> Alpaca{**************** ... ***}
ãã¼ã ãã
vcipher
ã¨ããããå®è¡ãã¦ã¿ã¾ãã
% ./vcipher #> Input 32-character flag: a #> Error: Flag must be exactly 32 characters. % ./vcipher #> Input 32-character flag: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx #> Input flag: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx #> Processing ... #> Processing ... #> Processing ... #> Processing ... #> Processing ... #> Processing ... #> Processing ... #> Processing ... #> The flag is incorrect.
ãããã£ãã¨ã¯éãã¾ããã
r2
㧠afl
ãã¦ã¿ã㨠C++ æããããã¦ã¯ã¼ã¨ããæ°æã¡ã«ãªãã¾ãã
s main
v
ãã¦ããããè¦ãã«ããã§ãã¯ã¯ãã®ããããé¢ä¿ãã¦ãããã§ãã
â â ââ> 0x00003a05 8b3c86 mov edi, dword [rsi + rax*4] â â â 0x00003a08 393c83 cmp dword [rbx + rax*4], edi â â â 0x00003a0b 0f45d1 cmovne edx, ecx â â â 0x00003a0e 48ffc0 inc rax â â â 0x00003a11 4883f808 cmp rax, 8 â â ââ< 0x00003a15 75ee jne 0x3a05
ã¨ãããã¨ã§ããã®ãããã« breakpoint ãæã¡ããã§ãã
(gdb) b main Breakpoint 1 at 0x3660 (gdb) r Starting program: /mnt/vcipher warning: Error disabling address space randomization: Operation not permitted [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, 0x0000555555557660 in main () (gdb) x/i 0x0000555555557a05 0x555555557a05 <main+933>: mov (%rsi,%rax,4),%edi
ããã£ã½ããããã¾ããã
Breakpoint 2, 0x0000555555557a05 in main () (gdb) x/8wx $rsi 0x5555555620a0 <_ZL14CORRECT_OUTPUT>: 0x345a7191 0xdcc4950a 0x8ad73f4e 0x6006deee 0x5555555620b0 <_ZL14CORRECT_OUTPUT+16>: 0xb474f6a4 0x9620574d 0x7fba5668 0x45cb397e (gdb) x/8wx $rbx 0x7fffffffeba8: 0x1558f6b2 0x1ca7b66f 0x03f6762c 0x094537e9 0x7fffffffebb8: 0xf095f7a7 0xf7e4b764 0xfd337721 0xe48238fe
ããã®å¤ãåãã«ãªããããªå ¥åãä¸ããã°ãããããªæ°ããã¾ããä¸å¿ç¢ºããã¦ããã¾ãããã
(gdb) set *0x7fffffffeba8 = 0x345a7191 (gdb) set *0x7fffffffebac = 0xdcc4950a (gdb) set *0x7fffffffebb0 = 0x8ad73f4e (gdb) set *0x7fffffffebb4 = 0x6006deee (gdb) set *0x7fffffffebb8 = 0xb474f6a4 (gdb) set *0x7fffffffebbc = 0x9620574d (gdb) set *0x7fffffffebc0 = 0x7fba5668 (gdb) set *0x7fffffffebc4 = 0x45cb397e (gdb) c Continuing. The flag is correct! [Inferior 1 (process 30123) exited normally]
ããããã§ããã
ã¨ããã¨ããã§ããããã©ããªæãã§ãããå¤ããã®ãã¨ããã®ã調ã¹ã¦ããã¾ãã
% gdb -ex 'b *0x0000555555557a05' -ex 'r' -ex 'x/8wx $rbx' ./vcipher <<< xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx #: #> 0x7fffffffeba8: 0x1558f6b2 0x1ca7b66f 0x03f6762c 0x094537e9 #> 0x7fffffffebb8: 0xf095f7a7 0xf7e4b764 0xfd337721 0xe48238fe #: % gdb -ex 'b *0x0000555555557a05' -ex 'r' -ex 'x/8wx $rbx' ./vcipher <<< xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy #: #> 0x7fffffffeba8: 0x1558f6b2 0x1ca7b66f 0x03f6762c 0x094537e9 #> 0x7fffffffebb8: 0xf095f7a7 0xf7e4b764 0xfd337721 0xc48238fe #: % gdb -ex 'b *0x0000555555557a05' -ex 'r' -ex 'x/8wx $rbx' ./vcipher <<< yxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx #: #> 0x7fffffffeba8: 0x1558f692 0x1ca7b66f 0x03f6762c 0x094537e9 #> 0x7fffffffebb8: 0xf095f7a7 0xf7e4b764 0xfd337721 0xe48238fe #: % gdb -ex 'b *0x0000555555557a05' -ex 'r' -ex 'x/8wx $rbx' ./vcipher <<< Alpaca{xxxxxxxxxxxxxxxxxxxxxxxx} #: #> 0x7fffffffeba8: 0x345a7191 0x1cc4950f 0x03f6762c 0x094537e9 #> 0x7fffffffebb8: 0xf095f7a7 0xf7e4b764 0xfd337721 0x448238fe #:
ãµããµãï¼ ã¨ããããããã£ãã®æ£è§£ã¨è¦æ¯ã¹ã¦ã¿ã¾ãã
0x5555555620a0: 0x345a7191 0xdcc4950a 0x8ad73f4e 0x6006deee 0x5555555620b0: 0xb474f6a4 0x9620574d 0x7fba5668 0x45cb397e 0x7fffffffeba8: 0x345a7191 0x1cc4950f 0x03f6762c 0x094537e9 0x7fffffffebb8: 0xf095f7a7 0xf7e4b764 0xfd337721 0x448238fe 0x7fffffffeba8: 0xoooooooo 0x.oooooo. 0x........ 0x........ 0x7fffffffebb8: 0x........ 0x........ 0x........ 0xo......o
o
ã§ãã¼ã¯ããé¨åã¯æ£è§£ã®ãã®ã¨ä¸è´ãã¦ããããªã®ã§ã1 byte ãã¨ã« 8 bits ã¶ã決ã¾ãããï¼ã¿ãããªæ°æã¡ã«ãªãã¾ãã
æåãè¦ãæãã ã¨ã3][22][11][00][3
ã¿ãããªæãã§ã·ããããã¦ããããªæ°é
ãããã¾ãã
ããããã°ãå ¥åã 32 bytes ã§ãã¨ã³ã³ã¼ããããåã 32 bytes ãªã®ã§ãï¼ãã©ã°ãè¤æ°éãããå¾ããå«ãªã®ã§ï¼å ¨åå°ã«ãªã£ã¦ãããã ãããªã¨ãããã¨ãæã£ã¦ã¯ãã¾ããã
ã¨ãããã¨ã§çµå± 1 byte ãã¨ã«æ±ºãã solver ãæ¸ãã®ã§ãããä¸åã®å®è¡ã«ãã¡ããã¡ãæéããããã®ã§ããã¡ããã¡ãæéããããããã§ãã
import sys from pwn import * target = [ 0x345A7191, 0xDCC4950A, 0x8AD73F4E, 0x6006DEEE, 0xB474F6A4, 0x9620574D, 0x7FBA5668, 0x45CB397E, ] context.log_level = "error" flag_raw = ["!"] * 32 mask = [0x00000FF0, 0x000FF000, 0x0FF00000, 0xF000000F] dec = [ lambda x: x >> 4, lambda x: x >> 12, lambda x: x >> 20, lambda x: (x >> 28) | ((x & 0xF) << 4), ] i = int(sys.argv[1]) flag_raw[i] = chr(int(sys.argv[2], 16)) target_i = dec[i % 4](target[i // 4] & mask[i % 4]) print(f"target: {target_i:#04x}") while flag_raw[i] <= "~": c = flag_raw[i] flag = "".join(flag_raw).replace("'", r"'\''") print("current:", flag) p = process( f"printf '%s\n' '{flag}' | gdb -ex 'b *0x0000555555557a05' -ex 'r' -ex 'x/8wx $rbx' vcipher", shell=True, ) p.recvuntil(b"--Type <RET> for more, q to quit, c to continue without paging--") recv1 = p.recvline()[:-1] recv2 = p.recvline()[:-1] p.close() words1 = [*map(lambda x: int(x, 16), recv1.decode().split(":")[1][1:].split("\t"))] words2 = [*map(lambda x: int(x, 16), recv2.decode().split(":")[1][1:].split("\t"))] words = words1 + words2 print(hex(dec[i % 4](words[i // 4]) & 0xFF)) if (target[i // 4] & mask[i % 4]) == (words[i // 4] & mask[i % 4]): print(c, flush=True) break flag_raw[i] = chr(ord(flag_raw[i]) + 1)
ã¨ãããããããªæãã§ãæ·»åã¨éå§æåã渡ãã¦å ¨æ¢ç´¢ã§ããã³ã¼ããæ¸ãã¾ããã ãããè¤çªã§ 20 並åããããããã°ä½è£ã§ããã¨æã£ãã®ã§ããã3â4 çªãããã§ã ãã¶éçã¿ï¼ããã»ã¹ã®çæããã¡ãé ãï¼ãæããã®ã§ããã¾ããã
% python3 after/solve-c.py 7 41 #> target: 0xad #> current: !!!!!!!A!!!!!!!!!!!!!!!!!!!!!!!! #> 0x83 #> current: !!!!!!!B!!!!!!!!!!!!!!!!!!!!!!!! #> 0x85 #: #> current: !!!!!!!V!!!!!!!!!!!!!!!!!!!!!!!! #> 0xad #> V
Alpaca{V...}
ã¨ãããã¨ãªã®ã§ã
ããã¨ã¹ãã¼ããã« V3r1l0g...
ã¨ããªã®ããªï¼ã¨äºæ³ããããã¾ãããå½ãã£ã¦ããã®ã§ã¦ã±ã¾ããã
ãªã«ããä¸ä½ 4 bits ã¯åºã¾ã£ã¦ç¾ãããï¼ã¨ããã®ã¨ãããã£ã½ãæç« ã«ãªã£ã¦ãããã¨ããã®ããã¨ã¹ãã¼ãã¦ããã¡ããã¡ã試ãã¾ããã æä½æ¥ã§ 40 åãããï¼ã³ã¼ããä¿®æ£ãã¤ã¤ï¼ããã°ããªããããã©ã°ã¯æã«å ¥ããã®ã§ä¸å¿æºè¶³ã§ãã
å·éã«ãªãã¨ããã©ã°ã®é·ããæ¢ç¥ã§ãå byte ãã¨ã«ä¸¦åãã¦ã§ããã®ã§ã'!' * 32
, '"' * 32
, ... ã¿ããã«ãã¦æ¢ç´¢ããã°ãããã§ãããï¼ã¨ãããã¨ã«ãä¸è¨ãæ¸ãã¦ãããã¾ã¨ããªè§£æ³ãããããªããã¨èããªããããããæ°ã¥ãã¾ããï¼ã
from pwn import * target = [ 0x345A7191, 0xDCC4950A, 0x8AD73F4E, 0x6006DEEE, 0xB474F6A4, 0x9620574D, 0x7FBA5668, 0x45CB397E, ] mask = [0x00000FF0, 0x000FF000, 0x0FF00000, 0xF000000F] dec = [ lambda x: x >> 4, lambda x: x >> 12, lambda x: x >> 20, lambda x: (x >> 28) | ((x & 0xF) << 4), ] def get(words, i): return dec[i % 4](words[i // 4]) & 0xFF table = [[0] * 256 for _ in range(32)] for c in range(0x0, 0x100): print(f"current: {c:#04x}") p = process("gdb vcipher", shell=True) p.sendline(b"b *0x00005555555577c0") p.sendline(b"b *0x0000555555557a05") p.sendline(b"r") p.recvuntil(b"Input 32-character flag: ") p.sendline(b"0" * 32) p.recvuntil(b"Breakpoint 1,") p.recvline() p.sendline(b"p $rsp + 0x8") sp = int(p.recvline()[41:55].decode(), 16) p.sendline(f"x/a {hex(sp)}".encode()) s = int(p.recvline()[35:49].decode(), 16) p.sendline(f"set *(long*){hex(s+0x00)} = {0x0101010101010101 * c}".encode()) p.sendline(f"set *(long*){hex(s+0x08)} = {0x0101010101010101 * c}".encode()) p.sendline(f"set *(long*){hex(s+0x10)} = {0x0101010101010101 * c}".encode()) p.sendline(f"set *(long*){hex(s+0x18)} = {0x0101010101010101 * c}".encode()) p.sendline(b"c") p.recvuntil(b"Breakpoint 2,") p.recvline() p.sendline(b"x/8wx $rbx") recv1 = p.recvline()[:-1] recv2 = p.recvline()[:-1] p.close() words1 = [*map(lambda x: int(x, 16), recv1.decode().split(":")[1][1:].split("\t"))] words2 = [*map(lambda x: int(x, 16), recv2.decode().split(":")[1][1:].split("\t"))] words = words1 + words2 for i in range(32): table[i][c] = get(words, i) for i in range(32): res = map(lambda x: f"{x:#04x}", table[i]) print(f'[{i}]: {", ".join(res)}')
å ¥åã¯é©å½ã«ä¸ãã¦ãã¾ã£ã¦ãå¾ãããããã¬ã§ããæãã®å ¥åãä¸ãããã¨ã«ããã°ã空ç½æåãªããªããªãã®å¶éãããæååããä¸ããããã¨ã«ã§ãããã§ããããã¨ããã®ã§ãããããã®ãæ¸ãã¾ããã
ã©ããã 0x80 以ä¸ã® byte ãä¸ããã¨ãã¯å ¨åå°ãããªãã£ã½ããã§ããããããæªæºã§ã¯ä¸è¨ã®ãããªè¦åã«ãªã£ã¦ãããã§ããã
0x00: {9,8,b,a,d,c,f,e,1,0,3,2,5,4,7,6}{b,9,f,d,3,1,7,5} 0x01: {7,6,5,4,3,2,1,0,f,e,d,c,b,a,9,8}{f,d,b,9,7,5,3,1} 0x02: {a,b,8,9,e,f,c,d,2,3,0,1,6,7,4,5}{5,7,1,3,d,f,9,b} 0x03: {d,c,f,e,9,8,b,a,5,4,7,6,1,0,3,2}{1,3,5,7,9,b,d,f} 0x04: {9,8,b,a,d,c,f,e,1,0,3,2,5,4,7,6}{6,4,2,0,e,c,a,8} 0x05: {8,9,a,b,c,d,e,f,0,1,2,3,4,5,6,7}{b,9,f,d,3,1,7,5} 0x06: {3,2,1,0,7,6,5,4,b,a,9,8,f,e,d,c}{a,8,e,c,2,0,6,4} 0x07: {0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f}{1,3,5,7,9,b,d,f} 0x08: {9,8,b,a,d,c,f,e,1,0,3,2,5,4,7,6}{2,0,6,4,a,8,e,c} 0x09: {9,8,b,a,d,c,f,e,1,0,3,2,5,4,7,6}{7,5,3,1,f,d,b,9} 0x0a: {c,d,e,f,8,9,a,b,4,5,6,7,0,1,2,3}{f,d,b,9,7,5,3,1} 0x0b: {3,2,1,0,7,6,5,4,b,a,9,8,f,e,d,c}{0,2,4,6,8,a,c,e} 0x0c: {8,9,a,b,c,d,e,f,0,1,2,3,4,5,6,7}{e,c,a,8,6,4,2,0} 0x0d: {a,b,8,9,e,f,c,d,2,3,0,1,6,7,4,5}{3,1,7,5,b,9,f,d} 0x0e: {6,7,4,5,2,3,0,1,e,f,c,d,a,b,8,9}{4,6,0,2,c,e,8,a} 0x0f: {6,7,4,5,2,3,0,1,e,f,c,d,a,b,8,9}{0,2,4,6,8,a,c,e} 0x10: {8,9,a,b,c,d,e,f,0,1,2,3,4,5,6,7}{a,8,e,c,2,0,6,4} 0x11: {a,b,8,9,e,f,c,d,2,3,0,1,6,7,4,5}{f,d,b,9,7,5,3,1} 0x12: {f,e,d,c,b,a,9,8,7,6,5,4,3,2,1,0}{9,b,d,f,1,3,5,7} 0x13: {8,9,a,b,c,d,e,f,0,1,2,3,4,5,6,7}{f,d,b,9,7,5,3,1} 0x14: {8,9,a,b,c,d,e,f,0,1,2,3,4,5,6,7}{6,4,2,0,e,c,a,8} 0x15: {b,a,9,8,f,e,d,c,3,2,1,0,7,6,5,4}{b,9,f,d,3,1,7,5} 0x16: {8,9,a,b,c,d,e,f,0,1,2,3,4,5,6,7}{e,c,a,8,6,4,2,0} 0x17: {b,a,9,8,f,e,d,c,3,2,1,0,7,6,5,4}{f,d,b,9,7,5,3,1} 0x18: {8,9,a,b,c,d,e,f,0,1,2,3,4,5,6,7}{2,0,6,4,a,8,e,c} 0x19: {c,d,e,f,8,9,a,b,4,5,6,7,0,1,2,3}{7,5,3,1,f,d,b,9} 0x1a: {2,3,0,1,6,7,4,5,a,b,8,9,e,f,c,d}{3,1,7,5,b,9,f,d} 0x1b: {e,f,c,d,a,b,8,9,6,7,4,5,2,3,0,1}{f,d,b,9,7,5,3,1} 0x1c: {7,6,5,4,3,2,1,0,f,e,d,c,b,a,9,8}{f,d,b,9,7,5,3,1} 0x1d: {d,c,f,e,9,8,b,a,5,4,7,6,1,0,3,2}{3,1,7,5,b,9,f,d} 0x1e: {b,a,9,8,f,e,d,c,3,2,1,0,7,6,5,4}{8,a,c,e,0,2,4,6} 0x1f: {1,0,3,2,5,4,7,6,9,8,b,a,d,c,f,e}{e,c,a,8,6,4,2,0}
ãã¨ãã°ã0x02: {a,b,8,9,e,f,c,d,2,3,0,1,6,7,4,5}{5,7,1,3,d,f,9,b}
ã¯ããæ·»åã [2]
㮠byte 㯠00
ã®ã¨ã a5
ãè¿ã£ã¦ãããã01
ã®ã¨ã a7
ãã07
ã®ã¨ã ab
ãã08
ã®ã¨ã b5
ã... ã®ãããªæå³ã§æ¸ãã¦ãã¾ãã45
ãè¿ã£ã¦ããã®ã¯ 70
ã®ã¨ãã§ããã㯠p
ã®ãã¨ã§ããã
çµå±ãã®è¡¨ã¯ãªãã§ããï¼ï¼ï¼ï¼ã¡ãã㨠â revâ ããã°ãããæãã§ããï¼ ç¹ã« Verilog ã¾ããã®ãã¨ã¯ããããã£ã¦ãã¾ããã
ãããã表ã«ãªãåæã§ããã°ããããã 00
01
02
03
... 07
08
10
18
20
... 70
78
ã® 23 éãã ã試ãã°ãããããªæ°ããã¦ãã¾ããï¼å®éã«ã¯ãã©ã°ã«ç¹æ®æåã¯å
¥ããªãããã ããã¡ãã£ã¨æ¸ãããï¼ã
ææ
rev ã¯ãï¼ã¾ã ä½ç³»ç«ã¦ãåå¼·ããã¦ããªããããããããã§ããï¼ãªãã¨ããã ad hoc ã£ã½ãæ°æã¡ã«ãªãã¨ãããããä»åã¯ããããç°¡åãªã¨ã³ã³ã¼ããããã¦ããããã§ãããã©ããããããªãã£ããã©ããããããªããªãï¼ãã¿ãããªæ°æã¡ã«ãªãã¾ãã ï¼è§£ãããããªãåé¡ã¯åºé¡ãããªãæ°ããã¾ããï¼ï¼
ã¨æã£ããã§ãããããããèªåããã£ãã®ã¯ rev ã§ã¯ãªãã¦å®é¨ã¨ã¨ã¹ãã¼ãªæ°ããã¦ãã¾ãããï¼r2
ã gdb
ãªã©ã§å¤å°ã® assembly ãèªãã§ããã¨ã¯ããï¼decompile ãããã¨ãããããé°å²æ°ã§ãã£ã¦ããã®ãå¾®å¦ããã§ãã
ãã¾ãé·ããªãæéã®ã³ã³ãã¹ãã§çããåºãåæã ã¨ä»æ¹ãªããããããã§ããã復ç¿ã¯ããæ¹ãããããã ãªã¨æãã¾ããã
pwn ã 㨠ROP ãªã ret2whatever ãªãã®æ¦ãä½ç³»ç«ã£ããã¾ããã£ããããããæ¹éã®ãã¨ããããããã¨ããã®ãããã¨æããã§ãããrev ã ã¨ã©ãããæããªãã§ãããããããã¬ã使ãã¤ã¤å®é¨ããªããè³çã§ããã®ã¯æ£çµ±æ´¾ã§ã¯ãªãããï¼ã¨ãããæ£çµ±æ´¾ã§ãªãã¦ã»ããï¼ã¿ãããªæ°æã¡ã¯ããã¾ããæã«ã¯å¿ è¦ã§ã¯ããããã ã¨ã¯æãã¤ã¤ã§ããã
ã¨ããããã(å°ããã®æ´æ°)/(ãããªãã®æ´æ°) ãè¦ããã®ã§ããããæ°æã¡ã«ãªãã¾ããã
ããã
ãããã§ãã