'분류 전체보기'에 해당하는 글 176건

2015.05.03

카테고리 없음 2015. 5. 3. 23:33
반응형

오늘은 블로그 포스팅에서 좋은글이있어서 공유한다 .

프로그래밍에 있어서 투명함과 예측성이 왜중요한지에 대해 잘설명해 주고 있는 글이다.

내용이 좋아서 글이 좀 되긴하는데  한번 볼만한 가치가 있는듯 하다.

http://www.codeproject.com/Articles/987698/The-Rule-of-Transparency

반응형
,

2015.05.01

카테고리 없음 2015. 5. 1. 23:19
반응형
반응형
,
반응형

*풀다가 노트북을 맥북으로 바꾸는 바람에 중간에 터미널모양이 약간 바뀌엇다 양해바람..  

GOT, PLT ,_dl_runtime_resolve가 어떤식으로 맞물려있는지 알게해준 굉장히 고마운 문제다.. 

ctf풀기 시작하면서 정말 많이 배우는것 같다..

#다른사람들이랑 환경이 달라서그런가.. 바이너리에서 더해주는 값이 다르다.. 

 

□ description

==========================================

ssh guest@58.229.183.15 / ExtremelyDangerousGuest

ssh guest@58.229.183.14 / ExtremelyDangerousGuest



==========================================


 □ number of solvers : 32

 □ breakthrough by

    1 : CodeRed (02/22 10:40)

    2 : euronop (02/22 11:37)

    3 : stratumauhuur (02/23 02:00)







# memory가 랜덤이지만, 로컬에서 익스플로잇 하는 문제이기 떄문에 ulimit -s unlimited 명령을 이용해 메모리 랜덤을 비활성화 해주고 진행하였다.


컴퓨터랑 4목을 두는 게임이다(근데 재미없음 ..) 



+)우왕 ㅋ 이김ㅋ (이기는 방법알아내는게 생각보다 좀 오래걸렷다 ...)



졋을때와 이겻을때의 output값


이겻을떄 몇초가 걸렷는지 output 값으로 내보내주는데, 이 부분에 뭔가 있을것 같아 IDA로 이부분을 찾아서 

Hex-ray로 디컴파일을 해보았다

[Decompile]



게임에서 0초 이내에 이기면,4byte의 값을 임의의 주소에 입력받는다는 것을 알 수 있다.


근데 밑의 부분에 


 HIWORD(v2) = HIWORD(argv1);

 LOWORD(v2) = 0;

 if ( v2 != 0x8040000 )                  // stack

        {

          if ( (argv1 & 0xF0000000) != 0xB0000000 )

            *(_DWORD *)argv1 = v3;



4byte 입력 받는 값이 stack의 주소를 갖지않고(stack의 주소라는 것은 아래의 그림을 통해 확인 할 수있

다,0x8040000),0xB0000000(바이너리) 의 주소를 갖지 않는다면, 

입력받은 값이 첫번쨰 인자의 값이 된다(4byte)


뿐만아니라, 이문제는 프로그램의 마지막 부분에서 처음으로 exit()함수를 사용한다. 

즉, 우리가 dl_runtime_resolve부분을 조작할 수  있다는 것을 의미한다.

그러면  exit()을 한번 따라 들어가보도록 하자 

[exit@plt 를 처음으로 호출하는 부분 ]



[exit@plt]



[exit@got]:  exit()가 _dl_runtime_resolve에 의해서 got상에 올라가기 전 상태,

~ exit@plt 부분에서 got호출 하는 주소의 바로다음 주소를 가르킨다.


+)반대로 got상에  exit()이 올라간 상태 



[exit@plt+11 에서 jmp한 부분] 

 objdump로 분석해본 결과 이부분의 심볼을 확인할 수 있엇는데 printf@plt-0x10 이라고 적혀있다.. 

이부분이 무슨기능을 하는지는 추후에 좀더 알아보고 추가하도록 하겟다.


+)plt 에서 _dl_runtime_resolve로 넘어가기전에 exit@plt -> .plt 영역 -> dl_runtime_resolve



[_dl_runtime_resolve]400139b0




[_dl_fixup] 0x4000db40 ~ 0x4000dc61




[_dl_fixup_  에서 반환 값을 결정해주는 부분]


eax :40082000


gdb-peda$ x/x $edi+0x4

0x4008e828: 0x00016d60

즉,  eax의 값 (0x40081000)에 [edi+0x4]의 값이 더해져서 반환값으로 사용된다.

따라서 0x40081000를 덮어씌우고, 0x00016d60을 더한곳으로 eip를 변조할 수 있음을 알아내었다.

랜덤스택으로인해서 그냥 환경변수를 때려넣어주게 되면 맞추기 힘들다 .. 

그래서 http://blackcon.tistory.com/90 를 참고해서 spraying 기법으로 환경변수를 뿌려서 이용해 보려 한다.




그러면 이제 분석을 모두 마쳣으니 본격적으로 쉘을 따보자





[payload]

[4목 이기는 로직 ] [환경변수 주소 ] ;cat| ./4stone  [rwx영역의 주소]

0x40081000 

 

