forked from g-rd/snortparser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdicts.py
More file actions
1223 lines (1194 loc) · 72.6 KB
/
Copy pathdicts.py
File metadata and controls
1223 lines (1194 loc) · 72.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
class Dicts():
def classtypes(self, cltype):
classtypes = {
"attempted-admin":"Attempted Administrator Privilege Gain",
"attempted-dos":"Attempted Denial of Service",
"attempted-recon":"Attempted Information Leak",
"attempted-user":"Attempted User Privilege Gain",
"bad-unknown":"Potentially Bad Traffic",
"client-side-exploit":"Known client side exploit attempt",
"default-login-attempt":"Attempt to Login By a Default Username and Password",
"denial-of-service":"Detection of a Denial of Service Attack",
"file-format":"Known malicious file or file based exploit",
"icmp-event":"Generic ICMP Event",
"inappropriate-content":"Inappropriate content was detected",
"malware-cnc":"Known malware command and control traffic",
"misc-activity":"Misc Activity",
"misc-attack":"Misc Attack",
"network-scan":"Detection of a Network Scan",
"non-standard-protocol":"Detection of a Non-Standard Protocol or Event",
"not-suspicious":"Not Suspicious Traffic",
"policy-violation":"Potential Corporate Policy Violation",
"protocol-command-decode":"Generic Protocol Command Decode",
"rpc-portmap-decode":" Decode of an RPC Query",
"sdf":"Sensitive Data",
"shellcode-detect":"Executable Code was Detected",
"string-detect":"A Suspicious String was Detected",
"successful-admin":"Successful Administrator Privilege Gain",
"successful-dos":"Denial of Service",
"successful-recon-largescale":"Large Scale Information Leak",
"successful-recon-limited":"Information Leak",
"successful-user":"Successful User Privilege Gain",
"suspicious-filename-detect":"A Suspicious Filename was Detected",
"suspicious-login":"An Attempted Login Using a Suspicious Username was Detected",
"system-call-detect":"A System Call was Detected",
"tcp-connection":"A TCP Connection was Detected",
"trojan-activity":"A Network Trojan was Detected",
"unknown":"Unknown Traffic",
"unsuccessful-user":"Unsuccessful User Privilege Gain",
"unusual-client-port-connection":"A Client was Using an Unusual Port",
"web-application-activity":"Access to a Potentially Vulnerable Web Application",
"web-application-attack":"Web Application Attack",
"nonstd-tcp":"Detection of a Non-Standard TCP Protocol"
}
if cltype in classtypes:
return classtypes[cltype]
else:
return False
def ip_variables(self, variable):
variables = {"$EXTERNAL_NET": "$EXTERNAL_NET",
"$HTTP_SERVERS": "$HTTP_SERVERS",
"$INTERNAL_NET": "$INTERNAL_NET",
"$SQL_SERVERS": "$SQL_SERVERS",
"$SMTP_SERVERS": "$SMTP_SERVERS",
"$DNS_SERVERS": "$DNS_SERVERS",
"$HOME_NET": "$HOME_NET",
"any": "any"
}
if variable in variables:
return variables[variable]
else:
return False
def general_options(self, option):
# TODO: maybe add Snort Default Classifications
general_options = {"msg": "msg",
# The msg keyword tells the
# logging and alerting engine
# the message to print with the packet
# dump or alert.
"reference": "reference",
# The reference keyword allows rules to include
# references to external attack identification
# systems.
"gid": "gid",
# The gid keyword (generator id) is used to
# identify what part of Snort generates the event
# when a particular rule fires.
"sid": "sid",
# The sid keyword is used to uniquely identify
# Snort rules.
"rev": "rev",
# The rev keyword is used to uniquely identify
# revisions of Snort rules.
"classtype": "classtype",
# The classtype keyword is used to categorize
# a rule as detecting an attack that is part
# of a more general type of attack class.
# The priority keyword assigns a severity level to
# rules. "priority": "priority",
"metadata": "metadata"
# The metadata keyword allows a rule writer
# to embed additional information about the rule,
# typically in a key-value format. Keys: engine
# ( Indicate a Shared Library Rule ) ex: "shared",
# soid ( Shared Library Rule Generator and
# SID ) ex: "gid|sid", service ( Target-Based
# Service Identifier ) ex: "http"
}
if option in general_options:
return general_options[option]
else:
return False
def payload_options(self, option):
payload_detection = {"content": "content",
# The content keyword allows
# the user to set rules that search for specific
# content in the packet payload and trigger
# response based on that data.
"protected_content": "protected_content",
# As with the content keyword,
# its primary purpose is to match strings of
# specific bytes. The search is performed by
# hashing portions of incoming packets and
# comparing the results against the hash provided,
# and as such, it is computationally expensive.
"hash": "hash",
# The hash keyword is used to specify the hashing
# algorithm to use when matching a
# protected_content rule.
"length": "length",
# The length keyword is used to specify the
# original length of the content specified
# in a protected_content rule digest.
# The value provided must be greater than 0 and
# less than 65536.
"nocase": "nocase",
# The nocase keyword allows the rule writer to
# specify that the Snort should look for the
# specific pattern, ignoring case. nocase
# modifies the previous content keyword
# in the rule.
"rawbytes": "rawbytes",
# The rawbytes keyword allows rules to look at
# the raw packet data, ignoring any decoding
# that was done by preprocessors.
"depth": "depth",
# The depth keyword allows the rule writer to
# specify how far into a packet Snort should
# search for the specified pattern.
"offset": "offset",
# The offset keyword allows the rule writer to
# specify where to start searching for a pattern
# within a packet.
"distance": "distance",
# The distance keyword allows the rule writer to
# specify how far into a packet Snort should
# ignore before starting to search for the
# specified pattern relative to the end of the
# previous pattern match.
"within": "within",
# The within keyword is a content modifier that
# makes sure that at most N bytes are between
# pattern matches using the content keyword.
# NOTE: The http_client_body modifier is not
# allowed to be used with the rawbytes modifier
# for the same content.
"http_client_body": "http_client_body",
# The http_client_body keyword is a content
# modifier that restricts the search to the body
# of an HTTP client request.
# NOTE: The http_cookie modifier is not
# allowed to be used with the
# rawbytes or fast_pattern modifiers for the same
# content
"http_cookie": "http_cookie",
# The http_cookie keyword is a content modifier
# that restricts the search to the extracted
# Cookie Header field As this keyword
# is a modifier to the previous content
# keyword, there must be a content in the rule
# before http_cookie is specified.
# This keyword is dependent
# on the enable_cookie config option.
# NOTE: The http_raw_cookie modifier
# is not allowed to be used with the rawbytes,
# http_cookie or fast_pattern modifiers for the
# same content
"http_raw_cookie": "http_raw_cookie",
# The http_raw_cookie keyword is a content
# modifier that restricts the search to the
# extracted UNNORMALIZED Cookie Header field
# NOTE: The http_header modifier is not allowed
# to be used with the rawbytes modifier for the
# same content.
"http_header": "http_header",
# The http_header keyword is a content modifier
# that restricts the search to the extracted
# Header fields.
# NOTE:The http_raw_header modifier
# is not allowed to be used with the rawbytes,
# http_header or fast_pattern modifiers for the
# same content.
"http_raw_header": "http_raw_header",
# The http_raw_header keyword is a content
# modifier that restricts the search to the
# extracted UNNORMALIZED Header fields
# NOTE: The http_method modifier
# is not allowed to be used with the rawbytes
# or fast_pattern
# modifiers for the same content.
"http_method": "http_method",
# The http_method keyword is a content modifier
# that restricts the search to the extracted
# Method from a HTTP client request.
# NOTE: The http_uri modifier is not allowed
# to be used with the rawbytes modifier for
# the same content.
"http_uri": "http_uri",
# The http_uri keyword is a content modifier
# that restricts the search to the NORMALIZED
# request URI field. NOTE: The http_raw_uri
# modifier is not allowed to be used with the
# rawbytes, http_uri or fast_pattern modifiers
# for the same content.
"http_raw_uri": "http_raw_uri",
# The http_raw_uri keyword is a content modifie
# that restricts the search to the UNNORMALIZED
# request URI field. NOTE: The http_stat_code
# modifier is not allowedi to be used with the
# rawbytes or fast_pattern modifiers for the
# same content.
"http_stat_code": "http_stat_code",
# The http_stat_code keyword is a content
# modifier that restricts the search
# to the extracted Status code field
# from a HTTP server response.
# NOTE: The http_stat_msg modifier is not allowed
# to be used with the rawbytes or fast_pattern
# modifiers for the same content.
"http_stat_msg": "http_stat_msg",
# The http_stat_msg keyword is a content modifier
# that restricts the search to the extracted
# Status Message field from a
# HTTP server response.
# NOTE: Negation(!) and OR(|) operations cannot
# be used in conjunction with each other for the
# http_encode keyword. The OR and negation
# operations work only on the encoding type
# field and not on http buffer type field.
# TODO: check for http_encode options
"http_encode": "http_encode",
# The http_encode keyword will enable alerting
# based on encoding type present in a HTTP client
# request or a HTTP server response
# NOTE: The fast_pattern modifier cannot be used
# with the following http content modifiers:
# 1. http_cookie,
# 2. http_raw_uri,
# 3. http_raw_header,
# 4. http_raw_cookie,
# 5. http_method,
# 6. http_stat_code,
# 7. http_stat_msg
# NOTE: The fast_pattern modifier can be used
# with negated contents onlyi if those contents
# are not modified with:
# 1. offset,
# 2. depth,
# 3. distance or
# 4. within.
# NOTE: The fast pattern matcher is always case
# insensitive. TODO: check for fast_pattern
# format
"fast_pattern": "fast_pattern",
# The fast_pattern keyword is a content modifier
# that sets the content within a rule to be used
# with the fast pattern matcher.
# NOTE: uricontent cannot be modified by
# a rawbytes modifier or any of the other
# HTTP modifiers. If you wish to search the
# UNNORMALIZED request URI field, use the
# http_raw_uri modifier with a content option.
"uricontent": "uricontent",
# The uricontent keyword in the Snort
# rule language searches the normalized request
# URI field.
"urilen": "urilen",
# The urilen keyword in the Snort rule
# language specifies the exact length,
# the minimum length, the maximum length,
# or range of URI lengths to match.
"isdataat": "isdataat",
# The isdataat keyword verifies that the
# payload has data at a specified location.
# TODO: check for Perl compatible modifiers
# for pcre. NOTE: Since this is an advanced
# option, check the manual for pitfalls.
"pcre": "pcre",
# The pcre keyword allows rules to
# be written using perl compatible regular
# expressions.
"pkt_data": "pkt_data",
# This option sets the cursor used for detection
# to the raw transport payload.
# NOTE: The argument mime to file_data is
# deprecated. The rule options file_data will
# itself point to the decoded MIME attachment.
"file_data": "file_data",
# This option sets the cursor used for detection
# to one of the following buffers:
# 1. HTTP response body
# 2. HTTP de-chunked response body
# 3. HTTP decompressed response
# 4. HTTP normalized response body
# 5. HTTP UTF normalized response body
# 6. All of the above
# 7. SMTP/POP/IMAP data body
# 8. Base64 decoded MIME attachment
# 9. Non-Encoded MIME attachment
# 10. Quoted-Printable decoded MIME attachment
# 11. Unix-to-Unix decoded attachment
# TODO: check for base64_decode options and
# format
"base64_decode": "base64_decode",
# This option is used to decode the
# base64 encoded data. This option is
# particularly useful in
# case of HTTP headers such as HTTP authorization
# headers. NOTE: Fast pattern content matches
# are not allowed with this buffer.
"base64_data": "base64_data",
# This option is similar to the rule option
# file_data and is used to set the
# cursor used for detection to the beginning
# of the base64 decoded
# buffer if present.
# TODO: check for options.
"byte_test": "byte_test",
# The byte_test keyword tests a byte
# field against a specific value
# (with operatori). TODO: check
# for options
"byte_jump": "byte_jump",
# The byte_jump keyword allows rules to read the
# length of a portion of data, then skip that
# far forward in the packet. NOTE: Only two
# byte_extract variables may be created per rule.
# They can be re-used in the same rule any number
# of times. TODO. check for options.
"byte_extract": "byte_extract",
# It reads in some number of bytes from the
# packet payload and saves it to a variable.
# TODO: check for byte_math syntax and options
"byte_math": "byte_math",
# Perform a mathematical
# operation on an extracted
# value and a specified value or
# existing variable,
# and store the outcome in a new resulting
# variable
"ftpbounce": "ftpbounce",
# The ftpbounce keyword detects FTP bounce
# attacks. TODO. check for options and syntax
# for asn1
"asn1": "asn1",
# The asn1 detection plugin decodes a packet or a
# portion of a packet, and looks for variou
# malicious encodings.
# NOTE: This plugin cannot do detection over
# encrypted sessions, e.g. SSH (usually port 22).
# TODO: find a way to check if the rule uses
# encrypted sessions
"cvs": "cvs",
# The cvs keyword detects invalid entry strings.
"dce_iface": "dce_iface",
# For DCE/RPC based rules it has been necessary
# to set flow-bits based on a client bind to a
# service to avoid false positives.
"dce_opnum": "dce_opnum",
# The opnum represents a specific function
# call to an interface.
"dce_stub_data": "dce_stub_data",
# This option is used to place the cursor
# (used to walk the packet payload in rules
# processing) at the beginning of the DCE/RPC
# stub data SIP Preprocessor provides ways to
# tackle Common Vulnerabilities and Exposures
# (CVEs) related with SIP found over the past
# few years.
"sip_method": "sip_method",
# The sip_method keyword is used to check for
# specific SIP request methods.
"sip_stat_code": "sip_stat_code",
# The sip_stat_code is used to check the SIP
# response status code.
# This option matches if any one of the state
# codes specified matches the status codes of
# the SIP response.
"sip_header": "sip_header",
# The sip_header keyword restricts the search
# to the extracted Header fields of a SIP message
# request or a response. This works similar to
# file_data.
"sip_body": "sip_body",
# The sip_body keyword places the cursor at the
# beginning of the Body fields of a SIP message.
# This works similar to file_data and
# dce_stub_data. The message body includes
# channel information using SDP protocol
# (Session Description Protocol).
# GTP (GPRS Tunneling Protocol) is used in core
# communication networks to establish a channel
# between GSNs (GPRS Serving Node). GTP decoding
# preprocessor provides ways to tackle
# intrusion attempts to those networks through
# GTP. It also makes detecting new attacks easier.
# TODO: identify also gtp message types, but for
# now keyword check has to cut it.
"gtp_type": "gtp_type",
# The gtp_type keyword is used to check for
# specific GTP types. User can input message type
# value, an integer in [0, 255], or a string
# defined in the Table below.
# TODO: gtp_info table check.
"gtp_info": "gtp_info",
# The gtp_info keyword is used to check for
# specific GTP information element.
# This keyword restricts the search to the
# information element field. User can input
# information element value,
# an integer in $[0, 255]$,
"gtp_version": "gtp_version",
# The gtp_version keyword is used to check for
# specific GTP version. Relates to gtp_info
# and gtp_type tables.
}
if option in payload_detection:
return payload_detection[option]
else:
return False
def non_payload_options(self, option):
non_payload_detect = {"fragoffset": "fragoffset",
# The fragoffset keyword allows one to compare
# the IP fragment offset field against a
# decimal value.
"ttl": "ttl",
# The ttl keyword is used to check the IP
# time-to-live value.
"tos": "tos",
# The tos keyword is used to check the IP
# TOS field for a specific value.
"id": "id",
# The id keyword is used to check the IP ID
# field for a specific value.
"ipopts": "ipopts",
# The ipopts keyword is used to check if a
# specific IP option is present.
"fragbits": "fragbits",
# The fragbits keyword is used to check if
# fragmentation and reserved bits are set
# in the IP header.
"dsize": "dsize",
# The dsize keyword is used to test the
# packet payload isize NOTE: The reserved bits
# '1' and '2' have been replaced with
# 'C' and 'E',respectively, to match
# RFC 3168, "The Addition of Explicit
# Congestion Notification (ECN) to IP".
# The old values of '1' and '2' are still
# valid for the flag keyword, but are now
# deprecated.
"flags": "flags",
# The flags keyword is used to check if
# specific TCP flag bits are present.
# TODO: check for syntax and options
"flow": "flow",
# The flow keyword allows rules to only
# apply to certain directions of the traffic
# flow. TODO. check for options and syntax
"flowbits": "flowbits",
# The flowbits keyword allows rules to
# track states during a transport protocol
# session.
"seq": "seq",
# The seq keyword is used to check for a
# specific TCP sequence number
"ack": "ack",
# The ack keyword is used to check for a
# specific TCP acknowledge number
"window": "window",
# The window keyword is used to check for
# a specific TCP window size
"itype": "itype",
# The itype keyword is used to check for a
# specific ICMP type value
"icode": "icode",
# The icode keyword is used to check for
# a specific ICMP code value
"icmp_id": "icmp_id",
# The icmp id keyword is used to check
# for a specific ICMP ID value.
"icmp_seq": "icmp_seq",
# The icmp seq keyword is used to check
# for a specific ICMP sequence value.
"rpc": "rpc",
# The rpc keyword is used to check
# for a RPC application, version, and
# procedure numbers in SUNRPC CALL requests
"ip_proto": "ip_proto",
# The ip proto keyword allows checks against
# the IP protocol header
"sameip": "sameip",
# The sameip keyword allows rules to check
# if the source ip is the same as the
# destination IP.
# NOTE: The stream_reassemble option is
# only available when the Stream preprocessor
# is enabled.
"stream_reassemble": "stream_reassemble",
# The stream_reassemble keyword allows a rule
# to enable or disable TCP stream
# reassembly on matching traffic.
# NOTE: The stream_size option is only
# available when the Stream preprocessor
# is enabled.
"stream_size": "stream_size"
# The stream_size keyword allows a rule
# to match traffic
# according to the number of bytes observed,
# as determined by the TCP sequence numbers.
}
if option in non_payload_detect:
return non_payload_detect[option]
else:
return False
def post_detect_options(self, option):
post_detect = {"logto": "logto",
# The logto keyword tells Snort to log all packets
# that trigger this rule to a special output log file.
"session": "session",
# The session keyword is built to extract user data
# from TCP Sessions
"resp": "resp",
# The resp keyword is used attempt to close sessions
# when an alert is triggered.
"react": "react",
# This keyword implements an ability for users to
# react to traffic that matches a Snort rule by
# closing connection and sending a noticei.
# NOTE: also check for options
"tag": "tag",
# The tag keyword allow rules to log more than
# just the single packet that triggered the rule
"activates": "activates",
# This keyword allows the rule writer to specify
# a rule to add when a specific network event occurs.
"activated_by": "activated_by",
# This keyword allows the rule writer to dynamically
# enable a rule when a specific activate rule is
# triggered.
"count": "count",
# This keyword must be used in combination with the
# activated by keyword. It
# allows the rule writer to specify how many packets
# to leave the rule enabled for
# after it is activated
"replace": "replace",
# Replace the prior matching content with the given
# string of the same length. Available in inline
# mode only. NOTE: As mentioned above, Snort evaluates
# detection_filter as the last step of the detection
# and not in post-detection.
"detection_filter": "detection_filter",
# Replace the prior matching content with the given
# string of the same length. Available
# in inline mode only.
"detection_filter": "detection_filter"
# Track by source or destination IP address and if
# the rule otherwise matches more
# than the configured rate it will fire.
}
if option in post_detect:
return post_detect[option]
else:
return False
def content_modifiers(self, option):
content_modifiers = {"nocase": "nocase",
"rawbytes": "rawbytes",
"depth": "depth",
"offset": "offset",
"distance": "distance",
"within": "within",
"http_client_body": "http_client_body",
"http_cookie": "http_cookie",
"http_raw_cookie": "http_raw_cookie",
"http_header": "http_header",
"http_raw_header": "http_raw_header",
"http_method": "http_method",
"http_uri": "http_uri",
"http_raw_uri": "http_raw_uri",
"http_stat_code": "http_stat_code",
"http_stat_msg": "http_stat_msg",
"http_encode": "http_encode",
"fast_pattern": "fast_pattern",
"uricontent": "uricontent",
"urilen": "urilen",
"isdataat": "isdataat",
"pcre": "pcre",
"pkt_data": "pkt_data",
"file_data": "file_data",
"base64_decode": "base64_decode",
"base64_data": "base64_data",
"byte_test": "byte_test",
"byte_jump": "byte_jump",
"byte_extract": "byte_extract",
"byte_math": "byte_math",
"ftpbounce": "ftpbounce",
"asn1": "asn1",
"cvs": "cvs",
"dce_iface": "dce_iface",
"dce_opnum": "dce_opnum",
"dce_stub_data": "dce_stub_data",
"sip_method": "sip_method",
"sip_stat_code": "sip_stat_code",
"sip_header": "sip_header",
"sip_body": "sip_body",
"gtp_type": "gtp_type",
"gtp_info": "gtp_info",
"gtp_version": "gtp_version",
"ssl_version": "ssl_version",
"ssl_state": "ssl_state"
}
if option in content_modifiers:
return content_modifiers[option]
else:
return False
def rule_tresholds(self, option):
rule_tresholds = {"threshold": "threshold"}
if option in rule_tresholds:
return rule_tresholds[option]
else:
return False
def options(self, option):
# TODO: maybe add Snort Default Classifications
general_options = {"msg": "msg",
# The msg keyword tells the logging and
# alerting engine the message to print with the
# packet dump or alert.
"reference": "reference",
# The reference keyword allows rules to include
# references to external attack identification
# systems.
"gid": "gid",
# The gid keyword (generator id) is used to
# identify what part of Snort generates the event
# when a particular rule fires.
"sid": "sid",
# The sid keyword is used to uniquely identify
# Snort rules.
"rev": "rev",
# The rev keyword is used to uniquely identify
# revisions of Snort rules.
"classtype": "classtype",
# The classtype keyword is used to categorize a
# rule as detecting an attack that is part of a
# more general type of attack class.
"priority": "priority",
# The priority keyword assigns a severity level
# to rules.
"metadata": "metadata"
# The metadata keyword allows a rule writer
# to embed additional information about the rule,
# typically in a key-value format.
# Keys: engine ( Indicate a Shared Library Rule )
# ex: "shared", soid ( Shared Library
# Rule Generator and SID ) ex: "gid|sid",
# service ( Target-Based Service Identifier )
# ex: "http"
}
payload_detection = {"content": "content",
# The content keyword allows the user
# to set rules that search for specific
# content in the packet payload and trigger
# response based on that data.
"protected_content": "protected_content",
# As with the content keyword, its primary purpose
# is to match strings of specific bytes. The
# search is performed by hashing portions of
# incoming packets and comparing the results
# against the hash provided, and as such, it is
# computationally expensive.
"hash": "hash",
# The hash keyword is used to specify
# the hashing algorithm to use when
# matching a protected_content rule.
"length": "length",
# The length keyword is used to specify the
# original length of the content specified
# in a protected_content rule digest.
# The value provided must be greater than 0 and
# less than 65536.
"nocase": "nocase",
# The nocase keyword allows the rule writer
# to specify that the Snort should look for
# the specific pattern, ignoring case. nocase
# modifies the previous content keyword in the
# rule.
"rawbytes": "rawbytes",
# The rawbytes keyword allows rules to look at
# the raw packet data, ignoring any decoding
# that was done by preprocessors.
"depth": "depth",
# The depth keyword allows the rule writer
# to specify how far into a packet Snort should
# search for the specified pattern.
"offset": "offset",
# The offset keyword allows the rule writer
# to specify where to start searching for a
# pattern within a packet.
"distance": "distance",
# The distance keyword allows the rule writer
# to specify how far into a packet Snort should
# ignore before starting to search for the
# specified pattern relative to the end of the
# previous pattern match.
"within": "within",
# The within keyword is a content modifier
# that makes sure that at most N bytes are
# between pattern matches using the content
# keyword. NOTE: The http_client_body modifier
# is not allowed to be used with the rawbytes
# modifier for the same content.
"http_client_body": "http_client_body",
# The http_client_body keyword is a content
# modifier that restricts the search
# to the body of an HTTP client request.
# NOTE: The http_cookie modifier is not allowed
# to be used with the rawbytes
# or fast_pattern modifiers for the same content
"http_cookie": "http_cookie",
# The http_cookie keyword is a content modifier
# that restricts the search to the extracted
# Cookie Header field As this keyword is a
# modifier to the previous content keyword,
# there must be a content in the rule before
# http_cookie is specified.
# This keyword is dependent on the enable_cookie
# config option. NOTE: The http_raw_cookie
# modifier is not allowed to be used with the
# rawbytes, http_cookie or fast_pattern modifiers
# for the same content
"http_raw_cookie": "http_raw_cookie",
# The http_raw_cookie keyword is a content
# modifier that restricts the search to the
# extracted UNNORMALIZED Cookie Header field
# NOTE: The http_header modifier is not allowed
# to be used with the rawbytes modifier for the
# same content.
"http_header": "http_header",
# The http_header keyword is a content modifier
# that restricts the search to the extracted
# Header fields NOTE: The http_raw_header
# modifier is not allowed to be used with the
# rawbytes, http_header or fast_pattern modifiers
# for the same content.
"http_raw_header": "http_raw_header",
# The http_raw_header keyword is a content
# modifier that restricts the search to the
# extracted UNNORMALIZED Header fields
# NOTE: The http_method modifier is not allowed
# to be used with the rawbytes or fast_pattern
# modifiers for the same content.
"http_method": "http_method",
# The http_method keyword is a content modifier
# that restricts the search to the extracted
# Method from a HTTP client request.
# NOTE: The http_uri modifier is not allowed
# to be used with the rawbytes modifier for the
# same content.
"http_uri": "http_uri",
# The http_uri keyword is a content modifier
# that restricts the search to the NORMALIZED
# request URI field. NOTE: The http_raw_uri
# modifier is not allowed to be used with the
# rawbytes, http_uri or fast_pattern modifiers
# for the same content.
"http_raw_uri": "http_raw_uri",
# The http_raw_uri keyword is a content modifie
# that restricts the search to the UNNORMALIZED
# request URI field.
# NOTE: The http_stat_code modifier is not allowed
# to be used with the rawbytes or fast_pattern
# modifiers for the same content.
"http_stat_code": "http_stat_code",
# The http_stat_code keyword is a content
# modifier that restricts the search to the
# extracted Status code field from a HTTP server
# response.
# NOTE: The http_stat_msg modifier is not allowed
# to be used with the rawbytes or fast_pattern
# modifiers for the same content.
"http_stat_msg": "http_stat_msg",
# The http_stat_msg keyword is a content modifier
# that restricts the search to the extracted
# status Message field from
# a HTTP server response.
# NOTE: Negation(!) and OR(|) operations cannot
# be used in conjunction
# with each other for the http_encode keyword.
# The OR and negation operations work only on the
# encoding type
# field and not on http buffer type field.
# TODO: check for http_encode options
"http_encode": "http_encode",
# The http_encode keyword will enable alerting
# based on encoding type present in a HTTP client
# request or a HTTP server response
# NOTE: The fast_pattern modifier cannot be used
# with the following http content modifiers:
# 1. http_cookie,
# 2. http_raw_uri,
# 3. http_raw_header,
# 4. http_raw_cookie,
# 5. http_method,
# 6. http_stat_code,
# 7. http_stat_msg
# NOTE: The fast_pattern modifier can be used
# with negated contents only
# if those contents are not modified with
# 1. offset,
# 2. depth,
# 3. distance or
# 4. within.
# NOTE: The fast pattern matcher is always case
# insensitive.
# TODO: check for fast_pattern format
"fast_pattern": "fast_pattern",
# The fast_pattern keyword is a content modifier
# that sets the content within a rule
# to be used with the fast pattern matcher.
# NOTE: uricontent cannot be modified by a
# rawbytes modifier or any of the other HTTP
# modifiers. If you wish to search the
# UNNORMALIZED request URI field,
# use the http_raw_uri modifier with a content
# option.
"uricontent": "uricontent",
# The uricontent keyword in the Snort
# rule language searches the normalized request
# URI field.
"urilen": "urilen",
# The urilen keyword in the Snort rule
# language specifies the exact length,
# the minimum length, the maximum length,
# or range of URI lengths to match.
"isdataat": "isdataat",
# The isdataat keyword verifies that the payload
# has data at a specified location.
# TODO: check for Perl compatible modifiers for
# pcre. NOTE: Since this is an advanced option,
# check the manual for pitfalls.
"pcre": "pcre",
# The pcre keyword allows rules to be written
# using perl compatible regular expressions.
"pkt_data": "pkt_data",
# This option sets the cursor used for detection
# to the raw transport payload. NOTE: The
# argument mime to file_data is deprecated.
# The rule options file_data will itself point
# to the decoded MIME attachment.
"file_data": "file_data",
# This option sets the cursor used for detection
# to one of the following buffers:
# 1. HTTP response body
# 2. HTTP de-chunked response body
# 3. HTTP decompressed response
# 4. HTTP normalized response body
# 5. HTTP UTF normalized response body
# 6. All of the above
# 7. SMTP/POP/IMAP data body
# 8. Base64 decoded MIME attachment
# 9. Non-Encoded MIME attachment
# 10. Quoted-Printable decoded MIME attachment
# 11. Unix-to-Unix decoded attachment
# TODO: check for base64_decode options and format
"base64_decode": "base64_decode",
# This option is used to decode the base64
# encoded data. This option is particularly
# useful in case of HTTP headers such as
# HTTP authorization headers.
# NOTE: Fast pattern content matches are not
# allowed with this buffer.
"base64_data": "base64_data",
# This option is similar to the rule option
# file_data and is used to set the cursor used
# for detection to the beginning of the base64
# decoded buffer if present.
# TODO: check for options
"byte_test": "byte_test",
# The byte_test keyword tests a byte field
# against a specific value (with operatori).
# TODO: check for options
"byte_jump": "byte_jump",
# The byte_jump keyword allows rules to read the
# length of a portion of data, then skip that
# far forward in the packet.
# NOTE: Only two byte_extract variables may be
# created per rule. They can be re-used in the
# same rule any number of times.
# TODO. check for options
"byte_extract": "byte_extract",
# It reads in some number of bytes from the
# packet payload and saves it to a variable.
# TODO: check for byte_math syntax and options
"byte_math": "byte_math",
# Perform a mathematical operation on an
# extracted value and a specified value or
# existing variable, and store the outcome in a
# new resulting variable
"ftpbounce": "ftpbounce",
# The ftpbounce keyword detects FTP bounce
# attacks.
# TODO. check for options and syntax for asn1
"asn1": "asn1",
# The asn1 detection plugin decodes a packet
# or a portion of a packet, and looks for
# various malicious encodings.
# NOTE: This plugin cannot do detection over
# encrypted sessions, e.g. SSH (usually port 22).
# TODO: find a way to check if the rule uses
# encrypted sessions
"cvs": "cvs",
# The cvs keyword detects invalid entry strings.
"dce_iface": "dce_iface",
# For DCE/RPC based rules it has been necessary
# to set flow-bits based on a client bind to a
# service to avoid false positives.
"dce_opnum": "dce_opnum",
# The opnum represents a specific function
# call to an interface.
"dce_stub_data": "dce_stub_data",
# This option is used to place the cursor
# (used to walk the packet payload in rule
# processing) at the beginning of the DCE/RPC
# stub data SIP Preprocessor provides ways
# to tackle Common Vulnerabilities and Exposures
# (CVEs) related with SIP found over the past
# few years.
"sip_method": "sip_method",
# The sip_method keyword is used to check
# for specific SIP request methods.
"sip_stat_code": "sip_stat_code",
# The sip_stat_code is used to check the
# SIP response status code. This option matches
# if any one of the state codes
# specified matches the status codes of the
# SIP response.
"sip_header": "sip_header",
# The sip_header keyword restricts the search
# to the extracted Header fields of a SIP message
# request or a response.
# This works similar to file_data.
"sip_body": "sip_body",
# The sip_body keyword places the cursor at the
# beginning of the Body fields of a SIP message.
# This works similar to file_data and
# dce_stub_data. The message body includes
# channel information using SDP protocol
# (Session Description Protocol).
# GTP (GPRS Tunneling Protocol) is used in core
# communication networks to establish a channel
# between GSNs (GPRS Serving Node). GTP decoding
# preprocessor provides ways to tackle
# intrusion attempts to those networks through
# GTP. It also makes detecting new attacks easier.
# TODO: identify also gtp message types, but for
# now keyword check has to cut it.
"gtp_type": "gtp_type",
# The gtp_type keyword is used to check for
# specific GTP types. User can input message
# type value, an integer in [0, 255], or a
# string defined in the Table below.
# TODO: gtp_info table check
"gtp_info": "gtp_info",
# The gtp_info keyword is used to check for
# specific GTP information element. This keyword
# restricts the search to the information
# element field. User can input information