mirror of
https://github.com/bettercap/bettercap
synced 2025-08-22 14:24:38 -07:00
Added port validation
This commit is contained in:
parent
06a93b44dd
commit
e6e2609547
1 changed files with 7 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"io"
|
"io"
|
||||||
|
@ -310,12 +311,16 @@ func (mod *RdpProxy) Configure() (err error) {
|
||||||
// TODO: Param validation and hydration
|
// TODO: Param validation and hydration
|
||||||
if err, mod.port = mod.IntParam("rdp.proxy.port"); err != nil {
|
if err, mod.port = mod.IntParam("rdp.proxy.port"); err != nil {
|
||||||
return
|
return
|
||||||
|
} else if mod.port < 1 || mod.port > 65535 {
|
||||||
|
return errors.New("rdp.proxy.port must be between 1 and 65535")
|
||||||
} else if err, mod.cmd = mod.StringParam("rdp.proxy.command"); err != nil {
|
} else if err, mod.cmd = mod.StringParam("rdp.proxy.command"); err != nil {
|
||||||
return
|
return
|
||||||
} else if err, mod.outpath = mod.StringParam("rdp.proxy.out"); err != nil {
|
} else if err, mod.outpath = mod.StringParam("rdp.proxy.out"); err != nil {
|
||||||
return
|
return
|
||||||
} else if err, mod.queueNum = mod.IntParam("rdp.proxy.queue.num"); err != nil {
|
} else if err, mod.queueNum = mod.IntParam("rdp.proxy.queue.num"); err != nil {
|
||||||
return
|
return
|
||||||
|
} else if mod.queueNum < 0 || mod.queueNum > 65535 {
|
||||||
|
return errors.New("rdp.proxy.queue.num must be between 0 and 65535")
|
||||||
} else if err, targets = mod.StringParam("rdp.proxy.targets"); err != nil {
|
} else if err, targets = mod.StringParam("rdp.proxy.targets"); err != nil {
|
||||||
return
|
return
|
||||||
} else if mod.targets, _, err = network.ParseTargets(targets, mod.Session.Lan.Aliases()); err != nil {
|
} else if mod.targets, _, err = network.ParseTargets(targets, mod.Session.Lan.Aliases()); err != nil {
|
||||||
|
@ -330,6 +335,8 @@ func (mod *RdpProxy) Configure() (err error) {
|
||||||
return
|
return
|
||||||
} else if err, mod.redirectPort = mod.IntParam("rdp.proxy.nla.redirect.port"); err != nil {
|
} else if err, mod.redirectPort = mod.IntParam("rdp.proxy.nla.redirect.port"); err != nil {
|
||||||
return
|
return
|
||||||
|
} else if mod.redirectPort < 1 || mod.redirectPort > 65535 {
|
||||||
|
return errors.New("rdp.proxy.nla.redirect.port must be between 1 and 65535")
|
||||||
} else if _, err = exec.LookPath(mod.cmd); err != nil {
|
} else if _, err = exec.LookPath(mod.cmd); err != nil {
|
||||||
return
|
return
|
||||||
} else if _, err = mod.fileExists(mod.cmd); err != nil {
|
} else if _, err = mod.fileExists(mod.cmd); err != nil {
|
||||||
|
@ -441,7 +448,6 @@ func (mod *RdpProxy) handleRdpConnection(payload *nfqueue.Payload) int {
|
||||||
} else {
|
} else {
|
||||||
NewRdpProxyEvent(client, target, "Non-target, won't intercept.").Push()
|
NewRdpProxyEvent(client, target, "Non-target, won't intercept.").Push()
|
||||||
|
|
||||||
|
|
||||||
// Add an exception in the firewall to avoid intercepting packets to this destination and port
|
// Add an exception in the firewall to avoid intercepting packets to this destination and port
|
||||||
mod.doReturn(dst, dport)
|
mod.doReturn(dst, dport)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue