47 Matching Annotations
  1. Dec 2020
  2. Sep 2020
  3. Dec 2018
    1. int i; int *a[1]; for( i = 0 ; i < 20; i++) printf("%p\n", a[i]);

      Imagine that you insert this code in a certain function. What is the meaning of the values printed? Hint: Notice the size of array a and the number of iterations of the for loop.

    2. 5. Extra: FixME [3p]

      The first 6 bytes of main.bad are damaged. Fix them manually using bless to look like those of a 64-bit ELF.

      Then find out what is the address of _start and change the starting address of the binary to that address.

    3. chmod +x ./mycode.bin && ./mycode.bin

      Just because the mycode.bin file contains assembly instructions does not mean that the loader will run. The loader needs the file in the ELF file format.

    4. ./shellcode generate > mycode.bin

      Running the shellcode with a CMA will output the binary of the byte array. You can inspect the mycode.bin it will contain the same bytes as the SC string.

    5. Inspect the source code of shellcode.c

      Whenever the code is invoked with no command line arguments (argc==1) it tries to run the SC bytes as code.

      ret = (int(*)())SC;
      
      (int)(*ret)();
      
    6. section

      The symbol table lists the address that is assigned to SC. You can find which section corresponds to that address in the Section Table (use the -S flag fro readelf).

    7. readelf -s ./shellcode | grep SC

      SC is a array of characters. SC and all other symbols are listed in the symbol table of the ELF. The symtab list information such as: name, scope (LOCAL, GLOBAL), size, type (FUN, OBJECT, SECTION).

    8. SIGSEGV

      A SIGSEGV is an error(signal) caused by an invalid memory reference or a segmentation fault. You are probably trying to access an array element out of bounds or trying to use too much memory.

  4. Mar 2018
    1. .fini

      This section holds executable instructions that contribute to the process termination code. That is, when a program exits normally, the system arranges to execute the code in this section

    1. Section Headers:

      ELF files are subdivided into sections.

      A section is an area in the object file that contains information which is useful for linking: program's code, program's data (variables, array, string), relocation information and other. So, in each area, several information is grouped and it has a distinct meaning: code section only hold code, data section only holds initialized or non-initialized data, etc

    1. .section .rodata

      "Here comes the read-only data segment"

      You can see the literal strings "%d" and "result is %d\n" that are parameters to the scanf and printf functions.

    2. .comm buffer,1048576,32

      This is saying "In this program there is a global variable called buffer of 1048576 bytes and 32-bit alignment.

      .comm name, size,alignment

      The '.comm' directive allocates storage in the data section.

  5. Jun 2017