Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debugging a 32bit binary on a 64bit machine with GDB, file not found

I understand from other SO threads that gdb can debug both 32bit and 64bit binaries on a 64bit architecture, but when I run it I have the following issue :

Starting program: /root/crackme-01 
/bin/bash: /root/crackme-01: No such file or directory
During startup program exited with code 127.

Here is the result of file on the program :

crackme-01: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=9feb70a8647779984dc69b1e5c90bd757343fb29, stripped

Is there anything else I should do to debug it?

Thanks for your help.

like image 641
user3779430 Avatar asked May 28 '15 12:05

user3779430


People also ask

How do I run a GDB file?

Use the run command to start your program under GDB. You must first specify the program name (except on VxWorks) with an argument to GDB (see section Getting In and Out of GDB), or by using the file or exec-file command (see section Commands to specify files).

What is GDB debugger in Linux?

Gdb is a debugger for C (and C++). It allows you to do things like run the program up to a certain point then stop and print out the values of certain variables at that point, or step through the program one line at a time and print out the values of each variable after executing each line.


2 Answers

GDB can only debug a program that can start by itself. In your case, the program couldn't start at all (not a single instruction was executed in user space for your process, the execve system call failed). This:

/bin/bash: /root/crackme-01: No such file or directory

is almost always caused by missing program interpreter. You can see the interpreter like so:

readelf -l /root/crackme-01 | grep interpreter

In your case, the interpreter is almost certainly /lib/ld-linux.so.2.

I was just missing the libraries

You were missing libc6:i386, which ld-linux.so.2 is part of.

like image 73
Employed Russian Avatar answered Sep 30 '22 13:09

Employed Russian


I was just missing the libraries as explained here

I needed to install the 32bit libs with :

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
like image 37
user3779430 Avatar answered Sep 30 '22 13:09

user3779430