(perl -e 'print "\xd","hh","\xd","h","\xd","\xd","hhhh","\xd","h","\xd","hhh","\xd","hh","\xdbf743089"';cat)|./4stone 40081000







+)32bit의 elf fileformat 이다

처음 파일 실행할때 64 bit 환경에서 실행을 했엇는데, 64bit 에서 gcc-multilib 없이 32 비트 프로그램을 실행시키면 그런파일이 없다고 뜬다..multilib 를 설치해주던가 32 bit 환경에서 실행하도록하자





반응형
,

2015.04.30

카테고리 없음 2015. 4. 30. 12:33
반응형

[google]
http://www.theregister.co.uk/…/google_polishes_chrome_secu…/

[ebay]
http://www.boannews.com/media/view.asp…


google은 피싱사이트에 대한 대응을 즉각(?)적으로 대응한거에 비해


ebay는 1년동안 취약점을 알고있음에도 방치한다니 .. 정말 상반된다 

반응형
,

2015.04.29

카테고리 없음 2015. 4. 29. 15:43
반응형


[Massive Vulnerability Discoverd eBay's Magento]

http://www.theregister.co.uk/2015/04/28/ebay_extreme_couponing_vulnerability/


반응형
,
반응형
반응형
,

2015.04.28

카테고리 없음 2015. 4. 28. 11:44
반응형

http://www.boannews.com/media/view.asp?idx=46042&kind=&sub_kind=


영자 기사중에는 오늘은 딱히 끌리는 기사는 없었다. 어제 본거중에 괜찬은 영자 기사 

http://itsjack.cc/blog/2015/04/unpacking-cctv-firmware/

반응형
,
반응형

우선 wiki 에서 본 결과

vDSOs (virtual dynamically linked shared objects) are a way to export kernel space routines to user space applications, using standard mechanisms forlinking and loading i.e. standard Executable and Linkable Format (ELF) format.[1][2]

It helps to reduce the calling overhead on simple kernel routines, and also can work as a way to select the best system call method on some architectures.

An advantage over other methods is that such exported routines can provide proper DWARF (debug with attributed record format) debugging information.

Implementation generally implies hooks in the dynamic linker to find the vDSOs.


즉, kernel space routines를 user space application으로 export 하기위한 방법이다. 

이부분을 공부하게 된 이유는 .. codegate작년 문제 (codegate Prequals 2014)중에 minibomb 문제를 풀면서 

다른 블로그글을 보고있는데 


처음 보는 영역을 디스어셈 하는것을 볼 수 있었다. 그래서 찾게되었다..

cat /proc /self/maps 


좀더 자세한 내용은 linux manual page 내용을 발췌한것이다 참고바란다 .

The "vDSO" (virtual dynamic shared object) is a small shared library
       that the kernel automatically maps into the address space of all
       user-space applications.  Applications usually do not need to concern
       themselves with these details as the vDSO is most commonly called by
       the C library.  This way you can code in the normal way using
       standard functions and the C library will take care of using any
       functionality that is available via the vDSO.

       Why does the vDSO exist at all?  There are some system calls the
       kernel provides that user-space code ends up using frequently, to the
       point that such calls can dominate overall performance.  This is due
       both to the frequency of the call as well as the context-switch
       overhead that results from exiting user space and entering the
       kernel.

       The rest of this documentation is geared toward the curious and/or C
       library writers rather than general developers.  If you're trying to
       call the vDSO in your own application rather than using the C
       library, you're most likely doing it wrong.

원본 페이지 : http://man7.org/linux/man-pages/man7/vdso.7.html

vdso영역을 공부하려하다보니까 자연스럽게 core파일에 대한 내용을 접하게되었다.

좋은 블로그가 있어서 URL을 추가한다.

http://studyfoss.egloos.com/5183167

http://egloos.zum.com/studyfoss/v/5183491


cat /proc/self/maps 라는 명령어에서 사용하는 경로들의 각각의 특징은

http://egloos.zum.com/powerenter/v/10949008

반응형

'과거의 컴퓨터 공부 > System Hacking' 카테고리의 다른 글

GOT OverWrite,FAKE EBP  (0) 2014.11.30
Shared Library Hijacking  (0) 2014.08.16
GOT OverWrite  (0) 2014.05.16
RTL 문서  (0) 2014.05.08
BOF 문서  (0) 2014.05.07
,

strace

카테고리 없음 2015. 4. 27. 15:33
반응형

sudo apt-get install strace로 설치가 안되서 조금 찾아봣는데 설정까지 정리가 잘된 자료가있어서 올립니다 

http://sourceforge.net/projects/strace/  

이 링크는 strace 받는 URL


https://www.redhat.com/magazine/010aug05/features/strace/

설정 URL 

반응형
,
반응형

GDT,IDT,TSS 세그먼트 추가햇는데 오류 ,,, 


헤더에 분명 저렇게 잘 선언해놧고,

소스코드 확인해봣는데도 문제가 없는데 

main.c에서 헤더를 끌어썻는데 kInitializeIDTTables 를 읽지를 못한다.. 아직 원인을 모르겟음 ... 

좀더 찾아보던지 아니면 일단 넘어가던지 해야겟다 .. 


반응형
,