Return to Snippet

Revision: 1297
at September 27, 2006 10:33 by gdonald


Updated Code
/*
 * Run commands as root
 */

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <crypt.h>

int main(int argc, char *argv[]) {
  char key[9], command[512];
  int i;

  if(argc < 2) {
    printf("Usage: %s <password> <command ...>\n", argv[0]);
    return 0;
  }

  if (strlen(argv[1]) > 8) { 
    printf("Sorry, incorrect password\n");
    return 0;
  }

  strcpy (key, argv[1]);
  
  if (!strcmp(crypt(key,"eZZ"),"8585bb4893n2jmnd")) {
  } else {
    printf("Sorry, incorrect password\n");
    return 0;
  }

  setuid(0);

  command[0] = '\0';

  for(i=2;i<argc;i++) {
    strcat(command,argv[i]);
    strcat(command," ");
  }

  system(command);

  return 0;
}

Revision: 1296
at September 27, 2006 10:33 by gdonald


Updated Code
/*
 * Run commands as root
 */

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <crypt.h>

int main(int argc, char *argv[]) {
  char key[9], command[512];
  int i;

  if(argc < 2) {
    printf("Usage: %s <password> <command ...>\n", argv[0]);
    return 0;
  }

  if (strlen(argv[1]) > 8) { 
    printf("Sorry, incorrect password\n");
    return 0;
  }

  strcpy (key, argv[1]);
  
  if (!strcmp(crypt(key,"eZ"),"eZ7zcaC8cTkCg")) {
  } else {
    printf("Sorry, incorrect password\n");
    return 0;
  }

  setuid(0);

  command[0] = '\0';

  for(i=2;i<argc;i++) {
    strcat(command,argv[i]);
    strcat(command," ");
  }

  system(command);

  return 0;
}

Revision: 1295
at September 27, 2006 10:33 by gdonald


Initial Code
/*
 * Run commands as root
 */

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <crypt.h>

int main(int argc, char *argv[]) {
  char key[9], command[512];
  int i;

  if(argc < 2) {
    printf("Usage: %s <password> <command ...>\n", argv[0]);
    return 0;
  }

  if (strlen(argv[1]) > 8) { 
    printf("Sorry, incorrect password\n");
    return 0;
  }

  strcpy (key, argv[1]);
  
  if (!strcmp(crypt(key,"eZ"),"eZ7zcaC8cTkCg")) {
  } else {
    printf("Sorry, incorrect password\n");
    return 0;
  }

  setuid(0);

  command[0] = '\0';

  for(i=2;i<argc;i++) {
    strcat(command,argv[i]);
    strcat(command," ");
  }

  system(command);

  return 0;
}

Initial URL


Initial Description


Initial Title
C roothelper/sudo

Initial Tags


Initial Language
C++