ARM assembly를 공부합시다.

2011. 10. 3. 12:39

리딧에 올라온 링크를 클릭했더니 ARM assembly에 대한 너무 좋은 블로그가 있더군요.

http://www.eggwall.com/2011/09/android-arm-assembly-device-set-up-part.html 

미루고 미뤄왔던 공부를 연휴를 맞이해서 해보자 라는 마음으로 시작했는데 처음부터 삐걱삐걱..

먼저 환경 셋팅에 대한 방법으로 2가지를 제시합니다.

1) QEMU를 이용한 방법
2) android 폰을 이용한 방법

둘다 해놓고 써도 될듯 싶었지만.. 우선 QEMU 를 선택했습니다.
툴까지 셋팅된 이미지를 압축 파일로 친절하게 올려놨습니다만 제 환경(vmware, ubuntu 10.04) 에서는 
세그 폴트를 뱉고 실행되질 않는 현상이..ㅠㅠ

이쪽은 잘 몰라서 뭘 어떻게 검색해야 될지도 막막했지만 구글신은 대충 입력해도 찾아주더이다. 


http://balau82.wordpress.com/2010/05/23/qemu-system-arm-segmentation-fault-in-ubuntu-lucid/ 

해결책은 메모리 옵션인 "-m 128M" 을 추가해주면 오케이.

qemu-system-arm  -m 128M -M versatilepb -kernel vmlinuz-2.6.26-2-versatile -initrd initrd.img-2.6.26-2-versatile -hda debian_lenny_arm_standard.qcow2 -append "root=/dev/sda1"

자자.. 이제 ARM assembly 공부를 해봅시다!




 

'Reversing' 카테고리의 다른 글

Protection ID  (0) 2011.05.11
Vmware detection by vmware I/O port  (0) 2011.04.18
TightVNC portable  (0) 2010.09.08
7.7 ddos 바이너리 대충 분석  (2) 2009.08.06
The best text for Reverse Engineering  (0) 2009.06.23
Reversing for Newbies (written by Lena)  (0) 2009.03.27
some instruction  (0) 2009.02.11
bypassing isDebuggerPresent WITHOUT changing mem  (0) 2009.01.28

badcob Reversing

Protection ID

2011. 5. 11. 11:19
Game cracking 에 관심 있어 하는 분이라면 이미 알고 있을만한 툴입니다.

주요 기능은 이 한줄로 설명이..

detection of every major PC ISO Game / Application protection

소스가 공개되었으면 하는 아쉬움이 남습니다. T_



URL : http://pid.gamecopyworld.com/

'Reversing' 카테고리의 다른 글

ARM assembly를 공부합시다.  (0) 2011.10.03
Vmware detection by vmware I/O port  (0) 2011.04.18
TightVNC portable  (0) 2010.09.08
7.7 ddos 바이너리 대충 분석  (2) 2009.08.06
The best text for Reverse Engineering  (0) 2009.06.23
Reversing for Newbies (written by Lena)  (0) 2009.03.27
some instruction  (0) 2009.02.11
bypassing isDebuggerPresent WITHOUT changing mem  (0) 2009.01.28

badcob Reversing

Vmware detection by vmware I/O port

2011. 4. 18. 15:37


악성코드 샘플을 수집해서 분석하는 중에 Vmware에서 실행을 하려 해도
제대로 실행이 되질 않는 놈이 있더군요. 몇번 클릭질 해보다 안되겠다 싶어
트레이싱을 해보니 아무래도 vmware 를 인식하고 알아서 죽는것 같더이다.

그래서 vmware detection 이라는 키워드로 구글링을 한참 해봤지만
원하는 자료가 쉬이 나오질 않으니, 시간은 점점 흐르고 분석 문서는 작성해야되는데
악성코드를 실행조차 못하는 상황T_T.. 그러던 와중에 원하는 자료를 발견(!)해서 정리해 둡니다.





In instruction에 대한 설명 - http://en.wikibooks.org/wiki/X86_Assembly/Other_Instructions

I/O Instructions

in dest, src

The IN instruction almost always has the operands AX and DX (or EAX and EDX) associated with it. DX (src) frequently holds the port address to read, and AX (dest) receives the data from the port. In Protected Mode operating systems, the IN instruction is frequently locked, and normal users can't use it in their programs.


