hupe1980 / fakedns

Tiny DNS proxy for Penetration Testers and Malware Analysts
MIT License
3 stars 0 forks source link

fakedns crashing on Raspberry Pi #1

Closed lindenaar closed 2 years ago

lindenaar commented 2 years ago

Hi,

I am trying fakedns on a RaspberyPi (armv6) binary but it crashes every few minutes with the following output:

fatal error: concurrent map writes fatal error: concurrent map writes goroutine 40 [running]: runtime.throw({0x32df4a, 0x15})

011/opt/hostedtoolcache/go/1.17.5/x64/src/runtime/panic.go:1198 +0x5c fp=0xd16e1c sp=0xd16e08 pc=0x45ee0

runtime.mapassign_faststr(0x2f3c20, 0xd1a820, {0xd86360, 0x15})

011/opt/hostedtoolcache/go/1.17.5/x64/src/runtime/map_faststr.go:294 +0x3e4 fp=0xd16e50 sp=0xd16e1c pc=0x215a4

github.com/hupe1980/fakedns.(*Rebind).Inc(...)

011/home/runner/work/fakedns/fakedns/rebind.go:24

github.com/hupe1980/fakedns.(*handler).ServeDNS(0xd2e300, {0x3a1498, 0xd943c0}, 0xd96460)

011/home/runner/work/fakedns/fakedns/handler.go:41 +0x398 fp=0xd16f54 sp=0xd16e50 pc=0x26da0c

github.com/miekg/dns.(*Server).serveDNS(0xd5a140, {0xd80200, 0x32, 0x200}, 0xd943c0)

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:651 +0x500 fp=0xd16fa8 sp=0xd16f54 pc=0x239448

github.com/miekg/dns.(*Server).serveUDPPacket(0xd5a140, 0xd42520, {0xd80200, 0x32, 0x200}, {0x3a0578, 0xd184c8}, 0xd825e0, {0x0, 0x0})

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:591 +0x18c fp=0xd16fc4 sp=0xd16fa8 pc=0x238f10

runtime.goexit()

011/opt/hostedtoolcache/go/1.17.5/x64/src/runtime/asm_arm.s:838 +0x4 fp=0xd16fc4 sp=0xd16fc4 pc=0x76f64

created by github.com/miekg/dns.(*Server).serveUDP

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:521 +0x3ac

goroutine 1 [IO wait]: internal/poll.runtime_pollWait(0x66cfbb28, 0x72)

011/opt/hostedtoolcache/go/1.17.5/x64/src/runtime/netpoll.go:234 +0xac

internal/poll.(*pollDesc).wait(0xd385b4, 0x72, 0x0)

011/opt/hostedtoolcache/go/1.17.5/x64/src/internal/poll/fd_poll_runtime.go:84 +0x30

internal/poll.(*pollDesc).waitRead(...)

011/opt/hostedtoolcache/go/1.17.5/x64/src/internal/poll/fd_poll_runtime.go:89

internal/poll.(*FD).ReadMsg(0xd385a0, {0xd76000, 0x200, 0x200}, {0xd848c0, 0x20, 0x20}, 0x0)

011/opt/hostedtoolcache/go/1.17.5/x64/src/internal/poll/fd_unix.go:250 +0x264

net.(*netFD).readMsg(0xd385a0, {0xd76000, 0x200, 0x200}, {0xd848c0, 0x20, 0x20}, 0x0)

011/opt/hostedtoolcache/go/1.17.5/x64/src/net/fd_posix.go:68 +0x58

net.(*UDPConn).readMsg(0xd184c8, {0xd76000, 0x200, 0x200}, {0xd848c0, 0x20, 0x20})

011/opt/hostedtoolcache/go/1.17.5/x64/src/net/udpsock_posix.go:62 +0x58

net.(*UDPConn).ReadMsgUDP(0xd184c8, {0xd76000, 0x200, 0x200}, {0xd848c0, 0x20, 0x20})

011/opt/hostedtoolcache/go/1.17.5/x64/src/net/udpsock.go:144 +0x58

github.com/miekg/dns.ReadFromSessionUDP(0xd184c8, {0xd76000, 0x200, 0x200})

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/udp.go:42 +0x70

