Skip to content

fzbian/server-inquiry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ServerInquiry

ServerInquiry is an API that enables communication between external applications and a server, opening ports and generating tokens that allow commands to be sent and executed more conveniently. In addition, thanks to its functionality, this API can improve the efficiency of data transmission and automate processes, providing a simpler and more effective solution for interaction between applications and servers.

Requirements

  • Ubuntu
  • Debian
  • CentOS
  • Red Hat Enterprise
  • FreeBSD
  • OpenBSD

Installation

Follow the following commands on your server to do the installation correctly

$ curl -LO https://raw.githubusercontent.com/fzbian/server-inquiry/main/tools/install.sh
$ chmod +x install.sh
$ ./install.sh

The console will return the following message

ServerInquiry (1.0.0b) is ready for use.

Now you can use server-inquiry at any time.

API Reference

Health

  GET /api/health?token=<token>
Parameter Type Description
token string the token generated by running the code

Command

  GET /api/command?token=<token>&cmd=<cmd>
Parameter Type Description
token string the token generated by running the code
cmd string the command to request

Contribute

We are open to, and grateful for, any contributions made by the community.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Example

By running server-inquiry the console will return this information

Server IP: 127.0.0.1:8000
Token: <Token>

You can implement the request in your application code, here is an example code in go.

package main

import (
	"fmt"
	"io"
	"net/http"
)

var (
	ip      = "ip"
	port    = "port"
	token   = "token"
	command = "pwd"
)

func main() {
	resp, err := http.Get("http://" + ip + ":" + port + "/api/command?token=" + token + "&cmd=" + command)
	if err != nil {
		fmt.Println("Error in the request: ", err)
	}
	defer func(Body io.ReadCloser) {
		err := Body.Close()
		if err != nil {
			fmt.Println(err)
		}
	}(resp.Body)

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("Error when reading the answer: ", err)
	}

	fmt.Println(string(body))
}

Or If you wish to make a direct request

curl -X GET "http://<ip>:<port>/api/command?token=<token>&cmd=pwd"

The two examples will answer the same:

/root

Acknowledgments