DX(src)는 읽을 port address를 가지고 있고, AX(dest)는 그 port의 데이터를 받습니다.

위의 코드에서, "in   eax, dx" 가 실행될 때,
dx에는 0x5658(port address)이, eax에는 0x564D5867 (VMXh)이 들어 있습니다.

즉  In  0x564D5867, 0x5658  요런 모양으로 실행되겠죠.

그 후에 ebx의 값을 0x564D5867 과 비교해서 같으면 Vmware 환경에서 작동하는 것으로 판단,
종료 시킵니다.


참고 사이트  : http://isc.sans.edu/diary.html?storyid=3190

'Reversing' 카테고리의 다른 글

ARM assembly를 공부합시다.  (0) 2011.10.03
Protection ID  (0) 2011.05.11
TightVNC portable  (0) 2010.09.08
7.7 ddos 바이너리 대충 분석  (2) 2009.08.06
The best text for Reverse Engineering  (0) 2009.06.23
Reversing for Newbies (written by Lena)  (0) 2009.03.27
some instruction  (0) 2009.02.11
bypassing isDebuggerPresent WITHOUT changing mem  (0) 2009.01.28

badcob Reversing

TightVNC portable

2010. 9. 8. 21:13

아는 분이 TightVNC portable을 크랙해 달라고 하셔서.. 잠깐 들여다본 적이 있는데..
정리해 두고자 끄적여 봅니다.

TightVNC portable은 30일간 사용할 수 있는 쉐어웨어 입니다.



Register를 클릭하면 사용자 등록을 할 수 있습니다.



접근할 만한 부분은 다음 2가지 정도일까요.

1) 남은 날짜를 카운팅 하는 루틴.
2) 사용자 등록 처리 루틴.

IDA로 열어서 살펴보면 WinMain에서 다음 부분을 볼 수 있습니다.



CreateWindow를 호출하고 이어서 0xFFFFFEBh(GWL_USERDATA)을 인자로 줘서 SetWindowLong을 호출합니다.
SetWindowLong 특정 윈도우의 속성을 바꿀때 쓰는 함수로 MSDN에 나온 설명입니다

SetWindowLong Function

Changes an attribute of the specified window.
The function also sets the 32-bit (long) value at the specified offset into the extra window memory.

LONG WINAPI SetWindowLong(
 HWND hWnd,
 int nIndex,
 LONG dwNewLong
)


olly 에서 보면 파라미터가 아래와 같이 호출됩니다.

핸들은 앞서 호출한 CreateWindow의 리턴값을, index에 GWL_USERDATA (-21) 을,
마지막 파라미터로 RegisterWindowMessage로 등록한 메시지를 던져줍니다.



GWL_USERDATA에 대한 MSDN의 설명입니다.

GWL_USERDATA(-21) Retrieves the user data associated with the window.
This data is intended for use by the application that created the window. Its value is initially zero.

계속 WinMain을 보면 로컬 변수 주소(dwInitParam)를 ecx와 스택에 넣고 sub_4036D0를 호출.
ecx를 쓰는걸 보니 클래스 멤버 함수 일까요. ecx를 직접 스택에 밀어넣는걸 보니 아리까리 하네요.



sub_4036D0 함수는 ecx주소에 0x200을 더해서 sub_4032A0을 호출.



 sub_4032A0은 인자로 받은 [ecx+200]을 esi에 넣고 (멤버 변수를) 초기화 하는 것 같습니다.



이어서 sub_4033E0을 호출.(dwInitParam을 계속 인자로 물고 갑니다.)



sub_4033E0 은 대충 다음과 같은 기능을 합니다.

1) data와 session 이라는 디렉토리 생성
2) GetFileTime 으로 디렉토리가 생성된 시간을 얻어와서 현재 시스템 시간을 빼고 30 을 더함
3) 이 값이 0 보다 크면  [esi+0x28h]에 1을 집어넣음

마지막에 비교하는 부분 중에 이런 코드가 있네요.



