Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
linux-xorg-screencapture
Advanced tools
A native Node.js addon which captures the screen content on Linux using the Xorg API
npm install linux-xorg-screencapture
const { XScreencap } = require('linux-xorg-screencapture');
let xsc = new XScreencap("RGBA");
let success = xsc.connect();
if (!success) {
console.log("Could not connect to X server");
process.exit(0);
}
let image;
try {
image = xsc.getImage(-1);
} catch(err) {
console.log("An error occured:", err.message);
process.exit(0);
}
// work with the data in image
More examples can be found in the examples/ directory.
All of the method returning images return an object with the format:
{
data: Buffer,
width: Number,
height: Number
}
The data in the buffer are the raw pixel values either in RGB or RGBA order. This object format is referred to as the "default format" in the rest of this documentation.
constructor(?pixel_format)
Create a new instance with an optional pixel format.
The pixel format determines the data contained in the returned buffers and can either be "RGB"
or "RGBA"
(default).
The alpha channel is always set to 255, however.
connect()
This method connects the library to the X server and it needs to be called before any other method.
Returns true
on success and false
if something went wrong.
getMonitorCount()
Returns the number of active monitors identified via RandR.
If RandR is not available, this method returns -1
.
getImage(monitor)
Synchronously gets the image of the specified monitor.
If RandR is not available, or -1
is supplied as the monitor value, the whole virtual X screen will be captured.
The method either returns an image in the default format or throws an error.
getImageAsync(monitor)
Asynchronous version of getImage
, which returns a promise resolving to image data in the default format.
startAutoCapture(delay, monitor)
Starts a new thread, which tries to capture the screen every delay
milliseconds.
Image data is then emitted as an image event.
This method functions similar to setInterval(() => xsc.getImageAsync().then(image => emit("image", image)), delay)
, but with the added bonus of all the timing stuff happening in native code and a separate thread, which should improve the performance. Note: You can only have one of these threads running at any time, so subsequent calls to startAutoCapture
without stopping the auto capture in between have no effect.
stopAutoCapture()
Stops the auto capture thread.
No futher image events will be emitted after this method has been called.
Event 'image'
Emitted in an interval which duration is determined by the delay parameter in the startAutoCapture
method.
The event handler will be called with an object in the default image format.
FAQs
Captures the Linux desktop using Xorg APIs
The npm package linux-xorg-screencapture receives a total of 6 weekly downloads. As such, linux-xorg-screencapture popularity was classified as not popular.
We found that linux-xorg-screencapture demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.