Update agents/meshcore.min.js

TotallyNotElite committed Nov 24, 2019 at 20:07 UTC 88654038b7db07d08519ca816a9263c6a2f8271d
1 file changed +91 -2
agents/meshcore.min.js
+91 -2
@@ -1099,11 +1099,15 @@ function createMeshCore(agent) {
1099 this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
1100 this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
1101 } else {
1102 - if (fs.existsSync("/bin/bash")) {
1102 + if (fs.existsSync("/usr/bin/python") && fs.existsSync("/bin/bash")) {
1103 + this.httprequest.process = childProcess.execFile("/usr/bin/python", [ "python", "-c", "import pty; pty.spawn([\"/bin/bash\"])" ]);
1104 + if (process.platform == 'linux') { this.httprequest.process.stdin.write("export TERM='xterm'\nalias ls='ls --color=auto'\nclear\n"); }
1105 + }
1106 + else if (fs.existsSync("/bin/bash")) {
1107 this.httprequest.process = childProcess.execFile("/bin/bash", ["bash", "-i"], { type: childProcess.SpawnTypes.TERM });
1108 if (process.platform == 'linux') { this.httprequest.process.stdin.write("alias ls='ls --color=auto'\nclear\n"); }
1109 } else {
1106 - this.httprequest.process = childProcess.execFile("/bin/sh", ["sh"], { type: childProcess.SpawnTypes.TERM });
1110 + this.httprequest.process = childProcess.execFile("/bin/sh", ["sh"], { type: childProcess.SpawnTypes.TERM }); // , uid: require('user-sessions').consoleUid()
1111 if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nPS1='\\u@\\h:\\w\\$ '\nclear\n"); }
1112 }
1113 this.httprequest.process.tunnel = this;
@@ -1788,6 +1792,78 @@ function createMeshCore(agent) {
1792 response = 'Available commands: \r\n' + fin + '.';
1793 break;
1794 }
1795 + case 'wallpaper':
1796 + if (process.platform != 'win32' && !(process.platform == 'linux' && require('linux-gnome-helpers').available))
1797 + {
1798 + response = 'wallpaper command not supported on this platform'
1799 + }
1800 + else
1801 + {
1802 + if (args['_'].length != 1)
1803 + {
1804 + response = 'Proper usage: wallpaper (GET|TOGGLE)'; // Display usage
1805 + }
1806 + else
1807 + {
1808 + switch (args['_'][0].toUpperCase())
1809 + {
1810 + default:
1811 + response = 'Proper usage: wallpaper (GET|TOGGLE)'; // Display usage
1812 + break;
1813 + case 'GET':
1814 + case 'TOGGLE':
1815 + if (process.platform == 'win32')
1816 + {
1817 + var id = require('user-sessions').getProcessOwnerName(process.pid).tsid == 0 ? 1 : 0;
1818 + var child = require('child_process').execFile(process.execPath, [process.execPath.split('\\').pop(), '-b64exec', 'dmFyIFNQSV9HRVRERVNLV0FMTFBBUEVSID0gMHgwMDczOwp2YXIgU1BJX1NFVERFU0tXQUxMUEFQRVIgPSAweDAwMTQ7CnZhciBHTSA9IHJlcXVpcmUoJ19HZW5lcmljTWFyc2hhbCcpOwp2YXIgdXNlcjMyID0gR00uQ3JlYXRlTmF0aXZlUHJveHkoJ3VzZXIzMi5kbGwnKTsKdXNlcjMyLkNyZWF0ZU1ldGhvZCgnU3lzdGVtUGFyYW1ldGVyc0luZm9BJyk7CgppZiAocHJvY2Vzcy5hcmd2Lmxlbmd0aCA9PSAzKQp7CiAgICB2YXIgdiA9IEdNLkNyZWF0ZVZhcmlhYmxlKDEwMjQpOwogICAgdXNlcjMyLlN5c3RlbVBhcmFtZXRlcnNJbmZvQShTUElfR0VUREVTS1dBTExQQVBFUiwgdi5fc2l6ZSwgdiwgMCk7CiAgICBjb25zb2xlLmxvZyh2LlN0cmluZyk7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQplbHNlCnsKICAgIHZhciBuYiA9IEdNLkNyZWF0ZVZhcmlhYmxlKHByb2Nlc3MuYXJndlszXSk7CiAgICB1c2VyMzIuU3lzdGVtUGFyYW1ldGVyc0luZm9BKFNQSV9TRVRERVNLV0FMTFBBUEVSLCBuYi5fc2l6ZSwgbmIsIDApOwogICAgcHJvY2Vzcy5leGl0KCk7Cn0='], { type: id });
1819 + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
1820 + child.stderr.on('data', function () { });
1821 + child.waitExit();
1822 + var current = child.stdout.str.trim();
1823 + if (args['_'][0].toUpperCase() == 'GET')
1824 + {
1825 + response = current;
1826 + break;
1827 + }
1828 + if (current != '')
1829 + {
1830 + require('MeshAgent')._wallpaper = current;
1831 + response = 'Wallpaper cleared';
1832 + }
1833 + else
1834 + {
1835 + response = 'Wallpaper restored';
1836 + }
1837 + child = require('child_process').execFile(process.execPath, [process.execPath.split('\\').pop(), '-b64exec', 'dmFyIFNQSV9HRVRERVNLV0FMTFBBUEVSID0gMHgwMDczOwp2YXIgU1BJX1NFVERFU0tXQUxMUEFQRVIgPSAweDAwMTQ7CnZhciBHTSA9IHJlcXVpcmUoJ19HZW5lcmljTWFyc2hhbCcpOwp2YXIgdXNlcjMyID0gR00uQ3JlYXRlTmF0aXZlUHJveHkoJ3VzZXIzMi5kbGwnKTsKdXNlcjMyLkNyZWF0ZU1ldGhvZCgnU3lzdGVtUGFyYW1ldGVyc0luZm9BJyk7CgppZiAocHJvY2Vzcy5hcmd2Lmxlbmd0aCA9PSAzKQp7CiAgICB2YXIgdiA9IEdNLkNyZWF0ZVZhcmlhYmxlKDEwMjQpOwogICAgdXNlcjMyLlN5c3RlbVBhcmFtZXRlcnNJbmZvQShTUElfR0VUREVTS1dBTExQQVBFUiwgdi5fc2l6ZSwgdiwgMCk7CiAgICBjb25zb2xlLmxvZyh2LlN0cmluZyk7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQplbHNlCnsKICAgIHZhciBuYiA9IEdNLkNyZWF0ZVZhcmlhYmxlKHByb2Nlc3MuYXJndlszXSk7CiAgICB1c2VyMzIuU3lzdGVtUGFyYW1ldGVyc0luZm9BKFNQSV9TRVRERVNLV0FMTFBBUEVSLCBuYi5fc2l6ZSwgbmIsIDApOwogICAgcHJvY2Vzcy5leGl0KCk7Cn0=', current != '' ? '""' : require('MeshAgent')._wallpaper], { type: id });
1838 + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
1839 + child.stderr.on('data', function () { });
1840 + child.waitExit();
1841 + }
1842 + else
1843 + {
1844 + var id = require('user-sessions').consoleUid();
1845 + var current = require('linux-gnome-helpers').getDesktopWallpaper(id);
1846 + if (args['_'][0].toUpperCase() == 'GET')
1847 + {
1848 + response = current;
1849 + break;
1850 + }
1851 + if (current != '/dev/null')
1852 + {
1853 + require('MeshAgent')._wallpaper = current;
1854 + response = 'Wallpaper cleared';
1855 + }
1856 + else
1857 + {
1858 + response = 'Wallpaper restored';
1859 + }
1860 + require('linux-gnome-helpers').setDesktopWallpaper(id, current != '/dev/null' ? undefined : require('MeshAgent')._wallpaper);
1861 + }
1862 + break;
1863 + }
1864 + }
1865 + }
1866 + break;
1867 case 'safemode':
1868 if (process.platform != 'win32')
1869 {
@@ -1815,6 +1891,19 @@ function createMeshCore(agent) {
1891 break;
1892 case 'STATUS':
1893 var nextboot = require('win-bcd').getKey('safeboot');
1894 + if (nextboot)
1895 + {
1896 + switch(nextboot)
1897 + {
1898 + case 'Network':
1899 + case 'network':
1900 + nextboot = 'SAFE_MODE_NETWORK';
1901 + break;
1902 + default:
1903 + nextboot = 'SAFE_MODE';
1904 + break;
1905 + }
1906 + }
1907 response = 'Current: ' + require('win-bcd').bootMode + ' , NextBoot: ' + (nextboot ? nextboot : 'NORMAL');
1908 break;
1909 }