Last active
December 18, 2015 15:25
-
-
Save thejh/3168128e147a04544dab to your computer and use it in GitHub Desktop.
ULTIMATE VULN FIX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <dlfcn.h> | |
#include <string.h> | |
int system(const char *cmd) { | |
static int (*realsystem)(const char *); | |
if (!realsystem) realsystem = dlsym(RTLD_NEXT, "system"); | |
if (strchr(cmd, ';') || strchr(cmd, '`') || strstr(cmd, "&&") || strstr(cmd, "../")) { | |
return 1; | |
} | |
return realsystem(cmd); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
LD_PRELOAD=/lib/x86_64-linux-gnu/libdl-2.19.so:/usr/ctf/simpleftp/bettersystem.so /usr/ctf/simpleftp//simpleftp |
Didn't stop everything, but good enough.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context: We used this to mitigate
system()
flaws in three iCTF 2014/2015 challenges: simpleftp, passwordverify, bassretard