ebx 레지스터에는 두개의 시간을 계산한 결과 값, 즉 처음 실행했으면 0x1E(30) 이라는 값이 들어와
있습니다.
여기에 test 연산을 하면 ZF 만 0이 되고 나머지는 변함이 없습니다.
따라서 setl al 에서 al은 그냥 0이 되고 
ebx는 0xffffffff와 and 연산을 합니다.
결국 eax는 0x1E가 되죠.

hexray로 보니 이렇게 보이네요.


테스트해보니 v8 이 0 보다 작으면 참 이므로 1이, 크면 거짓이므로 0 이 들어갑니다.
부족한 제게는 실로 내공이 느껴지는 한줄입니다.

register 루틴에서도 이 부분의 값 ([esi+40]) 을 확인합니다.
그러므로 등록하지 않고 계속 사용하려면 이 부분의 조건문을 바꿔주는 것만으로 가능합니다.

조금만 더 살펴보자면 WinMain에서는 이어서 DialogBoxParam을 호출합니다.



MSDN에 나온 DiaglogBoxParam의 설명입니다.

DialogBoxParam Function

Creates a modal dialog box from a dialog box template resource.
Before displaying the dialog box, the function passes an application-defined value
to the dialog box procedure as the lParam parameter of the WM_INITDIALOG message.
An application can use this value to initialize dialog box controls.

INT_PTR WINAPI DialogBoxParam(
  __in_opt  HINSTANCE hInstance,
  __in      LPCTSTR lpTemplateName,
  __in_opt  HWND hWndParent,
  __in_opt  DLGPROC lpDialogFunc,
  __in      LPARAM dwInitParam
);

...

dwInitParam [in]
 LPARAM

The value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG message.

마지막 파라미터인 dwInitParam으로 dialog box의 초기화 정보를 전달할 수 있네요.

DialogFunc에 두번째 파라미터가 0x110 (WM_INITDIALOG) 이면 멈추도록 브레이크 포인트를 겁니다.
olly나 immunity에서 쉬프트 + F2를 누르고 [esp+8] == 110h 라고 입력.
그러면 DialogBoxParam의 InitParam으로 넘겨준 값을(0x0012F3EC) SetWindowLong으로 설정하는 것을 볼 수 있습니다.



그리고 해당 컨트롤에 0x111(WM_COMMAND)가 발생하면 GetWindowLong으로 이 주소값을 얻어와서 어쩌고 저쩌고 처리하게 됩니다.

ps. olly, immunity에서 conditional breakpoint 걸 때 && 로 묶어서 조건을 여러 개 할 수 없는건지
제대로 걸리질 않는군요. 자꾸 전에 걸어놓은 구문하고 겹치게 되고-0-



'Reversing' 카테고리의 다른 글

ARM assembly를 공부합시다.  (0) 2011.10.03
Protection ID  (0) 2011.05.11
Vmware detection by vmware I/O port  (0) 2011.04.18
7.7 ddos 바이너리 대충 분석  (2) 2009.08.06
The best text for Reverse Engineering  (0) 2009.06.23
Reversing for Newbies (written by Lena)  (0) 2009.03.27
some instruction  (0) 2009.02.11
bypassing isDebuggerPresent WITHOUT changing mem  (0) 2009.01.28

badcob Reversing

7.7 ddos 바이너리 대충 분석

2009. 8. 6. 19:15
전에 잠깐 만지다 말았던..

사용자 삽입 이미지

'Reversing' 카테고리의 다른 글

ARM assembly를 공부합시다.  (0) 2011.10.03
Protection ID  (0) 2011.05.11
Vmware detection by vmware I/O port  (0) 2011.04.18
TightVNC portable  (0) 2010.09.08
The best text for Reverse Engineering  (0) 2009.06.23
Reversing for Newbies (written by Lena)  (0) 2009.03.27
some instruction  (0) 2009.02.11
bypassing isDebuggerPresent WITHOUT changing mem  (0) 2009.01.28

badcob Reversing

The best text for Reverse Engineering

2009. 6. 23. 03:06
http://www.reddit.com/r/ReverseEngineering/comments/8tq12/what_are_the_best_text_for_reverse_engineering/

Reverse Engineering 을 위한 괜찮은 문서들이 뭐가 있느냐
위의 링크를 클릭하면 여러 댓글들을 볼 수가 있으며 간략하게 정리하자면 다음과 같다.

