Hello World

This is an experiment in writing some Hello World analysis using Jupyter notebooks. Let's begin by looking at the environment that we are running in.

What version of Linux are we running?


In [13]:
!lsb_release -a


No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.1 LTS
Release:	18.04
Codename:	bionic

What version of Python are we running?


In [14]:
import sys
print(sys.version)


3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0]

What version of Jupyter are we running?


In [18]:
import jupyter
print(jupyter.__version__)


1.0.0

Hello World in K&R C

Let's take a look at the standard K&R C Hello, World source:


In [19]:
!cat hello.c







Let's compile a simple C file that contains the K&R Hello, World code


In [20]:
!gcc -o hello hello.c

Now, let's run that file


In [21]:
!./hello


Hello, World!

How big is hello.c?


In [22]:
!ls -l hello


-rwxrwxrwx 1 jlam jlam 8296 Sep  9 00:18 hello

Examining the ELF binary in more detail

Let's begin by installing some helper libraries


In [27]:
!pip3 install pyelftools


Collecting pyelftools
Installing collected packages: pyelftools
Successfully installed pyelftools-0.25

In [38]:
from elftools.elf.elffile import ELFFile

f = open('hello', 'rb')
elffile = ELFFile(f)

In [39]:
for sect in elffile.iter_sections():
    print(sect)


<elftools.elf.sections.NullSection object at 0x7f4c58043748>
<elftools.elf.sections.Section object at 0x7f4c4a8c7160>
<elftools.elf.sections.NoteSection object at 0x7f4c58043748>
<elftools.elf.sections.NoteSection object at 0x7f4c4a8a81d0>
<elftools.elf.sections.Section object at 0x7f4c58043748>
<elftools.elf.sections.SymbolTableSection object at 0x7f4c4a8cda20>
<elftools.elf.sections.StringTableSection object at 0x7f4c4a8cda58>
<elftools.elf.gnuversions.GNUVerSymSection object at 0x7f4c4a8cdb00>
<elftools.elf.gnuversions.GNUVerNeedSection object at 0x7f4c4a8cdb70>
<elftools.elf.relocation.RelocationSection object at 0x7f4c4a8a81d0>
<elftools.elf.relocation.RelocationSection object at 0x7f4c4a8cdb70>
<elftools.elf.sections.Section object at 0x7f4c4a8cda58>
<elftools.elf.sections.Section object at 0x7f4c4a8cdb00>
<elftools.elf.sections.Section object at 0x7f4c4a8a81d0>
<elftools.elf.sections.Section object at 0x7f4c4a8cdb38>
<elftools.elf.sections.Section object at 0x7f4c4a8cda58>
<elftools.elf.sections.Section object at 0x7f4c4a8cdb70>
<elftools.elf.sections.Section object at 0x7f4c4a8a81d0>
<elftools.elf.sections.Section object at 0x7f4c4a8cdb70>
<elftools.elf.sections.Section object at 0x7f4c4a8a81d0>
<elftools.elf.sections.Section object at 0x7f4c4a8cdb70>
<elftools.elf.dynamic.DynamicSection object at 0x7f4c4a8a81d0>
<elftools.elf.sections.Section object at 0x7f4c4a8cdb70>
<elftools.elf.sections.Section object at 0x7f4c4a8cdac8>
<elftools.elf.sections.Section object at 0x7f4c4a8cdb70>
<elftools.elf.sections.Section object at 0x7f4c4a8a81d0>
<elftools.elf.sections.SymbolTableSection object at 0x7f4c4a8cda58>
<elftools.elf.sections.StringTableSection object at 0x7f4c4a8cdb38>
<elftools.elf.sections.StringTableSection object at 0x7f4c4a8c72b0>

In [ ]: