Postingan

Assembly itu mudah, hanya butuh urut dan telaten part.2

 glosarium asm

enum option_e {
    STOP = 'q',
    CONTINUE = 'c',
    NEW = 'n',
    EDIT = 'e',
    DELETE = 'd'
}
int main(){
    char optionbuf[4];
    while(optionbuf[0] != STOP){
        scanf("%4s, optionbuf);
        switch (optionbuf[0]){
            case NEW:
                handleNew();
                break;
            case EDIT:
                handleEdit();
                break;
            case DELETE:
                handleDelete();
                break;
            case STOP:
                handlestop();
                break;
            case CONTINUE:
                handleContinue();
                break;
            default;
            break;
        }

how it goes



122f: call 1090 <__isoc99)scanf@plt>
1234: movzx eax, BYTE PTR [rbp-0xc] : moving zero extended of BYTE PTR to eax
1238: movsx eax, al: moving sign extended of last significant byte that came from eax
123b: sub eax, 0x63: subtract 0x63 (case from our value which is "c") with eax from BYTE PTR that processed by moving sign extended and moving zero extended we did before
123e: cmp eax, 0xe: compared 0xe with eax that we've been processed above (dunno what are 0xe really is)
1241: ja 12a2 <main+0xa6>: jump above to 12a2 stack entries, if comparison (value under of 0xe) doesn't meet

1259: lea rdx, [rip+0xe00] : load-ea with specific address is 0xe00 from 1241 into rdx

explanation of user input as negative index value:

(little endian)0xfffff242 => 4294963778: is a big chunk
0xffffffff(max size 32bit represent) - 0xfffff242 => 3517 is 123b: sub eax, 0x63 command substraction kind above
hex(3517+1) => 0xdbe: result is negative hex-dbe




rdx of 1259 then result 2054

# 2054 <_IO_stdin_used+0x54>
1260: add rax, rdx: add rdx from jump table to rax(2054)

2054 is rdx then added to rax which would compute (subtract) later on with 0xdbe

hex(0x2054-0xdbe) => 0x1296




debug hati

Posting Komentar

NextGen Digital Welcome to WhatsApp chat
Howdy! How can we help you today?
Type here...