Blade Terminal is a versatile web-based terminal interface designed to facilitate command-line interactions with remote servers or local systems through a user-friendly web interface. This repository houses the complete source code for the Blade Terminal application, providing a seamless bridge between users and their systems.
- Getting Started
- Usage
- index.js Overview
- Files
- External Dependencies
- Directories and Files
- Additional Notes
- Additional Resources
# Clone the repository
git clone https://github.com/StunsIO/BladeTerminal.git
# Navigate to the source directory
cd BladeTerminal/src
# Install the required dependencies
npm install
# Start the application
npm start
-
Login Page: Access the login page at
<http|https>://<HOST|localhost>:<PORT|8013>/login
and enter the token for authentication. -
Terminal Page: After successful login, you will be redirected to the terminal page where you can enter commands.
-
Commands: Enter commands in the input field and press "Submit". The output will be displayed below.
-
Get Server Info: Click the "Get Server Info" button to retrieve information about the server. This includes details about system resources and disk space.
-
Logout: To log out, use the "logout" command.
Please note that the "Get Server Info" button provides additional insights into the server's status and resource utilization.
The index.js
file serves as the main entry point for the Blade Terminal application. It utilizes the Express framework to handle HTTP requests, execute system commands, and manage user authentication.
-
Server Setup: Sets up an Express server and configures it to use EJS as the view engine. It also includes middleware for serving static files and parsing request bodies.
-
User Authentication:
- Generates a 64-character authentication token using the
generateToken
function. - Implements routes for user login, logout, and authentication checks.
- Generates a 64-character authentication token using the
-
Routes:
- Login Page: Renders the login page when accessed.
- Login Endpoint: Validates the user-provided token and authenticates the user.
- Logout Endpoint: Logs the user out and redirects to the login page.
- Terminal Page: Renders the terminal page for authenticated users, displaying system information based on the user's platform.
- Execute Command Endpoint: Executes commands sent via POST request, handling both Windows and Linux platforms.
- Server Info Endpoint: Retrieves and formats server information based on the user's platform.
-
User Authentication Middleware: Utilizes the
requireAuth
function to ensure that only authenticated users have access to certain routes. -
Starting the Server: Listens for incoming requests on the specified port, with a default of 8013, and logs the server's address.
-
Token Generation Function: Generates a random token of the specified length using a combination of alphanumeric characters.
File | Description |
---|---|
src/index.js |
Express server managing routes and serving HTML. |
src/views/login.ejs |
HTML code for the login page. |
src/views/index.ejs |
HTML code for the terminal page. |
src/public/app.js |
JavaScript code for handling terminal functions. |
src/public/style.css |
CSS file for styling the application. |
Dependency | Description |
---|---|
Prism CSS | Syntax highlighting for code blocks. |
Prism Tomorrow CSS | Additional Prism theme. |
Google Material Icons | Icons for UI elements. |
│
├── src
│ ├── views
│ │ ├── login.ejs
│ │ └── index.ejs
│ ├── public
│ │ ├── app.js
│ │ └── style.css
│ └── index.js
-
The login page (
views/login.ejs
) provides a simple form to enter a token for authentication. -
The terminal page (
views/index.ejs
) displays system information, allows input of commands, and provides links for documentation and support. -
The terminal supports syntax highlighting using Prism.
-
Make sure to have the necessary CSS and JavaScript files linked in your HTML.
For detailed information on Windows commands, you can refer to the official Microsoft documentation:
This resource provides comprehensive documentation for a wide range of commands available on the Windows platform.
If you are working on a Unix-based system, you can explore basic Unix commands using the following resource:
This guide offers an introduction to essential Unix commands and their usage.
To retrieve the public IP address of a user, you can use the ipify API. This API allows you to easily obtain the user's external IP address.