mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
new: HID devices are now exported by the api.rest module
This commit is contained in:
parent
f6649aa82b
commit
e0e1f4e6df
5 changed files with 64 additions and 7 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue