new: HID devices are now exported by the api.rest module

This commit is contained in:
evilsocket 2019-02-21 11:43:48 +01:00
parent f6649aa82b
commit e0e1f4e6df
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
5 changed files with 64 additions and 7 deletions

View file

@ -61,7 +61,7 @@ func (mod *RestAPI) showSession(w http.ResponseWriter, r *http.Request) {
mod.toJSON(w, session.I)
}
func (mod *RestAPI) showBle(w http.ResponseWriter, r *http.Request) {
func (mod *RestAPI) showBLE(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
mac := strings.ToLower(params["mac"])
@ -74,6 +74,19 @@ func (mod *RestAPI) showBle(w http.ResponseWriter, r *http.Request) {
}
}
func (mod *RestAPI) showHID(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
mac := strings.ToLower(params["mac"])
if mac == "" {
mod.toJSON(w, session.I.HID)
} else if dev, found := session.I.HID.Get(mac); found {
mod.toJSON(w, dev)
} else {
http.Error(w, "Not Found", 404)
}
}
func (mod *RestAPI) showEnv(w http.ResponseWriter, r *http.Request) {
mod.toJSON(w, session.I.Env)
}
@ -90,7 +103,7 @@ func (mod *RestAPI) showModules(w http.ResponseWriter, r *http.Request) {
mod.toJSON(w, session.I.Modules)
}
func (mod *RestAPI) showLan(w http.ResponseWriter, r *http.Request) {
func (mod *RestAPI) showLAN(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
mac := strings.ToLower(params["mac"])
@ -212,7 +225,7 @@ func (mod *RestAPI) sessionRoute(w http.ResponseWriter, r *http.Request) {
mod.showModules(w, r)
case strings.HasPrefix(path, "/api/session/lan"):
mod.showLan(w, r)
mod.showLAN(w, r)
case path == "/api/session/options":
mod.showOptions(w, r)
@ -224,7 +237,10 @@ func (mod *RestAPI) sessionRoute(w http.ResponseWriter, r *http.Request) {
mod.showStartedAt(w, r)
case strings.HasPrefix(path, "/api/session/ble"):
mod.showBle(w, r)
mod.showBLE(w, r)
case strings.HasPrefix(path, "/api/session/hid"):
mod.showHID(w, r)
case strings.HasPrefix(path, "/api/session/wifi"):
mod.showWiFi(w, r)