Merge pull request #6 from GoSecure/rdp_player

Added support for PyRDP player
This commit is contained in:
Alexandre Beaulieu 2019-06-18 15:21:08 -04:00 committed by GitHub
commit bb3c0af437
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,8 @@ type RdpProxy struct {
cmd string cmd string
outpath string outpath string
nlaMode string nlaMode string
playerIP net.IP
playerPort int
redirectIP net.IP redirectIP net.IP
redirectPort int redirectPort int
replay bool replay bool
@ -58,6 +60,8 @@ func NewRdpProxy(s *session.Session) *RdpProxy {
cmd: "pyrdp-mitm.py", cmd: "pyrdp-mitm.py",
outpath: "./pyrdp_output", outpath: "./pyrdp_output",
nlaMode: "IGNORE", nlaMode: "IGNORE",
playerIP: make(net.IP, 0),
playerPort: 3000,
redirectIP: make(net.IP, 0), redirectIP: make(net.IP, 0),
redirectPort: 3389, redirectPort: 3389,
replay: false, replay: false,
@ -86,8 +90,10 @@ mod.AddParam(session.NewStringParameter("rdp.proxy.targets", session.ParamSubnet
mod.AddParam(session.NewStringParameter("rdp.proxy.regexp", "(?i)(cookie:|mstshash=|clipboard data|client info|credential|username|password|error)", "", "Print PyRDP logs matching this regular expression.")) mod.AddParam(session.NewStringParameter("rdp.proxy.regexp", "(?i)(cookie:|mstshash=|clipboard data|client info|credential|username|password|error)", "", "Print PyRDP logs matching this regular expression."))
// Optional paramaters // Optional paramaters
mod.AddParam(session.NewStringParameter("rdp.proxy.nla.mode", "IGNORE", "(IGNORE|RELAY|REDIRECT)", "Specify how to handle connections to a NLA-enabled host. Either IGNORE, RELAY or REDIRECT.")) mod.AddParam(session.NewStringParameter("rdp.proxy.nla.mode", "IGNORE", "(IGNORE|RELAY|REDIRECT)", "Specify how to handle connections to a NLA-enabled host. Either IGNORE, RELAY or REDIRECT."))
mod.AddParam(session.NewStringParameter("rdp.proxy.nla.redirect.ip", "", "", "Specify IP to redirect clients that connects to NLA targets. Require rdp.proxy.nla.mode REDIRECT")) mod.AddParam(session.NewStringParameter("rdp.proxy.nla.redirect.ip", "", "", "Specify IP to redirect clients that connects to NLA targets. Require rdp.proxy.nla.mode REDIRECT."))
mod.AddParam(session.NewIntParameter("rdp.proxy.nla.redirect.port", "3389", "Specify port to redirect clients that connects to NLA targets. Require rdp.proxy.nla.mode REDIRECT")) mod.AddParam(session.NewIntParameter("rdp.proxy.nla.redirect.port", "3389", "Specify port to redirect clients that connects to NLA targets. Require rdp.proxy.nla.mode REDIRECT."))
mod.AddParam(session.NewStringParameter("rdp.proxy.player.ip", "", "", "Destination IP address of the PyRDP player."))
mod.AddParam(session.NewIntParameter("rdp.proxy.player.port", "3000", "Listening port of the PyRDP player."))
return mod return mod
} }
@ -189,6 +195,15 @@ func (mod *RdpProxy) startProxyInstance(client string, target string) (err error
args = append(args, "--no-replay") args = append(args, "--no-replay")
} }
// PyRDP Player options
if mod.playerIP != nil {
args = append(args, "-i")
args = append(args, mod.playerIP.String())
args = append(args, "-d")
args = append(args, fmt.Sprintf("%d", mod.playerPort))
}
args = append(args, target) args = append(args, target)
// 3.2. Spawn PyRDP proxy instance // 3.2. Spawn PyRDP proxy instance
@ -342,6 +357,12 @@ func (mod *RdpProxy) Configure() (err error) {
return return
} else if mod.redirectPort < 1 || mod.redirectPort > 65535 { } else if mod.redirectPort < 1 || mod.redirectPort > 65535 {
return errors.New("rdp.proxy.nla.redirect.port must be between 1 and 65535") return errors.New("rdp.proxy.nla.redirect.port must be between 1 and 65535")
} else if err, mod.playerIP = mod.IPParam("rdp.proxy.player.ip"); err != nil {
return
} else if err, mod.playerPort = mod.IntParam("rdp.proxy.player.port"); err != nil {
return
} else if mod.playerPort < 1 || mod.playerPort > 65535 {
return errors.New("rdp.proxy.player.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 {