Create alert event view 4728 add users in groups

Hi,I need to generate alerts when a user is added to a group within AD.

Hey @rodrigo_ferrari,

You shouldnā€™t have to create this alert as itā€™s already built-in as part of our UBA incident type.
If you have configured Active Directory to send security logs to InsightIDR then that alert type should trigger automatically each time the privileges of an account are escalated to an AD security group with administrator rights.
To add your AD security logs to InsightIDR, please follow this guide: https://docs.rapid7.com/insightidr/active-directory

Here is the list of our built-in alerts: Alerts | InsightIDR Documentation

Thanks,
Oli

And using this query: where(ā€œsource_json.eventCodeā€ = ā€œ4728ā€) on your Active Directory Security Logs will allow you to create pattern detection alerts.

In the log search, I just typed 4728 and selected the AD logs, returned some events.
Now it is possible to make a query with ā€œeventCodeā€: 4728 + ā€œgroup_scopeā€: ā€œSECURITY_ENABLED_GLOBAL_GROUPā€ + group ā€œ:ā€ XXXXX ",

ā€œgroupā€: "XXXX,
ā€œgroup_scopeā€: ā€œSECURITY_ENABLED_GLOBAL_GROUPā€,
ā€œgroup_domainā€: ā€œdomainā€,
ā€œsource_jsonā€: {
ā€œeventCodeā€: 4728,

You can use the following query:

where(source_json.eventCode=4728 AND group_scope="SECURITY_ENABLED_GLOBAL_GROUP" and group="test_group")

You can find more information about queries here:
https://docs.rapid7.com/insightidr/build-a-query

Hi,
I tried with this query but it didnā€™t work.

ā€œYour query is invalidā€

ItĀ“s work

I forgot ( )

Sorry

Tks

Can I also get to distribution group or do I need to enable auditing in AD?

Hey @rodrigo_ferrari

Yes you should be able to track this Distribution Group Management event ID (4746) by ticking ā€œSend Unparsed Dataā€ on your AD event source. Having this enabled will increase the amount of data you send to IDRā€¦Have a read through here.

Screenshot 2021-03-25 at 20.58.11

Thanks,
Oli

This is how I have done it:(example)

action=ā€œMEMBER_ADDED_TO_SECURITY_GROUPā€ AND group=ā€œenterprise adminsā€

1 Like

Hi Andry,

I will test and soon I will report.

Tks

Hi Andry,

I created it that way, but it didnā€™t return any results.

Can I put multiple groups in the same query?

action=ā€œMEMBER_ADDED_TO_SECURITY_GROUPā€ AND group_scope=ā€œSECURITY_ENABLED_DOMAIN_LOCAL_GROUPā€ AND group=ā€œaccount operatorsā€ AND group=ā€œBackup Operatorsā€ AND group="source_json.eventCode=ā€˜4732ā€™

Hi Rodrigo,

if you have an example log line such as

{
ā€œtimestampā€: ā€œ2021-01-12T16:01:30.544Zā€,
ā€œsource_userā€: ā€œjsmith adminā€,
ā€œtarget_userā€: ā€œjsmith adminā€,
ā€œsource_user_domainā€: ā€œr7mslab.localā€,
ā€œtarget_user_domainā€: ā€œr7mslab.localā€,
ā€œactionā€: ā€œMEMBER_ADDED_TO_SECURITY_GROUPā€,
ā€œsource_accountā€: ā€œjsmith_adminā€,
ā€œtarget_accountā€: ā€œcn=jsmith admin,ou=admin_accounts,ou=administration,ou=r7mslab,dc=r7mslab,dc=localā€,
ā€œgroupā€: ā€œzonepolicytestā€,
ā€œgroup_scopeā€: ā€œSECURITY_ENABLED_GLOBAL_GROUPā€,
ā€œgroup_domainā€: ā€œr7mslabā€,
ā€œsource_jsonā€: {
ā€œeventCodeā€: 4728,
ā€œcomputerNameā€: ā€œR7MSLAB-DC01.R7MSLAB.localā€,
ā€œinsertionStringsā€: [
ā€œCN=jsmith admin,OU=Admin_Accounts,OU=Administration,OU=R7MSLAB,DC=R7MSLAB,DC=localā€,
ā€œS-1-5-21-2587591228-874857867-111615119-1108ā€,
ā€œZonePolicyTestā€,
ā€œR7MSLABā€,
ā€œS-1-5-21-2587591228-874857867-111615119-1125ā€,
ā€œS-1-5-21-2587591228-874857867-111615119-1108ā€,
ā€œjsmith_adminā€,
ā€œR7MSLABā€,
ā€œ0x1dcae44ā€,
ā€œ-ā€
],
ā€œtimeGeneratedā€: ā€œ20210112160130.544610-000ā€
}
}

and you wanted to have multiple groups you would build your query like

ā€œactionā€ = ā€œMEMBER_ADDED_TO_SECURITY_GROUPā€ AND (ā€œgroupā€ = ā€œzonepolicytestā€ OR group=xyz OR ā€œgroupā€=/.*/ )

Its important to use parentheses when using ANDā€™s and ORā€™s together.

A AND (B OR C)

Note in my example I have ā€œgroupā€=/.*/ this is regex notation for ā€œany character any number of timesā€ so it will include all results where the key ā€œgroupā€ is equal to anything.

In order for your query to work it would need to be something like

action=ā€œMEMBER_ADDED_TO_SECURITY_GROUPā€ AND group_scope=ā€œSECURITY_ENABLED_DOMAIN_LOCAL_GROUPā€ AND (group=ā€œaccount operatorsā€ OR group=ā€œBackup Operatorsā€)

if you wanted to also include the source_json.eventCode you would include that as a key comparison like

source_json.eventCode=4732 not group="source_json.eventCode ā€¦ . . "

David

1 Like

In my first reply the ā€œwhereā€ did not get copied
where(action=ā€œMEMBER_ADDED_TO_SECURITY_GROUPā€ AND group=ā€œenterprise adminsā€)

yes, adding another group should work. Make sure you pull from the correct logs. Active Directory Admin Activity in my case.

1 Like

Hi Rodrigo,

I do have a couple of things to add to what Andy and David mentioned that I think might help you.

First, we have a series of blogs on Log Search that you might find useful as a resource. I think that they might answer some of your questions: The first one is at Your Guide to Log Search in Rapid7's SIEM Solution, InsightIDR. From it, you can continue to the next two blogs in the series.

Next, as David mentioned, when you are running your query, you can group inside the where () statement. That is, you could say:

where(action=ā€œMEMBER_ADDED_TO_SECURITY_GROUPā€ AND group_scope=ā€œSECURITY_ENABLED_DOMAIN_LOCAL_GROUPā€ AND (group=ā€œaccount operatorsā€ OR group=ā€œbackup operatorsā€ OR group="my domain local groupā€™))

Another way to run this same search is to switch into regular expression. That is explained here: Using Regular Expression to Expand Your Log Search Options. A query using regular expression would use the pipe ("|") to replace the OR quantifiers and would look like this:

where(action=ā€œMEMBER_ADDED_TO_SECURITY_GROUPā€ AND ā€œgroup_scopeā€ = ā€œSECURITY_ENABLED_DOMAIN_LOCAL_GROUPā€ AND group=/backup operators|account operators|lab - domain local security group/i)

Also, Log Search is case sensitive by default, so when you specify your groups, you either have to use the Loose Search feature, Loose Search | InsightIDR Documentation, or use regular expression and specify that you want a case-insensitive search with the lowercase ā€œiā€, or just type them in lower case since that is how they always show up in Log Search.

In other words, youā€™ll have better luck if you use OR instead of AND for the ā€œgroupā€ field, and also either specify either a case-insensitive search or just use the same case that you see in Log Search.

I hope this all makes sense and helps you with your searching!

Teresa

3 Likes