Skip to content

Instantly share code, notes, and snippets.

@thejh
Last active December 18, 2015 15:25
Show Gist options
  • Save thejh/3168128e147a04544dab to your computer and use it in GitHub Desktop.
Save thejh/3168128e147a04544dab to your computer and use it in GitHub Desktop.
ULTIMATE VULN FIX
#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);
}
#!/bin/sh
LD_PRELOAD=/lib/x86_64-linux-gnu/libdl-2.19.so:/usr/ctf/simpleftp/bettersystem.so /usr/ctf/simpleftp//simpleftp
@thejh
Copy link
Author

thejh commented Apr 11, 2015

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