Skip to content

Instantly share code, notes, and snippets.

@potetisensei
Created May 19, 2014 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save potetisensei/4c74cbaa274b1ba3aa25 to your computer and use it in GitHub Desktop.
Save potetisensei/4c74cbaa274b1ba3aa25 to your computer and use it in GitHub Desktop.
shitsco incomplete
int global_permission; /* global_permission */
int sub_8048C30(int fd, char *buf, int size, char splitter) {
char tmp_buf[]; /* var_1D */
unsigned int ind = 0; /* register ebx */
if (size <= 0) return ind;
while (1) {
if (read(fd, tmp_buf, 1) <= 0) return -1;
if (splitter == tmp_buf[0]) return ind;
buf[ind] = tmp_buf[0];
++ind;
if (ind == size) return ind;
}
}
sub_8048A50(char *input) {
ebx = off_804C260;
ebp = ebx;
int ret = 0;
char **arg_list = NULL;
unsigned int pos = 0; /*register esi*/
char *tmp; /* register edi */
while (1) {
if (strncmp(input, ebx, strlen(ebx)) == 0) {
if ( ((int*) input)[0] ) tmp = input;
while (tmp[0] == ' ') ++tmp;
if (tmp[0] != '\0') {
char *tmp2; /* register eax */
tmp2 = &tmp[1];
while (1) {
if (tmp2[0] == '\0') {
tmp = tmp2;
break;
} else if (eax[0] == ' ') {
tmp = tmp2+1;
tmp2[0] = '\0';
break;
} else {
tmp = tmp2+1;
tmp2 = tmp;
}
}
}
char* tmp3 = tmp; /* register ebx */
var_28 = ebp[0xc];
arg_list = (char**)malloc(var_28*4+4);
if (pos < var_28) {
tmp = arg_list;
while (1) {
char *tmp2 = tmp3; /* register eax */
while (tmp2[0] == ' ') tmp2++;
if (tmp2[0] != '\0') {
char *tmp5 = &tmp2[1]; /* register edx */
while (1) {
if (tmp5[0] == '\0') {
tmp3 = tmp5
} else if (tmp5[0] == '\0') {
tmp5[0] = '\0';
tmp3 = &tmp5[1];
break;
}
}
if (tmp2) {
tmp[pos] = strdup(tmp2);
pos++;
if (ebp[0xC] > pos) {
continue;
} else {
tmp = tmp3;
arg_list[pos][0] == '\0';
if (ebp[0x8] <= global_permission) {
ebp[0x10](arg_list);
ret = 1;
break;
} else {
return 0;
}
}
} else {
tmp = tmp3;
arg_list[pos][0] = '\0';
if (ebp[0x8] <= global_permission) {
ebp[0x10](arg_list);
ret = 1;
break;
} else {
return 0;
}
}
} else {
tmp = tmp2;
arg_list[pos][0] = '\0';
if (ebp[0x8] <= global_permission) {
ebp[0x10](arg_list);
ret = 1;
break;
} else {
return 0;
}
}
}
} else {
arg_list[pos][0] = '\0';
if (ebp[0x8] >= global_permission) {
ebp[0x10](arg_list);
ret = 1;
} else {
return 0;
}
}
}
ebp += 0x14;
ebx = ebp[0];
if (ebp[0] == 0) break;
}
if (arg_list) {
free(arg_list);
}
return ret;
}
int main() { /* sub_80487E0 */
char var1c[] =
byte_804C380 = 0x24;
byte_804C3C0 = 0;
sub_80489D0();
puts(" oooooooo8 oooo o88 o8 \n888 888ooooo oooo o888oo oooooooo8 ooooooo ooooooo \n 888oooooo 888 888 888 888 888ooooooo 888 888 888 888 \n 888 888 888 888 888 888 888 888 888 \no88oooo888 o888o o888o o888o 888o 88oooooo88 88ooo888 88ooo88");
___printf_chk(FILENO_STDOUT, "Welcome to Shitsco Internet Operating System (IOS)\nFor a command list, enter ?\n%c ", 0x24);
fflush(stdout);
while (1) {
memset(var1c, '\0', 0x14);
if (sub_8048C30(FILE_STDIN, var1c, 0x50, '\n') == -1) return 0; /* stack canary enabled*/
if (sub_8048A50(var1c) == 0) {
___printf_chk(FILENO_STDOUT, "\n%s: Invalid command\n%c ", var1c,
0x24? 0x23);
} else {
___printf_chk(FILENO_STDOUT, "%c ", 0x24?0x23);
}
fflush(stdout);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment