mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 05:53:20 -07:00
View HTTP Basic authorization credentials when sniffing
Undid changes in events_view_http.go Undid more changed to events_view_http.go Undid more changed to events_view_http.go Vew HTTP Basic authnoriyation credentials when sniffing Undid changes in events_view_http.go
This commit is contained in:
parent
e51e097e43
commit
a3b80fba74
2 changed files with 35 additions and 15 deletions
|
@ -6,11 +6,11 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bettercap/bettercap/modules/net_sniff"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bettercap/bettercap/modules/net_sniff"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
"github.com/evilsocket/islazy/tui"
|
"github.com/evilsocket/islazy/tui"
|
||||||
|
@ -137,7 +137,7 @@ func (mod *EventsStream) viewHttpRequest(e session.Event) {
|
||||||
tui.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
se.Message)
|
se.Message)
|
||||||
|
|
||||||
if mod.shouldDumpHttpRequest(req) {
|
if mod.shouldDumpHttpRequest(se.Data.(net_sniff.HTTPRequest)) {
|
||||||
dump := fmt.Sprintf("%s %s %s\n", tui.Bold(req.Method), req.URL, tui.Dim(req.Proto))
|
dump := fmt.Sprintf("%s %s %s\n", tui.Bold(req.Method), req.URL, tui.Dim(req.Proto))
|
||||||
dump += fmt.Sprintf("%s: %s\n", tui.Blue("Host"), tui.Yellow(req.Host))
|
dump += fmt.Sprintf("%s: %s\n", tui.Blue("Host"), tui.Yellow(req.Host))
|
||||||
for name, values := range req.Headers {
|
for name, values := range req.Headers {
|
||||||
|
|
|
@ -119,6 +119,25 @@ func toSerializableResponse(res *http.Response) HTTPResponse {
|
||||||
func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {
|
func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {
|
||||||
data := tcp.Payload
|
data := tcp.Payload
|
||||||
if req, err := http.ReadRequest(bufio.NewReader(bytes.NewReader(data))); err == nil {
|
if req, err := http.ReadRequest(bufio.NewReader(bytes.NewReader(data))); err == nil {
|
||||||
|
if user, pass, ok := req.BasicAuth(); ok {
|
||||||
|
NewSnifferEvent(
|
||||||
|
pkt.Metadata().Timestamp,
|
||||||
|
"http.request",
|
||||||
|
ip.SrcIP.String(),
|
||||||
|
req.Host,
|
||||||
|
toSerializableRequest(req),
|
||||||
|
"%s %s %s %s%s - %s %s, %s %s",
|
||||||
|
tui.Wrap(tui.BACKRED+tui.FOREBLACK, "http"),
|
||||||
|
vIP(ip.SrcIP),
|
||||||
|
tui.Wrap(tui.BACKLIGHTBLUE+tui.FOREBLACK, req.Method),
|
||||||
|
tui.Yellow(req.Host),
|
||||||
|
vURL(req.URL.String()),
|
||||||
|
tui.Bold("USER"),
|
||||||
|
tui.Red(user),
|
||||||
|
tui.Bold("PASS"),
|
||||||
|
tui.Red(pass),
|
||||||
|
).Push()
|
||||||
|
} else {
|
||||||
NewSnifferEvent(
|
NewSnifferEvent(
|
||||||
pkt.Metadata().Timestamp,
|
pkt.Metadata().Timestamp,
|
||||||
"http.request",
|
"http.request",
|
||||||
|
@ -132,6 +151,7 @@ func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {
|
||||||
tui.Yellow(req.Host),
|
tui.Yellow(req.Host),
|
||||||
vURL(req.URL.String()),
|
vURL(req.URL.String()),
|
||||||
).Push()
|
).Push()
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
} else if res, err := http.ReadResponse(bufio.NewReader(bytes.NewReader(data)), nil); err == nil {
|
} else if res, err := http.ReadResponse(bufio.NewReader(bytes.NewReader(data)), nil); err == nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue