<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: gdb leaves file descriptors open in debugee</title>
	<atom:link href="http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/feed/" rel="self" type="application/rss+xml" />
	<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 20 Oct 2009 16:47:36 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: More GDB Anti-Debugging &#171; xorl %eax, %eax</title>
		<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/#comment-178</link>
		<dc:creator>More GDB Anti-Debugging &#171; xorl %eax, %eax</dc:creator>
		<pubDate>Mon, 05 Jan 2009 15:19:08 +0000</pubDate>
		<guid isPermaLink="false">http://silviocesare.wordpress.com/?p=55#comment-178</guid>
		<description>[...] GDB&#160;Anti-Debugging  A couple of months ago, the almighty Silvio had found an interesting behavior on GDB. As he said at his post, this could be used to detect GDB. When a [...]</description>
		<content:encoded><![CDATA[<p>[...] GDB&nbsp;Anti-Debugging  A couple of months ago, the almighty Silvio had found an interesting behavior on GDB. As he said at his post, this could be used to detect GDB. When a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ilo</title>
		<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/#comment-152</link>
		<dc:creator>ilo</dc:creator>
		<pubDate>Wed, 05 Nov 2008 10:53:44 +0000</pubDate>
		<guid isPermaLink="false">http://silviocesare.wordpress.com/?p=55#comment-152</guid>
		<description>Sorry, I guess this is an old entry.. the fork process leaves the stack, nvironment and descriptors for the child as they were in the parent.

Take a look at this..
http://www.reversing.org/node/view/5

approach to passive fingerprint of debuggers and tracers</description>
		<content:encoded><![CDATA[<p>Sorry, I guess this is an old entry.. the fork process leaves the stack, nvironment and descriptors for the child as they were in the parent.</p>
<p>Take a look at this..<br />
<a href="http://www.reversing.org/node/view/5" rel="nofollow">http://www.reversing.org/node/view/5</a></p>
<p>approach to passive fingerprint of debuggers and tracers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: huku</title>
		<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/#comment-146</link>
		<dc:creator>huku</dc:creator>
		<pubDate>Thu, 09 Oct 2008 14:34:10 +0000</pubDate>
		<guid isPermaLink="false">http://silviocesare.wordpress.com/?p=55#comment-146</guid>
		<description>Hola Silvio,

I noticed this problem a few months ago while trying to develop a shellcode that called stat() on a hardcoded descriptor (fd=4). It really took me a while to resolve this problem :-)

Anywayz, I guess you can use env_audit to find out what exactly these descriptors are used for.

Cheers
./hk</description>
		<content:encoded><![CDATA[<p>Hola Silvio,</p>
<p>I noticed this problem a few months ago while trying to develop a shellcode that called stat() on a hardcoded descriptor (fd=4). It really took me a while to resolve this problem <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Anywayz, I guess you can use env_audit to find out what exactly these descriptors are used for.</p>
<p>Cheers<br />
./hk</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Hinman</title>
		<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/#comment-101</link>
		<dc:creator>Lee Hinman</dc:creator>
		<pubDate>Thu, 29 May 2008 17:32:53 +0000</pubDate>
		<guid isPermaLink="false">http://silviocesare.wordpress.com/?p=55#comment-101</guid>
		<description>Sorry to be littering your blog with comments, but I did find something similar to this when using gdbserver to debug remotely.

Using the program from here, which shows all the information read or written on a fd for that particular program:
http://www.dgp.toronto.edu/~ajr/209/a3/readall.c

I did:
gdbserver TCP4-LISTEN:5000 fdwatch
(fdwatch is the compiled readall.c program)

Then on the same machine:
shell&gt; gdb fdwatch
GNU gdb 6.8-debian
This GDB was configured as &quot;i486-linux-gnu&quot;...
(gdb) target remote localhost:5000
Remote debugging using localhost:5000
[New Thread 21850]
0xb7f79810 in ?? () from /lib/ld-linux.so.2
(gdb) run
The program being debugged has been started already.Start it from the beginning? (y or n) y
Starting program: /home/hinmanm/fdwatch
file descriptor 0 seems to be open
file descriptor 1 seems to be open(I&#039;ll assume it&#039;s open for write, rather than read)
file descriptor 2 seems to be open(I&#039;ll assume it&#039;s open for write, rather than read)
file descriptor 3 seems to be open
file descriptor 4 seems to be open
file descriptor 5 seems to be open
fd 5 says: ild-tree/i386-libc/csu/crti.S00/build/buildd/glibc-2.7/build-tree/glibc
fd 5 says: -2.7/csu00GNU AS 2.18.00001\37777777600\377777776110000000200]0000000401\37777777655000000 000000/build/buildd/glibc-2.7/bfd 5 says: uild-tree/i386-libc/csu/crtn.S00/build/buildd/glibc-2.7/build-tree/glib
... etc etc etc etc for quite a bit ...

Perhaps the other file descriptors are being used for remote debugging as well as fd 5?

Suppose I could start lookging through the source :)</description>
		<content:encoded><![CDATA[<p>Sorry to be littering your blog with comments, but I did find something similar to this when using gdbserver to debug remotely.</p>
<p>Using the program from here, which shows all the information read or written on a fd for that particular program:<br />
<a href="http://www.dgp.toronto.edu/~ajr/209/a3/readall.c" rel="nofollow">http://www.dgp.toronto.edu/~ajr/209/a3/readall.c</a></p>
<p>I did:<br />
gdbserver TCP4-LISTEN:5000 fdwatch<br />
(fdwatch is the compiled readall.c program)</p>
<p>Then on the same machine:<br />
shell&gt; gdb fdwatch<br />
GNU gdb 6.8-debian<br />
This GDB was configured as &#8220;i486-linux-gnu&#8221;&#8230;<br />
(gdb) target remote localhost:5000<br />
Remote debugging using localhost:5000<br />
[New Thread 21850]<br />
0xb7f79810 in ?? () from /lib/ld-linux.so.2<br />
(gdb) run<br />
The program being debugged has been started already.Start it from the beginning? (y or n) y<br />
Starting program: /home/hinmanm/fdwatch<br />
file descriptor 0 seems to be open<br />
file descriptor 1 seems to be open(I&#8217;ll assume it&#8217;s open for write, rather than read)<br />
file descriptor 2 seems to be open(I&#8217;ll assume it&#8217;s open for write, rather than read)<br />
file descriptor 3 seems to be open<br />
file descriptor 4 seems to be open<br />
file descriptor 5 seems to be open<br />
fd 5 says: ild-tree/i386-libc/csu/crti.S00/build/buildd/glibc-2.7/build-tree/glibc<br />
fd 5 says: -2.7/csu00GNU AS 2.18.00001\37777777600\377777776110000000200]0000000401\37777777655000000 000000/build/buildd/glibc-2.7/bfd 5 says: uild-tree/i386-libc/csu/crtn.S00/build/buildd/glibc-2.7/build-tree/glib<br />
&#8230; etc etc etc etc for quite a bit &#8230;</p>
<p>Perhaps the other file descriptors are being used for remote debugging as well as fd 5?</p>
<p>Suppose I could start lookging through the source <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Hinman</title>
		<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/#comment-100</link>
		<dc:creator>Lee Hinman</dc:creator>
		<pubDate>Thu, 29 May 2008 15:51:02 +0000</pubDate>
		<guid isPermaLink="false">http://silviocesare.wordpress.com/?p=55#comment-100</guid>
		<description>Interesting, on OSX with gdb 6.3.50-20050815 file descriptors 3, 4 and 5 won&#039;t open (no proc filesystem to check either). On Ubuntu with gdb 6.8-debian, file descriptor 4 opens with a return value of 3, but 3 and 5 return -1, even though 3 is shown in proc&#039;s fd list:

total 0
lrwx------ 1 hinmanm hinmanm 64 2008-05-29 09:44 0 -&gt; /dev/pts/2
lrwx------ 1 hinmanm hinmanm 64 2008-05-29 09:44 1 -&gt; /dev/pts/2
lrwx------ 1 hinmanm hinmanm 64 2008-05-29 09:44 2 -&gt; /dev/pts/2
lr-x------ 1 hinmanm hinmanm 64 2008-05-29 09:44 3 -&gt; pipe:[21982]
l-wx------ 1 hinmanm hinmanm 64 2008-05-29 09:44 4 -&gt; pipe:[21982]

I suppose it is because fd 3 doesn&#039;t have write permission. Still, I&#039;m really interested in what you can do with these pipes.</description>
		<content:encoded><![CDATA[<p>Interesting, on OSX with gdb 6.3.50-20050815 file descriptors 3, 4 and 5 won&#8217;t open (no proc filesystem to check either). On Ubuntu with gdb 6.8-debian, file descriptor 4 opens with a return value of 3, but 3 and 5 return -1, even though 3 is shown in proc&#8217;s fd list:</p>
<p>total 0<br />
lrwx&#8212;&#8212; 1 hinmanm hinmanm 64 2008-05-29 09:44 0 -&gt; /dev/pts/2<br />
lrwx&#8212;&#8212; 1 hinmanm hinmanm 64 2008-05-29 09:44 1 -&gt; /dev/pts/2<br />
lrwx&#8212;&#8212; 1 hinmanm hinmanm 64 2008-05-29 09:44 2 -&gt; /dev/pts/2<br />
lr-x&#8212;&#8212; 1 hinmanm hinmanm 64 2008-05-29 09:44 3 -&gt; pipe:[21982]<br />
l-wx&#8212;&#8212; 1 hinmanm hinmanm 64 2008-05-29 09:44 4 -&gt; pipe:[21982]</p>
<p>I suppose it is because fd 3 doesn&#8217;t have write permission. Still, I&#8217;m really interested in what you can do with these pipes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: silviocesare</title>
		<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/#comment-99</link>
		<dc:creator>silviocesare</dc:creator>
		<pubDate>Thu, 29 May 2008 05:10:14 +0000</pubDate>
		<guid isPermaLink="false">http://silviocesare.wordpress.com/?p=55#comment-99</guid>
		<description>I&#039;m not sure if your test will work,  I would presume attaching to a process from gdb wont work, and the bug will only reveal itself when the target is run from within gdb (presumably its because the bug is some missing close&#039;s before the execve).  Also, running from a script will probably cause some problems too.

This bug is in my testing of Fedora Linux 8, and also Debian etch.

gdb version 6.6-45.fc8rh 
gdb version 6.4.90-debian

$ cd /tmp
$ cat test.c
int
main(int argc, char *argv[])
{
        int ret;
        ret = write(atoi(argv[1]), &quot;hi&quot;, sizeof(&quot;hi&quot;));
        printf(&quot;ret %i\n&quot;, ret);
}
$ gcc test.c
$ gdb a.out
&gt; run 4
ret 3

&gt; break main
&gt; run 4
^Z
$ ps a&#124;grep gdb&#124;grep -v grep
28798 tty1     S+     0:00 gdb a.out
$ ls -la /proc/28799/fd
total 0
dr-x------ 2 silvio None  0 2008-05-29 14:48 .
dr-xr-xr-x 6 silvio None  0 2008-05-29 14:47 ..
lrwx------ 1 silvio None 64 2008-05-29 14:48 0 -&gt; /dev/tty1
lrwx------ 1 silvio None 64 2008-05-29 14:48 1 -&gt; /dev/tty1
lrwx------ 1 silvio None 64 2008-05-29 14:48 2 -&gt; /dev/tty1
lr-x------ 1 silvio None 64 2008-05-29 14:48 3 -&gt; pipe:[192216]
l-wx------ 1 silvio None 64 2008-05-29 14:48 4 -&gt; pipe:[192216]
lr-x------ 1 silvio None 64 2008-05-29 14:48 5 -&gt; /tmp/a.out

--
Silvio</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure if your test will work,  I would presume attaching to a process from gdb wont work, and the bug will only reveal itself when the target is run from within gdb (presumably its because the bug is some missing close&#8217;s before the execve).  Also, running from a script will probably cause some problems too.</p>
<p>This bug is in my testing of Fedora Linux 8, and also Debian etch.</p>
<p>gdb version 6.6-45.fc8rh<br />
gdb version 6.4.90-debian</p>
<p>$ cd /tmp<br />
$ cat test.c<br />
int<br />
main(int argc, char *argv[])<br />
{<br />
        int ret;<br />
        ret = write(atoi(argv[1]), &#8220;hi&#8221;, sizeof(&#8220;hi&#8221;));<br />
        printf(&#8220;ret %i\n&#8221;, ret);<br />
}<br />
$ gcc test.c<br />
$ gdb a.out<br />
&gt; run 4<br />
ret 3</p>
<p>&gt; break main<br />
&gt; run 4<br />
^Z<br />
$ ps a|grep gdb|grep -v grep<br />
28798 tty1     S+     0:00 gdb a.out<br />
$ ls -la /proc/28799/fd<br />
total 0<br />
dr-x&#8212;&#8212; 2 silvio None  0 2008-05-29 14:48 .<br />
dr-xr-xr-x 6 silvio None  0 2008-05-29 14:47 ..<br />
lrwx&#8212;&#8212; 1 silvio None 64 2008-05-29 14:48 0 -&gt; /dev/tty1<br />
lrwx&#8212;&#8212; 1 silvio None 64 2008-05-29 14:48 1 -&gt; /dev/tty1<br />
lrwx&#8212;&#8212; 1 silvio None 64 2008-05-29 14:48 2 -&gt; /dev/tty1<br />
lr-x&#8212;&#8212; 1 silvio None 64 2008-05-29 14:48 3 -&gt; pipe:[192216]<br />
l-wx&#8212;&#8212; 1 silvio None 64 2008-05-29 14:48 4 -&gt; pipe:[192216]<br />
lr-x&#8212;&#8212; 1 silvio None 64 2008-05-29 14:48 5 -&gt; /tmp/a.out</p>
<p>&#8211;<br />
Silvio</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Hinman</title>
		<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/#comment-98</link>
		<dc:creator>Lee Hinman</dc:creator>
		<pubDate>Wed, 28 May 2008 18:20:17 +0000</pubDate>
		<guid isPermaLink="false">http://silviocesare.wordpress.com/?p=55#comment-98</guid>
		<description>Hmm... last comment doesn&#039;t like characters in the script, the script is here: http://pastebin.ca/1032349</description>
		<content:encoded><![CDATA[<p>Hmm&#8230; last comment doesn&#8217;t like characters in the script, the script is here: <a href="http://pastebin.ca/1032349" rel="nofollow">http://pastebin.ca/1032349</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Hinman</title>
		<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/#comment-97</link>
		<dc:creator>Lee Hinman</dc:creator>
		<pubDate>Wed, 28 May 2008 18:18:35 +0000</pubDate>
		<guid isPermaLink="false">http://silviocesare.wordpress.com/?p=55#comment-97</guid>
		<description>Can you detail how you reproduced or found this problem? I was curious so I tried with the following script:

#!/usr/bin/env ruby 
puts &quot;STDIN: #{STDIN.to_i}&quot;
puts &quot;STDOUT: #{STDOUT.to_i}&quot;
puts &quot;STDERR: #{STDERR.to_i}&quot;
sleep(20) # give time to attach with gdb
i = 3
while (i  ruby fds.rb
STDIN: 0
STDOUT: 1
STDERR: 2
trying fd #3..
fd #3 closed.
trying fd #4..
fd #4 closed.
trying fd #5..
fd #5 closed.
trying fd #6..
fd #6 closed.
etc etc etc all the way to 20

I&#039;m very interested in how you found it and if it&#039;s reproducable.
(I tested on Ubuntu 8.04 and Mac OSX)</description>
		<content:encoded><![CDATA[<p>Can you detail how you reproduced or found this problem? I was curious so I tried with the following script:</p>
<p>#!/usr/bin/env ruby<br />
puts &#8220;STDIN: #{STDIN.to_i}&#8221;<br />
puts &#8220;STDOUT: #{STDOUT.to_i}&#8221;<br />
puts &#8220;STDERR: #{STDERR.to_i}&#8221;<br />
sleep(20) # give time to attach with gdb<br />
i = 3<br />
while (i  ruby fds.rb<br />
STDIN: 0<br />
STDOUT: 1<br />
STDERR: 2<br />
trying fd #3..<br />
fd #3 closed.<br />
trying fd #4..<br />
fd #4 closed.<br />
trying fd #5..<br />
fd #5 closed.<br />
trying fd #6..<br />
fd #6 closed.<br />
etc etc etc all the way to 20</p>
<p>I&#8217;m very interested in how you found it and if it&#8217;s reproducable.<br />
(I tested on Ubuntu 8.04 and Mac OSX)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thanasis K</title>
		<link>http://silviocesare.wordpress.com/2008/05/13/gdb-leaves-file-descriptors-open-in-debugee/#comment-78</link>
		<dc:creator>Thanasis K</dc:creator>
		<pubDate>Sun, 18 May 2008 00:23:31 +0000</pubDate>
		<guid isPermaLink="false">http://silviocesare.wordpress.com/?p=55#comment-78</guid>
		<description>If this indeed is a bug, be a sport and submit a bug report :)</description>
		<content:encoded><![CDATA[<p>If this indeed is a bug, be a sport and submit a bug report <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
