Server Text ?
In short, server-text is a program that allows users to run commands on their servers or computers via SMS. In simple, you can think of it as full-fledge shell but commands run via text message. This program runs by users adding their number with SMS gateway and their email address. When the script runs, users can write commands through their phone messaging and get an output. We highly recommend never to run this on production servers as there are a series of security issues related to this program
From this article, you will learn about our design process, implementation, and intent of this project.
You can see our repository here.
Why We Built This?
Two years ago we came across a video where a guy codes using text messages as this video turned out to be the inspiration for this program and then we decided to build this project. When building this project we had a specific use case in mind, where users could get information in regards to their server. For example, they could find out how much CPU was being used on a Rasberry Pi just over text. Our intention behind this project was to give the user a way to access information in regards to their server in a different way and easier way just by texting and that’s one of the reasons why we built this program.
You can view installation demo here Note: I use python version 3.9 but 3.6 is being widely used
- Before you clone the repo make sure you have
pipenvinstalled on your machine.You can always verify
python3 --versionon commandline and if you don’t have
pipenvinstalled you can refer to the docs
- Once you have
pipenvinstalled now you can clone the repo
git clone https://github.com/mtdevss/server-text.git.
cd server-text/and run
pipenv shellto activate the virtual environment and
pipenv installto install the dependencies.
- Once you have installed the dependencies before you run the script make sure to populate the script with your
numberfrom which you will be sending texts from, and
imap serverof your email provider
How it Works and Implementation
As we already built a simple text message project which allowed you to send text messages from the command line, we followed the similar approach of using SMS messaging with email to facilitate running commands on our server from our phones. We built the aplication using Flask so when a user runs a command he can view his output in HTML format.
Before the users can start the script, they need to enter their information.
mail = 'firstname.lastname@example.org' # Email - Where you will be receiving texts sent from phone pas = '<email_pass>' # Email password number = '+1[number]@SMS_GATEWAY' # Your phone number with SMS_Gateway imap_server = '<your_email_provider_imap'
Now start the server by running the command python3 script.py the server is waiting for the user’s message. Writing a simple command in my phone message
ls -la as a text message while my server is running, it will send this message to the email I entered. The script will look for the message, and check if the message was sent by the number added. If this is true, the server will execute this command on the server. With the response, we send the command and turn it into HTML using the
ANSI2HTML library which will then be rendered by the flask application to the user’s screen.
As a disclaimer, our program is by no means finished or fully developed. We know there are various security flaws, and we are researching the best means to properly address them. From our use case, the commands that we thought we wanted initially were read-only and wouldn’t ever change the server.
Since this was a very controversal project, we learned a lot from the feedback we got from the community. As beginners into the open source community, we want to continue to dive deep into creating new projects for the community and to learn from others.
MTDevs is an open source organization that focuses on writing open source software. The two founders are Muhammad Raza based in New York City, and Taichen Rose based in Bellingham, Washington. You can read more about us here
If You find it interesting!! we would really like to hear from you.
Ping us at Instagramemail@example.com
IF YOU WANT ARTICLES ON ANY TOPICS DM US ON INSTA.
Thanks for reading!!