UNPKG

t-share

Version:

Share Files And Directories from your Terminal

4 lines (2 loc) 10.7 kB
#! /usr/bin/env node const _0x2d6f26=_0xd298;function _0xd298(_0x5ca7bf,_0x1114ad){const _0x3ad8b9=_0x3ad8();return _0xd298=function(_0xd298d1,_0x8b178e){_0xd298d1=_0xd298d1-0x8e;let _0x50037b=_0x3ad8b9[_0xd298d1];return _0x50037b;},_0xd298(_0x5ca7bf,_0x1114ad);}function _0x3ad8(){const _0x32439a=['status','127.','receive','basename','trim','14LFqXml','user','Scan\x20the\x20QR-Code\x20to\x20access\x20\x27','log','debug','set\x20basic\x20authentication\x20(username\x20&\x20password)','send','default','\x0aUsage:\x0a•\x20Share\x20file\x20or\x20directory\x0a$\x20t-share\x20/path/to/file-or-directory\x0a\x0a•\x20Share\x20clipboard\x0a$\x20t-share\x20-c\x0a\x0a•\x20Receive\x20file\x0a$\x20t-share\x20/destination/directory\x20--receive;\x0a\x0a•\x20Share\x20file\x20with\x20Basic\x20Authentication\x0a$\x20t-share\x20/path/to/file-or-directory\x20-U\x20user\x20-P\x20password\x20\x20#\x20also\x20works\x20with\x20--receive','files','\x27);\x0a\x20\x20\x20\x20\x20\x20\x20\x20window.location.href\x20=\x20\x27','help','author','No\x20files\x20were\x20received.','port','node:os','toString','portfinder','\x20found','yargs','5479624AfJrsN','getTime','?time=','\x27\x20file\x20on\x20your\x20phone','ISHAAN\x20SHARMA\x20[JEHERILLAJANWAR]','/receive-form.html','http://','https://github.com/JeherillaJanwar','password','clipboard\x20data:\x0a\x20','exit','express','Get\x20to\x20know\x20the\x20library\x20AUTHOR','listen','lastIndexOf','IPv4','\x27;\x0a\x20\x20\x20\x20\x20\x20</script>\x0a\x20\x20\x20\x20','3021501qCvcGe','17444655IfUgfI','startsWith','http','.clipboard-tmp','isFile','qrcode','path','\x27\x20directory\x20on\x20your\x20phone','Specify\x20directory\x20or\x20file\x20path.','\x0aScan\x20the\x20QR-Code\x20to\x20upload\x20your\x20file','qrcode-terminal','Scan\x20the\x20QR-Code\x20to\x20access\x20your\x20Clipboard','Share\x20Clipboard','express-fileupload','indexOf','substring','auth','serve-handler','readFileSync','existsSync','enable\x20debuging\x20logs','selected','values','get','522484YnRpZI','username','generate','\x0a\x20\x20\x20\x20\x20\x20<script>\x0a\x20\x20\x20\x20\x20\x20\x20\x20window.alert(\x27Shared\x20at\x20','length','option','resolve','writeFileSync','use','3405085EtVmga','onWindowsNativeTerminal','file://','change\x20receive\x20default\x20port','receivePort','t-share','Enable\x20QR-Code\x20support\x20for\x20windows\x20native\x20terminal','4mqSokw','clipboard','or\x20access\x20this\x20link:\x20','argv','\x0aNOTE:\x20Use\x20your\x20INTERNET\x27s\x20private\x20IP\x20to\x20access\x20shared\x20files\x20from\x20another\x20device.','Receive\x20files','SIGINT','getPort','clipboardy','receive-port','\x0aSHARING\x20HAS\x20BEEN\x20STOPPED','usage','875539CfQqyB','clipboard\x20file\x20','2483844HJICnp','upload\x20path:\x20','Change\x20default\x20port','Directory\x20or\x20file\x20not\x20found.','/receive','Press\x20ctrl+c\x20to\x20stop\x20sharing','clipboard\x20file\x20path:\x0a\x20'];_0x3ad8=function(){return _0x32439a;};return _0x3ad8();}(function(_0x2ff61b,_0x244fe0){const _0x46b495=_0xd298,_0x450aeb=_0x2ff61b();while(!![]){try{const _0x386a69=parseInt(_0x46b495(0xd5))/0x1+-parseInt(_0x46b495(0xb9))/0x2+parseInt(_0x46b495(0xa0))/0x3+parseInt(_0x46b495(0xc9))/0x4*(parseInt(_0x46b495(0xc2))/0x5)+parseInt(_0x46b495(0xd7))/0x6*(parseInt(_0x46b495(0xe3))/0x7)+-parseInt(_0x46b495(0x8f))/0x8+-parseInt(_0x46b495(0xa1))/0x9;if(_0x386a69===_0x244fe0)break;else _0x450aeb['push'](_0x450aeb['shift']());}catch(_0x15b609){_0x450aeb['push'](_0x450aeb['shift']());}}}(_0x3ad8,0x7bd2d));const fs=require('fs'),http=require(_0x2d6f26(0xa3)),_path=require(_0x2d6f26(0xa7)),os=require(_0x2d6f26(0xf2)),yargs=require(_0x2d6f26(0x8e)),handler=require(_0x2d6f26(0xb2)),qrcode=require(_0x2d6f26(0xab)),portfinder=require(_0x2d6f26(0xf4)),express=require(_0x2d6f26(0x9a)),fileUpload=require(_0x2d6f26(0xae)),basicAuth=require('express-basic-auth'),usage=_0x2d6f26(0xeb),config={'debug':![],'qrcode':{'small':!![]},'auth':{'username':undefined,'password':undefined}};var createDefaultApp=()=>{const _0x4dc4f1=_0x2d6f26,_0x95dff4=express();if(config[_0x4dc4f1(0xb1)]['username']&&config[_0x4dc4f1(0xb1)][_0x4dc4f1(0x97)]){let _0x358858=config[_0x4dc4f1(0xb1)][_0x4dc4f1(0xba)],_0x398a83=config['auth'][_0x4dc4f1(0x97)];_0x95dff4[_0x4dc4f1(0xc1)](basicAuth({'challenge':!![],'realm':_0x4dc4f1(0xc7),'users':{[_0x358858[_0x4dc4f1(0xf3)]()]:_0x398a83[_0x4dc4f1(0xf3)]()}}));}return _0x95dff4;},getNetworkAddress=()=>{const _0x2289e7=_0x2d6f26;for(const _0x58c44e of Object[_0x2289e7(0xb7)](os['networkInterfaces']())){if(!_0x58c44e)continue;for(const _0x1809a3 of _0x58c44e){const {address:_0x4f9179,family:_0x42c784,internal:_0x1f9410}=_0x1809a3;if(_0x42c784===_0x2289e7(0x9e)&&!_0x1f9410&&!_0x4f9179[_0x2289e7(0xa2)](_0x2289e7(0xdf)))return _0x4f9179;}}},debugLog=_0x5f351e=>{const _0x63c666=_0x2d6f26;if(config[_0x63c666(0xe7)])console[_0x63c666(0xe6)](_0x5f351e);};((async()=>{const _0x144beb=_0x2d6f26,_0x4f3a17=yargs[_0x144beb(0xd4)](usage)[_0x144beb(0xbe)]('author',{'describe':_0x144beb(0x9b),'demandOption':![]})[_0x144beb(0xbe)](_0x144beb(0xe7),{'describe':_0x144beb(0xb5),'demandOption':![]})['option']('p',{'alias':_0x144beb(0xf1),'describe':_0x144beb(0xd9),'demandOption':![]})[_0x144beb(0xbe)]('ip',{'describe':'Your\x20machine\x20public\x20ip\x20address','demandOption':![]})['option']('c',{'alias':_0x144beb(0xca),'describe':_0x144beb(0xad),'demandOption':![]})['option']('w',{'alias':'on-windows-native-terminal','describe':_0x144beb(0xc8),'demandOption':![]})[_0x144beb(0xbe)]('r',{'alias':_0x144beb(0xe0),'describe':_0x144beb(0xce),'demandOption':![]})[_0x144beb(0xbe)]('q',{'alias':_0x144beb(0xd2),'describe':_0x144beb(0xc5),'demandOption':![]})['option']('U',{'default':_0x144beb(0xe4),'alias':_0x144beb(0xba),'describe':'set\x20basic\x20authentication\x20username','demandOption':![]})['option']('P',{'alias':_0x144beb(0x97),'describe':_0x144beb(0xe8),'demandOption':![]})[_0x144beb(0xee)](!![])[_0x144beb(0xcc)];if(_0x4f3a17[_0x144beb(0xe7)])config[_0x144beb(0xe7)]=!![];_0x4f3a17[_0x144beb(0xc3)]&&(config['qrcode']['small']=![]);_0x4f3a17[_0x144beb(0xef)]&&(qrcode[_0x144beb(0xbb)](_0x144beb(0x96),config[_0x144beb(0xa6)]),console['log'](_0x144beb(0x93)),process[_0x144beb(0x99)](0x0));_0x4f3a17['username']&&_0x4f3a17['password']&&(config['auth'][_0x144beb(0xba)]=_0x4f3a17['username'],config[_0x144beb(0xb1)][_0x144beb(0x97)]=_0x4f3a17[_0x144beb(0x97)]);let _0x59f673=undefined,_0x1adff2=undefined;if(_0x4f3a17[_0x144beb(0xca)]){const _0x35daf8=await import(_0x144beb(0xd1)),_0x1fb7eb=_0x35daf8[_0x144beb(0xea)]['readSync']();debugLog(_0x144beb(0x98)+_0x1fb7eb);let _0x4826be=_0x1fb7eb[_0x144beb(0xb0)](_0x1fb7eb[_0x144beb(0xaf)](_0x144beb(0xc4))+_0x144beb(0xc4)[_0x144beb(0xbd)])[_0x144beb(0xe2)]();_0x4826be=decodeURI(_0x4826be),debugLog(_0x144beb(0xdd)+_0x4826be),fs[_0x144beb(0xb4)](_0x4826be)?(debugLog(_0x144beb(0xd6)+_0x4826be+_0x144beb(0xf5)),_0x59f673=_0x4826be):(fs[_0x144beb(0xc0)]('.clipboard-tmp',_0x1fb7eb),_0x59f673=_path[_0x144beb(0xbf)](_0x144beb(0xa4)));}else _0x59f673=_0x4f3a17['_'][0x0];!_0x59f673&&(console[_0x144beb(0xe6)](_0x144beb(0xa9)),process['exit'](0x1));!fs['existsSync'](_0x59f673)&&(console[_0x144beb(0xe6)](_0x144beb(0xda)),process['exit'](0x1));if(fs['lstatSync'](_0x59f673)[_0x144beb(0xa5)]()){let _0x1ad1bf=_0x59f673[_0x144beb(0x9d)]('/')>-0x1?'/':'\x5c';_0x1adff2=_path[_0x144beb(0xe1)](_0x59f673),_0x59f673=_0x59f673['substring'](0x0,_0x59f673[_0x144beb(0x9d)](_0x1ad1bf)+0x1);}if(_0x4f3a17[_0x144beb(0xe0)]){const _0x3b3d7b=createDefaultApp();let _0x16f1d0=_0x4f3a17['ip']?_0x144beb(0x95)+_0x4f3a17['ip']+':'+_0x4f3a17['receivePort']+'/receive':_0x144beb(0x95)+getNetworkAddress()+':'+_0x4f3a17[_0x144beb(0xc6)]+_0x144beb(0xdb);_0x3b3d7b[_0x144beb(0xc1)](fileUpload());const _0x30fb39=fs[_0x144beb(0xb3)](__dirname+_0x144beb(0x94));_0x3b3d7b[_0x144beb(0xb8)](_0x144beb(0xdb),(_0xdfce3a,_0x2b7313)=>{const _0x375259=_0x144beb;_0x2b7313[_0x375259(0xe9)](_0x30fb39['toString']());}),_0x3b3d7b['post']('/upload',(_0x2bc149,_0x205120)=>{const _0x32b706=_0x144beb;if(!_0x2bc149[_0x32b706(0xec)]||Object['keys'](_0x2bc149[_0x32b706(0xec)])['length']===0x0){_0x205120['status'](0x190)[_0x32b706(0xe9)](_0x32b706(0xf0));return;}const _0x31fa58=_0x2bc149[_0x32b706(0xec)][_0x32b706(0xb6)],_0x47791c=_path[_0x32b706(0xbf)](_0x59f673,_0x31fa58['name']);debugLog(_0x32b706(0xd8)+_0x47791c),_0x31fa58['mv'](_0x47791c,_0x2d1aae=>{const _0x340191=_0x32b706;if(_0x2d1aae)return _0x205120[_0x340191(0xde)](0x1f4)[_0x340191(0xe9)](_0x2d1aae);_0x205120['send'](_0x340191(0xbc)+_0x47791c+_0x340191(0xed)+_0x16f1d0+_0x340191(0x9f));});});const _0x5701cb=()=>{const _0x18f4c2=_0x144beb;console['log'](_0x18f4c2(0xaa)),qrcode[_0x18f4c2(0xbb)](_0x16f1d0,config[_0x18f4c2(0xa6)]),console[_0x18f4c2(0xe6)](_0x18f4c2(0xcb)+_0x16f1d0+_0x18f4c2(0xcd)),console['log'](_0x18f4c2(0xdc));};if(_0x4f3a17[_0x144beb(0xc6)])_0x3b3d7b[_0x144beb(0x9c)](_0x4f3a17[_0x144beb(0xc6)],_0x5701cb);else portfinder[_0x144beb(0xd0)]({'port':0x55e,'stopPort':0x578},(_0x160b7e,_0x2f84a5)=>{const _0x1ad4bb=_0x144beb;_0x4f3a17[_0x1ad4bb(0xc6)]=_0x2f84a5,_0x16f1d0=_0x4f3a17['ip']?'http://'+_0x4f3a17['ip']+':'+_0x4f3a17[_0x1ad4bb(0xc6)]+'/receive':'http://'+getNetworkAddress()+':'+_0x4f3a17[_0x1ad4bb(0xc6)]+_0x1ad4bb(0xdb),_0x3b3d7b[_0x1ad4bb(0x9c)](_0x2f84a5,_0x5701cb);});}const _0x3e1c2d=createDefaultApp();_0x3e1c2d['get']('*',(_0x877656,_0x12eb8d)=>handler(_0x877656,_0x12eb8d,{'public':_0x59f673}));const _0x5c6c8e=()=>{const _0x1dac49=_0x144beb;let _0x8a4a01=_0x1dac49(0xe5)+_0x59f673+_0x1dac49(0xa8),_0x9f1708='';_0x1adff2&&(_0x8a4a01=_0x1dac49(0xe5)+_0x1adff2+_0x1dac49(0x92),_0x9f1708='/'+encodeURIComponent(_0x1adff2));if(_0x4f3a17[_0x1dac49(0xca)])_0x8a4a01=_0x1dac49(0xac);const _0x145b14=new Date()[_0x1dac49(0x90)](),_0x4c85d8=':'+_0x4f3a17[_0x1dac49(0xf1)]+_0x9f1708+_0x1dac49(0x91)+_0x145b14,_0x168860=_0x4f3a17['ip']?_0x1dac49(0x95)+_0x4f3a17['ip']+_0x4c85d8:_0x1dac49(0x95)+getNetworkAddress()+_0x4c85d8;console['log'](_0x8a4a01),qrcode[_0x1dac49(0xbb)](_0x168860,config[_0x1dac49(0xa6)]);if(!_0x4f3a17[_0x1dac49(0xca)])console[_0x1dac49(0xe6)](_0x1dac49(0xcb)+_0x168860+_0x1dac49(0xcd));if(!_0x4f3a17[_0x1dac49(0xe0)])console[_0x1dac49(0xe6)]('\x0aPress\x20ctrl+c\x20to\x20stop\x20sharing');};if(_0x4f3a17[_0x144beb(0xf1)])_0x3e1c2d[_0x144beb(0x9c)](_0x4f3a17[_0x144beb(0xf1)],_0x5c6c8e);else portfinder['getPort']({'port':0x1d36,'stopPort':0x1f40},(_0x14af47,_0x460ef5)=>{const _0x5336c4=_0x144beb;_0x4f3a17[_0x5336c4(0xf1)]=_0x460ef5,_0x3e1c2d[_0x5336c4(0x9c)](_0x460ef5,_0x5c6c8e);});process['on'](_0x144beb(0xcf),()=>{const _0x3bf564=_0x144beb;console[_0x3bf564(0xe6)](_0x3bf564(0xd3)),process[_0x3bf564(0x99)](0x0);});})());