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

add working agent_auth to windows #181

Closed
wants to merge 1 commit into from

Conversation

gaelmuller
Copy link
Contributor

@gaelmuller gaelmuller commented Apr 7, 2014

Add agent_auth functionnality to Windows.

Note that this is the same level of functionnality currently provided on UNIX: there is no authentication, resulting in poor security.


This change is Reviewable

@awiddersheim
Copy link
Member

Cool. People have been asking for this quite a bit. It even passed the build tests. 👍

@mstarks01
Copy link
Contributor

You the man! Thanks for your efforts. I wish I hadn't spent that time last week on the psexec script to parse/copy windows agent keys. :) I'm looking forward to trying this. I assume I can just compile this and use it with 2.7 right?

@gaelmuller
Copy link
Contributor Author

Yes, it should work.

@jrossi
Copy link
Member

jrossi commented Apr 12, 2014

Sorry I have not gotten to review this yet. Looks good and makes use of the native SSL on windows.

Code make sense and it works. Was going to just merge it but I am worried about having to merge the work going on here and the work going on at #166 code: https://github.com/mweigel/ossec-hids/tree/authd_certificate_verify .

With both codes moving the same code we need to get some conversation going. So please chat guys what is the right way? One takes down the native SSL support on windows the other takes us more down the OpenSSL Path.

CC: @mweigel @ossec @gaelmuller

@jrossi jrossi added the win32 label Apr 12, 2014
@mstarks01
Copy link
Contributor

Making use of native SSL functionality where available makes a lot of sense. Let Microsoft deal with SSL maintenance and issues. My .02

@jrossi
Copy link
Member

jrossi commented Apr 14, 2014

@mstarks01 agree, but that means more code and more dev time and features need to be implemented twice. @mweigel @gaelmuller do you have any input, suggestions, ideas, hate for ssl, or ....... :)

@mweigel
Copy link
Contributor

mweigel commented Apr 14, 2014

