-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathws.client.ts
More file actions
33 lines (27 loc) · 839 Bytes
/
ws.client.ts
File metadata and controls
33 lines (27 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { SocketToProxy,ProxyToSocket, sshConfig } from "./wss.services";
import {io, Socket} from "socket.io-client";
const proxyPath = "ws://localhost:3000";
const socket: Socket<ProxyToSocket,SocketToProxy> = io(proxyPath, {reconnectionDelay:5000});
const config:sshConfig = {
host:"KaliBox",
port: 22,
username:"player",
password:"kali"
}
socket.on('connect',()=>{
console.log("[>]","Connecting to",config.host+":"+config.port);
socket.emit('init',config);
const stdin = process.openStdin();
stdin.addListener("data",(data:Buffer)=>{
socket.emit('command',data.toString());
})
})
socket.on('disconnect',()=>{
console.log("[*]","Trying to reconnect...")
})
socket.on('tunnel',(data)=>{
process.stdout.write(data);
})
socket.on('error',(data)=>{
process.stdout.write(data);
})