Problems collecting the Windows Event ID 4698

380 views
Skip to first unread message

Cesar Fidel

unread,
Jul 2, 2023, 4:06:10 PM7/2/23
to Wazuh mailing list
Hello Wazuh community,

I'm trying to collect an event about scheduled tasks on Windows endpoints (event ID 4698), but it keeps failing, so I need to ask for help.

I have added this rule to my file:

<group name="windows,windows_security,">
  <rule id="100004" level="5">
    <if_sid>60001</if_sid>
    <field name="win.system.eventID">^4698$</field>
    <options>no_full_log</options>
    <description>A scheduled task was created.</description>
  </rule>
</group>

02-07-2023_15-05-06.png

But every time I fire the event, the alert doesn't reach "alerts.json, alerts.log or archives.json" and I don't know why.

Thanks, in any case, have a great day.

Daniel Sappa

unread,
Jul 2, 2023, 10:39:01 PM7/2/23
to Wazuh mailing list
Hi Cesar
Does this happen only with this rule?
Does are you try to test the rule using wazuh-logtest?
maybe there is some rule that overlaps with the one you created.

Daniel Sappa

unread,
Jul 3, 2023, 11:03:13 AM7/3/23
to Wazuh mailing list
Sure, Cesar!
First of all I would like to clarify that at this moment we are working to be able to test the Windows Events directly with the logtest, but to be able to do this it is necessary to make some modifications.

This first change enables logtest to interpret json messages for Windows events.
https://github.com/wazuh/wazuh/issues/13715#issuecomment-1151177227
If you have a problem with this let me know.

After this change you will be able to send the encapsulated events like this:
test.json:

{
      "win": {
        "eventdata": {
          "subjectLogonId": "0x3e7",
          "subjectDomainName": "WORKGROUP",
          "targetLinkedLogonId": "0x0",
          "impersonationLevel": "%%1833",
          "authenticationPackageName": "Negotiate",
          "targetLogonId": "0x3e7",
          "logonProcessName": "Advapi",
          "logonGuid": "{00000000-0000-0000-0000-000000000000}",
          "targetUserName": "SYSTEM",
          "keyLength": "0",
          "elevatedToken": "%%1842",
          "subjectUserSid": "S-1-5-18",
          "processId": "0x2a8",
          "processName": "C:\\\\Windows\\\\System32\\\\services.exe",
          "targetDomainName": "NT AUTHORITY",
          "targetUserSid": "S-1-5-18",
          "virtualAccount": "%%1843",
          "logonType": "5",
          "subjectUserName": "DESKTOP-A4542IQ$"
        },
        "system": {
          "eventID": "4624",
          "keywords": "0x8020000000000000",
          "providerGuid": "{54849625-5478-4994-a5ba-3e3b0328c30d}",
          "level": "0",
          "channel": "Security",
          "opcode": "0",
          "message": "\"An account was successfully logged on.\r\n\r\nSubject:\r\n\tSecurity ID:\t\tS-1-5-18\r\n\tAccount Name:\t\tDESKTOP-A4542IQ$\r\n\tAccount Domain:\t\tWORKGROUP\r\n\tLogon",
          "version": "2",
          "systemTime": "2023-06-26T23:23:16.6608061Z",
          "eventRecordID": "11469",
          "threadID": "2460",
          "computer": "DESKTOP-A4542IQ",
          "task": "12544",
          "processID": "700",
          "severityValue": "",
          "providerName": "Microsoft-Windows-Security-Auditing"
        }
      }
}

here you can see the EventID which in your case would be 4698
using this procedure you can see an output like this
The tr command replaces all newlines with single spaces because logtest interprets each event on a single line. 

wazuh-test:/var/ossec/bin# cat ~/logon-event.json | tr '\n' ' ' | ./wazuh-logtest
Starting wazuh-logtest v4.5.0
Type one log per line


**Phase 1: Completed pre-decoding.