Definitely advantages and disadvantages either way. Having separate clients does give people the flexibility to use solutions most appropriate for the given platform but at the cost of extra code. I don't know which is the right solution here but I don't think there would be too much of an issue merging my changes with the new client code here as they seem to be quite independent of each other (sorry if I've missed something).

I've made only small changes to ossec-authd currently and the default behaviour (no client verification) hasn't changed so I don't think there would be any issues interacting with this client but it would definitely need testing, which I'm happy to help with if needed. I most likely won't make any further changes to authd right now either as I don't want to change too much at once although I'm still keen on future enhancements.

Thanks guys.

@gaelmuller
Copy link
Contributor Author

I agree with @mweigel, there should be no problem merging both his changes and mine.

I chose to use native SSL support because I wanted the OSSEC agent to remain without external dependency (plus, use of openssl on Windows in not common).

@jrossi jrossi self-assigned this May 30, 2014
@jrossi jrossi added this to the ossec-hids-2.9 milestone May 30, 2014
@coonsmatthew
Copy link

I am testing ossec in our environment and one of the main issues we are running into is auto auth of clients. We have thousands of devices that will be connecting to ossec. The addition of agent-auth code to Windows clients is exactly what I am looking for! I am a security analyst, and don't have a ton of experience with coding per say. How can I incorporate this code into the ossec client windows binary? Thank You for your help!

@jrossi jrossi removed this from the ossec-hids-2.9 milestone Oct 20, 2014
@tkent
Copy link

tkent commented Oct 30, 2015

This feature would have saved me several hours over the past few days. Would really be great to see it merged in.

@aquerubin
Copy link
Contributor

The third parameter to OS_ConnectTCP() should be dropped.

@ghost
Copy link

ghost commented Apr 27, 2016

What is the status of this PR?

@ddpbsd
Copy link
Member

ddpbsd commented Apr 27, 2016

@ozonni IIRC, the changes in this PR don't work with the current tree. I think I had some changes that would enable this feature for the win32 port, but I don't remember the status.

@MagnusMWW
Copy link

MagnusMWW commented Aug 24, 2016

For anyone interested in building just the agent-auth.exe from the win-auth branch, you can just install a VM with CentOS6 or 7 and do the following (Other packages might be required, I did this on a CentOS6 with most development tools pre-installed):

yum install epel-release

yum install git mingw64-gcc

git clone https://github.com/SekoiaLab/ossec-hids

cd ossec-hids

git checkout -b win-auth origin/win-auth

cd src/win32

./gen_win.sh

cd ../win-pkg

/usr/bin/x86_64-w64-mingw32-gcc -o agent-auth.exe -Wall -DARGV0=\"agent-auth\" -DCLIENT -DWIN32 os_auth/agent_auth.c shared/*.c os_regex/*.c os_net/*.c os_crypto/md5/*.c win_service.c addagent/validate.c -Iheaders/ -I./ -lwsock32 -lsecur32

This should produce a working agent-auth.exe, without the dependency on specific directories or anything. Tested it, and you can run the tool stand-alone from anywhere, just copy the client.keys file to the ossec installation directory afterwards and it should be fine.

This might not be an option for everyone, but since we are re-packaging the OSSEC-agent in an MSI in my organization anyway, this turned out to be quite a nice solution for us. As @gaelmuller says, also remember that this version of the agent-auth.exe does not support any kind of authentication.

@soapergem
Copy link

Is this code ever going to be merged in? I found this from a comment on Server Fault. I want to automate the installation of OSSEC clients on Windows machines and it seems I need this agent-auth executable in order to do that. Alternatively, does anyone have an already compiled copy they could share?

@soapergem
Copy link

Also, I should mention that I tried following MagnusMWW's instructions (note that you have to add asterisks where Github added italics), and was able to compile the agent-auth.exe file, but when I run it, it just spits out this message: "This version of agent-auth.exe is not compatible with the version of Windows you're running. Check your computer's system information and the contact the software publisher."

@ddpbsd
Copy link
Member

ddpbsd commented Sep 10, 2016

Unfortunately it requires time and energy. Both are in short supply,
neither are free.

On Sep 9, 2016 2:38 PM, "soapergem" notifications@github.com wrote:

Is this code ever going to be merged in? I found this from a comment
http://serverfault.com/q/744116 on Server Fault. I want to automate the
installation of OSSEC clients on Windows machines and it seems I need this
agent-auth executable in order to do that. Alternatively, does anyone have
an already compiled copy they could share?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#181 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEwMtcpN0CKuCqDd2KU6orT3z5s-yhKkks5qoaeVgaJpZM4BwTrN
.

@MagnusMWW
Copy link

MagnusMWW commented Sep 10, 2016

@soapergem; Are you possibly trying to run the 64-bit binary that the instructions i posted will build on a 32-bit Windows system? You can adjust the process to instead build a 32-bit binary by substituting:
yum install git mingw64-gcc
with
yum install git mingw32-gcc
and
/usr/bin/x86-w32-mingw32-gcc -o agent-auth.exe -Wall -DARGV0=\"agent-auth\" -DCLIENT -DWIN32 os_auth/agent_auth.c shared/*.c os_regex/*.c os_net/*.c os_crypto/md5/*.c win_service.c addagent/validate.c -Iheaders/ -I./ -lwsock32 -lsecur32
with
/usr/bin/i686-w64-mingw32-gcc -o agent-auth.exe -Wall -DARGV0=\"agent-auth\" -DCLIENT -DWIN32 os_auth/agent_auth.c shared/*.c os_regex/*.c os_net/*.c os_crypto/md5/*.c win_service.c addagent/validate.c -Iheaders/ -I./ -lwsock32 -lsecur32

btw, I'm updating my reply above to use code markdown instead of the simple ">", to avoid those stars being stripped out and confusing anyone else. Good catch!

@snaow
Copy link
Contributor

snaow commented Sep 10, 2016

Hi guys,

I have being testing everything and works fine on 2.8.3, but it does not on ossec-hids/master.
I made it work on Wazuh fork, I think it is working properly, I also create new rules in the Makefile so we can generate the Windows installer which include agent-auth.exe.
Still pending implement the authentication.

Use development branch and run:

cd src && make TARGET=winagent

The installer ossec-win32-agent.exe generated is located on src/win32 folder.

Many thanks to @gaelmuller, @MagnusMWW and everyone here.

@ddpbsd
Copy link
Member

ddpbsd commented Sep 10, 2016

I got agent_auth.exe to compile, but it doesn't appear to do anything. Unfortunately I don't know how to do much debugging in windows, so any help would be appreciated.

@MagnusMWW
Copy link

MagnusMWW commented Sep 10, 2016

@ddpbsd: That's strange... What system did you try to run it on? I only have a Windows 7 Pro (x86_64) systems accessible to test on, but both the 32-bit and the 64-bit build works for me on those systems. Afraid that I'm not that seasoned in Windows application debugging myself either, sorry.

If you'd like, you could try my builds and see if they work diffrently (they shouldn't really, but maybe worth a try?).

ftp://kalasarn.se/pub/temp/agent-auth-x86.exe
ftp://kalasarn.se/pub/temp/agent-auth-x86_64.exe

When running, i just have to use these options when invoking: agent-auth-x86.exe -m <managerip>

@soapergem
Copy link

@MagnusMWW I tried downloading the files you posted on your FTP site, but the file transfers consistently fail. If it's not too much trouble, can you either check on that, or share them a different way? Thanks so much.