github.com/miekg/dns.(*Server).readUDP(0xd5a140, 0xd184c8, 0x77359400)

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:687 +0xf4

github.com/miekg/dns.defaultReader.ReadUDP({0xd5a140}, 0xd184c8, 0x77359400)

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:174 +0x34

github.com/miekg/dns.(*Server).serveUDP(0xd5a140, {0x3a0578, 0xd184c8})

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:501 +0x244

github.com/miekg/dns.(*Server).ListenAndServe(0xd5a140)

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:330 +0x54c

github.com/hupe1980/fakedns.(*FakeDNS).ListenAndServe(0xd26220, {0x7edb7de3, 0xd}, {0x7edb7df7, 0x3})

011/home/runner/work/fakedns/fakedns/fakedns.go:76 +0x220

main.main.func1(0xd54420, {0xd52420, 0x1, 0xc})

011/home/runner/work/fakedns/fakedns/cmd/main.go:73 +0x3a8

github.com/spf13/cobra.(*Command).execute(0xd54420, {0xd1c388, 0xc, 0xd})

011/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:856 +0x66c

github.com/spf13/cobra.(*Command).ExecuteC(0xd54420)

011/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:974 +0x414

github.com/spf13/cobra.(*Command).Execute(...)

011/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:902

main.main()

011/home/runner/work/fakedns/fakedns/cmd/main.go:90 +0x584

goroutine 39 [running]:

011goroutine running on other thread; stack unavailable

created by github.com/miekg/dns.(*Server).serveUDP

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:521 +0x3ac

goroutine 39 [running]: runtime.throw({0x32df4a, 0x15})

011/opt/hostedtoolcache/go/1.17.5/x64/src/runtime/panic.go:1198 +0x5c fp=0xd17e1c sp=0xd17e08 pc=0x45ee0

runtime.mapassign_faststr(0x2f3c20, 0xd1a820, {0xd4a480, 0x15})

011/opt/hostedtoolcache/go/1.17.5/x64/src/runtime/map_faststr.go:294 +0x3e4 fp=0xd17e50 sp=0xd17e1c pc=0x215a4

github.com/hupe1980/fakedns.(*Rebind).Inc(...)

011/home/runner/work/fakedns/fakedns/rebind.go:24

github.com/hupe1980/fakedns.(*handler).ServeDNS(0xd2e300, {0x3a1498, 0xd2e740}, 0xd38a50)

011/home/runner/work/fakedns/fakedns/handler.go:41 +0x398 fp=0xd17f54 sp=0xd17e50 pc=0x26da0c

github.com/miekg/dns.(*Server).serveDNS(0xd5a140, {0xd80000, 0x32, 0x200}, 0xd2e740)

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:651 +0x500 fp=0xd17fa8 sp=0xd17f54 pc=0x239448

github.com/miekg/dns.(*Server).serveUDPPacket(0xd5a140, 0xd42520, {0xd80000, 0x32, 0x200}, {0x3a0578, 0xd184c8}, 0xd825d0, {0x0, 0x0})

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:591 +0x18c fp=0xd17fc4 sp=0xd17fa8 pc=0x238f10

runtime.goexit()

011/opt/hostedtoolcache/go/1.17.5/x64/src/runtime/asm_arm.s:838 +0x4 fp=0xd17fc4 sp=0xd17fc4 pc=0x76f64

created by github.com/miekg/dns.(*Server).serveUDP

011/home/runner/go/pkg/mod/github.com/miekg/dns@v1.1.45/server.go:521 +0x3ac

the command used to start fakedns is:

fakedns --addr=10.10.10.10:53 --net=udp --ipv4=11.11.11.11 --ipv6= --mx=mail.my.net --text=Internally redirected --upstream= --ttl=60 --rebind-v4= --rebind-v6= --rebind-threshold=1

the process is running under systemd and restarting automatically.

the only DNS client is a Cisco router.

any clue where to look at?

regards,

Frederik

hupe1980 commented 2 years ago

A mutex was missing and you cannot call the program with such flags: --rebind-v4= --rebind-v6= This would be right: fakedns * --addr=10.10.10.10:53 --net=udp --ipv4=11.11.11.11 --mx=mail.my.net --text=Internally redirected --ttl=60