Advertisement
Guest User

source

a guest
May 15th, 2019
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <string.h>
  5.  
  6. int active = 1;
  7. char name[200];
  8. char * secret = "The Secret is No Longer Here. Get Shell!";
  9.  
  10. void print_warning() {
  11.     puts("=======================================================================================");
  12.     puts("This Kaizen-86 Artificial Intelligence would like to remind you that this is not a toy.");
  13.     puts("Please treat this terminal with the utmost care.");
  14.     puts("Crashing this program will result in ship malfunction.");
  15.     puts("You have been warned.");
  16.     puts("=======================================================================================\n");
  17. }
  18.  
  19. void print_prompt() {
  20.     printf("Options for ");
  21.     puts(name);
  22.     puts("1. Peek Memory Address");
  23.     puts("2. Change Name");
  24.     puts("3. Overwite Memory Address");
  25.     puts("9. Exit Terminal");
  26. }
  27.  
  28. void peek_prompt() {
  29.     int * address;
  30.     printf("Address: ");
  31.     scanf("%p", &address);
  32.     printf("Contents: 0x%x\n", *address);
  33. }
  34.  
  35. void change_name() {
  36.     char buffer[100];
  37.     printf("Name: ");
  38.     read(0, buffer, sizeof(name));
  39.     buffer[strcspn(buffer, "\n")] = 0;
  40.     strncpy(name, buffer, sizeof(name));
  41. }
  42.  
  43. void poke_prompt() {
  44.     int * address;
  45.     int data;
  46.     printf("Address: ");
  47.     scanf("%p", &address);
  48.     printf("Data: ");
  49.     scanf("%x", &data);
  50.     *address = data;
  51. }
  52.  
  53. void print_secret() {
  54.     if (getpid() == 0) {
  55.         puts("secret");
  56.     }
  57. }
  58.  
  59. int main() {
  60.     setvbuf(stdin, NULL, _IONBF, 0);
  61.     setvbuf(stdout, NULL, _IONBF, 0);
  62.  
  63.     int option;
  64.     print_warning();
  65.     change_name();
  66.     while (active) {
  67.         print_prompt();
  68.         printf("Option: ");
  69.         scanf("%d", &option);
  70.         if (option == 9) {
  71.             active = 0;
  72.             puts("Goodbye.");
  73.         }
  74.         else if (option == 1) {
  75.             peek_prompt();
  76.         }
  77.         else if (option == 2) {
  78.             change_name();
  79.         }
  80.         else if (option == 3) {
  81.             poke_prompt();
  82.         }
  83.         else if (option == 4) {
  84.             print_secret();
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement