Skip to content

Instantly share code, notes, and snippets.

@seclib
Created July 20, 2018 01:58
Show Gist options
  • Save seclib/04e49e1dedde029cb210a9a2232b16b8 to your computer and use it in GitHub Desktop.
Save seclib/04e49e1dedde029cb210a9a2232b16b8 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <pthread.h>
#include <time.h>
/* WolfHound: Wolf Killing Dog
*
* AKA "stop_all_hackers.c
*
* Script created by SIGTERM h2kchicken/notballin)
*
* How to use:
* Ensure that you have multiple terminals open, be they individual windows,
* multiple tabs, or multiplexed via TMUX.
*
* This script has only been tested with "gcc" and "clang" specifically. Other
* compilers have not been tested (t hough testing should be easy as adding
* another Loop and adding the binary name).
*/
#define tput(X, ...) fprintf(stdout, "\x1B[34m" X "\x1B[0m", __VA_ARGS__)
void *
_(void * shell)
{
char cmd[256];
sprintf(cmd, "killall %s -q -v -y 5s >/dev/null 2>&1", (char *)shell);
do {
#pragma unroll
for (int i = 0; i < 60; i++) {
sleep(1);
system(cmd);
}} while(true);
pthread_exit(NULL);
}
int
main(int argc, char ** argv)
{
(void)argc;
(void)argv;
char d[1024];
time_t t = time(NULL);
char * sh;
if (getuid() != 0) {
printf("Not Root.\n");
exit(EXIT_FAILURE);
}
strftime(d, sizeof(d), "%Y-%m-%d", localtime(&t));
tput("Checking Installed Shells : %s\n", d);
setusershell();
while ((sh = getusershell())) {
printf("%s\n", sh);
}
printf("\n");
tput("Forking Loops : %s\n", d);
sleep(5);
pthread_t stop_sh_hacker_hdl;
pthread_t stop_bs_hacker_hdl;
pthread_create(&stop_sh_hacker_hdl, NULL, _, (void *)"sh");
pthread_detach(stop_sh_hacker_hdl);
pthread_create(&stop_bs_hacker_hdl, NULL, _, (void *)"bash");
pthread_detach(stop_bs_hacker_hdl);
tput("Begin tests by opening shells (as both a regular user and a user with root privileges %s\n", d);
/*
* In denying yourself the ability to open new terminals, you deny an
* attacker the ability to open terminals. The terminal that an attacker
* relies on during a hack resides on the user's PC.
*/
/*No Ego, but...
* To the NSA: YOU FUCKING LOSE.
*/
return 0;
} /* main */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment