TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Awesome-ld-preload: List of resources related to LD_PRELOAD

85 pointsby gaulover 5 years ago

14 comments

zwpover 5 years ago
I have another that I sometimes use: overriding getenv(3). (I typically just printf() the variable name and return NULL).<p>Most of the time you can spot environment variable usage in binaries using strings(1) (folks still like to use upper case env vars in non-system applications even though this goes against POSIX).<p>But by using LD_PRELOAD you can easily see if the program is actually hitting the codepath reads that variable without debuggers or grovelling about in the assembly.
f-over 5 years ago
Disappointed that my LD_PRELOAD exploit - still unpatched after 20 years! - did not make the list:<p><a href="http:&#x2F;&#x2F;lcamtuf.coredump.cx&#x2F;soft&#x2F;ld-expl" rel="nofollow">http:&#x2F;&#x2F;lcamtuf.coredump.cx&#x2F;soft&#x2F;ld-expl</a>
评论 #22153600 未加载
评论 #22153112 未加载
nonesuchluckover 5 years ago
Nice list of fun hacks. My personal favorite preload is [stderr in red](<a href="https:&#x2F;&#x2F;github.com&#x2F;sickill&#x2F;stderred" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sickill&#x2F;stderred</a>). (Not my github, but I&#x27;ve used this for a long time on my macbook)
评论 #22152895 未加载
dixie_landover 5 years ago
I actually recently worked on an LD_PRELOAD wrapper to enable TLS for existing plain sockets.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;zliuva&#x2F;ktlswrapper" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zliuva&#x2F;ktlswrapper</a><p>Did it for fun to get my Transmission daemon behind TLS without socat or nginx.
adrianmonkover 5 years ago
&gt; <i>drop files content from page cache after closing, useful for backups</i><p>It took me a minute to understand why this is useful for backups. It prevents your backup tool from leaving a bunch of stuff in cache that isn&#x27;t needed. It&#x27;s a performance thing. (And it&#x27;s not a data integrity thing, which came to mind because one reason for flushing a cache is to be sure writes to the underlying layer been done.)<p>This leads to an interesting question: do most backup tools not already have this optimization built in? From a quick perusal of the GNU tar manual page and source and running it under strace, it doesn&#x27;t seem like it supports it. (Though tar is really more of an archive tool than a backup tool, which isn&#x27;t precisely the same thing.)
terminaljunkidover 5 years ago
It reminds me my experiments to get a debian rootfs running on a plain Android terminal emulator without something like termux.<p>I remember I used LD_PRELOAD along with fakechroot and fakeroot packages to get most things working. Those days&#x27; android allowed running statically linked binaries among other things.<p>(except DNS resolution and argv[0] was always ${some_large_path}&#x2F;ld-linux-armhf.so, as I invoked glibc dynamic loader)..<p>Those days I didn&#x27;t have a laptop and learned some C programming and unix stuff through termux. I sometimes think, as a CSE student, I lack the enthusiasm I had in those 12th grade days..
estover 5 years ago
the most crazy LD_PRELOAD was using 4.X kernel on a centos6 machine with LKL<p><a href="https:&#x2F;&#x2F;github.com&#x2F;lkl&#x2F;linux" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lkl&#x2F;linux</a><p>There are tons of extremely OpenVZ hostings on the interweb but with an ancient 2.6 kernel like centos5.<p>With LKL you can enjoy the benefits of modern kernel with minimal performance penalty.<p>Submitted an issue here: <a href="https:&#x2F;&#x2F;github.com&#x2F;gaul&#x2F;awesome-ld-preload&#x2F;issues&#x2F;1" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gaul&#x2F;awesome-ld-preload&#x2F;issues&#x2F;1</a>
EvilTerranover 5 years ago
Neat! I can see myself using several of these.<p>Erratum: the link meant for &quot;openssl-hook&quot; actually takes you to &quot;otherport&quot;.
评论 #22151270 未加载
huksleyover 5 years ago
As far as I know LD_PRELOAD does not allows overriding syscalls, for example mmap. I believe also open call can not be overriden to (because it is a syscall too), so I wonder how ld-preload-open works?<p><a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;31439038" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;31439038</a>
评论 #22152841 未加载
scottlambover 5 years ago
<a href="https:&#x2F;&#x2F;github.com&#x2F;libhugetlbfs&#x2F;libhugetlbfs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;libhugetlbfs&#x2F;libhugetlbfs</a> can use LD_PRELOAD to remap segments onto huge pages for a performance boost (via fewer TLB misses).
mrobover 5 years ago
Here&#x27;s another that I&#x27;ve found useful:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;mariusae&#x2F;trickle" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mariusae&#x2F;trickle</a><p>&quot;Trickle is a userland bandwidth shaper for Unix-like systems.&quot;
_nalplyover 5 years ago
LD_PRELOAD is powerful. For example run pacman4console, but hide that with a LD_PRELOAD calling prctl() and overwriting the argv array. So even if your boss knows ps he will not know you&#x27;re playing.
ComputerGuruover 5 years ago
&gt; Copyright Google LLC?<p>There’s no such thing...<p>Edit: I stand corrected. I thought it was a C-Corp.
评论 #22153202 未加载
codesectionsover 5 years ago
Is the existence of LD_PRELOAD a <i>strong</i> argument in favor of static linking?<p>I hadn&#x27;t heard of LD_PRELOAD before now, but my first reaction was &quot;oh wow, better static link <i>all the things</i>!&quot;. Is that wrong?
评论 #22152247 未加载
评论 #22152253 未加载
评论 #22152278 未加载
评论 #22153130 未加载