mirror of
https://github.com/bettercap/bettercap
synced 2025-07-10 23:33:28 -07:00
fix: tcp_proxy module do not panic on empty script
This commit is contained in:
parent
b8e48e7f8a
commit
6115ea7e3f
1 changed files with 10 additions and 6 deletions
|
@ -145,13 +145,17 @@ func (p *TcpProxy) doPipe(from, to net.Addr, src, dst io.ReadWriter, wg *sync.Wa
|
|||
}
|
||||
b := buff[:n]
|
||||
|
||||
if p.script != nil {
|
||||
ret := p.script.OnData(from, to, b)
|
||||
|
||||
if ret != nil {
|
||||
nret := len(ret)
|
||||
log.Info("Overriding %d bytes of data from %s to %s with %d bytes of new data.", n, from.String(), to.String(), nret)
|
||||
log.Info("Overriding %d bytes of data from %s to %s with %d bytes of new data.",
|
||||
n, from.String(), to.String(), nret)
|
||||
b = make([]byte, nret)
|
||||
copy(b, ret)
|
||||
}
|
||||
}
|
||||
|
||||
n, err = dst.Write(b)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue