16

I'm following these lessons from OpenSecurityTraining.

I've reached the lab part where I've to train myself on a CMU Bomb. They provide a x86_64 compiled CMU Bomb that you can find here to train on : CMU Bomb x86-64 originally from a 32-bit bomb from CMU Labs for Computer Systems: A Programmer's Perspective (CS:APP) 1st edition.

I had a virtualized 64 bits Elementary OS distribution where I disassembled the CMU Bomb without problems using GDB. Now, I've a 64 bits Ubuntu 14.04 LTS (not virtualized) and when I try to reproduce why I did on my Elementary OS, I get the famous error.

I run these commands :

gdb ./bomb-x64
(gdb) b main
Breakpoint 1 at 0x400dbd: file bomb.c, line 37. -- why bomb.c ?
(gdb) r
...
bomb.c: no such file or directory

Edit : I can create breakpoints on others functions of the CMU Bomb and it works as expected.
Example :

(gdb) b phase_1
Breakpoint 3 at 0x400f00
(gdb) r

Breakpoint 1, 0x0000000000400f00 in phase_1 ()
(gdb) disas
Dump of assembler code for function phase_1:
=> 0x0000000000400f00 <+0>: sub    $0x8,%rsp
   0x0000000000400f04 <+4>: mov    $0x4023b0,%esi
   0x0000000000400f09 <+9>: callq  0x401308 <strings_not_equal>
   0x0000000000400f0e <+14>:    test   %eax,%eax
   0x0000000000400f10 <+16>:    je     0x400f17 <phase_1+23>
   0x0000000000400f12 <+18>:    callq  0x40140a <explode_bomb>
   0x0000000000400f17 <+23>:    add    $0x8,%rsp
   0x0000000000400f1b <+27>:    retq   
End of assembler dump.

I've heard of ia32-libs but this doesn't do anything more since I'm on 64bits Ubuntu and run a 64bits compiled CMU Bomb, am I wrong ?

5
  • 1
    It appears your bomb.c file is not in gdb's source path. You'll need to use the "directory" command. See stackoverflow.com/q/21928876/10077. Commented Jan 8, 2015 at 22:33
  • 1
    When the error happens, what happens if you type disas or, failing that, next?
    – Tony
    Commented Jan 9, 2015 at 6:33
  • @FredLarson I don't have sources. This is the point of this lab/exercise. It's on purpose. However, I can add breakpoints on others functions and it works as expected. Only the break main refers to the source file.
    – Cédric M.
    Commented Jan 9, 2015 at 12:20
  • @Tony I'll try this as soon as I'm at home.
    – Cédric M.
    Commented Jan 9, 2015 at 16:15
  • 2
    I downloaded it and ran it under gdb on 64-bit Ubuntu 14.04. Aside from periodic complaints bomb.c: No such file or directory, it runs normally. After b main and run, I get Starting program: /var/tmp/bomb-x64, Breakpoint 1, main (argc=1, argv=0x7fffffffe088) at bomb.c:37, 37 bomb.c: No such file or directory., and (gdb). Typing c allows it to proceed normally to the Welcome message. Are you seeing something different? Commented Jan 12, 2015 at 17:00

3 Answers 3

21

Use dir command to set source path

dir /usr/src/debug

in above path. Your code should present.

2
  • 18
    You should elaborate . Commented Dec 21, 2016 at 16:56
  • 1
    Does it search recursively?
    – keyur
    Commented Apr 16, 2021 at 15:59
9

The executable contains debugging symbols, which indicate the file (and particular line in the file) corresponding to each bit of assembled code. This is what allows you to step through C code in the debugger. The debugging symbols are put there by the compiler (e.g. by using the -g argument to gcc).

If you don't have the C files that were used to compile the executable, the debugger won't be able to show you the C, and you'll be limited to looking at assembly.

1
  • I do want to look at assembly but I can't since the breakpoint main is referring to a source file I don't have. I would like to remind you that I'm issuing this error on my Ubuntu only. I don't have this error on my (virtualized) Elementary OS.
    – Cédric M.
    Commented Jan 9, 2015 at 13:23
0
(gdb) list 
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c: No such file or directory.
(gdb) set substitute-path /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/ C:/Espressif/frameworks/esp-idf-v4.4/  
    

Not the answer you're looking for? Browse other questions tagged or ask your own question.