PDA

View Full Version : how to convert this asm code to c or delphi


monxxx
02-18-2008, 11:07 AM
Hi,

how to convert this asm code to c or delphi?

RAM:00002392 FLDecodeClaudia
RAM:00002392 PUSH {R4,R5,LR}
RAM:00002394 ADD R4, R0, #0 ; R4 = receive buffer
RAM:00002396 ADD R0, R4, #1 ; R0 = Pointer to Claudia data
RAM:00002398 MOV R1, #0x40 ; '@' ; R1 = Size
RAM:0000239A LDR R2, =FLTmpBuf
RAM:0000239C MOV R3, #0x20 ; ' '
RAM:0000239E LDR R5, =0x84000F
RAM:000023A0 MOV LR, PC
RAM:000023A2 BX R5 ; Call Decode
RAM:000023A4 MOV R0, #0x3C ; '<'
RAM:000023A6 LDRB R0, [R0,R4]
RAM:000023A8 LSL R1, R0, #8
RAM:000023AA LDRB R0, [R4,#5]
RAM:000023AC ORR R0, R1
RAM:000023AE LDR R1, =FLFlashCipher
RAM:000023B0 STR R0, [R1]
RAM:000023B2 LDR R0, =FLFlashCfg
RAM:000023B4 MOV R1, #0x2E ; '.'
RAM:000023B6 LDRB R1, [R1,R4]
RAM:000023B8 LSL R1, R1, #0x1C
RAM:000023BA LSR R1, R1, #7
RAM:000023BC STR R1, [R0]
RAM:000023BE LDRB R2, [R4,#8]
RAM:000023C0 LSR R2, R2, #1
RAM:000023C2 BCC loc_23CC
RAM:000023C4 MOVL R2, 0x2000000
RAM:000023C8 ORR R2, R1
RAM:000023CA STR R2, [R0]
RAM:000023CC
RAM:000023CC loc_23CC ; CODE XREF: FLDecodeClaudia+30j
RAM:000023CC MOV R1, #0x36 ; '6'
RAM:000023CE LDRB R1, [R1,R4]
RAM:000023D0 LSR R1, R1, #1
RAM:000023D2 BCC loc_23DC
RAM:000023D4 LDRB R2, [R0,#1]
RAM:000023D6 MOV R1, #0x10
RAM:000023D8 ORR R1, R2
RAM:000023DA STRB R1, [R0,#1]
RAM:000023DC
RAM:000023DC loc_23DC ; CODE XREF: FLDecodeClaudia+40j
RAM:000023DC MOV R1, #0x20 ; ' '
RAM:000023DE LDRB R1, [R1,R4]
RAM:000023E0 LSR R1, R1, #1
RAM:000023E2 BCC loc_23EC
RAM:000023E4 LDRB R2, [R0]
RAM:000023E6 MOV R1, #4
RAM:000023E8 ORR R1, R2
RAM:000023EA STRB R1, [R0]
RAM:000023EC
RAM:000023EC loc_23EC ; CODE XREF: FLDecodeClaudia+50j
RAM:000023EC ADD R2, R4, #7
RAM:000023EE LDRB R1, [R2]
RAM:000023F0 LSL R1, R1, #29
RAM:000023F2 LSR R1, R1, #29
RAM:000023F4 LDR R3, =(FLBackupFAID+0xC)
RAM:000023F6 STRH R1, [R3] ; Set FAID Algo ID
RAM:000023F8 LDR R3, [R0]
RAM:000023FA LSL R1, R1, #0x1D
RAM:000023FC LSR R1, R1, #0xD
RAM:000023FE ORR R3, R1
RAM:00002400 STR R3, [R0]
RAM:00002402 LDRB R1, [R4,#0xF]
RAM:00002404 LSL R4, R1, #4
RAM:00002406 LDRB R1, [R2,#0x1D]
RAM:00002408 LSL R1, R1, #0x1C
RAM:0000240A LSR R1, R1, #0x1C
RAM:0000240C ORR R1, R4
RAM:0000240E LSL R1, R1, #0x18
RAM:00002410 LSR R1, R1, #0x18
RAM:00002412 ORR R1, R3
RAM:00002414 STR R1, [R0]
RAM:00002416 MOV R0, #1
RAM:00002418 POP {R4,R5,PC}
RAM:00002418 ; End of function FLDecodeClaudia

BR

Git
02-18-2008, 11:58 AM
The only way is to study the disassembly until you understand it, then write the equivelant functionality in C or Pascal. In can help a lot to write the equivelant C source for each line as a comment.

I don't recognise the instruction set, what CPU is it?

Git

monxxx
02-19-2008, 06:09 AM
The only way is to study the disassembly until you understand it, then write the equivelant functionality in C or Pascal. In can help a lot to write the equivelant C source for each line as a comment.

I don't recognise the instruction set, what CPU is it?

Git

hi, i think it is intel.

dont much understand with asm, i want to learn this stuff :D hope you can make me this sample into a code in c or pascal ;)

BR

uel888
02-19-2008, 07:07 AM
I think it is arm processor....

Git
02-19-2008, 09:40 AM
Oh sorry, from your original post I thought you wanted to know how to do it yourself, but it seems you just want somebody to do it for you.

How can you possibly not know what the CPU is? Where did the code come from?

Git

kiki
02-19-2008, 10:44 AM
Oh sorry, from your original post I thought you wanted to know how to do it yourself, but it seems you just want somebody to do it for you.

How can you possibly not know what the CPU is? Where did the code come from?

Git

it look like binary from symbian OS.
@monxx try search tutorial from arteam page

amtr1
02-22-2008, 05:42 PM
Hi,

how to convert this asm code to c or delphi?



BR

you need ida pro 5.2 with hex-ray it will convert your code to c language.:)

souze_villy
02-23-2008, 06:25 AM
you need ida pro 5.2 with hex-ray it will convert your code to c language.:)
amtr1 is tell 100% Yes, But depend ur source code if he build in Visual C++ then he also convert Visual C++ too.

monxxx
02-23-2008, 09:16 AM
what is hex-ray? i am really a beginner in asm :D

by the way, i have again some question how i can identify its line where is DTR/RTS, Purge_Out/Purge_In, Baudrate etc..

Partial of code:

procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
{ '4F488C
loc_004F488C: push ebp
loc_004F488D: mov ebp, esp
loc_004F488F: mov ecx, 00000016h
loc_004F4894: push 00000000h
loc_004F4896: push 00000000h
loc_004F4898: dec ecx
loc_004F4899: jnz 4F4894h
loc_004F489B: push ebx
loc_004F489C: push esi
loc_004F489D: mov esi, eax
loc_004F489F: xor eax, eax
loc_004F48A1: push ebp
loc_004F48A2: push 004F58EFh ; 'é˜ęđ˙éĄţ˙˙^[‹ĺ]Ă'
loc_004F48A7: push fs:[eax]
loc_004F48AA: mov fs:[eax], esp
loc_004F48AD: cmp byte ptr [0050C1B4h], 00h
loc_004F48B4: Method_89645959
loc_004F48BA: cmp byte ptr [0050C1DCh], 00h
loc_004F48C1: Method_89645959
loc_004F48C7: mov eax, [esi+00000300h]
loc_004F48CD: call 0043CA34h
loc_004F48D2: cmp eax, 00000004h
loc_004F48D5: Method_89645959
loc_004F48DB: mov eax, [esi+000004B0h]
loc_004F48E1: mov edx, [eax]
loc_004F48E3: call [edx+000000C8h]
loc_004F48E9: test al, al
loc_004F48EB: jz 4F4904h

Full code is here! (http://www.cybersurf.biz/x82/Flash.txt)

Thanks

BR

__snake__
02-24-2008, 11:32 AM
Arm processor ?

But , if you want to search RTS/DTR , it's not here , with this if u want acces Rom mémory , u must send a loader , RTS and DTS most of case are not used , u need search Rx , Tx .

Have u désassembled the banry file binary (.o) ?

souze_villy
02-24-2008, 11:50 AM
Arm processor ?

But , if you want to search RTS/DTR , it's not here , with this if u want acces Rom mémory , u must send a loader , RTS and DTS most of case are not used , u need search Rx , Tx .

Have u désassembled the banry file binary (.o) ?
Download the (IDA Pro 5.2) full setup with cracks from the (www.cracklab.ru), and he also have the (Hex-rays) directory Install it and then open your resource at IDA Pro 5.2 and select the compile option, and select the language. and then save it. Resource is maked *.c.

monxxx
02-25-2008, 09:18 AM
Arm processor ?

But , if you want to search RTS/DTR , it's not here , with this if u want acces Rom mémory , u must send a loader , RTS and DTS most of case are not used , u need search Rx , Tx .

Have u désassembled the banry file binary (.o) ?

you mean in that disassembled file RTS/DTS is not there? i am making the same apps with the disassembled file but my problem is the proper timing meaning i need to know FlowControl,DTR,RTS,Baudrate,Parity Control etc.. mostly Communication... i thought it can be viewed in IDA about TX and RX i know this already since i sniff the apps communication.

__snake__
02-25-2008, 10:23 AM
I agree with you .

But which relation that have a wire with a function ?

How you can read the .O flash file from Mcu or Flash , Ic , If you dont know Rx , Tx line's ?

Git
02-25-2008, 11:06 AM
Hex Rays converts assembler to Pseudocode inside the IDA Pro disassembler. It does an 80% job. That's another way of saying 20% of it's output is wrong or misinterpreted. It's a dangerous tool even in the hands of an experienced reverser, begineers shouldn't go near it. Nobody, experienced or otherwise, should treat its output as C source that you can just plug into VC and compile back into the application. Not even the manufacturer claims that, or even close to that.

In time, it will a useful tool. At the moment it's just a curiosity.

Git

kiki
02-25-2008, 11:55 AM
Hex Rays converts assembler to Pseudocode inside the IDA Pro disassembler. It does an 80% job. That's another way of saying 20% of it's output is wrong or misinterpreted. It's a dangerous tool even in the hands of an experienced reverser, begineers shouldn't go near it. Nobody, experienced or otherwise, should treat its output as C source that you can just plug into VC and compile back into the application. Not even the manufacturer claims that, or even close to that.

In time, it will a useful tool. At the moment it's just a curiosity.

Git

Git you are 100% correct. it just a pseudocode...that help to understanding the function that disassembled