**Phase 2: Completed decoding.
name: 'json'
win.eventdata.authenticationPackageName: 'Negotiate'
win.eventdata.elevatedToken: '%%1842'
win.eventdata.impersonationLevel: '%%1833'
win.eventdata.keyLength: '0'
win.eventdata.logonGuid: '{00000000-0000-0000-0000-000000000000}'
win.eventdata.logonProcessName: 'Advapi'
win.eventdata.logonType: '5'
win.eventdata.processId: '0x2a8'
win.eventdata.processName: 'C:\\Windows\\System32\\services.exe'
win.eventdata.subjectDomainName: 'WORKGROUP'
win.eventdata.subjectLogonId: '0x3e7'
win.eventdata.subjectUserName: 'DESKTOP-A4542IQ$'
win.eventdata.subjectUserSid: 'S-1-5-18'
win.eventdata.targetDomainName: 'NT AUTHORITY'
win.eventdata.targetLinkedLogonId: '0x0'
win.eventdata.targetLogonId: '0x3e7'
win.eventdata.targetUserName: 'SYSTEM'
win.eventdata.targetUserSid: 'S-1-5-18'
win.eventdata.virtualAccount: '%%1843'
win.system.channel: 'Security'
win.system.computer: 'DESKTOP-A4542IQ'
win.system.eventID: '4624'
win.system.eventRecordID: '11469'
win.system.keywords: '0x8020000000000000'
win.system.level: '0'
win.system.message: '"An account was successfully logged on.

Subject:
Security ID: S-1-5-18
Account Name: DESKTOP-A4542IQ$
Account Domain: WORKGROUP
Logon ID: 0x3E7

Logon Information:
Logon Type: 5
Restricted Admin Mode: -
Virtual Account: No
Elevated Token: Yes

Impersonation Level: Impersonation

New Logon:
Security ID: S-1-5-18
Account Name: SYSTEM
Account Domain: NT AUTHORITY
Logon ID: 0x3E7
Linked Logon ID: 0x0
Network Account Name: -
Network Account Domain: -
Logon GUID: {00000000-0000-0000-0000-000000000000}

Process Information:
Process ID: 0x2a8
Process Name: C:\Windows\System32\services.exe

Network Information:
Workstation Name: -
Source Network Address: -
Source Port: -

Detailed Authentication Information:
Logon Process: Advapi  
Authentication Package: Negotiate
Transited Services: -
Package Name (NTLM only): -
Key Length: 0

This event is generated when a logon session is created. It is generated on the computer that was accessed.

The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe.

The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network).

The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on.

The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases.

The impersonation level field indicates the extent to which a process in the logon session can impersonate.

The authentication information fields provide detailed information about this specific logon request.
- Logon GUID is a unique identifier that can be used to correlate this event with a KDC event.
- Transited services indicate which intermediate services have participated in this logon request.
- Package name indicates which sub-protocol was used among the NTLM protocols.
- Key length indicates the length of the generated session key. This will be 0 if no session key was requested."'
win.system.opcode: '0'
win.system.processID: '700'
win.system.providerGuid: '{54849625-5478-4994-a5ba-3e3b0328c30d}'
win.system.providerName: 'Microsoft-Windows-Security-Auditing'
win.system.severityValue: 'AUDIT_SUCCESS'
win.system.systemTime: '2023-06-26T23:23:16.6608061Z'
win.system.task: '12544'
win.system.threadID: '2460'
win.system.version: '2'

**Phase 3: Completed filtering (rules).
id: '60001'
level: '0'
description: 'Group of Windows rules for the security channel.'
groups: '['windows']'
firedtimes: '1'
mail: 'False'

Phase 3 shows which rule is being used, if one exists

If you replace the Event ID with 4698 you will be able to check which rule it is applying to and in that case you can modify it by your own.

I hope the explanation is understood.
Let me know how it went!
Reply all
Reply to author
Forward
0 new messages