Skip to content

Instantly share code, notes, and snippets.

@HalfdanJ
Created October 1, 2019 22:44
Show Gist options
  • Save HalfdanJ/32b7891aff8017a27dd36ba1f3b12130 to your computer and use it in GitHub Desktop.
Save HalfdanJ/32b7891aff8017a27dd36ba1f3b12130 to your computer and use it in GitHub Desktop.
A websocket server sending screenshot as base64 encoded blob
// Requires ws and screenshot-desktop
const WebSocket = require('ws');
const screenshot = require('screenshot-desktop')
const wss = new WebSocket.Server({ port: 8889 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.on('close', ()=>{
clearInterval(interval);
console.log("disconnect")
})
console.log("connect")
const interval = setInterval(()=>{
screenshot({
format: 'jpg'
}).then(img => {
ws.send(img);
})
}, 500)
});
@kavindupasan
Copy link

Hi, I'm a security researcher participating in Google VRP. I have a few security related questions about this gist.

  1. Is there a channel for reporting vulnerabilities of this gist?
  2. Is this gist related to Teachable Machine?
  3. Are users expected to run this code on their computers, or is it not meant to be run as-is?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment