Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to run as a windows service #70

Closed
ChrisPritchard opened this issue Oct 20, 2022 · 13 comments
Closed

Ability to run as a windows service #70

ChrisPritchard opened this issue Oct 20, 2022 · 13 comments

Comments

@ChrisPritchard
Copy link
Contributor

In a few 'engagements' I have needed to replace a windows service binary to hijack the account running the service. reverse_ssh golang clients compiled for windows do not respond to the start/status requests made by the windows service system, so do not start properly and are quickly killed.

To get around this, I have built basic .NET windows service projects that simply call the reverse_ssh binary on start, but this is a bit annoying.

The x/sys golang library suports creating windows services - this issue proposes that this functionality be built into the windows client build so that the windows client can serve both as a standalone executable and a windows service as needed - there is a .IsWindowsService method in this library that should be able to change the operating mode based on context

@ChrisPritchard
Copy link
Contributor Author

ChrisPritchard commented Oct 20, 2022

Existing state of this shamblesdelightful example of a project:
no-service-for-you

@NHAS
Copy link
Owner

NHAS commented Oct 20, 2022

The project already uses what you describe to determine if its in a windows service.

image

image

@NHAS
Copy link
Owner

NHAS commented Oct 20, 2022

Whats missing seems to be the start command

@ChrisPritchard
Copy link
Contributor Author

Oh. Alright ill tweak that and test it

@NHAS
Copy link
Owner

NHAS commented Oct 20, 2022

For some additional info, rssh can install itself as a service, and I have used it there. So Im not sure what the issue is here.

@ChrisPritchard
Copy link
Contributor Author

The issue is described in the original comment, where you are hijacking an existing service to assume its identity. That is, for example, you have write access over a binary or a binary's location used by a service that isn't presently running or you can stop and start. You replace the binary then start the service - at present this will fail with the message in the prior screenshot.

@NHAS
Copy link
Owner

NHAS commented Oct 20, 2022

Hm, thanks.

I think it may be due to this: golang/go#44921

As I cant spot anything that would make rssh unable to communicate as a service otherwise

@ChrisPritchard
Copy link
Contributor Author

Hmm okay. Ill do some testing - see if it functions properly with a low privilege service

@NHAS
Copy link
Owner

NHAS commented Oct 20, 2022

Please try with the unstable branch, I've just bumped the modules

@ChrisPritchard
Copy link
Contributor Author

Just tried and it starts fine now, ta. Working well with nt authority\system coming through for a service run as LocalSystem. However, it won't stop properly:
no-service-stop
Somewhat debatable if this is an issue - a service that won't stop is possibly suspicious, but stopping a rssh client is not really what you want anyway

@ChrisPritchard
Copy link
Contributor Author

It can still be stopped by killing the client from the rssh catcher interface. I'm fine to close this issue, ta.

@NHAS
Copy link
Owner

NHAS commented Oct 20, 2022

Ah yes, actually thats a bug funny enough. The break statement is breaking the switch rather than the outer for loop

@NHAS
Copy link
Owner

NHAS commented Oct 20, 2022

This change is now on unstable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants