problem with .elf file, elf32-i386, asm code

-2

I have to work on .elf file, but I'm new to asm and I don't understand how program works. I know I should focus on parts below and change them little bit. I should change void init and time_guard, but I don't know how. It seems like it counts very short time, so you can't do anything while program is run.

080485b5 <main>:
 80485b5:   55                      push   %ebp
 80485b6:   89 e5                   mov    %esp,%ebp
 80485b8:   83 e4 f0                and    $0xfffffff0,%esp
 80485bb:   83 ec 30                sub    $0x30,%esp
 80485be:   e8 b7 ff ff ff          call   804857a <init>
 80485c3:   e8 dc fe ff ff          call   80484a4 <time_guard>
 80485c8:   85 c0                   test   %eax,%eax
 80485ca:   74 0a                   je     80485d6 <main+0x21>
 80485cc:   e8 11 ff ff ff          call   80484e2 <cheater>
 80485d1:   e9 a2 00 00 00          jmp    8048678 <main+0xc3>
 80485d6:   b8 97 87 04 08          mov    $0x8048797,%eax
 80485db:   89 04 24                mov    %eax,(%esp)
 80485de:   e8 c5 fd ff ff          call   80483a8 <printf@plt>
 80485e3:   b8 ae 87 04 08          mov    $0x80487ae,%eax
 80485e8:   8d 54 24 2c             lea    0x2c(%esp),%edx
 80485ec:   89 54 24 04             mov    %edx,0x4(%esp)
 80485f0:   89 04 24                mov    %eax,(%esp)
 80485f3:   e8 d0 fd ff ff          call   80483c8 <__isoc99_scanf@plt>
 80485f8:   8b 44 24 2c             mov    0x2c(%esp),%eax
 80485fc:   89 c2                   mov    %eax,%edx
 80485fe:   d1 ea                   shr    %edx
 8048600:   89 d0                   mov    %edx,%eax
 8048602:   01 c0                   add    %eax,%eax
 8048604:   8d 0c 10                lea    (%eax,%edx,1),%ecx
 8048607:   8b 44 24 2c             mov    0x2c(%esp),%eax
 804860b:   89 44 24 1c             mov    %eax,0x1c(%esp)
 804860f:   ba d3 4d 62 10          mov    $0x10624dd3,%edx
 8048614:   8b 44 24 1c             mov    0x1c(%esp),%eax
 8048618:   f7 e2                   mul    %edx
 804861a:   89 d0                   mov    %edx,%eax
 804861c:   c1 e8 05                shr    $0x5,%eax
 804861f:   29 c1                   sub    %eax,%ecx
 8048621:   89 ca                   mov    %ecx,%edx
 8048623:   d1 ea                   shr    %edx
 8048625:   89 54 24 1c             mov    %edx,0x1c(%esp)
 8048629:   ba 31 0c c3 30          mov    $0x30c30c31,%edx
 804862e:   8b 44 24 1c             mov    0x1c(%esp),%eax
 8048632:   f7 e2                   mul    %edx
 8048634:   89 d0                   mov    %edx,%eax
 8048636:   c1 e8 02                shr    $0x2,%eax
 8048639:   6b c0 2a                imul   $0x2a,%eax,%eax
 804863c:   89 ca                   mov    %ecx,%edx
 804863e:   29 c2                   sub    %eax,%edx
 8048640:   89 d0                   mov    %edx,%eax
 8048642:   89 44 24 2c             mov    %eax,0x2c(%esp)
 8048646:   e8 59 fe ff ff          call   80484a4 <time_guard>
 804864b:   85 c0                   test   %eax,%eax
 804864d:   74 07                   je     8048656 <main+0xa1>
 804864f:   e8 8e fe ff ff          call   80484e2 <cheater>
 8048654:   eb 22                   jmp    8048678 <main+0xc3>
 8048656:   8b 44 24 2c             mov    0x2c(%esp),%eax
 804865a:   8b 04 85 60 a0 04 08    mov    0x804a060(,%eax,4),%eax
 8048661:   ff d0                   call   *%eax
 8048663:   e8 3c fe ff ff          call   80484a4 <time_guard>
 8048668:   85 c0                   test   %eax,%eax
 804866a:   74 07                   je     8048673 <main+0xbe>
 804866c:   e8 71 fe ff ff          call   80484e2 <cheater>
 8048671:   eb 05                   jmp    8048678 <main+0xc3>
 8048673:   b8 00 00 00 00          mov    $0x0,%eax
 8048678:   c9                      leave  
 8048679:   c3                      ret    
 804867a:   90                      nop
 804867b:   90                      nop
 804867c:   90                      nop
 804867d:   90                      nop
 804867e:   90                      nop
 804867f:   90                      nop

0804857a <init>:
 804857a:   55                      push   %ebp
 804857b:   89 e5                   mov    %esp,%ebp
 804857d:   83 ec 18                sub    $0x18,%esp
 8048580:   c7 45 f4 00 00 00 00    movl   $0x0,-0xc(%ebp)
 8048587:   eb 13                   jmp    804859c <init+0x22>
 8048589:   8b 45 f4                mov    -0xc(%ebp),%eax
 804858c:   ba 52 85 04 08          mov    $0x8048552,%edx
 8048591:   89 14 85 60 a0 04 08    mov    %edx,0x804a060(,%eax,4)
 8048598:   83 45 f4 01             addl   $0x1,-0xc(%ebp)
 804859c:   83 7d f4 29             cmpl   $0x29,-0xc(%ebp)
 80485a0:   7e e7                   jle    8048589 <init+0xf>
 80485a2:   e8 54 ff ff ff          call   80484fb <generate_code>
 80485a7:   ba 66 85 04 08          mov    $0x8048566,%edx
 80485ac:   89 14 85 60 a0 04 08    mov    %edx,0x804a060(,%eax,4)
 80485b3:   c9                      leave  
 80485b4:   c3                      ret    

08048552 <looser>:
 8048552:   55                      push   %ebp
 8048553:   89 e5                   mov    %esp,%ebp
 8048555:   83 ec 18                sub    $0x18,%esp
 8048558:   c7 04 24 63 87 04 08    movl   $0x8048763,(%esp)
 804855f:   e8 74 fe ff ff          call   80483d8 <puts@plt>
 8048564:   c9                      leave  
 8048565:   c3                      ret    

08048566 <winner>:
 8048566:   55                      push   %ebp
 8048567:   89 e5                   mov    %esp,%ebp
 8048569:   83 ec 18                sub    $0x18,%esp
 804856c:   c7 04 24 78 87 04 08    movl   $0x8048778,(%esp)
 8048573:   e8 60 fe ff ff          call   80483d8 <puts@plt>
 8048578:   c9                      leave  
 8048579:   c3                      ret   

080484a4 <time_guard>:
 80484a4:   55                      push   %ebp
 80484a5:   89 e5                   mov    %esp,%ebp
 80484a7:   83 ec 18                sub    $0x18,%esp
 80484aa:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
 80484b1:   e8 02 ff ff ff          call   80483b8 <time@plt>
 80484b6:   8b 15 20 a0 04 08       mov    0x804a020,%edx
 80484bc:   29 d0                   sub    %edx,%eax
 80484be:   83 f8 02                cmp    $0x2,%eax
 80484c1:   7e 07                   jle    80484ca <time_guard+0x26>
 80484c3:   b8 ff ff ff ff          mov    $0xffffffff,%eax
 80484c8:   eb 16                   jmp    80484e0 <time_guard+0x3c>
 80484ca:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
 80484d1:   e8 e2 fe ff ff          call   80483b8 <time@plt>
 80484d6:   a3 20 a0 04 08          mov    %eax,0x804a020
 80484db:   b8 00 00 00 00          mov    $0x0,%eax
 80484e0:   c9                      leave  
 80484e1:   c3                      ret   

 080484e2 <cheater>:
 80484e2:   55                      push   %ebp
 80484e3:   89 e5                   mov    %esp,%ebp
 80484e5:   83 ec 18                sub    $0x18,%esp
 80484e8:   c7 04 24 40 87 04 08    movl   $0x8048740,(%esp)
 80484ef:   e8 e4 fe ff ff          call   80483d8 <puts@plt>
 80484f4:   b8 ff ff ff ff          mov    $0xffffffff,%eax
 80484f9:   c9                      leave  
 80484fa:   c3                      ret    

