mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
new: new net.sniff.source parameter to use a PCAP file as source instead of the interface
This commit is contained in:
parent
0d266ec4d5
commit
6e36256dd1
2 changed files with 18 additions and 2 deletions
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
type SnifferContext struct {
|
||||
Handle *pcap.Handle
|
||||
Source string
|
||||
DumpLocal bool
|
||||
Verbose bool
|
||||
Filter string
|
||||
|
@ -30,10 +31,20 @@ func (s *Sniffer) GetContext() (error, *SnifferContext) {
|
|||
|
||||
ctx := NewSnifferContext()
|
||||
|
||||
if ctx.Handle, err = pcap.OpenLive(s.Session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil {
|
||||
if err, ctx.Source = s.StringParam("net.sniff.source"); err != nil {
|
||||
return err, ctx
|
||||
}
|
||||
|
||||
if ctx.Source == "" {
|
||||
if ctx.Handle, err = pcap.OpenLive(s.Session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil {
|
||||
return err, ctx
|
||||
}
|
||||
} else {
|
||||
if ctx.Handle, err = pcap.OpenOffline(ctx.Source); err != nil {
|
||||
return err, ctx
|
||||
}
|
||||
}
|
||||
|
||||
if err, ctx.Verbose = s.BoolParam("net.sniff.verbose"); err != nil {
|
||||
return err, ctx
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue