1

I'm using GDB to do some reverse engineering of a basic C program. The program does not accept command line input. It does accept input from standard in during run time. I'm trying to script the standard in by doing

run < temp

Where temp is a file containing something like

1
0
AAAAAAAAA
AAAAA
0

Unfortunately, when I do this, GDB appears to loop infinitely over this programs input.

I tried to make this file using python

python -c 'print "AAAAA"' > temp

And with the solution presented here: How to debug a program that takes user input from stdin with GDB?

But no luck. When I just step through the program with GDB, I can pass input via standard in and that work's just fine.

I'm a bit stumped...

Community
  • 1
  • 1
Smipims
  • 343
  • 1
  • 8
  • 20
  • Are you using Cygwin? There's a comment [here](http://stackoverflow.com/questions/4758175/how-to-use-gdb-with-input-redirection) that says this doesn't work there. – Barmar Jan 27 '16 at 21:42
  • See https://www.cygwin.com/ml/cygwin/1999-04/msg00308.html – Barmar Jan 27 '16 at 21:43
  • @Barmar: I'm not using Cygwin.... but that error does sound very similar. I'm going to try on a different computer later and provide an update. Hmm... How did you find that? My google-fu is apparently weak. – Smipims Jan 27 '16 at 21:45
  • I googled "gdb redirect program input" and it found that question. – Barmar Jan 27 '16 at 21:49
  • Nope. Tried on a new computer with a fresh OS install. No luck. – Smipims Jan 28 '16 at 00:23
  • What operating system? Unix or Windows? – Barmar Jan 28 '16 at 00:24
  • Unix. One time with a RHEL install and the other time with Kali. – Smipims Jan 28 '16 at 14:17
  • Are you sure the program is reading from stdin, not /dev/tty? If you run it outside `gdb`, can you redirect its input to a file? – Barmar Jan 28 '16 at 15:13

0 Answers0