Advertisement
Guest User

Untitled

a guest
Feb 9th, 2018
1,417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.78 KB | None | 0 0
  1. import os
  2. import socket
  3. import fileinput
  4. #Devices IP address
  5. DeviceIP = socket.gethostbyname(socket.gethostname())
  6.  
  7. #New config File
  8.  
  9. configtext = """#--------------------------------------------------
  10. # VRT Rule Packages Snort.conf
  11. #
  12. # For more information visit us at:
  13. # http://www.snort.org Snort Website
  14. # http://vrt-blog.snort.org/ Sourcefire VRT Blog
  15. #
  16. # Mailing list Contact: [email protected]
  17. # False Positive reports: [email protected]
  18. # Snort bugs: [email protected]
  19. #
  20. # Compatible with Snort Versions:
  21. # VERSIONS : 2.9.9.0
  22. #
  23. # Snort build options:
  24. # OPTIONS : --enable-gre --enable-mpls --enable-targetbased --enable-ppm --enable-perfprofiling --enable-zlib --enable-active-response --enable-normalizer --enable-reload --enable-react --enable-flexresp3
  25. #
  26. # Additional information:
  27. # This configuration file enables active response, to run snort in
  28. # test mode -T you are required to supply an interface -i <interface>
  29. # or test mode will fail to fully validate the configuration and
  30. # exit with a FATAL error
  31. #--------------------------------------------------
  32.  
  33. ###################################################
  34. # This file contains a sample snort configuration.
  35. # You should take the following steps to create your own custom configuration:
  36. #
  37. # 1) Set the network variables.
  38. # 2) Configure the decoder
  39. # 3) Configure the base detection engine
  40. # 4) Configure dynamic loaded libraries
  41. # 5) Configure preprocessors
  42. # 6) Configure output plugins
  43. # 7) Customize your rule set
  44. # 8) Customize preprocessor and decoder rule set
  45. # 9) Customize shared object rule set
  46. ###################################################
  47.  
  48. ###################################################
  49. # Step #1: Set the network variables. For more information, see README.variables
  50. ###################################################
  51.  
  52. # Setup the network addresses you are protecting
  53. ipvar HOME_NET any
  54.  
  55. # Set up the external network addresses. Leave as "any" in most situations
  56. ipvar EXTERNAL_NET !$HOME_NET
  57.  
  58. # List of DNS servers on your network
  59. ipvar DNS_SERVERS $HOME_NET
  60.  
  61. # List of SMTP servers on your network
  62. ipvar SMTP_SERVERS $HOME_NET
  63.  
  64. # List of web servers on your network
  65. ipvar HTTP_SERVERS $HOME_NET
  66.  
  67. # List of sql servers on your network
  68. ipvar SQL_SERVERS $HOME_NET
  69.  
  70. # List of telnet servers on your network
  71. ipvar TELNET_SERVERS $HOME_NET
  72.  
  73. # List of ssh servers on your network
  74. ipvar SSH_SERVERS $HOME_NET
  75.  
  76. # List of ftp servers on your network
  77. ipvar FTP_SERVERS $HOME_NET
  78.  
  79. # List of sip servers on your network
  80. ipvar SIP_SERVERS $HOME_NET
  81.  
  82. # List of ports you run web servers on
  83. portvar HTTP_PORTS [36,80,81,82,83,84,85,86,87,88,89,90,311,383,555,591,593,631,801,808,818,901,972,1158,1220,1414,1533,1741,1830,1942,2231,2301,2381,2578,2809,2980,3029,3037,3057,3128,3443,3702,4000,4343,4848,5000,5117,5250,5450,5600,5814,6080,6173,6988,7000,7001,7005,7071,7144,7145,7510,7770,7777,7778,7779,8000,8001,8008,8014,8015,8020,8028,8040,8080,8081,8082,8085,8088,8090,8118,8123,8180,8181,8182,8222,8243,8280,8300,8333,8344,8400,8443,8500,8509,8787,8800,8888,8899,8983,9000,9002,9060,9080,9090,9091,9111,9290,9443,9447,9710,9788,9999,10000,11371,12601,13014,15489,19980,29991,33300,34412,34443,34444,40007,41080,44449,50000,50002,51423,53331,55252,55555,56712]
  84.  
  85. # List of ports you want to look for SHELLCODE on.
  86. portvar SHELLCODE_PORTS !80
  87.  
  88. # List of ports you might see oracle attacks on
  89. portvar ORACLE_PORTS 1024:
  90.  
  91. # List of ports you want to look for SSH connections on:
  92. portvar SSH_PORTS 22
  93.  
  94. # List of ports you run ftp servers on
  95. portvar FTP_PORTS [21,2100,3535]
  96.  
  97. # List of ports you run SIP servers on
  98. portvar SIP_PORTS [5060,5061,5600]
  99.  
  100. # List of file data ports for file inspection
  101. portvar FILE_DATA_PORTS [$HTTP_PORTS,110,143]
  102.  
  103. # List of GTP ports for GTP preprocessor
  104. portvar GTP_PORTS [2123,2152,3386]
  105.  
  106. # other variables, these should not be modified
  107. ipvar AIM_SERVERS [64.12.24.0/23,64.12.28.0/23,64.12.161.0/24,64.12.163.0/24,64.12.200.0/24,205.188.3.0/24,205.188.5.0/24,205.188.7.0/24,205.188.9.0/24,205.188.153.0/24,205.188.179.0/24,205.188.248.0/24]
  108.  
  109. # Path to your rules files (this can be a relative path)
  110. # Note for Windows users: You are advised to make this an absolute path,
  111. # such as: c:\\snort\\rules
  112. var RULE_PATH c:\\Snort\\rules
  113. #var SO_RULE_PATH ../so_rules
  114. var PREPROC_RULE_PATH c:\\Snort\\preproc_rules
  115.  
  116. # If you are using reputation preprocessor set these
  117. var WHITE_LIST_PATH c:\\Snort\\rules
  118. var BLACK_LIST_PATH c:\\Snort\\rules
  119.  
  120. ###################################################
  121. # Step #2: Configure the decoder. For more information, see README.decode
  122. ###################################################
  123.  
  124. # Stop generic decode events:
  125. config disable_decode_alerts
  126.  
  127. # Stop Alerts on experimental TCP options
  128. config disable_tcpopt_experimental_alerts
  129.  
  130. # Stop Alerts on obsolete TCP options
  131. config disable_tcpopt_obsolete_alerts
  132.  
  133. # Stop Alerts on T/TCP alerts
  134. config disable_tcpopt_ttcp_alerts
  135.  
  136. # Stop Alerts on all other TCPOption type events:
  137. config disable_tcpopt_alerts
  138.  
  139. # Stop Alerts on invalid ip options
  140. config disable_ipopt_alerts
  141.  
  142. # Alert if value in length field (IP, TCP, UDP) is greater th elength of the packet
  143. # config enable_decode_oversized_alerts
  144.  
  145. # Same as above, but drop packet if in Inline mode (requires enable_decode_oversized_alerts)
  146. # config enable_decode_oversized_drops
  147.  
  148. # Configure IP / TCP checksum mode
  149. config checksum_mode: all
  150.  
  151. # Configure maximum number of flowbit references. For more information, see README.flowbits
  152. # config flowbits_size: 64
  153.  
  154. # Configure ports to ignore
  155. # config ignore_ports: tcp 21 6667:6671 1356
  156. # config ignore_ports: udp 1:17 53
  157.  
  158. # Configure active response for non inline operation. For more information, see REAMDE.active
  159. # config response: eth0 attempts 2
  160.  
  161. # Configure DAQ related options for inline operation. For more information, see README.daq
  162. #
  163. # config daq: <type>
  164. # config daq_dir: <dir>
  165. # config daq_mode: <mode>
  166. # config daq_var: <var>
  167. #
  168. # <type> ::= pcap | afpacket | dump | nfq | ipq | ipfw
  169. # <mode> ::= read-file | passive | inline
  170. # <var> ::= arbitrary <name>=<value passed to DAQ
  171. # <dir> ::= path as to where to look for DAQ module so's
  172.  
  173. # Configure specific UID and GID to run snort as after dropping privs. For more information see snort -h command line options
  174. #
  175. # config set_gid:
  176. # config set_uid:
  177.  
  178. # Configure default snaplen. Snort defaults to MTU of in use interface. For more information see README
  179. #
  180. # config snaplen:
  181. #
  182.  
  183. # Configure default bpf_file to use for filtering what traffic reaches snort. For more information see snort -h command line options (-F)
  184. #
  185. # config bpf_file:
  186. #
  187.  
  188. # Configure default log directory for snort to log to. For more information see snort -h command line options (-l)
  189. #
  190. config logdir: c:\\snort\\log
  191.  
  192.  
  193. ###################################################
  194. # Step #3: Configure the base detection engine. For more information, see README.decode
  195. ###################################################
  196.  
  197. # Configure PCRE match limitations
  198. config pcre_match_limit: 3500
  199. config pcre_match_limit_recursion: 1500
  200.  
  201. # Configure the detection engine See the Snort Manual, Configuring Snort - Includes - Config
  202. config detection: search-method ac-split search-optimize max-pattern-len 20
  203.  
  204. # Configure the event queue. For more information, see README.event_queue
  205. config event_queue: max_queue 8 log 5 order_events content_length
  206.  
  207. ###################################################
  208. ## Configure GTP if it is to be used.
  209. ## For more information, see README.GTP
  210. ####################################################
  211.  
  212. # config enable_gtp
  213.  
  214. ###################################################
  215. # Per packet and rule latency enforcement
  216. # For more information see README.ppm
  217. ###################################################
  218.  
  219. # Per Packet latency configuration
  220. #config ppm: max-pkt-time 250, # fastpath-expensive-packets, # pkt-log
  221.  
  222. # Per Rule latency configuration
  223. #config ppm: max-rule-time 200, # threshold 3, # suspend-expensive-rules, # suspend-timeout 20, # rule-log alert
  224.  
  225. ###################################################
  226. # Configure Perf Profiling for debugging
  227. # For more information see README.PerfProfiling
  228. ###################################################
  229.  
  230. #config profile_rules: print all, sort avg_ticks
  231. #config profile_preprocs: print all, sort avg_ticks
  232.  
  233. ###################################################
  234. # Configure protocol aware flushing
  235. # For more information see README.stream5
  236. ###################################################
  237. config paf_max: 16000
  238.  
  239. ###################################################
  240. # Step #4: Configure dynamic loaded libraries.
  241. # For more information, see Snort Manual, Configuring Snort - Dynamic Modules
  242. ###################################################
  243.  
  244. # path to dynamic preprocessor libraries
  245. dynamicpreprocessor directory C:\Snort\lib\snort_dynamicpreprocessor
  246.  
  247. # path to base preprocessor engine
  248. dynamicengine C:\\Snort\\lib\\snort_dynamicengine\\sf_engine.dll
  249.  
  250. # path to dynamic rules libraries
  251. #dynamicdetection directory /usr/local/lib/snort_dynamicrules
  252.  
  253. ###################################################
  254. # Step #5: Configure preprocessors
  255. # For more information, see the Snort Manual, Configuring Snort - Preprocessors
  256. ###################################################
  257.  
  258. # GTP Control Channle Preprocessor. For more information, see README.GTP
  259. # preprocessor gtp: ports { 2123 3386 2152 }
  260.  
  261. # Inline packet normalization. For more information, see README.normalize
  262. # Does nothing in IDS mode
  263. #preprocessor normalize_ip4
  264. #preprocessor normalize_tcp: block, rsv, pad, urp, req_urg, req_pay, req_urp, ips, ecn stream
  265. #preprocessor normalize_icmp4
  266. #preprocessor normalize_ip6
  267. #preprocessor normalize_icmp6
  268.  
  269. # Target-based IP defragmentation. For more inforation, see README.frag3
  270. preprocessor frag3_global: max_frags 65536
  271. preprocessor frag3_engine: policy windows detect_anomalies overlap_limit 10 min_fragment_length 100 timeout 180
  272.  
  273. # Target-Based stateful inspection/stream reassembly. For more inforation, see README.stream5
  274. preprocessor stream5_global: track_tcp yes, track_udp yes, track_icmp no, \
  275. max_tcp 262144, max_udp 131072, max_active_responses 2, min_response_seconds 5
  276. preprocessor stream5_tcp: policy windows, detect_anomalies, require_3whs 180, overlap_limit 10, small_segments 3 bytes 150, timeout 180, ports client 21 22 23 25 42 53 70 79 109 110 111 113 119 135 136 137 139 143 161 445 513 514 587 593 691 1433 1521 1741 2100 3306 6070 6665 6666 6667 6668 6669 7000 8181 32770 32771 32772 32773 32774 32775 32776 32777 32778 32779, ports both 36 80 81 82 83 84 85 86 87 88 89 90 110 311 383 443 465 563 555 591 593 631 636 801 808 818 901 972 989 992 993 994 995 1158 1220 1414 1533 1741 1830 1942 2231 2301 2381 2578 2809 2980 3000 3001 3029 3037 3057 3128 3443 3702 4000 4343 4848 5000 5117 5250 5450 5600 5814 6080 6173 6988 7907 7000 7001 7005 7071 7144 7145 7510 7802 7770 7777 7778 7779 7801 7900 7901 7902 7903 7904 7905 7906 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 8000 8001 8008 8014 8015 8020 8028 8040 8080 8081 8082 8085 8088 8090 8118 8123 8180 8181 8182 8222 8243 8280 8300 8333 8344 8400 8443 8500 8509 8787 8800 8888 8899 8983 9000 9002 9060 9080 9090 9091 9111 9290 9443 9447 9710 9788 9999 10000 11371 12601 13014 15489 19980 29991 33300 34412 34443 34444 40007 41080 44449 50000 50002 51423 53331 55252 55555 56712
  277. preprocessor stream5_udp: timeout 180
  278.  
  279. # performance statistics. For more information, see the Snort Manual, Configuring Snort - Preprocessors - Performance Monitor
  280. # preprocessor perfmonitor: time 300 file /var/snort/snort.stats pktcnt 10000
  281.  
  282. # HTTP normalization and anomaly detection. For more information, see README.http_inspect
  283. # preprocessor http_inspect: global iis_unicode_map unicode.map 1252 compress_depth 65535 decompress_depth 65535
  284. # preprocessor http_inspect_server: server default http_methods { GET POST PUT SEARCH MKCOL COPY MOVE LOCK UNLOCK NOTIFY POLL BCOPY BDELETE BMOVE LINK UNLINK OPTIONS HEAD DELETE TRACE TRACK CONNECT SOURCE SUBSCRIBE UNSUBSCRIBE PROPFIND PROPPATCH BPROPFIND BPROPPATCH RPC_CONNECT PROXY_SUCCESS BITS_POST CCM_POST SMS_POST RPC_IN_DATA RPC_OUT_DATA RPC_ECHO_DATA } chunk_length 500000 server_flow_depth 0 client_flow_depth 0 post_depth 65495 oversize_dir_length 500 max_header_length 750 max_headers 100 max_spaces 200 small_chunk_length { 10 5 } ports { 36 80 81 82 83 84 85 86 87 88 89 90 311 383 555 591 593 631 801 808 818 901 972 1158 1220 1414 1533 1741 1830 1942 2231 2301 2381 2578 2809 2980 3029 3037 3057 3128 3443 3702 4000 4343 4848 5000 5117 5250 5450 5600 5814 6080 6173 6988 7000 7001 7005 7071 7144 7145 7510 7770 7777 7778 7779 8000 8001 8008 8014 8015 8020 8028 8040 8080 8081 8082 8085 8088 8090 8118 8123 8180 8181 8182 8222 8243 8280 8300 8333 8344 8400 8443 8500 8509 8787 8800 8888 8899 8983 9000 9002 9060 9080 9090 9091 9111 9290 9443 9447 9710 9788 9999 10000 11371 12601 13014 15489 19980 29991 33300 34412 34443 34444 40007 41080 44449 50000 50002 51423 53331 55252 55555 56712 } non_rfc_char { 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 } enable_cookie extended_response_inspection inspect_gzip normalize_utf unlimited_decompress normalize_javascript apache_whitespace no ascii no bare_byte no directory no double_decode no iis_backslash no iis_delimiter no iis_unicode no multi_slash no utf_8 no u_encode yes webroot no decompress_swf { deflate lzma } decompress_pdf { deflate }
  285.  
  286. # ONC-RPC normalization and anomaly detection. For more information, see the Snort Manual, Configuring Snort - Preprocessors - RPC Decode
  287. preprocessor rpc_decode: 111 32770 32771 32772 32773 32774 32775 32776 32777 32778 32779 no_alert_multiple_requests no_alert_large_fragments no_alert_incomplete
  288.  
  289. # Back Orifice detection.
  290. # preprocessor bo
  291.  
  292. # FTP / Telnet normalization and anomaly detection. For more information, see README.ftptelnet
  293. preprocessor ftp_telnet: global inspection_type stateful encrypted_traffic no check_encrypted
  294. preprocessor ftp_telnet_protocol: telnet ayt_attack_thresh 20 normalize ports { 23 } detect_anomalies
  295. preprocessor ftp_telnet_protocol: ftp server default def_max_param_len 100 ports { 21 2100 3535 } telnet_cmds yes ignore_telnet_erase_cmds yes ftp_cmds { ABOR ACCT ADAT ALLO APPE AUTH CCC CDUP } ftp_cmds { CEL CLNT CMD CONF CWD DELE ENC EPRT } ftp_cmds { EPSV ESTA ESTP FEAT HELP LANG LIST LPRT } ftp_cmds { LPSV MACB MAIL MDTM MIC MKD MLSD MLST } ftp_cmds { MODE NLST NOOP OPTS PASS PASV PBSZ PORT } ftp_cmds { PROT PWD QUIT REIN REST RETR RMD RNFR } ftp_cmds { RNTO SDUP SITE SIZE SMNT STAT STOR STOU } ftp_cmds { STRU SYST TEST TYPE USER XCUP XCRC XCWD } ftp_cmds { XMAS XMD5 XMKD XPWD XRCP XRMD XRSQ XSEM } ftp_cmds { XSEN XSHA1 XSHA256 } alt_max_param_len 0 { ABOR CCC CDUP ESTA FEAT LPSV NOOP PASV PWD QUIT REIN STOU SYST XCUP XPWD } alt_max_param_len 200 { ALLO APPE CMD HELP NLST RETR RNFR STOR STOU XMKD } alt_max_param_len 256 { CWD RNTO } alt_max_param_len 400 { PORT } alt_max_param_len 512 { SIZE } chk_str_fmt { ACCT ADAT ALLO APPE AUTH CEL CLNT CMD } chk_str_fmt { CONF CWD DELE ENC EPRT EPSV ESTP HELP } chk_str_fmt { LANG LIST LPRT MACB MAIL MDTM MIC MKD } chk_str_fmt { MLSD MLST MODE NLST OPTS PASS PBSZ PORT } chk_str_fmt { PROT REST RETR RMD RNFR RNTO SDUP SITE } chk_str_fmt { SIZE SMNT STAT STOR STRU TEST TYPE USER } chk_str_fmt { XCRC XCWD XMAS XMD5 XMKD XRCP XRMD XRSQ } \
  296. chk_str_fmt { XSEM XSEN XSHA1 XSHA256 } cmd_validity ALLO < int [ char R int ] > \
  297. cmd_validity EPSV < [ { char 12 | char A char L char L } ] > cmd_validity MACB < string > cmd_validity MDTM < [ date nnnnnnnnnnnnnn[.n[n[n]]] ] string > cmd_validity MODE < char ASBCZ > cmd_validity PORT < host_port > cmd_validity PROT < char CSEP > cmd_validity STRU < char FRPO [ string ] > \
  298. cmd_validity TYPE < { char AE [ char NTC ] | char I | char L [ number ] } >
  299. preprocessor ftp_telnet_protocol: ftp client default max_resp_len 256 bounce yes ignore_telnet_erase_cmds yes telnet_cmds yes
  300.  
  301.  
  302. # SMTP normalization and anomaly detection. For more information, see README.SMTP
  303. preprocessor smtp: ports { 25 465 587 691 } inspection_type stateful b64_decode_depth 0 qp_decode_depth 0 bitenc_decode_depth 0 uu_decode_depth 0 log_mailfrom log_rcptto log_filename log_email_hdrs normalize cmds normalize_cmds { ATRN AUTH BDAT CHUNKING DATA DEBUG EHLO EMAL ESAM ESND ESOM ETRN EVFY } normalize_cmds { EXPN HELO HELP IDENT MAIL NOOP ONEX QUEU QUIT RCPT RSET SAML SEND SOML } normalize_cmds { STARTTLS TICK TIME TURN TURNME VERB VRFY X-ADAT X-DRCP X-ERCP X-EXCH50 } normalize_cmds { X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN XLICENSE XQUE XSTA XTRN XUSR } max_command_line_len 512 max_header_line_len 1000 max_response_line_len 512 alt_max_command_line_len 260 { MAIL } alt_max_command_line_len 300 { RCPT } alt_max_command_line_len 500 { HELP HELO ETRN EHLO } alt_max_command_line_len 255 { EXPN VRFY ATRN SIZE BDAT DEBUG EMAL ESAM ESND ESOM EVFY IDENT NOOP RSET } alt_max_command_line_len 246 { SEND SAML SOML AUTH TURN ETRN DATA RSET QUIT ONEX QUEU STARTTLS TICK TIME TURNME VERB X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN XLICENSE XQUE XSTA XTRN XUSR } valid_cmds { ATRN AUTH BDAT CHUNKING DATA DEBUG EHLO EMAL ESAM ESND ESOM ETRN EVFY } \
  304. valid_cmds { EXPN HELO HELP IDENT MAIL NOOP ONEX QUEU QUIT RCPT RSET SAML SEND SOML } valid_cmds { STARTTLS TICK TIME TURN TURNME VERB VRFY X-ADAT X-DRCP X-ERCP X-EXCH50 } valid_cmds { X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN XLICENSE XQUE XSTA XTRN XUSR } xlink2state { enabled }
  305.  
  306. # Portscan detection. For more information, see README.sfportscan
  307. # preprocessor sfportscan: proto { all } memcap { 10000000 } sense_level { low }
  308.  
  309. # ARP spoof detection. For more information, see the Snort Manual - Configuring Snort - Preprocessors - ARP Spoof Preprocessor
  310. # preprocessor arpspoof
  311. # preprocessor arpspoof_detect_host: 192.168.40.1 f0:0f:00:f0:0f:00
  312.  
  313. # SSH anomaly detection. For more information, see README.ssh
  314. preprocessor ssh: server_ports { 22 } autodetect max_client_bytes 19600 max_encrypted_packets 20 max_server_version_len 100 enable_respoverflow enable_ssh1crc32 enable_srvoverflow enable_protomismatch
  315.  
  316. # SMB / DCE-RPC normalization and anomaly detection. For more information, see README.dcerpc2
  317. preprocessor dcerpc2: memcap 102400, events [co ]
  318. preprocessor dcerpc2_server: default, policy WinXP, detect [smb [139,445], tcp 135, udp 135, rpc-over-http-server 593], autodetect [tcp 1025:, udp 1025:, rpc-over-http-server 1025:], smb_max_chain 3, smb_invalid_shares ["C$", "D$", "ADMIN$"]
  319.  
  320. # DNS anomaly detection. For more information, see README.dns
  321. preprocessor dns: ports { 53 } enable_rdata_overflow
  322.  
  323. # SSL anomaly detection and traffic bypass. For more information, see README.ssl
  324. preprocessor ssl: ports { 443 465 563 636 989 992 993 994 995 5061 7801 7802 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 }, trustservers, noinspect_encrypted
  325.  
  326. # SDF sensitive data preprocessor. For more information see README.sensitive_data
  327. preprocessor sensitive_data: alert_threshold 25
  328.  
  329. # SIP Session Initiation Protocol preprocessor. For more information see README.sip
  330. preprocessor sip: max_sessions 40000, ports { 5060 5061 5600 }, methods { invite cancel ack bye register options refer subscribe update join info message notify benotify do qauth sprack publish service unsubscribe prack }, max_uri_len 512, max_call_id_len 80, max_requestName_len 20, max_from_len 256, max_to_len 256, max_via_len 1024, max_contact_len 512, max_content_len 2048
  331.  
  332. # IMAP preprocessor. For more information see README.imap
  333. preprocessor imap: ports { 143 } b64_decode_depth 0 qp_decode_depth 0 bitenc_decode_depth 0 uu_decode_depth 0
  334.  
  335. # POP preprocessor. For more information see README.pop
  336. preprocessor pop: ports { 110 } b64_decode_depth 0 qp_decode_depth 0 bitenc_decode_depth 0 uu_decode_depth 0
  337.  
  338. # Modbus preprocessor. For more information see README.modbus
  339. preprocessor modbus: ports { 502 }
  340.  
  341. # DNP3 preprocessor. For more information see README.dnp3
  342. preprocessor dnp3: ports { 20000 } memcap 262144 check_crc
  343.  
  344. # Reputation preprocessor. For more information see README.reputation
  345. preprocessor reputation: memcap 500, priority whitelist, nested_ip inner, whitelist $WHITE_LIST_PATH\\white.list, blacklist $BLACK_LIST_PATH\\black.list
  346.  
  347. ###################################################
  348. # Step #6: Configure output plugins
  349. # For more information, see Snort Manual, Configuring Snort - Output Modules
  350. ###################################################
  351.  
  352. # unified2
  353. # Recommended for most installs
  354. # output unified2: filename merged.log, limit 128, nostamp, mpls_event_types, vlan_event_types
  355.  
  356. # Additional configuration for specific types of installs
  357. # output alert_unified2: filename snort.alert, limit 128, nostamp
  358. # output log_unified2: filename snort.log, limit 128, nostamp
  359.  
  360. # syslog
  361. # output alert_syslog: LOG_AUTH LOG_ALERT
  362.  
  363. # pcap
  364. # output log_tcpdump: tcpdump.log
  365.  
  366. # metadata reference data. do not modify these lines
  367. include classification.config
  368. include reference.config
  369.  
  370.  
  371. ###################################################
  372. # Step #7: Customize your rule set
  373. # For more information, see Snort Manual, Writing Snort Rules
  374. #
  375. # NOTE: All categories are enabled in this conf file
  376. ###################################################
  377.  
  378. # site specific rules
  379. #include $RULE_PATH\local.rules
  380. #include $RULE_PATH\community.rules
  381. include $RULE_PATH\\IoTProtection.rules
  382. #include $RULE_PATH/app-detect.rules
  383. #include $RULE_PATH/attack-responses.rules
  384. #include $RULE_PATH/backdoor.rules
  385. #include $RULE_PATH/bad-traffic.rules
  386. #include $RULE_PATH/blacklist.rules
  387. #include $RULE_PATH/botnet-cnc.rules
  388. #include $RULE_PATH/browser-chrome.rules
  389. #include $RULE_PATH/browser-firefox.rules
  390. #include $RULE_PATH/browser-ie.rules
  391. #include $RULE_PATH/browser-other.rules
  392. #include $RULE_PATH/browser-plugins.rules
  393. #include $RULE_PATH/browser-webkit.rules
  394. #include $RULE_PATH/chat.rules
  395. #include $RULE_PATH/content-replace.rules
  396. #include $RULE_PATH/ddos.rules
  397. #include $RULE_PATH/dns.rules
  398. #include $RULE_PATH/dos.rules
  399. #include $RULE_PATH/experimental.rules
  400. #include $RULE_PATH/exploit-kit.rules
  401. #include $RULE_PATH/exploit.rules
  402. #include $RULE_PATH/file-executable.rules
  403. #include $RULE_PATH/file-flash.rules
  404. #include $RULE_PATH/file-identify.rules
  405. #include $RULE_PATH/file-image.rules
  406. #include $RULE_PATH/file-java.rules
  407. #include $RULE_PATH/file-multimedia.rules
  408. #include $RULE_PATH/file-office.rules
  409. #include $RULE_PATH/file-other.rules
  410. #include $RULE_PATH/file-pdf.rules
  411. #include $RULE_PATH/finger.rules
  412. #include $RULE_PATH/ftp.rules
  413. #include $RULE_PATH/icmp-info.rules
  414. #include $RULE_PATH/icmp.rules
  415. #include $RULE_PATH/imap.rules
  416. #include $RULE_PATH/indicator-compromise.rules
  417. #include $RULE_PATH/indicator-obfuscation.rules
  418. #include $RULE_PATH/indicator-scan.rules
  419. #include $RULE_PATH/indicator-shellcode.rules
  420. #include $RULE_PATH/info.rules
  421. #include $RULE_PATH/malware-backdoor.rules
  422. #include $RULE_PATH/malware-cnc.rules
  423. #include $RULE_PATH/malware-other.rules
  424. #include $RULE_PATH/malware-tools.rules
  425. #include $RULE_PATH/misc.rules
  426. #include $RULE_PATH/multimedia.rules
  427. #include $RULE_PATH/mysql.rules
  428. #include $RULE_PATH/netbios.rules
  429. #include $RULE_PATH/nntp.rules
  430. #include $RULE_PATH/oracle.rules
  431. #include $RULE_PATH/os-linux.rules
  432. #include $RULE_PATH/os-mobile.rules
  433. #include $RULE_PATH/os-other.rules
  434. #include $RULE_PATH/os-solaris.rules
  435. #include $RULE_PATH/os-windows.rules
  436. #include $RULE_PATH/other-ids.rules
  437. #include $RULE_PATH/p2p.rules
  438. #include $RULE_PATH/phishing-spam.rules
  439. #include $RULE_PATH/policy-multimedia.rules
  440. #include $RULE_PATH/policy-other.rules
  441. #include $RULE_PATH/policy.rules
  442. #include $RULE_PATH/policy-social.rules
  443. #include $RULE_PATH/policy-spam.rules
  444. #include $RULE_PATH/pop2.rules
  445. #include $RULE_PATH/pop3.rules
  446. #include $RULE_PATH/protocol-dns.rules
  447. #include $RULE_PATH/protocol-finger.rules
  448. #include $RULE_PATH/protocol-ftp.rules
  449. #include $RULE_PATH/protocol-icmp.rules
  450. #include $RULE_PATH/protocol-imap.rules
  451. #include $RULE_PATH/protocol-nntp.rules
  452. #include $RULE_PATH/protocol-other.rules
  453. #include $RULE_PATH/protocol-pop.rules
  454. #include $RULE_PATH/protocol-rpc.rules
  455. #include $RULE_PATH/protocol-scada.rules
  456. #include $RULE_PATH/protocol-services.rules
  457. #include $RULE_PATH/protocol-snmp.rules
  458. #include $RULE_PATH/protocol-telnet.rules
  459. #include $RULE_PATH/protocol-tftp.rules
  460. #include $RULE_PATH/protocol-voip.rules
  461. #include $RULE_PATH/pua-adware.rules
  462. #include $RULE_PATH/pua-other.rules
  463. #include $RULE_PATH/pua-p2p.rules
  464. #include $RULE_PATH/pua-toolbars.rules
  465. #include $RULE_PATH/rpc.rules
  466. #include $RULE_PATH/rservices.rules
  467. #include $RULE_PATH/scada.rules
  468. #include $RULE_PATH/scan.rules
  469. #include $RULE_PATH/server-apache.rules
  470. #include $RULE_PATH/server-iis.rules
  471. #include $RULE_PATH/server-mail.rules
  472. #include $RULE_PATH/server-mssql.rules
  473. #include $RULE_PATH/server-mysql.rules
  474. #include $RULE_PATH/server-oracle.rules
  475. #include $RULE_PATH/server-other.rules
  476. #include $RULE_PATH/server-samba.rules
  477. #include $RULE_PATH/server-webapp.rules
  478. #include $RULE_PATH/shellcode.rules
  479. #include $RULE_PATH/smtp.rules
  480. #include $RULE_PATH/snmp.rules
  481. #include $RULE_PATH/specific-threats.rules
  482. #include $RULE_PATH/spyware-put.rules
  483. #include $RULE_PATH/sql.rules
  484. #include $RULE_PATH/telnet.rules
  485. #include $RULE_PATH/tftp.rules
  486. #include $RULE_PATH/virus.rules
  487. #include $RULE_PATH/voip.rules
  488. #include $RULE_PATH/web-activex.rules
  489. #include $RULE_PATH/web-attacks.rules
  490. #include $RULE_PATH/web-cgi.rules
  491. #include $RULE_PATH/web-client.rules
  492. #include $RULE_PATH/web-coldfusion.rules
  493. #include $RULE_PATH/web-frontpage.rules
  494. #include $RULE_PATH/web-iis.rules
  495. #include $RULE_PATH/web-misc.rules
  496. #include $RULE_PATH/web-php.rules
  497. #include $RULE_PATH/x11.rules
  498.  
  499. ###################################################
  500. # Step #8: Customize your preprocessor and decoder alerts
  501. # For more information, see README.decoder_preproc_rules
  502. ###################################################
  503.  
  504. # decoder and preprocessor event rules
  505. include $PREPROC_RULE_PATH\\preprocessor.rules
  506. include $PREPROC_RULE_PATH\\decoder.rules
  507. include $PREPROC_RULE_PATH\\sensitive-data.rules
  508.  
  509. ###################################################
  510. # Step #9: Customize your Shared Object Snort Rules
  511. # For more information, see http://vrt-blog.snort.org/2009/01/using-vrt-certified-shared-object-rules.html
  512. ###################################################
  513.  
  514. # dynamic library rules
  515. # include $SO_RULE_PATH/browser-ie.rules
  516. # include $SO_RULE_PATH/browser-other.rules
  517. # include $SO_RULE_PATH/exploit-kit.rules
  518. # include $SO_RULE_PATH/file-flash.rules
  519. # include $SO_RULE_PATH/file-image.rules
  520. # include $SO_RULE_PATH/file-java.rules
  521. # include $SO_RULE_PATH/file-multimedia.rules
  522. # include $SO_RULE_PATH/file-office.rules
  523. # include $SO_RULE_PATH/file-other.rules
  524. # include $SO_RULE_PATH/file-pdf.rules
  525. # include $SO_RULE_PATH/indicator-shellcode.rules
  526. # include $SO_RULE_PATH/malware-cnc.rules
  527. # include $SO_RULE_PATH/malware-other.rules
  528. # include $SO_RULE_PATH/netbios.rules
  529. # include $SO_RULE_PATH/os-linux.rules
  530. # include $SO_RULE_PATH/os-other.rules
  531. # include $SO_RULE_PATH/os-windows.rules
  532. # include $SO_RULE_PATH/policy-social.rules
  533. # include $SO_RULE_PATH/protocol-dns.rules
  534. # include $SO_RULE_PATH/protocol-nntp.rules
  535. # include $SO_RULE_PATH/protocol-other.rules
  536. # include $SO_RULE_PATH/protocol-snmp.rules
  537. # include $SO_RULE_PATH/protocol-voip.rules
  538. # include $SO_RULE_PATH/pua-p2p.rules
  539. # include $SO_RULE_PATH/server-apache.rules
  540. # include $SO_RULE_PATH/server-iis.rules
  541. # include $SO_RULE_PATH/server-mail.rules
  542. # include $SO_RULE_PATH/server-mysql.rules
  543. # include $SO_RULE_PATH/server-oracle.rules
  544. # include $SO_RULE_PATH/server-other.rules
  545. # include $SO_RULE_PATH/server-webapp.rules
  546.  
  547. # legacy dynamic library rule files
  548. # include $SO_RULE_PATH/bad-traffic.rules
  549. # include $SO_RULE_PATH/browser-ie.rules
  550. # include $SO_RULE_PATH/chat.rules
  551. # include $SO_RULE_PATH/dos.rules
  552. # include $SO_RULE_PATH/exploit.rules
  553. # include $SO_RULE_PATH/file-flash.rules
  554. # include $SO_RULE_PATH/icmp.rules
  555. # include $SO_RULE_PATH/imap.rules
  556. # include $SO_RULE_PATH/misc.rules
  557. # include $SO_RULE_PATH/multimedia.rules
  558. # include $SO_RULE_PATH/netbios.rules
  559. # include $SO_RULE_PATH/nntp.rules
  560. # include $SO_RULE_PATH/p2p.rules
  561. # include $SO_RULE_PATH/smtp.rules
  562. # include $SO_RULE_PATH/snmp.rules
  563. # include $SO_RULE_PATH/specific-threats.rules
  564. # include $SO_RULE_PATH/web-activex.rules
  565. # include $SO_RULE_PATH/web-client.rules
  566. # include $SO_RULE_PATH/web-iis.rules
  567. # include $SO_RULE_PATH/web-misc.rules
  568.  
  569. # Event thresholding or suppression commands. See threshold.conf
  570. include threshold.conf"""
  571.  
  572. #Checks to see if rule is already implemented
  573. def rulecreation():
  574. if os.path.exists('C:\\Snort\\rules\\IoTProtection.rules') and os.path.exists('C:\\Snort\\rules\\black.list') and os.path.exists ('C\\Snort\\rules\\white.list'):
  575. print("Already Protected!")
  576. input("Press Enter key to continue.")
  577.  
  578.  
  579. #creates the rule in correct directory
  580. else:
  581. newfile = open("C:\\Snort\\Rules\\IoTProtection.rules",'w')
  582. print("File Created!")
  583. modified = newfile.write("reject tcp any any -> {} 23 (msg:""Unauthorized access to IoT device!""; sid:212345;rev:003; )".format(DeviceIP))
  584. whitelist = open("C:\\Snort\Rules\\white.list",'w')
  585. blacklist = open("C:\\Snort\Rules\\black.list",'w')
  586. print("Rules Added!")
  587. input("Press Enter key to continue.")
  588. return newfile
  589.  
  590. #Swaps old config for new
  591. def configswap(configtext):
  592.  
  593.  
  594. if os.path.exists("C:\\Snort\\etc\\snort.conf"):
  595. os.remove("C:\\Snort\\etc\\snort.conf")
  596.  
  597.  
  598. newconf = open("C:\\Snort\\etc\\snort.conf",'w')
  599. modconf = newconf.write(configtext)
  600. print("Config Swapped!")
  601.  
  602.  
  603. #Sets deviceIP as ip address in config file
  604. def ipswap():
  605. text = "ipvar HOME_NET any" # if any line contains this text, I want to modify the whole line.
  606. new_text = "ipvar HOME_NET {}".format(DeviceIP)
  607.  
  608. for line in fileinput.input("C:\\Snort\\etc\\snort.conf", inplace = 1):
  609. if text in line:
  610. print(line.replace(line,new_text))
  611.  
  612. else:
  613. print(line.strip())
  614.  
  615.  
  616.  
  617. def adddevice():
  618. decision = input("If you would like to add further devices please enter 1, or press enter to end.")
  619. if decision == '1':
  620. ip = input(str("Please enter additional devices IP here, including dots."))
  621. append = open("C:\\Snort\Rules\IoTProtection.rules",'a')
  622. added = append.write("reject tcp any any -> {} 23 (msg:""Unauthorized access to IoT device!""; sid:212345;rev:003; )")
  623. configured = added.format(str(ip))
  624. print("Device added!")
  625. else:
  626. quit()
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633. rulecreation()
  634. configswap(configtext)
  635. ipswap()
  636. adddevice()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement