fix: now api.rest can execute multiple commands divided by ;

This commit is contained in:
evilsocket 2019-03-20 19:28:04 +01:00
parent f8dda1e8e9
commit a202f7eaca
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -158,11 +158,16 @@ func (mod *RestAPI) runSessionCommand(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Bad Request", 400)
} else if err = json.NewDecoder(r.Body).Decode(&cmd); err != nil {
http.Error(w, "Bad Request", 400)
} else if err = session.I.Run(cmd.Command); err != nil {
http.Error(w, err.Error(), 400)
} else {
mod.toJSON(w, APIResponse{Success: true})
}
for _, aCommand := range session.ParseCommands(cmd.Command) {
if err = mod.Session.Run(aCommand); err != nil {
http.Error(w, err.Error(), 400)
return
}
}
mod.toJSON(w, APIResponse{Success: true})
}
func (mod *RestAPI) showEvents(w http.ResponseWriter, r *http.Request) {