Texts

  Lena151's video tutorials
                                      - 유명한 튜토리얼
  Reversing: Secrets of Reverse Engineering    - 얼마전에 번역되서 출판됨
  Application Hacking  
  Hacking: The Art of exploitation                    
  The Shellcoder`s Handbook                         

  The Art of Assembly Language                                  
  Grey Hat Hacking
  The IDA Pro Book                                     

Links

  http://crackmes.de
 
http://reversing.be
 
http://3564020356.org/
  http://www.woodmann.com/fravia/index.htm  
 
http://www.sploitlab.org/reverse-engineering/
  http://www.tuts4you.com

국내
 
   
http://www.simples.co.kr                             


 본것도 있고 안본것도 있으며 모르는것도 있다.  
 괜찮은 사이트나 책 또는 문서들을 보게되면 하나씩 추가를.

 해야될 것은 안하고 새벽에 머하는 짓인지 모르겠다..

'Reversing' 카테고리의 다른 글

ARM assembly를 공부합시다.  (0) 2011.10.03
Protection ID  (0) 2011.05.11
Vmware detection by vmware I/O port  (0) 2011.04.18
TightVNC portable  (0) 2010.09.08
7.7 ddos 바이너리 대충 분석  (2) 2009.08.06
Reversing for Newbies (written by Lena)  (0) 2009.03.27
some instruction  (0) 2009.02.11
bypassing isDebuggerPresent WITHOUT changing mem  (0) 2009.01.28

badcob Reversing

Reversing for Newbies (written by Lena)

2009. 3. 27. 09:53

01. Olly + assembler + patching a basic reverseme
02. Keyfiling the reverseme + assembler
03. Basic nag removal + header problems
04. Basic + aesthetic patching
05. Comparing on changes in cond jumps, animate over/in, breakpoints
06. "The plain stupid patching method", searching for textstrings
07. Intermediate level patching, Kanal in PEiD
08. Debugging with W32Dasm, RVA, VA and offset, using LordPE as a hexeditor
09. Explaining the Visual Basic concept, introduction to SmartCheck and configuration
10. Continued reversing techniques in VB, use of decompilers and a basic anti-anti-trick
http://rapidshare.com/files/36725909/_file_snd-reversingwithlena-tutorial1.tutorial.zip
http://rapidshare.com/files/36725904/_file_snd-reversingwithlena-tutorial2.tutorial.zip
http://rapidshare.com/files/36725918/_file_snd-reversingwithlena-tutorial3.tutorial.zip
http://rapidshare.com/files/36725954/_file_snd-reversingwithlena-tutorial4.tutorial.zip
http://rapidshare.com/files/36725986/_file_snd-reversingwithlena-tutorial5.tutorial.zip
http://rapidshare.com/files/36726006/_file_snd-reversingwithlena-tutorial6.tutorial.zip
http://rapidshare.com/files/36725932/_file_snd-reversingwithlena-tutorial7.tutorial.zip
http://rapidshare.com/files/36725939/_file_snd-reversingwithlena-tutorial8.tutorial.zip
http://rapidshare.com/files/36725944/_file_snd-reversingwithlena-tutorial9.tutorial.zip
http://rapidshare.com/files/36725920/_file_snd-reversingwithlena-tutorial10.tutorial.zip

11. Intermediate patching using Olly's "pane window"
12. Guiding a program by multiple patching.
13. The use of API's in software, avoiding doublechecking tricks
14. More difficult schemes and an introduction to inline patching
15. How to study behaviour in the code, continued inlining using a pointer
16. Reversing using resources
17. Insights and practice in basic (self)keygenning
18. Diversion code, encryption/decryption, selfmodifying code and polymorphism
19. Debugger detected and anti-anti-techniques
20. Packers and protectors : an introduction  
http://rapidshare.com/files/36726362/_file_snd-reversingwithlena-tutorial11.tutorial.zip
http://rapidshare.com/files/36726439/_file_snd-reversingwithlena-tutorial12.tutorial.zip
http://rapidshare.com/files/36726444/_file_snd-reversingwithlena-tutorial13.tutorial.zip
http://rapidshare.com/files/36726433/_file_snd-reversingwithlena-tutorial14.tutorial.zip
http://rapidshare.com/files/36726382/_file_snd-reversingwithlena-tutorial15.tutorial.zip
http://rapidshare.com/files/36728587/_file_snd-reversingwithlena-tutorial16.tutorial.zip
http://rapidshare.com/files/36727545/_file_snd-reversingwithlena-tutorial17.tutorial.zip
http://rapidshare.com/files/36727561/_file_snd-reversingwithlena-tutorial18.tutorial.zip
http://rapidshare.com/files/36727572/_file_snd-reversingwithlena-tutorial19.tutorial.zip
http://rapidshare.com/files/36727662/_file_snd-reversingwithlena-tutorial20.tutorial.zip

21. Imports rebuilding
22. API Redirection
23. Stolen bytes 
24. Patching at runtime using loaders from lena151 original 
25. Continued patching at runtime & unpacking armadillo standard protection 
26. Machine specific loaders, unpacking & debugging armadillo 
27. tElock + advanced patching  
28. Bypassing & killing server checks  
29. Killing & inlining a more difficult server check  
http://rapidshare.com/files/36728621/_file_snd-reversingwithlena-tutorial29.tutorial.zip
http://rapidshare.com/files/36728552/_file_snd-reversingwithlena-tutorial28.tutorial.zip
http://rapidshare.com/files/36728570/_file_snd-reversingwithlena-tutorial27.tutorial.zip
http://rapidshare.com/files/36727888/_file_snd-reversingwithlena-tutorial26.tutorial.zip
http://rapidshare.com/files/36727957/_file_snd-reversingwithlena-tutorial25.tutorial.zip
http://rapidshare.com/files/36727836/_file_snd-reversingwithlena-tutorial24.tutorial.zip
http://rapidshare.com/files/36727766/_file_snd-reversingwithlena-tutorial23.tutorial.zip
http://rapidshare.com/files/36727772/_file_snd-reversingwithlena-tutorial22.tutorial.zip
http://rapidshare.com/files/36727828/_file_snd-reversingwithlena-tutorial21.tutorial.zip 

30. SFX, Run Trace & more advanced string searching 
31. Delphi in Olly & DeDe
32.  Author tricks, HIEW & approaches in inline patching                                  
33. The FPU, integrity checks & loader versus patcher
34. Reversing  techniques  in packed soft & A S&R loader for aspr 
35. Inlining inside polymorphic code
36. Keygenning
37. Indept  Unpacking  &  Anti-Anti-Debugging  A Combination Packer/Protector
38. Unpacking continued & debugger detection by DLL and TLS
39. Inlining blowfish in a dll + unpacking aspr SKE 2.2
http://rapidshare.com/files/36728875/_file_snd-reversingwithlena-tutorial39.tutorial.zip
http://rapidshare.com/files/36728822/_file_snd-reversingwithlena-tutorial38.tutorial.zip
http://rapidshare.com/files/36728818/_file_snd-reversingwithlena-tutorial37.tutorial.zip
http://rapidshare.com/files/36728885/_file_snd-reversingwithlena-tutorial36.tutorial.zip
http://rapidshare.com/files/36728927/_file_snd-reversingwithlena-tutorial35.tutorial.zip
http://rapidshare.com/files/36728868/_file_snd-reversingwithlena-tutorial34.tutorial.zip
http://rapidshare.com/files/36733021/_file_snd-reversingwithlena-tutorial33.tutorial.zip
http://rapidshare.com/files/36728897/_file_snd-reversingwithlena-tutorial32.tutorial.zip
http://rapidshare.com/files/36728554/_file_snd-reversingwithlena-tutorial31.tutorial.zip
http://rapidshare.com/files/36728551/_file_snd-reversingwithlena-tutorial30.tutorial.zip

'Reversing' 카테고리의 다른 글

ARM assembly를 공부합시다.  (0) 2011.10.03
Protection ID  (0) 2011.05.11
Vmware detection by vmware I/O port  (0) 2011.04.18
TightVNC portable  (0) 2010.09.08
7.7 ddos 바이너리 대충 분석  (2) 2009.08.06
The best text for Reverse Engineering  (0) 2009.06.23
some instruction  (0) 2009.02.11
bypassing isDebuggerPresent WITHOUT changing mem  (0) 2009.01.28

badcob Reversing

some instruction

2009. 2. 11. 15:39
맨날 헷갈리는 test!

test
http://faydoc.tripod.com/cpu/test.htm
Computes the bit-wise logical AND of first operand (source 1 operand) and the second operand (source 2 operand) and sets the SF, ZF, and PF status flags according to the result. The result is then discarded.

test a, a a null인지 Check 하는 명령어. test a,b a&b 같이 AND 연산을 의미한다. 이후에 jxx 연산을 하여 a값이 null이 아닐 경우에 looping 돌고, null이면 해당 loop에서 빠져나간다. 




lodsb

http://faydoc.tripod.com/cpu/lodsb.htm
Loads a byte, word, or doubleword from the source operand into the AL, AX, or EAX register, respectively. The source operand is a memory location, the address of which is read from the DS:EDI or the DS:SI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). The DS segment may be overridden with a segment override prefix.

LODSB : LODS BYTE
[LODSB] 명령은 DS:SI에 입력된 주소의 한 바이트를  AL 레지스터로 전달.
그 후 SI를 하나 증가시켜 SI로 지정된 주소의 다음 내용을 읽을 준비를 함 Stores a byte, word, or doubleword from the AL, AX, or EAX register, respectively, into the destination operand. The destination operand is a memory location, the address of which is read from either the ES:EDI or the ES:DI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively).

process environment structure
http://baeg.tistory.com/entry/Windows-Heap-Overflows-using-the-Process-Environment-Block-PEB

'Reversing' 카테고리의 다른 글

ARM assembly를 공부합시다.  (0) 2011.10.03
Protection ID  (0) 2011.05.11
Vmware detection by vmware I/O port  (0) 2011.04.18
TightVNC portable  (0) 2010.09.08
7.7 ddos 바이너리 대충 분석  (2) 2009.08.06
The best text for Reverse Engineering  (0) 2009.06.23
Reversing for Newbies (written by Lena)  (0) 2009.03.27
bypassing isDebuggerPresent WITHOUT changing mem  (0) 2009.01.28

badcob Reversing

bypassing isDebuggerPresent WITHOUT changing mem

2009. 1. 28. 16:38
If you change the JE, you are modding the program code, and it no doubt detects this with a CRC routine of some sort. Also, if you wait until the code returns, and then change the value in eax, you are once again "modding" the code in a way because you are setting a breakpoint in the code.

The safest and most effective way to modify IsDebuggerPresent detection is to edit the Program's thread block. This is easy in OllyDbg. You can do this before the program even starts to run, after Olly loads it.

NOTE THIS example works for Windows 2000 / XP.

Open your program in OllyDbg. Note the value of the FS register. On my 2000 system, it's 7FFDE000. Go to the hex dump window in Olly (at the bottom) and right click and say Go To->Expression and type in this value.

Now, at FS[30], which would be 7FFDE030 on my machine (30 bytes in ) there is another address, this points to the program's thread environment block (TEB). Select this address in the window by clicking and selecting it, then right click and say "Follow DWORD in dump". This address by the way in my 2000 system is 7FFDF000.

Now, 3 bytes in you will see a 01. This is telling windows the program is being debugged. Change it to a zero by selecting it, and just start typing in zero, zero. Olly brings up the memory edit window, after entering the zeros just push ok and now you are hidden from the IsDebuggerPresent detector, and you didn't modify or edit any program memory or API memory. In fact, the program hasn't even started yet.

-nt20

- 출처 - http://www.woodmann.com/forum/archive/index.php/t-5875.html 

'Reversing' 카테고리의 다른 글

ARM assembly를 공부합시다.  (0) 2011.10.03
Protection ID  (0) 2011.05.11
Vmware detection by vmware I/O port  (0) 2011.04.18
TightVNC portable  (0) 2010.09.08
7.7 ddos 바이너리 대충 분석  (2) 2009.08.06
The best text for Reverse Engineering  (0) 2009.06.23
Reversing for Newbies (written by Lena)  (0) 2009.03.27
some instruction  (0) 2009.02.11

badcob Reversing