Jump to content

C2 - Error starting SSH server: listen tcp 0.0.0.0:2022: bind: address already in use


NickBeanDNB

Recommended Posts

Okay, I saved it and ran the following commands, but still showing an error, so I know I messed up somewhere. (Ubuntu 22.04.1 LTS)
 

sudo systemctl daemon-reload
sudo systemctl enable cloudc2.service
sudo systemctl start cloudc2.service
sudo systemctl status cloudc2.service

Active: failed (Result: exit-code) since Wed 2024-01-17 17:12:22 UTC; 11s ago
    Process: 11402 ExecStart=/usr/local/bin/c2-3.3.0_amd64_linux -hostname x -https -db /var/cloudc2/c2.db (code=exited, status=1/FAILURE)

Jan 17 17:12:22 ip-x systemd[1]: Started Hak5 Cloud C2.
Jan 17 17:12:22 ip-x c2-3.3.0_amd64_linux[11411]: [*] Initializing Hak5 Cloud C2 v3.3.0
Jan 17 17:12:22 ip-x c2-3.3.0_amd64_linux[11411]: [*] Hostname: x
Jan 17 17:12:22 ip-x c2-3.3.0_amd64_linux[11411]: [*] DB Path: /var/cloudc2/c2.db
Jan 17 17:12:22 ip-x c2-3.3.0_amd64_linux[11411]: [*] Validating License
Jan 17 17:12:22 ip-x c2-3.3.0_amd64_linux[11411]: [*] License Valid
Jan 17 17:12:22 ip-x c2-3.3.0_amd64_linux[11411]: [!] Error starting SSH server: listen tcp 0.0.0.0:2022: bind: address already in use
Jan 17 17:12:22 ip-x systemd[1]: cloudc2.service: Main process exited, code=exited, status=1/FAILURE
Jan 17 17:12:22 ip-x systemd[1]: cloudc2.service: Failed with result 'exit-code'.
~


 
Link to comment
Share on other sites

Regarding

1 hour ago, NickBeanDNB said:

Jan 17 17:12:22 ip-x c2-3.3.0_amd64_linux[11411]: [!] Error starting SSH server: listen tcp 0.0.0.0:2022: bind: address already in use

you need to check and verify what I said in the beginning of this thread when getting that error. I.e. you can't have other things running on the VPS on port 2022 at the same time as C2 (or multiple instances of C2, or anything else that might use port 2022).

Check your running processes (ps ax) and/or what ports that are used by running processes ( sudo ss -tulpn | grep 2022 or sudo netstat -tulpn | grep 2022 )

Link to comment
Share on other sites

You are right, I think 2 instances are running somehow. Also, I did not check my processes earlier when you mentioned it. Thank you again for your help.

ubuntu@ip-X:~$ sudo ss -tulpn | grep 2022
tcp   LISTEN 0      4096                                *:2022            *:*    users:(("c2-3.3.0_amd64_",pid=10519,fd=7))
ubuntu@ip-X:~$ sudo netstat -tulpn | grep 2022
tcp6       0      0 :::2022                 :::*                    LISTEN      10519/./c2-3.3.0_am 

Link to comment
Share on other sites

  10510 ?        S      0:00 sudo ./c2-3.3.0_amd64_linux -hostname X -https
  10511 ?        Ss     0:00 sudo ./c2-3.3.0_amd64_linux -hostname X -https
  10512 ?        Sl     0:00 ./c2-3.3.0_amd64_linux -hostname X -https
  10519 ?        Tl     0:00 ./c2-3.3.0_amd64_linux -hostname X -https

Link to comment
Share on other sites

1 hour ago, dark_pyrro said:

(if it's not a result of you manually starting C2 in a specific session without reboot)

Let's say that is what I did. What would be the correct process to resolve it?

Also, seeking to understand here, if I were to remove the CloudC2 directory and database file(s), reboot, and then manually run C2 again, would it start?

Link to comment
Share on other sites

4 minutes ago, NickBeanDNB said:

Let's say that is what I did. What would be the correct process to resolve it?

If you have a C2 service set up and you started C2 manually in parallel to that, then a reboot should solve it (i.e. the manually started C2 instance won't be started on a reboot, only the configured service).

5 minutes ago, NickBeanDNB said:

if I were to remove the CloudC2 directory and database file(s), reboot, and then manually run C2 again, would it start?

The service wouldn't start if the files (binary, db, and such) isn't located were the service file says they should be located. Manually starting C2 shouldn't be an issue, but it would create a new database if not using any existing one.

Link to comment
Share on other sites

I removed the db file and reran the command without https and I can access the WebUI again. I had to reset it up from scratch, but hey, I am happy to be here, lol. Thanks for your help and walking me though this. I really appreciate your time and I know you didn't have to. I hope the rest of your day goes well.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...