HavocFramework / Havoc

The Havoc Framework.
https://havocframework.com
GNU General Public License v3.0
6.72k stars 949 forks source link

[Teamserver-Client--Bug]: Error when running Havoc server with Systemd #364

Closed gobiursus closed 1 year ago

gobiursus commented 1 year ago

Contact Details

No response

What happened?

I am trying to run Havoc team server with Systemd as a specific user but not succeed. Here's are my systemd file and environment information: Error:

Havoc/cmd.glob..func2(0x1303600?, {0xd45e59?, 0x5?, 0x5?})
        /opt/havoc/teamserver/cmd/server.go:38 +0x10a
github.com/spf13/cobra.(*Command).execute(0x1303600, {0xc00008df40, 0x5, 0x5})
        /opt/havoc/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0x1303380)
        /opt/havoc/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        /opt/havoc/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
main.main()
        /opt/havoc/teamserver/main.go:7 +0x25

My systemd file under /etc/systemd/system/havoc.service:

 [Unit]
Description=Havoc C2 Team Server
After=network.target 
Wants=network.target 

[Service]
User=havoc
Group=havoc
ExecStart=/opt/havoc/havoc server --profile /opt/havoc/profiles/havoc.yaotl -v --debug &
ExecStop=/usr/bin/pkill --signal SIGINT -f 'havoc'

[Install]
WantedBy=multi-user.target

The ownership of everything under /opt/havoc belongs to havoc:havoc OS:

root@havoc:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:    12
Codename:   bookworm

root@havoc:~# go version
go version go1.19.8 linux/amd64

root@havoc:~# gcc -v
gcc version 12.2.0 (Debian 12.2.0-14)

Python version: Python3.11(Python3.10 does not available on Debian 12)

Did You Do a Pull First?

Latest (You performed a pull first)

Did You Try With the Dev Branch?

Yes (You tried using the dev branch but the problem persist)

Relevant log output

No response

Did You Read Over Your Issue First?

sonsu commented 1 year ago

i had similar issue (errors) when creating service for the root user. It helped to change service WorkingDirectory to havoc folder

...

[Service]
Type=simple
Restart=on-failure
RestartSec=3
User=root
ExecStart=/opt/havoc/havoc server --profile /opt/havoc/profiles/c2.yaotl -v --debug &
ExecStop=/usr/bin/pkill --signal SIGINT -f 'havoc'
WorkingDirectory=/srv/Havoc

...
gobiursus commented 1 year ago

i had similar issue (errors) when creating service for the root user. It helped to change service WorkingDirectory to havoc folder

...

[Service]
Type=simple
Restart=on-failure
RestartSec=3
User=root
ExecStart=/opt/havoc/havoc server --profile /opt/havoc/profiles/c2.yaotl -v --debug &
ExecStop=/usr/bin/pkill --signal SIGINT -f 'havoc'
WorkingDirectory=/srv/Havoc

...

Thank you, this solves my problem!

gobiursus commented 1 year ago

@sonsu solved my problem. Issue solved and closed.