teleshell
Gain shell access to your machine using a Telegram Bot.
Some cases where this might be helpful:
- You're in a double NAT environment and do not have access to your ISP's routers.
- You're behind a firewall which blocks incoming traffic.
- You have a dynamic IP address and don't want to set up Dynamic DNS
- You have no one to turn to, and you need to run a few commands to get a reverse SSH tunnel going
Quick Start
- Generate a telegram bot authorization token by following the instructions here
- Rename the configuration template file (config.example.json) to config.json. Here are the properties that are supported
Property | Type | Description |
---|---|---|
token |
String | The authorization token for your telegram bot |
whitelist |
Array(Number) | An array of whitelisted user ID (see below), from which commands will be run. |
processTimeout |
Number | Number of milliseconds after which the spawned process will be killed (Optional) |
npm install
node server.js
- Now go to Telegram and ping the bot that you've created. If the token has been set correctly, you should see loglines like so on your terminal:
Unauthorized command from user <NAME> (<USER ID>) [Thu Sep 08 2016 22:39:02 GMT+0530 (IST)]: ls
- Copy the User ID and add it to the whitelist and you are done. The bot will alert you if it receives messages from non-whitelisted IDs
Autostart
Using pm2, you can get teleshell to autoexecute on startup
npm install --global pm2
sudo pm2 startup
pm2 server.js --name teleshell
pm2 save
Suggestions, contributions, criticism and pull requests welcome.