6
6
7
7
import com .carrotsearch .randomizedtesting .generators .RandomNumbers ;
8
8
import org .apache .lucene .tests .util .LuceneTestCase ;
9
+ import org .opensearch .core .common .bytes .BytesReference ;
9
10
import org .opensearch .common .xcontent .LoggingDeprecationHandler ;
11
+ import org .opensearch .core .xcontent .NamedXContentRegistry ;
12
+ import org .opensearch .core .xcontent .ToXContent ;
10
13
import org .opensearch .common .xcontent .XContentFactory ;
14
+ import org .opensearch .core .xcontent .XContentBuilder ;
15
+ import org .opensearch .core .xcontent .XContentParser ;
11
16
import org .opensearch .common .xcontent .XContentType ;
12
17
import org .opensearch .commons .alerting .model .IntervalSchedule ;
13
18
import org .opensearch .commons .alerting .model .Schedule ;
14
19
import org .opensearch .commons .alerting .model .action .Action ;
15
20
import org .opensearch .commons .alerting .model .action .Throttle ;
16
21
import org .opensearch .commons .authuser .User ;
17
- import org .opensearch .core .common .bytes .BytesReference ;
18
- import org .opensearch .core .xcontent .NamedXContentRegistry ;
19
- import org .opensearch .core .xcontent .ToXContent ;
20
- import org .opensearch .core .xcontent .XContentBuilder ;
21
- import org .opensearch .core .xcontent .XContentParser ;
22
22
import org .opensearch .script .Script ;
23
23
import org .opensearch .script .ScriptType ;
24
24
import org .opensearch .securityanalytics .model .CorrelationQuery ;
@@ -239,6 +239,35 @@ public static String randomRule() {
239
239
"level: high" ;
240
240
}
241
241
242
+ public static String randomRuleWithRawField () {
243
+ return "title: Remote Encrypting File System Abuse\n " +
244
+ "id: 5f92fff9-82e2-48eb-8fc1-8b133556a551\n " +
245
+ "description: Detects remote RPC calls to possibly abuse remote encryption service via MS-EFSR\n " +
246
+ "references:\n " +
247
+ " - https://attack.mitre.org/tactics/TA0008/\n " +
248
+ " - https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-36942\n " +
249
+ " - https://github.com/jsecurity101/MSRPC-to-ATTACK/blob/main/documents/MS-EFSR.md\n " +
250
+ " - https://github.com/zeronetworks/rpcfirewall\n " +
251
+ " - https://zeronetworks.com/blog/stopping_lateral_movement_via_the_rpc_firewall/\n " +
252
+ "tags:\n " +
253
+ " - attack.defense_evasion\n " +
254
+ "status: experimental\n " +
255
+ "author: Sagie Dulce, Dekel Paz\n " +
256
+ "date: 2022/01/01\n " +
257
+ "modified: 2022/01/01\n " +
258
+ "logsource:\n " +
259
+ " product: rpc_firewall\n " +
260
+ " category: application\n " +
261
+ " definition: 'Requirements: install and apply the RPC Firewall to all processes with \" audit:true action:block uuid:df1941c5-fe89-4e79-bf10-463657acf44d or c681d488-d850-11d0-8c52-00c04fd90f7e'\n " +
262
+ "detection:\n " +
263
+ " selection:\n " +
264
+ " eventName: testinghere\n " +
265
+ " condition: selection\n " +
266
+ "falsepositives:\n " +
267
+ " - Legitimate usage of remote file encryption\n " +
268
+ "level: high" ;
269
+ }
270
+
242
271
public static String randomNullRule () {
243
272
return "title: null field\n " +
244
273
"id: 5f92fff9-82e2-48eb-8fc1-8b133556a551\n " +
@@ -1774,6 +1803,46 @@ public static String randomDoc() {
1774
1803
"}" ;
1775
1804
}
1776
1805
1806
+ public static String randomNetworkDoc () {
1807
+ return "{\n " +
1808
+ "\" @timestamp\" :\" 2020-02-04T14:59:39.343541+00:00\" ,\n " +
1809
+ "\" EventTime\" :\" 2020-02-04T14:59:39.343541+00:00\" ,\n " +
1810
+ "\" HostName\" :\" EC2AMAZ-EPO7HKA\" ,\n " +
1811
+ "\" Keywords\" :\" 9223372036854775808\" ,\n " +
1812
+ "\" SeverityValue\" :2,\n " +
1813
+ "\" Severity\" :\" INFO\" ,\n " +
1814
+ "\" EventID\" :22,\n " +
1815
+ "\" SourceName\" :\" Microsoft-Windows-Sysmon\" ,\n " +
1816
+ "\" SourceIp\" :\" 1.2.3.4\" ,\n " +
1817
+ "\" ProviderGuid\" :\" {5770385F-C22A-43E0-BF4C-06F5698FFBD9}\" ,\n " +
1818
+ "\" Version\" :5,\n " +
1819
+ "\" TaskValue\" :22,\n " +
1820
+ "\" OpcodeValue\" :0,\n " +
1821
+ "\" RecordNumber\" :9532,\n " +
1822
+ "\" ExecutionProcessID\" :1996,\n " +
1823
+ "\" ExecutionThreadID\" :2616,\n " +
1824
+ "\" Channel\" :\" Microsoft-Windows-Sysmon/Operational\" ,\n " +
1825
+ "\" Domain\" :\" NTAUTHORITY\" ,\n " +
1826
+ "\" AccountName\" :\" SYSTEM\" ,\n " +
1827
+ "\" UserID\" :\" S-1-5-18\" ,\n " +
1828
+ "\" AccountType\" :\" User\" ,\n " +
1829
+ "\" Message\" :\" Dns query:\\ r\\ nRuleName: \\ r\\ nUtcTime: 2020-02-04 14:59:38.349\\ r\\ nProcessGuid: {b3c285a4-3cda-5dc0-0000-001077270b00}\\ r\\ nProcessId: 1904\\ r\\ nQueryName: EC2AMAZ-EPO7HKA\\ r\\ nQueryStatus: 0\\ r\\ nQueryResults: 172.31.46.38;\\ r\\ nImage: C:\\ \\ Program Files\\ \\ nxlog\\ \\ nxlog.exe\" ,\n " +
1830
+ "\" Category\" :\" Dns query (rule: DnsQuery)\" ,\n " +
1831
+ "\" Opcode\" :\" Info\" ,\n " +
1832
+ "\" UtcTime\" :\" 2020-02-04 14:59:38.349\" ,\n " +
1833
+ "\" ProcessGuid\" :\" {b3c285a4-3cda-5dc0-0000-001077270b00}\" ,\n " +
1834
+ "\" ProcessId\" :\" 1904\" ,\" QueryName\" :\" EC2AMAZ-EPO7HKA\" ,\" QueryStatus\" :\" 0\" ,\n " +
1835
+ "\" QueryResults\" :\" 172.31.46.38;\" ,\n " +
1836
+ "\" Image\" :\" C:\\ \\ Program Files\\ \\ nxlog\\ \\ regsvr32.exe\" ,\n " +
1837
+ "\" EventReceivedTime\" :\" 2020-02-04T14:59:40.780905+00:00\" ,\n " +
1838
+ "\" SourceModuleName\" :\" in\" ,\n " +
1839
+ "\" SourceModuleType\" :\" im_msvistalog\" ,\n " +
1840
+ "\" CommandLine\" : \" eachtest\" ,\n " +
1841
+ "\" id.orig_h\" : \" 123.12.123.12\" ,\n " +
1842
+ "\" Initiated\" : \" true\" \n " +
1843
+ "}" ;
1844
+ }
1845
+
1777
1846
public static String randomCloudtrailAggrDoc (String eventType , String accountId ) {
1778
1847
return "{\n " +
1779
1848
" \" AccountName\" : \" " + accountId + "\" ,\n " +
@@ -1791,6 +1860,7 @@ public static String randomVpcFlowDoc() {
1791
1860
" \" srcport\" : 9000,\n " +
1792
1861
" \" dstport\" : 8000,\n " +
1793
1862
" \" severity_id\" : \" -1\" ,\n " +
1863
+ " \" id.orig_h\" : \" 1.2.3.4\" ,\n " +
1794
1864
" \" class_name\" : \" Network Activity\" \n " +
1795
1865
"}" ;
1796
1866
}
@@ -2366,7 +2436,7 @@ public static List<String> randomLowerCaseStringList() {
2366
2436
stringList .add (randomLowerCaseString ());
2367
2437
return stringList ;
2368
2438
}
2369
-
2439
+
2370
2440
public static XContentParser parser (String xc ) throws IOException {
2371
2441
XContentParser parser = XContentType .JSON .xContent ().createParser (xContentRegistry (), LoggingDeprecationHandler .INSTANCE , xc );
2372
2442
parser .nextToken ();
0 commit comments