Skip to content

Commit d566325

Browse files
committed
Fixed wrong arguments
1 parent fd7c207 commit d566325

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

action/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ func (this *Action) Unblock() {
3535
}
3636

3737
func (this *Action) Unregister() {
38-
this.channel <- service.EventRWC{service.EUnregister, nil}
38+
this.channel <- service.EventRWC{Event: service.EUnregister}
3939
this.service.Stop(this.channel)
4040
}

action/raiseTTY.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/dzervas/netcatty/service"
77
)
88

9+
// TODO: Windows (cmd & powershell)
910
var shellInit = map[string][]string{
1011
"python": { "import pty; pty.spawn('python')" },
1112
"sh": {

inout/tty.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/mattn/go-tty"
66
)
77

8+
// TODO: Windows requires local echo
89
type Tty struct {
910
*tty.TTY
1011
reset func() error

main.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ func NewReadWriteCloser(r io.Reader, w io.Writer, c io.Closer) io.ReadWriteClose
3535
}
3636

3737
var opts struct {
38-
// TODO
39-
Close bool `short:"c" long:"close" description:"Close connection on EOF from stdin"`
38+
// This is already the behaviour. Probably too difficult (and no reason) to implement
39+
// Close bool `short:"c" long:"close" description:"Close connection on EOF from stdin"`
4040
Detect bool `short:"D" long:"detect" description:"Detect remote shell automatically and try to raise a TTY on the remote (action)"`
41-
// TODO
4241
Exec string `short:"e" long:"exec" description:"Program to exec after connect"`
4342
// TODO
4443
Gateway []string `short:"g" long:"gateway" description:"Source-routing hop point[s], up to 8"`
@@ -53,12 +52,11 @@ var opts struct {
5352
DontResolve bool `short:"n" long:"dont-resolve" description:"Numeric-only IP addresses, no DNS"`
5453
// TODO
5554
Output string `short:"o" long:"output" description:"Output hexdump traffic to FILE (implies -x)"`
56-
Port string `short:"p" long:"port" description:"Local port number"`
55+
Port string `short:"p" long:"local-port" description:"Local port number"`
5756
Protocol string `short:"P" long:"protocol" description:"Provide protocol in the form of tcp{,4,6}|udp{,4,6}|unix{,gram,packet}|ip{,4,6}[:<protocol-number>|:<protocol-name>]\nFor <protocol-number> check https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml"`
58-
// TODO
57+
// Does not have any effect - even on netcat
5958
Randomize bool `short:"r" long:"randomize" description:"Randomize local and remote ports"`
6059
Raw bool `short:"R" long:"auto-raw" description:"Put local TTY in Raw mode on connect (action)"`
61-
// TODO
6260
Source string `short:"s" long:"source" description:"Local source address (ip or hostname)"`
6361
TCP bool `short:"t" long:"tcp" description:"TCP mode (default)"`
6462
// TODO
@@ -90,10 +88,15 @@ func main() {
9088

9189
// netcat behaviour where to connect you do `nc <ip> <port>`
9290
// but to listen you do `nc -lp <port>`
93-
address := strings.Join([]string{opts.Positional.Hostname, opts.Positional.Port}, ":")
94-
if opts.Listen {
95-
address = strings.Join([]string{opts.Positional.Hostname, opts.Port}, ":")
91+
hostname := opts.Positional.Hostname
92+
port := opts.Positional.Port
93+
if opts.Listen && len(opts.Source) > 0 {
94+
port = opts.Source
95+
}
96+
if opts.Listen && len(opts.Port) > 0 {
97+
port = opts.Port
9698
}
99+
address := strings.Join([]string{hostname, port}, ":")
97100

98101
protocol := "tcp"
99102
if opts.UDP {

0 commit comments

Comments
 (0)