jella_flores@[EMAIL PROTECTED]
wrote:
> hi to everyone,
> i'm posting here in hope to find help for my troubles in tracing the
> code line by line...i cannot go on finding the exact string that this
> program requires...i want to track line by line but my problem is,i
> dont know how to follow the codes...i only understand few instructions
> and though i am familiar with all the instructions,i dont know how to
> understand it if it in a code being applied...please help me by
> commenting the codes...or if you can do better,please?i beg you
> guys...more power to you all!
> i just want some sample how to trace...
You better ask in alt.lang.asm or comp.lang.asm.x86 where such
programs have been discussed a few days ago. But you can tell
your teacher, he will not get a good grade for this program
(at least if it was written in assembler and not in a HLL).
Here a maybe better understandable disassembly:
key1=$cefa
key2='.'
@[EMAIL PROTECTED]
br.w begin
; encrypted message
dat: dc.b 'Y' ^ key1 &$ff
dc.b 'o' ^ key1 >>8
dc.b 'u' ^ key1 &$ff
dc.b "'" ^ key1 >>8
dc.b 'v' ^ key1 &$ff
dc.b 'e' ^ key1 >>8
dc.b ' ' ^ key1 &$ff
dc.b 'g' ^ key1 >>8
dc.b 'o' ^ key1 &$ff
dc.b 't' ^ key1 >>8
dc.b ' ' ^ key1 &$ff
dc.b 'i' ^ key1 >>8
dc.b 't' ^ key1 &$ff
dc.b ' ' ^ key1 >>8
dc.b 'r' ^ key1 &$ff
dc.b 'i' ^ key1 >>8
dc.b 'g' ^ key1 &$ff
dc.b 'h' ^ key1 >>8
dc.b 't' ^ key1 &$ff
dc.b '!' ^ key1 >>8
dc.b '!' ^ key1 &$ff
dc.b '!' ^ key1 >>8
dc.b ' ' ^ key1 &$ff
dc.b 'I' ^ key1 >>8
dc.b ' ' ^ key1 &$ff
dc.b 'h' ^ key1 >>8
dc.b 'o' ^ key1 &$ff
dc.b 'p' ^ key1 >>8
dc.b 'e' ^ key1 &$ff
dc.b ' ' ^ key1 >>8
dc.b 'y' ^ key1 &$ff
dc.b 'o' ^ key1 >>8
dc.b 'u' ^ key1 &$ff
dc.b "'" ^ key1 >>8
dc.b 'l' ^ key1 &$ff
dc.b 'l' ^ key1 >>8
dc.b ' ' ^ key1 &$ff
dc.b 'p' ^ key1 >>8
dc.b 'a' ^ key1 &$ff
dc.b 's' ^ key1 >>8
dc.b 's' ^ key1 &$ff
dc.b ' ' ^ key1 >>8
dc.b 't' ^ key1 &$ff
dc.b 'h' ^ key1 >>8
dc.b 'e' ^ key1 &$ff
dc.b ' ' ^ key1 >>8
dc.b 't' ^ key1 &$ff
dc.b 'e' ^ key1 >>8
dc.b 'c' ^ key1 &$ff
dc.b 'h' ^ key1 >>8
dc.b 'n' ^ key1 &$ff
dc.b 'i' ^ key1 >>8
dc.b 'c' ^ key1 &$ff
dc.b 'a' ^ key1 >>8
dc.b 'l' ^ key1 &$ff
dc.b ' ' ^ key1 >>8
dc.b 'e' ^ key1 &$ff
dc.b 'x' ^ key1 >>8
dc.b 'a' ^ key1 &$ff
dc.b 'm' ^ key1 >>8
dc.b '.' ^ key1 &$ff
dc.b '.' ^ key1 >>8
dat62: dc.b key2^ key1 &$ff
dc.b '$' ^ key1 >>8
dat_end:
inbuf: blk.b 15,$24 ; 15 byte input buffer
msg1: dc.b "Enter the password: $"
msg2: dc.b "Don't push it...exciting...$"
begin: move.w #msg1,r1
move.b #9,m0 ; print message1
trap #$21
eor.w r5,r5
input: move.b #1,m0
trap #$21
cmp.b #13,r0 ; <RETURN>?
beq.b process ; yes, then exit input routine
move.b r0,inbuf(r5.w) ; store in input buffer
inc.w r5
cmpq.w #10,r5 ; 10 bytes read?
beq.b wrong ; yes, that's too much
br.b input ; read next character
process:bclr.w #10,sr ; clear direction flag
move.w #dat,r5 ; pointer to dat
move.w r5,r6 ; pointer to dat
move.w #dat_end,r2
sub.w r5,r2 ; size of encrypted data in byte
lsr.w #1,r2 ; size of encrypted data in word
_10: move.w (r5.w)+-,r0 ; read next word from data
eor.w #key1,r0 ; decrypt it
move.w r0,(r6.w)+-{s1} ; store it back
dbf.w r2,_10 ; loop until complete data processed
move.b #0,r0
move.w #dat_end,r3
subq.w #2,r3 ; pointer to dat62
move.b (r3.w,r0.b),r0 ; dat62 = key2
move.b r0,r1 ; dat62
move.w #pass_end,r5
subq.w #pass_length,r5 ; pointer to pass
move.w r5,-(sp)
move.w r5,r6
move.w #10,r2 ; prozess pass0 - pass9
_20: move.b (r5.w)+-,r0 ; get next byte of pass
eor.b r1,r0 ; eor it with dat62
move.b r0,(r6.w)+-{s1} ; store it back
dbf.w r2,_20 ; loop until dat62 processed
move.w #10,r2 ; compare 10 bytes
move.w (sp)+,r5 ; pointer to pass
move.w #inbuf,r6 ; pointer to input input string
repeq_r2 cmp.b (r6.w)+-{s1},(r5.w)+- ; compare
bne.b wrong ; strings not equal
move.w #dat,r1 ; decrypted text
move.b #$09,m0 ; print it
trap #$21
br.b byebye ; exit
nop
wrong: move.w #msg2,r1
move.b #$09,m0 ; print message2
trap #$21
br.b byebye ; exit
nop
pass: dc.b 'J' ^ key2
dc.b 'o' ^ key2
dc.b 'h' ^ key2
dc.b 'n' ^ key2
dc.b ' ' ^ key2
dc.b '3' ^ key2
dc.b ':' ^ key2
dc.b '1' ^ key2
dc.b '6' ^ key2
dc.b '$' ^ key2
dc.b 0
pass_end:
pass_length=pass_end-pass
byebye: move.w #$4c00,r0
trap #$21
>
;-------------------------------------------------------------------------------------
> .model tiny
> .code
> org 100h
>
> START:
> jmp begin
>
> data1 DB 0A3H, 0A1H, 8FH, 0E9H, 8CH, 0ABH, 0DAH, 0A9H
> DB 95H, 0BAH, 0DAH, 0A7H, 8EH, 0EEH, 88H, 0A7H
> data2 DB 9DH, 0A6H, 8EH, 0EFH, 0DBH, 0EFH, 0DAH, 87H
> DB 0DAH, 0A6H, 95H, 0BEH, 9FH, 0EEH, 83H, 0A1H
> data3 DB 8FH, 0E9H, 96H, 0A2H, 0DAH, 0BEH, 9BH, 0BDH
> DB 89H, 0EEH, 8EH, 0A6H, 9FH, 0EEH, 8EH, 0ABH
> data4 DB 99H, 0A6H, 94H, 0A7H, 99H, 0AFH, 96H, 0EEH
> DB 9FH, 0B6H, 9BH, 0A3H, 0D4H, 0E0H, 0D4H, 0EAH
> data5 DB 15 DUP(24H)
> data6 DB "Enter the password: $"
> data7 DB "Don't push it...exciting...$"
>
> BEGIN:
> LEA DX, data6
> MOV AH, 9
> INT 21H
> XOR SI, SI
>
> INPUT:
> MOV AH, 1
> INT 21H
> CMP AL, 0DH ;what is the need for checking
the carriage return?
> JZ PROCESS
> MOV BYTE PTR [data5 + SI], AL
> INC SI
> CMP SI, 0AH ;what is line feed needed for?
> JZ WHAT_THE
> JMP INPUT
>
> PROCESS:
> CLD ;string is done forward (why?)
> LEA SI, data1
> MOV DI, SI
> LEA CX, data5
> SUB CX, SI
> SHR CX, 1
>
> CONVERT: ;what is this routine is for?
> LODSW
> XOR AX, 0CEFAH
> STOSW
> LOOP CONVERT
> MOV AL, 0
> LEA BX, data5
> SUB BX, 2
> XLAT
> MOV DL, AL
> LEA SI, BYEBYE
> SUB SI, 0BH
> PUSH SI
> MOV DI, SI
> MOV CX, 000AH
>
> DECODE: what is this routine decoding?how?
> LODSB
> XOR AL, DL
> STOSB
> LOOP DECODE
> MOV CX, 000AH
> POP SI
> LEA DI, data5
> REPE CMPSB
> JNE WHAT_THE
> LEA DX, data1
> MOV AH, 9
> INT 21H
> JMP BYEBYE
>
> WHAT_THE:
> LEA DX, data7
> MOV AH,9
> INT 21H
> JMP BYEBYE
> DB 64H, 41H, 46H, 40H, 0EH, 1DH, 14H, 1FH, 18H,0AH, 00H
>
> BYEBYE: ;exit to DOS
> MOV AX, 4C00H
> INT 21H
>
> END START
>
;-----------------------------------------------------------------------------


|