//can we get the current direcory or even change it? so a more proper prompt //can shellshock be a full bash replacement? //what about pipe mechanism mentioned here: /* When the child process calls exec(), all data in the original program is lost, and replaced with a running copy of the new program. This is known as overlaying. Although all data is replaced, the file descriptors that were open in the parent are closed only if the program has explicitly marked them close-on-exec. This allows for the common practice of the parent creating a pipe prior to calling fork() and using it to communicate with the executed program. */ /* What is this btw: Files open when an exec call is made remain open in the new process. All open files must be flushed before an exec call. The exec calls do not preserve the translation modes of open files. If the new process image uses previously opened files, setmode function can be called to set the translation mode to the desired mode. //////////////////////////////////// by REZA GHALAVAND; //////////////////////////////////// */ #include #include #include // errno #include // exit() #include // _exit(), fork(), exec(), sleep(), usleep() #include // pid_t #include // wait() #define VER 0.001 #define CODE "Unbourne!" #define ARG_COUNT 51 #define ARG_LEN 257 #define EXIT 0 #define INTERNAL 1 #define EXTERNAL 2 #define SYNTAX_ERR 3 using namespace std; void show_prompt(){ cout<<"\nShellShock!>"; } bool dist_command(char *argv[ARG_COUNT], int& command_t){ if (argv[0] == NULL) return false; if ((!strcmp ("exit", argv[0])) && (argv[1] == NULL)) command_t = EXIT; else if ((!strcmp ("help", argv[0])) && (argv[1] == NULL)) command_t = INTERNAL; else command_t = EXTERNAL; return true; } bool read_command(char *argv[ARG_COUNT]){ char input[ARG_COUNT * (ARG_LEN - 1) + 1]; cin.getline(input, (ARG_COUNT * (ARG_LEN - 1)) + 1, '\n'); long input_len = (((long)cin.gcount()) - 1); int i = 0, j = 0, k = 0; while (i < input_len){ if (input[i] == '\"'){ for (i++, j = 0; (i < input_len) && (j < ARG_LEN) && (input[i] != '\"'); i++, j++) argv[k][j] = input[i]; if (((i == input_len) || (j == ARG_LEN))&& input[i-1] != '\"') return false; argv[k][j] = NULL; i++; k++; } else if (input[i] != '\t' && input[i] != ' '){ for (j = 0; (i < input_len) && (j < ARG_LEN) && (input[i] != ' ') && (input[i] != '\t'); i++, j++){ if (input[i] == '\"') return false; argv[k][j] = input[i]; } argv[k][j] = NULL; k++; } for ( ; (i < input_len) && ((input[i] == ' ') || (input[i] == '\t')); i++); } argv[k] = NULL; return true; } void handle_int(char *argv[ARG_COUNT]){ char *message="\nLook my friend, Among all types & kinds of computer programs, we Shells are the most powerful & the most flexible! That's why you should never trust a good looking EVIL shell like me! You dare pressing any single key & I will reformat & erase all your Data!!!\n Ha Ha Ha... - ShellShock a.k.a the ForkVirus. \n"; for (int i = 0; message[i] != NULL; i++){ cout< 0) wait(NULL); else cerr << "Can not create a new process!\tfork() Error Code:"<