Порылся и вот чего нашел
hhvm работает налету.
phc - преобразовывает в xml
Везде пишут, что в код c# нельзя пока преобразовать.
Ну а бинарник получить как-том можно из кода php?
P.S.
Даже скрипт на bash можно преобразовать в с#, а потом скомпилировать c помощью shc.
Кстати, кому интересно:
Hello World на bash
1. dcc0 - 25 Апреля, 2015 - 16:13:53 - перейти к сообщению
Преобразуем в c#
shc -r -T -f hello.sh
Спойлер (Отобразить)
CODE (htmlphp):
скопировать код в буфер обмена
скопировать код в буфер обмена
- #if 0
- shc Version 3.8.9, Generic Script Compiler
- Copyright (c) 1994-2012 Francisco Rosales <frosal@fi.upm.es>
- shc -r -T -f hello.sh
- #endif
- static char data [] =
- #define opts_z 1
- #define opts ((&data[0]))
- "\154"
- #define pswd_z 256
- #define pswd ((&data[14]))
- "\017\024\326\230\343\376\347\302\301\325\160\302\363\046\153\324"
- "\027\231\045\261\064\200\220\011\106\273\150\232\255\013\317\026"
- "\031\304\356\025\156\074\360\224\135\157\117\037\225\273\364\255"
- "\125\032\136\211\232\357\223\341\252\373\173\130\006\113\156\040"
- "\017\135\066\175\231\047\022\366\226\142\026\054\036\012\331\163"
- "\044\067\374\276\046\217\240\321\212\033\051\221\147\230\262\167"
- "\365\350\365\216\020\007\205\247\152\233\323\210\245\254\374\312"
- "\344\370\211\013\210\051\334\023\105\006\244\254\236\127\044\223"
- "\100\031\042\120\041\247\367\213\102\312\024\350\167\020\262\133"
- "\011\074\147\221\145\103\244\252\111\111\127\350\240\173\173\340"
- "\225\236\061\266\105\050\102\210\363\126\161\152\147\044\306\160"
- "\140\056\002\306\162\246\160\273\360\310\244\220\104\037\161\331"
- "\275\242\217\003\313\321\214\276\050\376\051\217\042\360\000\203"
- "\036\002\111\220\251\272\114\231\202\360\051\306\020\233\237\316"
- "\075\056\322\010\000\136\307\050\134\361\270\177\341\270\002\000"
- "\273\113\221\144\005\335\376\210\316\050\116\337\303\356\256\000"
- "\035\200\011\035\337\321\106\074\302\376\273\244\267\361\314\021"
- "\320\236\127\014\140\126\310\005\016\206\252\201\220\341\131\237"
- "\365\060\070\331\056\037\234\360\365\015\262\351\376\177\372\316"
- "\035\121\333\176\250\243\203\266\051\056\070\271\020\222\131\006"
- "\302\222\337"
- #define chk2_z 19
- #define chk2 ((&data[327]))
- "\341\247\210\210\272\005\302\151\024\101\032\070\061\227\213\362"
- "\373\372\070\225\061\221\224\220"
- #define tst1_z 22
- #define tst1 ((&data[348]))
- "\376\073\342\260\067\007\333\312\062\106\257\073\041\014\025\115"
- "\140\154\320\166\243\320\126\060\334"
- #define date_z 1
- #define date ((&data[373]))
- "\370"
- #define text_z 33
- #define text ((&data[375]))
- "\376\274\241\040\102\070\177\141\341\051\224\263\101\045\235\247"
- "\244\364\065\353\032\263\330\253\372\251\247\060\355\234\006\326"
- "\112\072\141\163"
- #define rlax_z 1
- #define rlax ((&data[410]))
- "\343"
- #define msg1_z 42
- #define msg1 ((&data[416]))
- "\244\127\271\126\323\323\136\144\310\340\143\204\375\267\030\225"
- "\257\037\134\066\056\152\210\132\002\054\113\066\057\270\075\336"
- "\264\213\064\206\374\266\243\333\323\256\276\235\140\005\133\232"
- "\375\134\056\216\343\101\031"
- #define shll_z 10
- #define shll ((&data[467]))
- "\153\012\212\161\016\175\375\236\375\110\207\041\172"
- #define inlo_z 3
- #define inlo ((&data[479]))
- "\227\247\263"
- #define xecc_z 15
- #define xecc ((&data[484]))
- "\367\047\302\124\035\163\140\040\044\255\175\027\204\037\316\221"
- "\232"
- #define lsto_z 1
- #define lsto ((&data[499]))
- "\146"
- #define chk1_z 22
- #define chk1 ((&data[504]))
- "\257\005\312\112\234\146\217\033\230\255\050\374\120\031\250\216"
- "\151\234\204\061\170\070\242\057\076\166\003\046\170\221\012"
- #define tst2_z 19
- #define tst2 ((&data[534]))
- "\054\237\256\000\214\015\155\236\036\106\323\276\223\146\121\303"
- "\231\102\273\270\215\220\115"
- #define msg2_z 19
- #define msg2 ((&data[558]))
- "\317\055\127\370\355\036\301\145\306\256\257\266\102\272\325\225"
- "\330\045\157\075\071\207\335\045\176\047"/* 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 */
- /* 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 DEBUGEXEC
- void 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];
- }
- int chkenv(int argc)
- {
- char buff[512];
- unsigned long mask, m;
- int l, a, c;
- char * string;
- extern char ** environ;
- mask = (unsigned long)&chkenv;
- mask ^= (unsigned long)getpid() * ~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;
- }
- #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
- #endif
- void 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 = getenv("_");
- if (me == NULL) { me = argv[0]; }
- 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;
- 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);
- 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 = 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 = malloc(512);
- if (!scrpt)
- return 0;
- sprintf(scrpt, xecc, me);
- } else {
- scrpt = me;
- }
- }
- 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 */
- #if DEBUGEXEC
- debugexec(shll, j, varg);
- #endif
- execvp(shll, varg);
- return shll;
- }
- int main(int argc, char ** argv)
- {
- #if DEBUGEXEC
- debugexec("main", argc, argv);
- #endif
- #if !TRACEABLE
- untraceable(argv[0]);
- #endif
- argv[1] = xsh(argc, argv);
- fprintf(stderr, "%s%s%s: %s\n", argv[0],
- errno ? ": " : "",
- errno ? strerror(errno) : "",
- argv[1] ? argv[1] : "<null>"
- );
- return 1;
- }