080484fb <generate_code>:
 80484fb:   55                      push   %ebp
 80484fc:   89 e5                   mov    %esp,%ebp
 80484fe:   83 ec 38                sub    $0x38,%esp
 8048501:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
 8048508:   e8 ab fe ff ff          call   80483b8 <time@plt>
 804850d:   89 c1                   mov    %eax,%ecx
 804850f:   ba c5 b3 a2 91          mov    $0x91a2b3c5,%edx
 8048514:   89 c8                   mov    %ecx,%eax
 8048516:   f7 ea                   imul   %edx
 8048518:   8d 04 0a                lea    (%edx,%ecx,1),%eax
 804851b:   89 c2                   mov    %eax,%edx
 804851d:   c1 fa 0b                sar    $0xb,%edx
 8048520:   89 c8                   mov    %ecx,%eax
 8048522:   c1 f8 1f                sar    $0x1f,%eax
 8048525:   89 d1                   mov    %edx,%ecx
 8048527:   29 c1                   sub    %eax,%ecx
 8048529:   89 c8                   mov    %ecx,%eax
 804852b:   89 45 f4                mov    %eax,-0xc(%ebp)
 804852e:   8b 4d f4                mov    -0xc(%ebp),%ecx
 8048531:   89 c8                   mov    %ecx,%eax
 8048533:   d1 e8                   shr    %eax
 8048535:   89 45 e4                mov    %eax,-0x1c(%ebp)
 8048538:   ba 31 0c c3 30          mov    $0x30c30c31,%edx
 804853d:   8b 45 e4                mov    -0x1c(%ebp),%eax
 8048540:   f7 e2                   mul    %edx
 8048542:   89 d0                   mov    %edx,%eax
 8048544:   c1 e8 02                shr    $0x2,%eax
 8048547:   6b c0 2a                imul   $0x2a,%eax,%eax
 804854a:   89 ca                   mov    %ecx,%edx
 804854c:   29 c2                   sub    %eax,%edx
 804854e:   89 d0                   mov    %edx,%eax
 8048550:   c9                      leave  
 8048551:   c3                      ret    

080483a8 <printf@plt>:
 80483a8:   ff 25 08 a0 04 08       jmp    *0x804a008
 80483ae:   68 10 00 00 00          push   $0x10
 80483b3:   e9 c0 ff ff ff          jmp    8048378 <.plt>

080483b8 <time@plt>:
 80483b8:   ff 25 0c a0 04 08       jmp    *0x804a00c
 80483be:   68 18 00 00 00          push   $0x18
 80483c3:   e9 b0 ff ff ff          jmp    8048378 <.plt>

080483c8 <__isoc99_scanf@plt>:
 80483c8:   ff 25 10 a0 04 08       jmp    *0x804a010
 80483ce:   68 20 00 00 00          push   $0x20
 80483d3:   e9 a0 ff ff ff          jmp    8048378 <.plt>

080483d8 <puts@plt>:
 80483d8:   ff 25 14 a0 04 08       jmp    *0x804a014
 80483de:   68 28 00 00 00          push   $0x28
 80483e3:   e9 90 ff ff ff          jmp    8048378 <.plt>
assembly
x86
nasm
elf
disassembly
asked on Stack Overflow Dec 10, 2019 by John

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0