jpillora / jpillora/chisel

When a port is already assigned to another process and I run the chisel to listen on that port, chisel crashes instead of showing the port open error

Open
#211 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

need-more-info
Dominant language
Go
Stars
16.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

When port 80 is already binded to another application but I ran chisel to listen on that port I encounter:

C:\WINDOWS\system32>"C:\Users\kevin\Downloads\chisel_1.7.1_windows_amd64\chisel.exe" server --port 80 --socks5 --reverse
2020/11/07 19:23:34 server: Reverse tunnelling enabled
2020/11/07 19:23:34 server: Fingerprint 2f:52:47:ed:8b:31:2e:b8:02:e2:7f:92:94:65:e8:62
panic: runtime error: invalid memory address or nil pointer dereference
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x28 pc=0x692914]

goroutine 8 [running]:
net/http.(*onceCloseListener).close(...)
        net/http/server.go:3371
sync.(*Once).doSlow(0xc000172490, 0xc000045c00)
        sync/once.go:66 +0xf7
sync.(*Once).Do(...)
        sync/once.go:57
net/http.(*onceCloseListener).Close(0xc000172480, 0x0, 0x0)
        net/http/server.go:3367 +0x7e
panic(0x835d80, 0xbc38a0)
        runtime/panic.go:969 +0x176
net/http.(*onceCloseListener).Accept(0xc000172480, 0xc00001e0d8, 0x82bca0, 0xbc37e0, 0x8a3300)
        <autogenerated>:1 +0x39
net/http.(*Server).Serve(0xc00014e1c0, 0x0, 0x0, 0x0, 0x0)
        net/http/server.go:2937 +0x26e
github.com/jpillora/chisel/share/cnet.(*HTTPServer).GoServe.func1(0x0, 0x0)
        github.com/jpillora/chisel/share/cnet/http_server.go:53 +0x46
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc000172450, 0xc000005ec0)
        golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208/errgroup/errgroup.go:57 +0x62
created by golang.org/x/sync/errgroup.(*Group).Go
        golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208/errgroup/errgroup.go:54 +0x71

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at share/cnet/http_server.go:53 and reproduce the Windows server startup with port 80 occupied by another process. Trace how the listener error reaches net/http.Server.Serve; done means chisel reports the port-open failure instead of panicking, with the existing reproduction no longer producing the shown stack trace.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.