| const { execSync } = require('child_process'); |
| const readline = require('readline'); |
|
|
| function run(command) { |
| try { |
| const output = execSync(command, { stdio: 'pipe' }); |
| console.log(output.toString()); |
| } catch (error) { |
| |
| console.log('Error executing command:', error.stdout ? error.stdout.toString() : error.message); |
| } |
| } |
|
|
| function prompt(question) { |
| const rl = readline.createInterface({ |
| input: process.stdin, |
| output: process.stdout, |
| }); |
| return new Promise(resolve => rl.question(question, ans => { |
| rl.close(); |
| resolve(ans.trim()); |
| })); |
| } |
|
|
| async function main() { |
| const CRD_SSH_Code = await prompt('Google CRD SSH Code: '); |
| const username = 'user'; |
| const password = 'root'; |
| const Pin = '123456'; |
|
|
| if (!CRD_SSH_Code) { |
| console.log('Please enter authcode from the given link'); |
| return; |
| } |
| if (Pin.length < 6) { |
| console.log('Enter a pin more or equal to 6 digits'); |
| return; |
| } |
|
|
| |
| run(`sudo useradd -m ${username}`); |
| run(`sudo adduser ${username} sudo`); |
| run(`echo '${username}:${password}' | sudo chpasswd`); |
| run(`sudo sed -i 's/\\/bin\\/sh/\\/bin\\/bash/g' /etc/passwd`); |
|
|
| |
| run('sudo apt update'); |
|
|
| |
| run('wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb'); |
| run('sudo dpkg --install chrome-remote-desktop_current_amd64.deb'); |
| run('sudo apt install --assume-yes --fix-broken'); |
| console.log('Chrome Remote Desktop Installed!'); |
|
|
| |
| run('export DEBIAN_FRONTEND=noninteractive'); |
| run('sudo apt install --assume-yes xfce4 desktop-base xfce4-terminal'); |
| run(`sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/xfce4-session" > /etc/chrome-remote-desktop-session'`); |
| run('sudo apt remove --assume-yes gnome-terminal'); |
| run('sudo apt install --assume-yes xscreensaver'); |
| run('sudo systemctl disable lightdm.service'); |
| console.log('Installed XFCE4 Desktop Environment!'); |
|
|
| |
| run('wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb'); |
| run('sudo dpkg --install google-chrome-stable_current_amd64.deb'); |
| run('sudo apt install --assume-yes --fix-broken'); |
| console.log('Google Chrome Installed!'); |
|
|
| |
| run(`sudo adduser ${username} chrome-remote-desktop`); |
|
|
| |
| |
| |
| run(`sudo bash -c 'runuser -l ${username} -c "${CRD_SSH_Code} --pin=${Pin}"'`); |
|
|
| |
| run('sudo service chrome-remote-desktop start'); |
|
|
| console.log('..........................................................'); |
| console.log('..............Upgraded by Automation Habibi...............'); |
| console.log('..........................................................'); |
| console.log(`Log in PIN : ${Pin}`); |
| console.log(`User Name : ${username}`); |
| console.log(`User Pass : ${password}`); |
|
|
| |
| while (true) { |
| await new Promise(resolve => setTimeout(resolve, 1000)); |
| } |
| } |
|
|
| main().catch(console.log); |