mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-10 21:32:20 +08:00
552 lines
20 KiB
C
552 lines
20 KiB
C
#if 0
|
|
shc Version 3.9.6, Generic Shell Script Compiler
|
|
GNU GPL Version 3 Md Jahidul Hamid <jahidulhamid@yahoo.com>
|
|
|
|
shc -f sender-d.sh
|
|
#endif
|
|
|
|
static char data [] =
|
|
#define rlax_z 1
|
|
#define rlax ((&data[0]))
|
|
"\063"
|
|
#define tst1_z 22
|
|
#define tst1 ((&data[4]))
|
|
"\361\021\166\247\054\162\052\130\306\260\015\342\206\111\251\225"
|
|
"\014\257\133\377\311\127\030\125\000\302\054\054\113\243"
|
|
#define text_z 1976
|
|
#define text ((&data[444]))
|
|
"\371\056\127\353\324\272\303\246\127\103\073\027\017\312\311\013"
|
|
"\011\120\251\004\101\273\172\004\347\246\120\212\167\046\371\161"
|
|
"\124\121\134\051\014\037\320\143\142\013\173\161\326\104\175\337"
|
|
"\224\047\343\326\342\135\332\311\004\052\124\173\120\116\354\245"
|
|
"\237\111\316\254\150\236\017\313\252\212\075\200\317\273\137\144"
|
|
"\342\103\072\304\240\025\216\245\077\343\041\220\061\015\065\321"
|
|
"\126\004\176\277\243\215\212\115\030\310\315\350\203\055\114\145"
|
|
"\160\207\052\021\234\270\267\334\234\330\154\315\346\242\237\075"
|
|
"\246\035\374\112\253\207\227\304\117\145\254\322\223\370\070\004"
|
|
"\200\142\026\034\033\315\370\267\245\145\205\213\007\045\310\256"
|
|
"\103\304\370\356\114\220\263\234\366\137\156\211\130\247\216\330"
|
|
"\012\244\364\045\161\355\335\027\122\143\242\131\210\152\010\313"
|
|
"\057\000\272\173\221\155\030\207\314\206\021\045\056\237\376\070"
|
|
"\104\363\136\266\340\073\315\062\236\157\214\047\332\224\362\011"
|
|
"\225\254\205\047\032\235\256\347\044\300\014\123\140\012\213\245"
|
|
"\375\351\133\336\045\050\021\304\227\235\353\162\062\336\173\310"
|
|
"\213\001\357\245\237\236\215\303\137\231\026\300\244\242\145\242"
|
|
"\214\300\200\262\350\222\166\200\060\142\363\142\101\156\053\314"
|
|
"\160\033\162\017\272\377\323\031\231\351\331\076\214\077\340\030"
|
|
"\377\141\312\350\364\101\151\044\244\134\206\345\313\262\261\073"
|
|
"\315\044\112\210\043\036\242\275\007\173\373\224\272\334\254\272"
|
|
"\076\167\242\062\270\013\126\134\150\335\102\063\217\364\156\135"
|
|
"\030\271\345\074\327\210\371\337\004\364\163\276\320\037\171\016"
|
|
"\227\034\101\120\047\227\254\217\164\357\303\004\343\061\141\373"
|
|
"\352\107\067\302\317\060\241\323\045\024\222\365\064\014\004\314"
|
|
"\050\105\034\120\335\311\340\121\270\243\126\233\324\122\357\013"
|
|
"\070\017\057\033\361\302\125\023\157\131\212\025\047\257\370\016"
|
|
"\010\366\143\065\131\176\051\066\270\360\232\062\302\250\250\177"
|
|
"\136\117\242\120\250\347\324\357\214\270\132\335\126\136\050\114"
|
|
"\222\114\360\150\163\035\211\116\174\332\227\153\326\016\366\366"
|
|
"\072\123\302\126\122\137\270\200\001\155\105\331\354\075\055\326"
|
|
"\220\047\224\036\275\257\275\117\123\205\136\141\102\024\270\310"
|
|
"\107\134\354\353\353\042\127\124\122\074\302\346\005\014\334\232"
|
|
"\152\144\130\275\141\331\214\251\153\141\043\352\112\002\315\206"
|
|
"\340\315\070\004\346\240\255\002\135\342\156\334\237\163\250\267"
|
|
"\175\120\003\240\051\367\113\007\247\061\171\233\300\274\140\152"
|
|
"\235\043\211\064\154\113\027\106\256\110\210\265\050\347\221\121"
|
|
"\267\310\161\074\356\126\221\004\312\253\305\025\012\251\360\062"
|
|
"\056\043\144\341\034\005\004\273\234\305\201\126\233\320\266\073"
|
|
"\024\033\223\126\012\311\022\322\312\341\043\070\146\153\137\307"
|
|
"\046\174\220\116\101\360\320\213\035\140\366\275\075\140\157\153"
|
|
"\073\246\030\245\010\061\134\031\012\325\245\332\235\150\054\253"
|
|
"\342\052\334\033\222\303\163\311\046\251\332\170\177\037\020\355"
|
|
"\246\311\236\003\146\043\116\234\127\061\176\166\001\162\066\167"
|
|
"\015\056\045\316\155\276\113\011\010\343\044\363\001\004\030\370"
|
|
"\303\000\137\326\235\356\336\026\132\246\200\264\155\326\201\215"
|
|
"\016\275\072\353\002\315\252\115\353\335\007\001\244\370\112\212"
|
|
"\130\115\005\264\250\162\010\130\042\145\272\020\337\002\303\143"
|
|
"\064\136\343\301\174\020\243\346\321\233\146\316\263\110\222\371"
|
|
"\173\324\003\323\254\354\004\134\367\077\346\160\061\013\030\273"
|
|
"\025\071\021\050\235\317\024\323\161\371\220\137\042\356\235\322"
|
|
"\174\334\201\125\241\221\376\232\271\015\175\043\007\212\335\314"
|
|
"\073\141\100\134\277\332\242\010\162\261\021\203\244\061\026\210"
|
|
"\360\045\322\151\304\270\114\051\125\060\362\265\005\300\134\176"
|
|
"\132\040\215\273\264\074\312\021\141\307\236\372\376\163\037\353"
|
|
"\103\114\213\176\350\207\272\236\112\311\030\075\165\221\006\007"
|
|
"\104\135\121\024\270\210\031\160\205\317\344\253\016\016\124\007"
|
|
"\025\317\220\045\070\323\354\205\017\023\063\020\041\323\236\317"
|
|
"\133\063\271\022\224\223\147\242\104\177\276\312\000\003\267\203"
|
|
"\361\033\051\371\035\001\051\117\304\105\007\011\115\242\160\145"
|
|
"\036\216\162\273\025\206\107\240\254\103\314\364\221\346\316\177"
|
|
"\107\262\376\226\114\203\167\055\077\356\170\243\016\010\140\301"
|
|
"\135\330\346\136\037\301\177\120\042\063\206\067\155\354\036\036"
|
|
"\072\065\346\274\130\205\372\263\062\342\275\133\124\271\311\061"
|
|
"\074\005\056\226\126\221\056\303\113\370\216\313\062\011\205\001"
|
|
"\212\170\377\316\345\026\014\067\065\214\071\257\046\204\226\341"
|
|
"\343\344\100\253\112\123\307\334\170\303\334\170\070\170\130\216"
|
|
"\224\350\020\336\230\141\067\272\233\016\035\255\206\345\101\152"
|
|
"\233\360\260\342\101\047\335\155\334\311\257\304\226\137\001\112"
|
|
"\071\367\057\253\342\034\230\201\077\103\207\123\142\364\264\370"
|
|
"\223\212\164\034\031\051\045\127\315\270\323\322\133\006\247\265"
|
|
"\366\244\012\222\175\272\273\307\144\044\066\261\124\112\270\322"
|
|
"\001\247\234\225\324\000\007\330\033\121\236\233\367\013\233\303"
|
|
"\311\200\315\010\104\326\274\004\257\233\267\152\367\214\367\032"
|
|
"\021\230\307\240\350\164\045\374\345\345\374\045\322\173\333\054"
|
|
"\005\204\271\171\313\020\064\031\375\006\352\275\324\301\312\114"
|
|
"\120\265\001\124\371\161\043\071\271\231\136\270\344\143\315\361"
|
|
"\072\032\246\303\242\074\250\203\153\014\320\315\361\175\251\036"
|
|
"\277\304\162\115\132\363\362\100\255\322\241\015\120\065\102\363"
|
|
"\024\367\330\317\210\342\155\055\320\211\337\000\052\310\345\203"
|
|
"\030\345\265\352\343\132\015\367\120\273\362\216\123\047\367\377"
|
|
"\130\156\215\051\154\255\045\216\115\116\310\264\331\134\122\132"
|
|
"\177\130\266\246\346\307\226\067\014\071\076\023\266\226\205\127"
|
|
"\027\005\334\124\302\045\263\330\276\001\264\021\000\306\112\207"
|
|
"\077\217\057\104\303\055\362\154\334\334\376\064\275\232\337\265"
|
|
"\253\122\270\335\274\332\326\333\176\063\321\276\041\366\001\341"
|
|
"\361\004\263\273\361\054\251\006\330\312\171\056\016\015\265\140"
|
|
"\173\332\351\334\001\327\024\204\304\345\034\103\371\133\140\171"
|
|
"\074\002\111\001\357\070\252\311\003\200\064\124\151\051\342\203"
|
|
"\144\027\000\265\046\302\105\206\132\235\061\130\313\037\206\337"
|
|
"\354\166\300\062\161\027\051\135\277\216\143\230\106\120\063\147"
|
|
"\253\362\275\307\302\321\255\075\370\152\164\302\341\114\037\043"
|
|
"\227\223\140\377\264\071\127\372\324\320\116\104\332\224\200\304"
|
|
"\131\304\007\226\074\331\073\246\154\300\175\313\226\014\132\362"
|
|
"\357\101\356\334\024\016\346\130\216\004\226\040\221\165\244\223"
|
|
"\015\071\034\323\226\166\244\031\376\254\364\246\104\165\223\062"
|
|
"\045\245\144\253\154\356\016\266\264\005\005\227\012\110\050\017"
|
|
"\366\262\144\171\055\104\200\175\234\235\061\067\043\300\105\110"
|
|
"\037\100\220\232\123\236\125\274\047\010\331\300\206\052\335\012"
|
|
"\316\262\014\103\256\171\333\132\042\023\325\250\131\221\362\203"
|
|
"\324\054\333\020\307\153\031\340\155\313\174\036\023\202\017\142"
|
|
"\303\204\115\055\057\106\104\157\152\310\061\256\174\101\036\176"
|
|
"\324\007\062\216\152\120\276\334\260\124\126\200\274\046\273\141"
|
|
"\311\307\037\330\307\134\261\270\306\076\272\203\022\310\252\365"
|
|
"\313\330\110\056\045\027\350\130\301\123\351\023\325\250\322\375"
|
|
"\244\363\314\276\050\223\174\215\161\171\357\271\007\052\065\102"
|
|
"\062\151\205\164\272\201\162\352\221\337\316\235\353\124\031\041"
|
|
"\037\115\204\207\051\234\263\354\171\203\152\144\271\240\362\143"
|
|
"\121\013\327\010\167\244\123\300\022\235\233\037\240\143\273\261"
|
|
"\325\061\137\316\357\072\367\331\267\114\102\264\215\134\272\160"
|
|
"\241\022\353\166\141\023\052\004\110\260\165\251\236\072\256\362"
|
|
"\344\312\344\170\125\230\056\237\220\251\005\336\255\060\211\105"
|
|
"\026\200\072\116\104\074\370\300\242\041\125\056\273\356\173\340"
|
|
"\146\350\357\152\330\105\045\362\174\342\202\371\047\115\356\241"
|
|
"\233\122\325\366\346\137\132\173\166\246\120\131\171\237\031\147"
|
|
"\362\304\065\304\040\356\303\146\353\056\322\355\246\155\336\225"
|
|
"\135\335\344\212\171\010\254\210\002\046\004\012\015\037\270\216"
|
|
"\110\161\212\203\164\273\322\176\207\205\166\361\157\113\172\261"
|
|
"\304\230\024\113\117\212\360\310\243\254\104\307\001\173\013\253"
|
|
"\206\317\037\060\354\223\356\300\146\161\052\100\234\300\175\230"
|
|
"\224\002\056\217\233\126\045\337\314\111\231\230\074\054\360\146"
|
|
"\144\341\142\320\023\244\022\307\360\213\023\310\213\101\023\216"
|
|
"\275\056\245\130\375\320\213\176\177\377\251\222\132\166\312\103"
|
|
"\117\072\242\152\275\256\033\204\210\126\026\055\343\104\167\362"
|
|
"\165\132\173\106\245\247\263\000\205\117\353\217\371\307\214\222"
|
|
"\111\260\301\006\074\356\025\016\152\172\350\227\372\172\055\043"
|
|
"\007\344\200\325\221\102\227\237\315\367\045\352\220\015\224\355"
|
|
"\324\303\142\040\227\107\130\264\334\252\076\144\053\224\100\244"
|
|
"\345\321\074\170\271\317\040\100\152\031\233\201\103\363\015\207"
|
|
"\232\131\054\124\052\272\350\341\212\116\254\322\307\316\002\165"
|
|
"\362\146\015\121\352\343\335\266\273\362\020\030\035\243\064\132"
|
|
"\110\327\003\144\000\167\333\323\272\362\144\127\236\147\057\073"
|
|
"\061\355\072\123\242\330\300\031\245\107\143\345\142\210\162\020"
|
|
"\244\237\025\222\265\335\034\066\150\344\000\077\143\145\204\134"
|
|
"\066\112\166\256\030\245\250\145\374\211\240\105\316\075\005\271"
|
|
"\221\112\303\272\352\060\133\306\245\102\164\350\007\355\170\233"
|
|
"\015\157\306\151\156\064\376\120\377\161\263\161\214\132\114\005"
|
|
"\325\105\215\333\163\073\023\313\314\203\035\132\153\375\263\042"
|
|
"\265\053\016\335\163\003\075\322\006\176\213\156\234\043\024\377"
|
|
"\103\102\035\173\057\061\152\015\327\037\250\054\334\303\243\057"
|
|
"\240\112\002\053\266\146\135\257\347\131\000\013\264\117\235\313"
|
|
"\351\103\357\361\243\273\161\001\127\032\322\215\377\366\164\340"
|
|
"\137\310\110\217\242\260\165\347\340\141\241\034\352\217\105\130"
|
|
"\003\015\341\101\173\142\326\142\075\132\315\302\033\106\164\261"
|
|
"\212\177\221\240\344\302\137\142\326\115\221\250\052\202\103\057"
|
|
"\177\352\147\060\244\376\316\130\127\163\076\173\146\302\041\232"
|
|
"\350\020\266\311\033\271\157\177\121\043\005\062\312\263\262\060"
|
|
"\075\063\047\023\221\361\020\337\050\042\132\072\247\334\211\176"
|
|
"\127\050\002\075\374\357\362\114\042\246\244\111\110\017\264\215"
|
|
"\002\236\114\127\232\267\226\277\377\316\201\317\376\043\243\044"
|
|
"\070\066\031\155\103\036\071\153\144\125\274\101\036\234\223\327"
|
|
"\077\351\162\024\241\011\324\241\327\126\161\326\171\025\372\262"
|
|
"\114\024\037\217\063\131\373\227\256\267\331\315\123\155\244\223"
|
|
"\127\027\247\371\040\173\232\370\321\014\316\113\041\311\375\155"
|
|
"\335\035\375\020\166\370\250\045\257\202\362\003\360\227\226\107"
|
|
"\256\075\100\317\271\333\307\213\347\226\327\011\137\325\167\075"
|
|
"\362\164\115\150\154\366\215\034\170\200\037\151\027\266\260\306"
|
|
"\363\360\226\255\314\136\071\263\364\020\275\124\345\064\221\327"
|
|
"\250\337\100\025\326\315\062\117\115\122\270\145\010\150\054\374"
|
|
"\131\302\251\045\041\343\331\026\363\226\152\331\313\374\261\164"
|
|
"\334\361\211\262\277\274\001\015\016\272\163\026\042\237\022\174"
|
|
"\142\274\242\203\237\173\231\223\022\004\155\336\000\036\122\335"
|
|
"\020\334\217\317\230\221\335\247\113\120\275\156"
|
|
#define chk2_z 19
|
|
#define chk2 ((&data[2639]))
|
|
"\122\215\215\326\254\156\367\131\245\150\023\100\222\145\033\255"
|
|
"\221\065\047\012\113\366\232\054\011\157\300"
|
|
#define msg1_z 65
|
|
#define msg1 ((&data[2669]))
|
|
"\372\165\113\114\122\134\050\147\272\275\200\201\317\154\106\232"
|
|
"\347\373\057\320\014\123\274\261\222\205\223\033\263\362\155\320"
|
|
"\157\217\077\166\061\374\373\334\033\035\312\163\330\110\036\276"
|
|
"\065\375\137\264\267\307\216\263\362\023\157\214\324\042\252\153"
|
|
"\072\341\103\047\276\003\317\212\342\054\301"
|
|
#define lsto_z 1
|
|
#define lsto ((&data[2737]))
|
|
"\166"
|
|
#define opts_z 1
|
|
#define opts ((&data[2738]))
|
|
"\126"
|
|
#define date_z 1
|
|
#define date ((&data[2739]))
|
|
"\006"
|
|
#define shll_z 10
|
|
#define shll ((&data[2741]))
|
|
"\245\120\032\327\074\336\117\215\105\162\100\162"
|
|
#define tst2_z 19
|
|
#define tst2 ((&data[2755]))
|
|
"\161\312\126\130\156\376\051\126\202\366\153\372\216\321\052\312"
|
|
"\061\263\236\122\364\211\237\304\313\353"
|
|
#define inlo_z 3
|
|
#define inlo ((&data[2778]))
|
|
"\270\246\000"
|
|
#define xecc_z 15
|
|
#define xecc ((&data[2784]))
|
|
"\373\163\175\232\263\074\171\320\261\163\206\331\252\020\227\143"
|
|
"\020\246\144"
|
|
#define chk1_z 22
|
|
#define chk1 ((&data[2805]))
|
|
"\141\041\203\171\275\321\255\040\267\363\057\347\326\007\040\342"
|
|
"\271\052\224\344\246\315\077\014\343\011\120\010\037\060"
|
|
#define pswd_z 256
|
|
#define pswd ((&data[2882]))
|
|
"\053\231\150\313\136\064\266\157\122\375\252\122\161\246\305\356"
|
|
"\012\370\306\226\132\347\031\323\244\041\363\325\333\302\347\007"
|
|
"\134\117\322\272\204\210\052\326\206\324\050\370\172\355\347\205"
|
|
"\346\255\034\100\117\237\241\001\377\312\136\172\147\102\271\007"
|
|
"\154\045\155\221\344\017\240\323\145\152\314\235\103\000\241\031"
|
|
"\327\250\361\047\110\222\051\107\135\207\302\304\312\173\314\066"
|
|
"\241\071\310\205\111\150\131\256\323\045\113\027\046\355\060\376"
|
|
"\226\041\045\336\264\116\046\021\325\350\326\237\143\243\326\005"
|
|
"\335\236\212\046\007\344\324\333\012\040\362\060\015\043\056\243"
|
|
"\104\124\202\371\242\250\013\170\221\341\030\364\204\357\372\142"
|
|
"\216\205\210\226\151\134\161\163\174\144\244\211\207\322\055\314"
|
|
"\046\257\305\311\127\320\102\350\262\133\335\067\112\327\231\331"
|
|
"\135\041\157\306\175\341\072\372\105\336\203\314\261\260\230\330"
|
|
"\140\136\242\267\056\344\240\340\077\176\027\212\126\260\143\263"
|
|
"\322\323\172\117\264\265\111\371\224\315\306\105\176\137\036\336"
|
|
"\275\300\226\353\244\067\314\344\265\344\157\014\225\323\277\147"
|
|
"\246\072\267\133\357\001\125\203\316\034\310\115\173\347\054\070"
|
|
"\247\302\044\114\372\360\061\257\325\240\273\152\164\173\321\033"
|
|
"\265\210\166\245\212\314\050\130\350\361\246\143\330\322\234\177"
|
|
"\224\300\313\216\224\065\024\071"
|
|
#define msg2_z 19
|
|
#define msg2 ((&data[3142]))
|
|
"\120\022\076\170\355\122\230\332\246\007\333\366\215\012\226\304"
|
|
"\030\062\202"/* 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 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];
|
|
}
|
|
|
|
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
|
|
#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 = 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 = 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;
|
|
#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)
|
|
{
|
|
#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;
|
|
}
|