$re = '/Subject:.+?Security ID:\t{1,}(?<mswin_security_id>.+?)\n/s';
$str = '{ [-]
@timestamp: 2021-01-13T14:30:13.835Z
@version: 1
cloud_service_name: MOS-WIN
id: fd5c4ce8-b5cb-4cb4-a1e5-82c7e531673d
log_entry: An account was successfully logged on.
Subject:
Security ID: S-1-5-18
Account Name: PT1-X-CHRDB-1$
Account Domain: DRACO910
Logon ID: 0x3E7
Logon Information:
Logon Type: 44
Restricted Admin Mode: -
Virtual Account: No
Elevated Token: Yes
Impersonation Level: Impersonation
New Logon:
Security ID: S-1-5-21-3515936613-886961063-2664560780-6781
Account Name: ABB-ESC-9e8ec
Account Domain: DRACO910
Logon ID: 0xF0D94929
Linked Logon ID: 0x0
Network Account Name: -
Network Account Domain: -
Logon GUID: {6D3F87DE-7E78-7F6F-EF45-BFC1FC1C1BFE}
Process Information:
Process ID: 0x1b0
Process Name: C:\\Program Files\\EMC NetWorker\\nsr\\bin\\nsrexecd.exe
Network Information:
Workstation Name: PT1-X-CHRDB-1
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.
log_type: SECURITY
tenant_name: draco-910
timestamp: 2021-01-13T14:30:08.442Z
version: 1.0
}';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php