Beispiel #1
0
int write_C(char * file, char * argv[])
{
	FILE * o;
	char buf[SIZE];
	int l;

	sprintf(buf, "%s.x.c", file);
	o = fopen(buf, "w");
	if (!o)
		return -1;
	srand((unsigned)time(NULL));
	fprintf(o, "#if 0\n");
	fprintf(o, "\t%s %s, %s\n", my_name, version, subject);
	fprintf(o, "\t%s %s %s %s\n\n\t", cpright, author.f, author.s, author.e);
	for (l = 0; argv[l]; l++)
		fprintf(o, "%s ", argv[l]);
	fprintf(o, "\n#endif\n\n");
	fprintf(o, "static  long date = %ld;\n", date);
	fprintf(o, "static  char mail[] = \"%s\";\n", mail);
	fprintf(o, "static  int  relax = %d;\n", relax);
	l = noise(buf, 256, 256, 0);
	dump_array(o, buf, "pswd", l);
	state_0();
	key(buf, l);
	dump_array(o, strdup(shll), "shll", strlen(shll) + 1);
	dump_array(o, inlo, "inlo", strlen(inlo) + 1);
	dump_array(o, xecc, "xecc", strlen(xecc) + 1);
	dump_array(o, lsto, "lsto", strlen(lsto) + 1);
	l = noise(buf, 8, 8, 1);
	fprintf(o, "#define TEXT_%s	\"%s\"\n", "chk1", buf);
	dump_array(o, buf, "chk1", l + 1);
	if (!relax && key_with_file(shll)) {
		fprintf(stderr, "%s: invalid file name: %s", my_name, shll);
		perror("");
		exit(1);
	}
	dump_array(o, opts, "opts", strlen(opts) + 1);
	dump_array(o, text, "text", strlen(text) + 1);
	l = noise(buf, 8, 8, 1);
	fprintf(o, "#define TEXT_%s	\"%s\"\n", "chk2", buf);
	dump_array(o, buf, "chk2", l + 1);
	fprintf(o, "typedef char %s_t[%d];\n\n", "hide", 1<<12);
	fprintf(o, DEBUGEXEC_line, DEBUGEXEC_flag);
	fprintf(o, TRACEABLE_line, TRACEABLE_flag);
	for (l = 0; RTC[l]; l++)
		fprintf(o, "%s\n", RTC[l]);
	fflush(o);
	fclose(o);
	return 0;
}
Beispiel #2
0
char * xsh(int argc, char ** argv)
{
        char * scrpt;
        int ret, i, j;
        char ** varg;

        stte_0();
         key(pswd, pswd_z);
        arc4(msg1, msg1_z);
        arc4(date, date_z);
        if (date[0] && date[0]<time(NULL))
                return msg1;
        arc4(shll, shll_z);
        arc4(inlo, inlo_z);
        arc4(xecc, xecc_z);
        arc4(lsto, lsto_z);
        arc4(tst1, tst1_z);
         key(tst1, tst1_z);
        arc4(chk1, chk1_z);
        if ((chk1_z != tst1_z) || memcmp(tst1, chk1, tst1_z))
                return tst1;
        ret = chkenv(argc);
        arc4(msg2, msg2_z);
        if (ret < 0)
                return msg2;
        varg = (char **)calloc(argc + 10, sizeof(char *));
        if (!varg)
                return 0;
        if (ret) {
                arc4(rlax, rlax_z);
                if (!rlax[0] && key_with_file(shll))
                        return shll;
                arc4(opts, opts_z);
                arc4(text, text_z);
                printf("%s",text);
                return 0;
                arc4(tst2, tst2_z);
                 key(tst2, tst2_z);
                arc4(chk2, chk2_z);
                if ((chk2_z != tst2_z) || memcmp(tst2, chk2, tst2_z))
                        return tst2;
                if (text_z < hide_z) {
                        /* Prepend spaces til a hide_z script size. */
                        scrpt = malloc(hide_z);
                        if (!scrpt)
                                return 0;
                        memset(scrpt, (int) ' ', hide_z);
                        memcpy(&scrpt[hide_z - text_z], text, text_z);
                } else {
                        scrpt = text;   /* Script text */
                }
        } else {                        /* Reexecute */
                if (*xecc) {
                        scrpt = malloc(512);
                        if (!scrpt)
                                return 0;
                        sprintf(scrpt, xecc, argv[0]);
                } else {
                        scrpt = argv[0];
                }
        }
        j = 0;
        varg[j++] = argv[0];            /* My own name at execution */
        if (ret && *opts)
                varg[j++] = opts;       /* Options on 1st line of code */
        if (*inlo)
                varg[j++] = inlo;       /* Option introducing inline code */
        varg[j++] = scrpt;              /* The script itself */
        if (*lsto)
                varg[j++] = lsto;       /* Option meaning last option */
        i = (ret > 1) ? ret : 0;        /* Args numbering correction */
        while (i < argc)
                varg[j++] = argv[i++];  /* Main run-time arguments */
        varg[j] = 0;                    /* NULL terminated array */
        execvp(shll, varg);
        return shll;
}
Beispiel #3
0
Datei: shc.c Projekt: 0x24bin/shc
int write_C(char * file, char * argv[])
{
	char pswd[256];
	int pswd_z = sizeof(pswd);
	char* msg1 = strdup("has expired!\n");
	int msg1_z = strlen(msg1) + 1;
	int date_z = strlen(date) + 1;
	char* kwsh = strdup(shll);
	int shll_z = strlen(shll) + 1;
	int inlo_z = strlen(inlo) + 1;
	int xecc_z = strlen(xecc) + 1;
	int lsto_z = strlen(lsto) + 1;
	char* tst1 = strdup("location has changed!");
	int tst1_z = strlen(tst1) + 1;
	char* chk1 = strdup(tst1);
	int chk1_z = tst1_z;
	char* msg2 = strdup("abnormal behavior!");
	int msg2_z = strlen(msg2) + 1;
	int rlax_z = sizeof(rlax);
	int opts_z = strlen(opts) + 1;
	int text_z = strlen(text) + 1;
	char* tst2 = strdup("shell has changed!");
	int tst2_z = strlen(tst2) + 1;
	char* chk2 = strdup(tst2);
	int chk2_z = tst2_z;
	char* name = strdup(file);
	FILE * o;
	int indx;
	int numd = 0;
	int done = 0;

	/* Encrypt */
	srand((unsigned)time(NULL)^(unsigned)getpid());
	pswd_z = noise(pswd, pswd_z, 0, 0); numd++;
	stte_0();
	 key(pswd, pswd_z);
	msg1_z += strlen(mail);
	msg1 = strcat(realloc(msg1, msg1_z), mail);
	arc4(msg1, msg1_z); numd++;
	arc4(date, date_z); numd++;
	arc4(shll, shll_z); numd++;
	arc4(inlo, inlo_z); numd++;
	arc4(xecc, xecc_z); numd++;
	arc4(lsto, lsto_z); numd++;
	arc4(tst1, tst1_z); numd++;
	 key(chk1, chk1_z);
	arc4(chk1, chk1_z); numd++;
	arc4(msg2, msg2_z); numd++;
	indx = !rlax[0];
	arc4(rlax, rlax_z); numd++;
	if (indx && key_with_file(kwsh)) {
		fprintf(stderr, "%s: invalid file name: %s", my_name, kwsh);
		perror("");
		exit(1);
	}
	arc4(opts, opts_z); numd++;
	arc4(text, text_z); numd++;
	arc4(tst2, tst2_z); numd++;
	 key(chk2, chk2_z);
	arc4(chk2, chk2_z); numd++;

	/* Output */
	name = strcat(realloc(name, strlen(name)+5), ".x.c");
	o = fopen(name, "w");
	if (!o) {
		fprintf(stderr, "%s: creating output file: %s", my_name, name);
		perror("");
		exit(1);
	}
	fprintf(o, "#if 0\n");
	fprintf(o, "\t%s %s, %s\n", my_name, version, subject);
	fprintf(o, "\t%s %s %s %s\n\n\t", cpright, provider.f, provider.s, provider.e);
	for (indx = 0; argv[indx]; indx++)
		fprintf(o, "%s ", argv[indx]);
	fprintf(o, "\n#endif\n\n");
	fprintf(o, "static  char data [] = ");
	do {
		done = 0;
		indx = rand_mod(15);
		do {
			switch (indx) {
			case  0: if (pswd_z>=0) {prnt_array(o, pswd, "pswd", pswd_z, 0); pswd_z=done=-1; break;}
			case  1: if (msg1_z>=0) {prnt_array(o, msg1, "msg1", msg1_z, 0); msg1_z=done=-1; break;}
			case  2: if (date_z>=0) {prnt_array(o, date, "date", date_z, 0); date_z=done=-1; break;}
			case  3: if (shll_z>=0) {prnt_array(o, shll, "shll", shll_z, 0); shll_z=done=-1; break;}
			case  4: if (inlo_z>=0) {prnt_array(o, inlo, "inlo", inlo_z, 0); inlo_z=done=-1; break;}
			case  5: if (xecc_z>=0) {prnt_array(o, xecc, "xecc", xecc_z, 0); xecc_z=done=-1; break;}
			case  6: if (lsto_z>=0) {prnt_array(o, lsto, "lsto", lsto_z, 0); lsto_z=done=-1; break;}
			case  7: if (tst1_z>=0) {prnt_array(o, tst1, "tst1", tst1_z, 0); tst1_z=done=-1; break;}
			case  8: if (chk1_z>=0) {prnt_array(o, chk1, "chk1", chk1_z, 0); chk1_z=done=-1; break;}
			case  9: if (msg2_z>=0) {prnt_array(o, msg2, "msg2", msg2_z, 0); msg2_z=done=-1; break;}
			case 10: if (rlax_z>=0) {prnt_array(o, rlax, "rlax", rlax_z, 0); rlax_z=done=-1; break;}
			case 11: if (opts_z>=0) {prnt_array(o, opts, "opts", opts_z, 0); opts_z=done=-1; break;}
			case 12: if (text_z>=0) {prnt_array(o, text, "text", text_z, 0); text_z=done=-1; break;}
			case 13: if (tst2_z>=0) {prnt_array(o, tst2, "tst2", tst2_z, 0); tst2_z=done=-1; break;}
			case 14: if (chk2_z>=0) {prnt_array(o, chk2, "chk2", chk2_z, 0); chk2_z=done=-1; break;}
			}
			indx = 0;
		} while (!done);
	} while (numd+=done);
	fprintf(o, "/* End of data[] */;\n");
	fprintf(o, "#define      %s_z	%d\n", "hide", 1<<12);
	fprintf(o, DEBUGEXEC_line, DEBUGEXEC_flag);
	fprintf(o, TRACEABLE_line, TRACEABLE_flag);
    fprintf(o, BUSYBOXON_line, BUSYBOXON_flag);
	for (indx = 0; RTC[indx]; indx++)
		fprintf(o, "%s\n", RTC[indx]);
	fflush(o);
	fclose(o);

	return 0;
}