#if 0shc Version 3.9.6, Generic Shell Script CompilerGNU GPL Version 3 Md Jahidul Hamid <jahidulhamid@yahoo.com>shc -f script.sh#endifstatic char data [] = #define chk1_z 22 #define chk1 ((&data[5])) "\034\211\203\142\103\214\051\304\217\220\357\205\025\146\352\335" "\136\105\040\211\114\220\241\174\342\366\001" #define shll_z 10 #define shll ((&data[28])) "\253\050\334\247\244\217\055\155\100\144\122" #define msg1_z 65 #define msg1 ((&data[39])) "\114\145\330\366\371\063\134\143\014\137\114\173\327\373\213\264" "\011\231\317\340\245\156\301\205\136\240\040\136\340\310\003\005" "\277\105\135\342\015\144\254\054\263\032\063\263\016\350\324\245" "\260\342\040\352\077\104\321\200\140\171\356\373\157\130\116\061" "\131\103\213\264\272\013\126\007\133\062\301\215\226" #define xecc_z 15 #define xecc ((&data[117])) "\301\131\026\020\222\006\000\040\165\057\252\333\006\377\255\325" "\162\156\305" #define lsto_z 1 #define lsto ((&data[134])) "\000" #define text_z 862 #define text ((&data[184])) "\173\177\065\220\220\336\334\033\222\227\047\351\237\203\033\140" "\020\262\275\320\103\177\051\261\104\236\252\214\167\345\026\362" "\144\113\202\364\052\137\020\275\367\070\246\226\273\302\367\313" "\165\314\016\007\303\127\154\254\245\040\142\143\262\062\174\063" "\256\220\345\313\340\223\065\077\006\230\060\367\105\064\017\117" "\303\171\131\164\302\153\104\376\050\070\110\205\027\065\171\243" "\171\215\366\324\373\123\320\107\161\015\277\373\134\360\065\261" "\346\142\046\371\054\353\126\372\176\004\023\032\037\357\321\305" "\224\025\356\273\251\015\102\345\012\025\304\063\150\045\242\115" "\161\271\031\301\174\325\246\341\127\320\041\316\156\035\031\225" "\107\171\154\243\355\342\047\011\151\162\064\076\216\056\253\326" "\227\240\101\276\067\153\303\321\112\060\164\135\366\201\026\070" "\223\167\354\051\377\156\310\361\201\323\354\252\163\206\235\274" "\014\271\127\326\067\234\060\060\300\352\006\301\241\172\264\111" "\276\151\041\272\374\172\025\124\266\041\316\032\353\060\111\064" "\315\155\227\064\316\150\147\017\100\353\107\264\137\012\144\376" "\306\170\375\133\146\170\253\265\347\076\103\253\311\104\204\073" "\324\133\274\321\055\227\154\201\042\077\006\243\276\300\207\304" "\206\246\064\011\012\177\333\047\211\377\174\110\346\147\151\073" "\136\071\026\054\155\250\153\260\121\264\205\301\231\262\167\347" "\375\010\176\361\056\104\262\175\001\317\104\272\036\261\252\151" "\324\034\174\157\257\236\102\106\177\312\232\155\256\202\165\214" "\257\163\355\175\316\055\026\113\246\016\071\320\244\345\342\351" "\041\010\027\332\234\334\312\367\132\221\222\072\066\023\250\361" "\271\236\070\153\122\304\074\304\020\357\321\270\373\156\317\311" "\330\324\073\156\217\127\246\347\354\327\354\043\113\100\051\021" "\300\140\262\342\204\216\113\351\130\377\205\060\353\331\042\044" "\342\334\372\061\011\356\317\202\250\053\200\313\030\374\003\167" "\041\127\320\154\313\156\110\310\071\201\070\363\354\205\167\217" "\303\061\234\077\257\030\267\063\132\042\161\035\032\252\210\360" "\005\271\074\306\147\363\246\051\134\065\261\354\326\132\237\050" "\163\343\353\325\360\123\014\311\353\241\076\214\215\320\347\312" "\071\077\030\206\162\145\163\114\247\032\253\326\373\040\323\102" "\275\035\274\361\346\341\117\030\271\322\145\372\130\244\107\226" "\117\117\052\015\216\252\217\157\260\064\376\364\214\345\204\157" "\075\032\251\171\364\232\025\056\236\072\374\301\167\111\054\144" "\240\326\274\143\212\056\354\126\344\026\122\352\275\124\361\243" "\044\046\160\211\374\366\267\163\250\357\244\170\023\036\257\327" "\211\101\041\140\206\314\212\224\217\122\343\353\017\225\164\322" "\174\040\053\024\043\263\064\215\166\220\242\360\333\061\317\061" "\153\332\375\261\120\074\267\144\032\073\133\342\331\101\024\220" "\173\172\202\142\117\067\265\127\113\073\260\007\052\206\134\170" "\211\000\063\145\352\012\052\353\264\201\022\346\115\002\123\312" "\062\057\335\301\202\377\316\040\026\077\217\207\303\361\322\201" "\260\036\275\052\226\220\143\045\326\377\304\240\177\276\112\335" "\166\031\043\165\066\161\060\323\074\255\144\353\277\157\263\110" "\111\033\165\221\225\030\264\225\352\042\324\123\265\142\365\071" "\204\320\027\263\154\135\022\253\150\053\127\227\206\046\360\324" "\013\150\153\373\347\304\335\027\023\255\365\173\162\235\156\076" "\046\162\343\137\120\376\323\046\034\263\062\104\243\344\026\270" "\272\167\161\371\377\343\324\050\364\335\317\055\240\372\001\141" "\357\145\052\161\157\127\270\104\234\264\246\346\114\143\210\176" "\121\151\250\173\046\272\362\151\327\370\011\376\236\053\060\175" "\017\236\035\330\165\231\116\146\316\162\254\353\171\125\306\207" "\314\230\253\356\244\055\052\327\257\254\252\023\246\062\172\113" "\066\275\231\241\124\136\004\341\117\072\270\301\060\066\117\046" "\240\276\002\265\350\005\212\140\121\273\005\207\212\134\303\265" "\233\270\065\304\152\171\143\024\006\332\371\035\315\136\151\117" "\123\223\256\144\120\246\234\367\075\127\272\064\043\057\352\276" "\347\037\203\121\231\347\146\240\301\137\276\216\276\047\336\021" "\272\215\165\013\063\022\003\160\151\275\245\215\355\220\114\325" "\260\317\047\111\266\215\352\170\355\250\007\253\317\345\274\212" "\162\062\226\246\104\231\026\256\127\273\074\105\114\210\032\374" "\127\101\106\016\316\060\207\274\331\216\147\251\163\044\063\346" "\127\312\214" #define msg2_z 19 #define msg2 ((&data[1163])) "\112\175\163\243\363\276\161\256\231\064\304\040\357\250\111\004" "\103\256\346\037\273\136\207" #define pswd_z 256 #define pswd ((&data[1228])) "\033\247\147\134\355\165\053\036\375\347\367\213\117\240\377\163" "\324\346\312\236\162\146\002\025\261\276\164\070\277\037\110\332" "\307\257\067\264\045\143\322\042\113\312\255\132\143\072\307\322" "\140\325\174\026\070\101\331\063\320\136\144\321\060\361\360\370" "\040\104\112\273\301\100\317\341\143\255\074\306\347\003\231\110" "\330\025\136\020\126\070\104\047\226\251\371\306\233\351\277\273" "\055\011\167\357\112\107\321\255\364\015\164\334\020\015\044\350" "\043\203\371\172\273\076\242\121\350\233\030\203\204\330\077\262" "\341\266\242\053\375\163\331\362\200\116\316\221\133\363\172\177" "\166\163\371\062\262\233\204\232\067\234\036\273\164\135\156\126" "\023\020\202\021\204\134\003\004\252\321\225\006\305\020\205\073" "\204\177\155\066\033\361\320\122\216\356\016\003\114\175\132\140" "\216\334\161\022\071\165\027\343\107\255\351\014\275\157\107\101" "\357\265\167\013\247\110\135\065\067\154\071\203\351\223\344\167" "\160\125\212\251\312\242\214\022\117\166\036\014\346\146\116\325" "\034\306\340\303\017\076\371\107\253\062\313\224\305\257\014\065" "\004\227\337\317\071\153\342\210\342\000\225\310\147\344\236\203" "\252\177\106\272\276\077\001\151\162\314\376\070\173\012\155\200" "\242\115\117\333\271\061\144\233\062\372\144\232\152\255" #define date_z 1 #define date ((&data[1487])) "\263" #define tst2_z 19 #define tst2 ((&data[1492])) "\077\337\033\361\333\207\302\321\334\365\152\023\175\144\322\160" "\066\004\320\032\076\356\016" #define rlax_z 1 #define rlax ((&data[1511])) "\324" #define tst1_z 22 #define tst1 ((&data[1516])) "\070\167\041\160\145\313\020\114\134\161\216\052\077\235\334\320" "\074\252\225\121\211\153\217\254\252\214\053\106" #define chk2_z 19 #define chk2 ((&data[1544])) "\036\310\026\271\025\166\317\212\113\012\033\175\223\015\231\046" "\311\071\122\212\003\225\162\062\303" #define opts_z 1 #define opts ((&data[1565])) "\051" #define inlo_z 3 #define inlo ((&data[1566])) "\171\257\117"/* End of data[] */;#define hide_z 4096#define DEBUGEXEC 0 /* Define as 1 to debug execvp calls */#define TRACEABLE 1 /* Define as 1 to enable ptrace the executable */#define BUSYBOXON 0 /* Define as 1 to enable work with busybox *//* rtc.c */#include <sys/stat.h>#include <sys/types.h>#include <errno.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>/* 'Alleged RC4' */static unsigned char stte[256], indx, jndx, kndx;/* * Reset arc4 stte. */void stte_0(void){ indx = jndx = kndx = 0; do { stte[indx] = indx; } while (++indx);}/* * Set key. Can be used more than once. */void key(void * str, int len){ unsigned char tmp, * ptr = (unsigned char *)str; while (len > 0) { do { tmp = stte[indx]; kndx += tmp; kndx += ptr[(int)indx % len]; stte[indx] = stte[kndx]; stte[kndx] = tmp; } while (++indx); ptr += 256; len -= 256; }}/* * Crypt data. */void arc4(void * str, int len){ unsigned char tmp, * ptr = (unsigned char *)str; while (len > 0) { indx++; tmp = stte[indx]; jndx += tmp; stte[indx] = stte[jndx]; stte[jndx] = tmp; tmp += stte[indx]; *ptr ^= stte[tmp]; ptr++; len--; }}/* End of ARC4 *//* * Key with file invariants. */int key_with_file(char * file){ struct stat statf[1]; struct stat control[1]; if (stat(file, statf) < 0) return -1; /* Turn on stable fields */ memset(control, 0, sizeof(control)); control->st_ino = statf->st_ino; control->st_dev = statf->st_dev; control->st_rdev = statf->st_rdev; control->st_uid = statf->st_uid; control->st_gid = statf->st_gid; control->st_size = statf->st_size; control->st_mtime = statf->st_mtime; control->st_ctime = statf->st_ctime; key(control, sizeof(control)); return 0;}#if DEBUGEXECvoid debugexec(char * sh11, int argc, char ** argv){ int i; fprintf(stderr, "shll=%s\n", sh11 ? sh11 : "<null>"); fprintf(stderr, "argc=%d\n", argc); if (!argv) { fprintf(stderr, "argv=<null>\n"); } else { for (i = 0; i <= argc ; i++) fprintf(stderr, "argv[%d]=%.60s\n", i, argv[i] ? argv[i] : "<null>"); }}#endif /* DEBUGEXEC */void rmarg(char ** argv, char * arg){ for (; argv && *argv && *argv != arg; argv++); for (; argv && *argv; argv++) *argv = argv[1];}void chkenv_end(void);int chkenv(int argc){ char buff[512]; unsigned long mask, m; int l, a, c; char * string; extern char ** environ; mask = (unsigned long)getpid(); stte_0(); ///key(&chkenv, (void*)&chkenv_end - (void*)&chkenv); //**** Эту строку я закомментировал, так как проект не компилировался, без неё код работает key(&data, sizeof(data)); key(&mask, sizeof(mask)); arc4(&mask, sizeof(mask)); sprintf(buff, "x%lx", mask); string = getenv(buff);#if DEBUGEXEC fprintf(stderr, "getenv(%s)=%s\n", buff, string ? string : "<null>");#endif l = strlen(buff); if (!string) { /* 1st */ sprintf(&buff[l], "=%lu %d", mask, argc); putenv(strdup(buff)); return 0; } c = sscanf(string, "%lu %d%c", &m, &a, buff); if (c == 2 && m == mask) { /* 3rd */ rmarg(environ, &string[-l - 1]); return 1 + (argc - a); } return -1;}void chkenv_end(void){}#if !TRACEABLE#define _LINUX_SOURCE_COMPAT#include <sys/ptrace.h>#include <sys/types.h>#include <sys/wait.h>#include <fcntl.h>#include <signal.h>#include <stdio.h>#include <unistd.h>#if !defined(PTRACE_ATTACH) && defined(PT_ATTACH)# define PTRACE_ATTACH PT_ATTACH#endifvoid untraceable(char * argv0){ char proc[80]; int pid, mine; switch(pid = fork()) { case 0: pid = getppid(); /* For problematic SunOS ptrace */#if defined(__FreeBSD__) sprintf(proc, "/proc/%d/mem", (int)pid);#else sprintf(proc, "/proc/%d/as", (int)pid);#endif close(0); mine = !open(proc, O_RDWR|O_EXCL); if (!mine && errno != EBUSY) mine = !ptrace(PTRACE_ATTACH, pid, 0, 0); if (mine) { kill(pid, SIGCONT); } else { perror(argv0); kill(pid, SIGKILL); } _exit(mine); case -1: break; default: if (pid == waitpid(pid, 0, 0)) return; } perror(argv0); _exit(1);}#endif /* !TRACEABLE */char * xsh(int argc, char ** argv){ char * scrpt; int ret, i, j; char ** varg; char * me = argv[0]; if (me == NULL) { me = getenv("_"); } if (me == 0) { fprintf(stderr, "E: neither argv[0] nor $_ works."); exit(1); } ret = chkenv(argc); stte_0(); key(pswd, pswd_z); arc4(msg1, msg1_z); arc4(date, date_z); if (date[0] && (atoll(date)<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; 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); arc4(tst2, tst2_z); key(tst2, tst2_z); arc4(chk2, chk2_z); if ((chk2_z != tst2_z) || memcmp(tst2, chk2, tst2_z)) return tst2; /* Prepend hide_z spaces to script text to hide it. */ scrpt = (char*)malloc(hide_z + text_z); if (!scrpt) return 0; memset(scrpt, (int) ' ', hide_z); memcpy(&scrpt[hide_z], text, text_z); } else { /* Reexecute */ if (*xecc) { scrpt = (char*)malloc(512); if (!scrpt) return 0; sprintf(scrpt, xecc, me); } else { scrpt = me; } } j = 0;#if BUSYBOXON varg[j++] = "busybox"; varg[j++] = "sh";#else varg[j++] = argv[0]; /* My own name at execution */#endif 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 */#if DEBUGEXEC debugexec(shll, j, varg);#endif execvp(shll, varg); return shll;}int main(int argc, char ** argv){ // дата в формате YYYY-MM-DD !!! xsh(argc, argv); return 0;}
#!/bin/bashTODAY=$1YEAR=(`echo $TODAY | awk -F "-" '{print $1;}'`)MONTH=(`echo $TODAY | awk -F "-" '{print $2;}'`)DAY=(`echo $TODAY | awk -F "-" '{print $3;}'`)LAST_YEAR=(`expr $YEAR - 1`)DAY_IN_THIS_YEAR=(`ncal -H $TODAY $YEAR -J | grep -E "[_]{1}[^0-9]{1}[0-9[:space:]]+[_]{1}[^0-9]{1}[0-9]*" -o | grep -E "[0-9]{1,2}" -o | awk '{s=s$1}END{print s;}'`)DAY_IN_LAST_YEAR=(`ncal -H $TODAY $LAST_YEAR -J | grep -E "[_]{1}[^0-9]{1}[0-9[:space:]]+[_]{1}[^0-9]{1}[0-9]*" -o | grep -E "[0-9]{1,2}" -o | awk '{s=s$1}END{print s;}'`)if [[ "$DAY_IN_THIS_YEAR" == "" ]]thenMONTH=12echo $LAST_YEAR" "$MONTH" "$DAY_IN_LAST_YEAR | awk '{printf("%s-%02d-%02d\n",$1,$2,$3);}'elseif [ "$DAY_IN_THIS_YEAR" -gt "$DAY" ]thenMONTH=(`expr $MONTH - 1`)fiecho $YEAR" "$MONTH" "$DAY_IN_THIS_YEAR | awk '{printf("%s-%02d-%02d\n",$1,$2,$3);}'fi