@snaow
Copy link
Contributor

snaow commented Sep 12, 2016

I uploaded a working agent-auth.exe, tested on Win10, Win7 and Win 2012 R2.

http://52.51.47.120:8000/agent-auth.exe
(Virustotal URL check)

@MagnusMWW
Copy link

@soapergem i see that @snaow beat me to it, but I've fixed the files now as well. Wrong permissions... ;)

@snaow
Copy link
Contributor

snaow commented Sep 13, 2016

Just trying to help @MagnusMWW :D

btw we also included "-P" option for using ossec-authd password protected wazuh/wazuh@6c7326d

Still everything on development! WIP!

PS: I am using the agent-auth.exe daily and it works really good, you don't know how happy I am registering agents on Windows with no external-tools needed haha

@MagnusMWW
Copy link

@snaow: I appreciate it! :)

The password-protection sounds promising. Think I'll give that a go. Thanks for the tip!

It really helps, doesn't it? We have a tricky situation where we need to deploy a lot of agents on Windows machines during tight change-windows, and being able to use agent-auth certainly is helping with that! :)

@soapergem
Copy link

soapergem commented Oct 21, 2016

So I've noticed that this Windows version of the agent-auth utility doesn't support the -v flag to supply a CA certificate. But I also see some comments back and forth about native SSL vs. OpenSSL. I confess I'm a novice when it comes to certificates and authentication, so can someone tell me: does this (windows) agent-auth utility handle the use of a certificate during authentication with the ossec-authd service? Even if it involves adding a certificate to Windows' store... would that work?

@igorgatis
Copy link

How long until this gets merged and make into a release?

@@ -20,6 +20,7 @@ ${MING_BASE}-gcc -o ossec-agent.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWI
${MING_BASE}-gcc -o ossec-agent-eventchannel.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 -DOSSECHIDS -DEVENTCHANNEL_SUPPORT icon.o os_regex/*.c os_net/*.c os_xml/*.c zlib-1.2.8/*.c config/*.c shared/*.c os_execd/*.c os_crypto/blowfish/*.c os_crypto/md5/*.c os_crypto/sha1/*.c os_crypto/md5_sha1/*.c os_crypto/shared/*.c rootcheck/*.c *.c -Iheaders/ -I./ -lwsock32 -lwevtapi
${MING_BASE}-gcc -o ossec-rootcheck.exe -Wall -DARGV0=\"ossec-rootcheck\" -DCLIENT -DWIN32 icon.o os_regex/*.c os_net/*.c os_xml/*.c config/*.c shared/*.c win_service.c rootcheck/*.c -Iheaders/ -I./ -lwsock32
${MING_BASE}-gcc -o manage_agents.exe -Wall -DARGV0=\"manage-agents\" -DCLIENT -DWIN32 -DMA os_regex/*.c zlib-1.2.8/*.c os_zlib.c shared/*.c os_crypto/blowfish/*.c os_crypto/md5/*.c os_crypto/shared/*.c addagent/*.c -Iheaders/ -I./ -lwsock32 -lshlwapi
${MING_BASE}-gcc -o agent-auth.exe -Wall -DARGV0=\"agent-auth\" -DCLIENT -DWIN32 os_auth/agent_auth.c shared/*.c os_regex/*.c os_net/*.c os_crypto/md5/*.c win_service.c addagent/validate.c -Iheaders/ -I./ -lwsock32 -lsecur32

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os_auth/agent_auth.c -> agent_auth.c
win_service.c -> win32/win_service.c

@stevenmdatt
Copy link

Is agent-auth now working correctly for automation purposes on windows?

Also @snaow your link doesn't work anymore, just FYI.

@snaow
Copy link
Contributor

snaow commented Jan 15, 2018

@stevenmdatt agent-auth is working properly in Wazuh fork, I've been using it every day since a few months ago.

You can download the release .msi and extract the agent-auth.exe tool from there:

It should be compatible with OSSEC 2.8/2.9.

@ddpbsd
Copy link
Member

ddpbsd commented Jan 15, 2018

There's an agent-auth.exe created when compiling the windows version. Does it work?

@JLeClerc
Copy link

+1 to this PR. It would be very valuable to have this merged in.

@ddpbsd
Copy link
Member

ddpbsd commented Jul 11, 2018

@JLeClerc Does it work?

@atomicturtle
Copy link
Member

Closing this one out since we finished implementing this in another PR. Thanks for everyones contributions on this PR. Much appreciated everyone!

You can find this functionality in OSSEC 3.0.0, with enhancements already on the way for 3.0.1

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

Successfully merging this pull request may close these issues.

None yet