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.
thsq-simulator
Advanced tools
The thsq-simulator
is a simulator for Thingsquare devices. This simulator can run on any desktop machine, which makes it easier to work with than the actual hardware.
The purpose of the simulator is to make backend integration and algorithm development easier.
NodeJS and npm.
npm install --save thsq-simulator
Here's a full implementation of a simple simulator. This implementation can be modified to alter the behavior of the simulated devices. Save this content to simulator.js
.
var thsqsim = require('thsq-simulator');
var getopts = require('getopts');
require('console-stamp')(console, { pattern : 'HH:MM:ss.l' });
function usage() {
console.info('usage: node simulator.js -u <token> -d <num devices> -n <num networks>');
console.info('<token> is an API token that can be retrieved from https://developer.thingsquare.com/web/, under the User tab, by checking the "Enable API access" checkbox');
console.info('<num devices> is the number of simulated devices to spin up');
console.info('optional: -f <frontend> -b <backend>');
process.exit(1);
}
var options = getopts(process.argv.slice(2), {
alias: {
user: 'u',
frontend: 'f',
backend: 'b',
networks: 'n',
devices: 'd',
platform: 'p',
applatform: 'a',
filename: 'F'
},
default: {
frontend: 'b72af87d-42d7-4f09-bf8c-b9f721a3e6ef',
backend: 'developer.thingsquare.com',
networks: 1,
devices: 10,
proptime: 100,
period: 3600 * 10,
}
});
if (!options.user || !options.devices) {
usage();
return;
}
thsqsim.on('boot', function (device) {
});
thsqsim.on('variable', function (device, key, val, oldval) {
});
thsqsim.on('command', function (device, command, data) {
});
thsqsim.init({
token: options.user,
frontend: options.frontend,
backend: options.backend,
platform: options.platform,
applatform: options.applatform,
devices: options.devices,
period: options.period,
proptime: options.proptime,
networks: options.networks,
deadleaf: options.deadleaf,
statefilename: options.filename }, function () {
console.log('started');
});
First grab an API key.
Go to https://developer.thingsquare.com/web/ and log in.
The API key can be found under the User tab (make sure to enable API access
first).
Then run:
node thsq-simulator.js -u <API token from above> -n <number of simulated devices>
This will produce output similar to this:
$ node simulator.js -u <the API token> -n 10
[18:00:00.726] [LOG] Creating device 0 / 11
[18:00:01.760] [LOG] Creating device 1 / 11
[18:00:02.914] [LOG] Creating device 2 / 11
[18:00:04.078] [LOG] Creating device 3 / 11
[18:00:05.384] [LOG] Creating device 4 / 11
[18:00:06.397] [LOG] Creating device 5 / 11
[18:00:07.637] [LOG] Creating device 6 / 11
[18:00:08.197] [LOG] Creating device 7 / 11
[18:00:08.581] [LOG] Creating device 8 / 11
[18:00:08.948] [LOG] Creating device 9 / 11
[18:00:10.082] [LOG] Creating device 10 / 11
[18:00:10.901] [LOG] Creating device 11 / 11
[18:00:10.902] [LOG] All simulated devices started
The simulated devices will then show up in https://developer.thingsquare.com/web/.
By default simulated devices post a randomized value to the server variable t
. To override what the device post, pass a periodiccallback
parameters to the thsqsim.init
function. Here's a full example of how to instead set and push a myvariable
server variable.
function pushmyvariable(device) {
device.pushVariable('s', 'myvariable', 'myvalue');
device.sendStats();
}
thsqsim.init({
...
periodiccallback: pushmyvariable,
...
});
FAQs
Javascript simulator for Thingsquare IoT mesh networks
The npm package thsq-simulator receives a total of 0 weekly downloads. As such, thsq-simulator popularity was classified as not popular.
We found that thsq-simulator 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.