Update 'src/eros/eros.go'
added clientside api functionality for exploit; my json code might get cucked by json-iterator tho
This commit is contained in:
parent
8d5e1ab6b8
commit
eeba082e90
@ -23,13 +23,12 @@ import (
|
||||
bluetooth "git.tcp.direct/kayos/prototooth"
|
||||
"github.com/prologic/bitcask"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
structs "protomolecule/src/eros/structs"
|
||||
|
||||
structs "protomolecule/src/eros/structs"
|
||||
"github.com/labstack/echo/middleware"
|
||||
"github.com/labstack/echo"
|
||||
"net/http"
|
||||
"fmt"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -269,11 +268,11 @@ func Hypnosis(repo string) {
|
||||
// CORS
|
||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
||||
AllowOrigins: []string{"*"},
|
||||
AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE} //TODO: possibly trim the methods
|
||||
AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE} //TODO: possibly trim the methods for security purposes
|
||||
}))
|
||||
|
||||
// GET
|
||||
e.GET("/exploits", func(c echo.Context) error { // This will definitely need to be updated
|
||||
e.GET("/exploits", func(c echo.Context) error {
|
||||
// Build request
|
||||
req, err := http.NewRequest("GET", repo, nil)
|
||||
if err != nil {
|
||||
@ -281,7 +280,7 @@ func Hypnosis(repo string) {
|
||||
}
|
||||
|
||||
// Certificate sanity checks
|
||||
caCert, err := os.Readfile("server.crt")
|
||||
caCert, err := ioutil.Readfile("server.crt")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -314,7 +313,7 @@ func Hypnosis(repo string) {
|
||||
defer res.Body.Close()
|
||||
|
||||
// Late binding data from JSON
|
||||
var exp Exploit
|
||||
var exp structs.Exploit
|
||||
|
||||
// Decode JSON stream
|
||||
If err := json.NewDecoder(res.Body).Decode(&exp); err != nil {
|
||||
@ -322,7 +321,9 @@ func Hypnosis(repo string) {
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, exp)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// Trauma - store details of an exploit/attack against BLE devices
|
||||
@ -381,4 +382,4 @@ func Flashback(Addr string) (Exploit, error) {
|
||||
|
||||
json.Unmarshal(bytes, &member)
|
||||
return member, err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user