Kano001 commited on
Commit
c533563
1 Parent(s): 5f0c253

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +5 -2
server.js CHANGED
@@ -16,9 +16,12 @@ wss.on('connection', (ws) => {
16
  console.log(`Received message: ${message}`);
17
 
18
  // Convert message (Buffer) to string
19
- const command = message.toString();
20
 
21
- // Execute the command received from the client
 
 
 
22
  exec(command, (error, stdout, stderr) => {
23
  if (error) {
24
  ws.send(`Error: ${error.message}`);
 
16
  console.log(`Received message: ${message}`);
17
 
18
  // Convert message (Buffer) to string
19
+ let command = message.toString();
20
 
21
+ // Prefix command with 'sudo'
22
+ command = `sudo ${command}`;
23
+
24
+ // Execute the command with superuser privileges
25
  exec(command, (error, stdout, stderr) => {
26
  if (error) {
27
  ws.send(`Error: ${error.message}`);