diff --git a/CHANGES b/CHANGES index 06ad4c1fa2..6dbaea2555 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,216 @@ +2.4-beta | 2015-05-07 21:55:31 -0700 + + * Release 2.4-beta. + + * Update local-compat.test (Johanna Amann) + +2.3-913 | 2015-05-06 09:58:00 -0700 + + * Add /sbin to PATH in btest.cfg and remove duplicate default_path. + (Daniel Thayer) + +2.3-911 | 2015-05-04 09:58:09 -0700 + + * Update usage output and list of command line options. (Daniel + Thayer) + + * Fix to ssh/geo-data.bro for unset directions. (Vlad Grigorescu) + + * Improve SIP logging and remove reporter messages. (Seth Hall) + +2.3-905 | 2015-04-29 17:01:30 -0700 + + * Improve SIP logging and remove reporter messages. (Seth Hall) + +2.3-903 | 2015-04-27 17:27:59 -0700 + + * BIT-1350: Improve record coercion type checking. (Jon Siwek) + +2.3-901 | 2015-04-27 17:25:27 -0700 + + * BIT-1384: Remove -O (optimize scripts) command-line option, which + hadn't been working for a while already. (Jon Siwek) + +2.3-899 | 2015-04-27 17:22:42 -0700 + + * Fix the -J/--set-seed cmd-line option. (Daniel Thayer) + + * Remove unused -l, -L, and -Z cmd-line options. (Daniel Thayer) + +2.3-892 | 2015-04-27 08:22:22 -0700 + + * Fix typos in the Broker BIF documentation. (Daniel Thayer) + + * Update installation instructions and remove outdated references. + (Johanna Amann) + + * Easier support for systems with tcmalloc_minimal installed. (Seth + Hall) + +2.3-884 | 2015-04-23 12:30:15 -0500 + + * Fix some outdated documentation unit tests. (Jon Siwek) + +2.3-883 | 2015-04-23 07:10:36 -0700 + + * Fix -N option to work with builtin plugins as well. (Robin Sommer) + +2.3-882 | 2015-04-23 06:59:40 -0700 + + * Add missing .pac dependencies for some binpac analyzer targets. + (Jon Siwek) + +2.3-879 | 2015-04-22 10:38:07 -0500 + + * Fix compile errors. (Jon Siwek) + +2.3-878 | 2015-04-22 08:21:23 -0700 + + * Fix another compiler warning in DTLS. (Johanna Amann) + +2.3-877 | 2015-04-21 20:14:16 -0700 + + * Adding missing include. (Robin Sommer) + +2.3-876 | 2015-04-21 16:40:10 -0700 + + * Attempt at fixing a potential std::length_error exception in RDP + analyzer. Addresses BIT-1337. (Robin Sommer) + + * Fixing compile problem caused by overeager factorization. (Robin + Sommer) + +2.3-874 | 2015-04-21 16:09:20 -0700 + + * Change details of escaping when logging/printing. (Seth Hall/Robin + Sommer) + + - Log files now escape non-printable characters consistently + as "\xXX'. Furthermore, backslashes are escaped as "\\", + making the representation fully reversible. + + - When escaping via script-level functions (escape_string, + clean), we likewise now escape consistently with "\xXX" and + "\\". + + - There's no "alternative" output style anymore, i.e., fmt() + '%A' qualifier is gone. + + Addresses BIT-1333. + + * Remove several BroString escaping methods that are no longer + useful. (Seth Hall) + +2.3-864 | 2015-04-21 15:24:02 -0700 + + * A SIP protocol analyzer. (Vlad Grigorescu) + + Activity gets logged into sip.log. It generates the following + events: + + event sip_request(c: connection, method: string, original_URI: string, version: string); + event sip_reply(c: connection, version: string, code: count, reason: string); + event sip_header(c: connection, is_orig: bool, name: string, value: string); + event sip_all_headers(c: connection, is_orig: bool, hlist: mime_header_list); + event sip_begin_entity(c: connection, is_orig: bool); + event sip_end_entity(c: connection, is_orig: bool); + + The analyzer support SIP over UDP currently. + + * BIT-1343: Factor common ASN.1 code from RDP, SNMP, and Kerberos + analyzers. (Jon Siwek/Robin Sommer) + +2.3-838 | 2015-04-21 13:40:12 -0700 + + * BIT-1373: Fix vector index assignment reference count bug. (Jon Siwek) + +2.3-836 | 2015-04-21 13:37:31 -0700 + + * Fix SSH direction field being unset. Addresses BIT-1365. (Vlad + Grigorescu) + +2.3-835 | 2015-04-21 16:36:00 -0500 + + * Clarify Broker examples. (Jon Siwek) + +2.3-833 | 2015-04-21 12:38:32 -0700 + + * A Kerberos protocol analyzer. (Vlad Grigorescu) + + Activity gets logged into kerberos.log. It generates the following + events: + + event krb_as_request(c: connection, msg: KRB::KDC_Request); + event krb_as_response(c: connection, msg: KRB::KDC_Response); + event krb_tgs_request(c: connection, msg: KRB::KDC_Request); + event krb_tgs_response(c: connection, msg: KRB::KDC_Response); + event krb_ap_request(c: connection, ticket: KRB::Ticket, opts: KRB::AP_Options); + event krb_priv(c: connection, is_orig: bool); + event krb_safe(c: connection, is_orig: bool, msg: KRB::SAFE_Msg); + event krb_cred(c: connection, is_orig: bool, tickets: KRB::Ticket_Vector); + event krb_error(c: connection, msg: KRB::Error_Msg); + +2.3-793 | 2015-04-20 20:51:00 -0700 + + * Add decoding of PROXY-AUTHORIZATION header to HTTP analyze, + treating it the same as AUTHORIZATION. (Josh Liburdi) + + * Remove deprecated fields "hot" and "addl" from the connection + record. Remove the functions append_addl() and + append_addl_marker(). (Robin Sommer) + + * Removing the NetFlow analyzer, which hasn't been used anymore + since then corresponding command-line option went away. (Robin + Sommer) + +2.3-787 | 2015-04-20 19:15:23 -0700 + + * A file analyzer for Portable Executables. (Vlad Grigorescu/Seth + Hall). + + Activity gets logged into pe.log. It generates the following + events: + + event pe_dos_header(f: fa_file, h: PE::DOSHeader); + event pe_dos_code(f: fa_file, code: string); + event pe_file_header(f: fa_file, h: PE::FileHeader); + event pe_optional_header(f: fa_file, h: PE::OptionalHeader); + event pe_section_header(f: fa_file, h: PE::SectionHeader); + +2.3-741 | 2015-04-20 13:12:39 -0700 + + * API changes to file analysis mime type detection. Removed + "file_mime_type" and "file_mime_types" event, replacing them with + a new event called "file_metadata_inferred". Addresses BIT-1368. + (Jon Siwek) + + * A large series of improvements for file type identification. This + inludes a many signature updates (new types, cleanup, performance + improvments) and splitting out signatures into subfiles. (Seth + Hall) + + * Fix an issue with files having gaps before the bof_buffer is + filled, which could lead to file type identification not working + correctly. (Seth Hall) + + * Fix an issue with packet loss in HTTP file reporting for file type + identification wasn't working correctly zero-length bodies. (Seth + Hall) + + * X.509 certificates are now populating files.log with the mime type + application/pkix-cert. (Seth Hall) + + * Normalized some FILE_ANALYSIS debug messages. (Seth Hall) + +2.3-725 | 2015-04-20 12:54:54 -0700 + + * Updating submodule(s). + +2.3-724 | 2015-04-20 14:11:02 -0500 + + * Fix uninitialized field in raw input reader. (Jon Siwek) + 2.3-722 | 2015-04-20 12:59:03 -0500 * Remove unneeded documentation cross-referencing. (Jon Siwek) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f60ab95ad..2b1e060f77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,7 @@ if (NOT DISABLE_PERFTOOLS) find_package(GooglePerftools) endif () -if (GOOGLEPERFTOOLS_FOUND) +if (GOOGLEPERFTOOLS_FOUND OR TCMALLOC_FOUND) set(HAVE_PERFTOOLS true) # Non-Linux systems may not be well-supported by gperftools, so # require explicit request from user to enable it in that case. diff --git a/NEWS b/NEWS index 93ffbea5a3..54deaf1e25 100644 --- a/NEWS +++ b/NEWS @@ -13,10 +13,12 @@ New Functionality - Bro now has support for external plugins that can extend its core functionality, like protocol/file analysis, via shared libraries. Plugins can be developed and distributed externally, and will be - pulled in dynamically at startup. Currently, a plugin can provide - custom protocol analyzers, file analyzers, log writers, input - readers, packet sources and dumpers, and new built-in functions. A - plugin can furthermore hook into Bro's processing at a number of + pulled in dynamically at startup (the environment variables + BRO_PLUGIN_PATH and BRO_PLUGIN_ACTIVATE can be used to specify the + locations and names of plugins to activate). Currently, a plugin + can provide custom protocol analyzers, file analyzers, log writers, + input readers, packet sources and dumpers, and new built-in functions. + A plugin can furthermore hook into Bro's processing at a number of places to add custom logic. See https://www.bro.org/sphinx-git/devel/plugins.html for more @@ -25,17 +27,37 @@ New Functionality - Bro now has support for the MySQL wire protocol. Activity gets logged into mysql.log. -- Bro now parses DTLS traffic. +- Bro now parses DTLS traffic. Activity gets logged into ssl.log. -- Bro now has an RDP analyzer. +- Bro now has support for the Kerberos KRB5 protocol over TCP and + UDP. Activity gets logged into kerberos.log. -- Bro now features a completely rewritten, enhanced SSH analyzer, with - a set of addedd events being generated. A lot more information about - SSH sessions is logged. The analyzer is able to determine if logins - failed or succeeded in most circumstances. +- Bro now has an RDP analyzer. Activity gets logged into rdp.log. + +- Bro now has a file analyzer for Portable Executables. Activity gets + logged into pe.log. + +- Bro now has support for the SIP protocol over UDP. Activity gets + logged into sip.log. + +- Bro now features a completely rewritten, enhanced SSH analyzer. The + new analyzer is able to determine if logins failed or succeeded in + most circumstances, logs a lot more more information about SSH + sessions, supports v1, and introduces the intelligence type + ``Intel::PUBKEY_HASH`` and location ``SSH::IN_SERVER_HOST_KEY``. The + analayzer also generates a set of additional events + (``ssh_auth_successful``, ``ssh_auth_failed``, ``ssh_capabilities``, + ``ssh2_server_host_key``, ``ssh1_server_host_key``, + ``ssh_encrypted_packet``, ``ssh2_dh_server_params``, + ``ssh2_gss_error``, ``ssh2_ecc_key``). See next section for + incompatible SSH changes. - Bro's file analysis now supports reassembly of files that are not - transferred/seen sequentially. + transferred/seen sequentially. The default file reassembly buffer + size is set with the ``Files::reassembly_buffer_size`` variable. + +- Bro's file type identification has been greatly improved (new file types, + bug fixes, and performance improvements). - Bro's scripting language now has a ``while`` statement:: @@ -61,7 +83,7 @@ New Functionality C++11 compiler (e.g. GCC 4.8+ or Clang 3.3+). Broker will become a mandatory dependency in future Bro versions and - replace the current communcation and serialization system. + replace the current communication and serialization system. - Add --enable-c++11 configure flag to compile Bro's source code in C++11 mode with a corresponding compiler. Note that 2.4 will be the @@ -69,10 +91,10 @@ New Functionality - The SSL analysis now alerts when encountering SSL connections with old protocol versions or unsafe cipher suites. It also gained - extended reporting of weak keys, caching of already valdidated - certificates, full support TLS record defragmentation. SSL generally + extended reporting of weak keys, caching of already validated + certificates, and full support for TLS record defragmentation. SSL generally became much more robust and added several fields to ssl.log (while - removing some other). + removing some others). - A new icmp_sent_payload event provides access to ICMP payload. @@ -85,6 +107,9 @@ New Functionality threshold in terms of packets or bytes. The primary API for that functionality is in base/protocols/conn/thresholds.bro. +- There is a new command-line option -Q/--time that prints Bro's execution + time and memory usage to stderr. + - BroControl now has a new command "deploy" which is equivalent to running the "check", "install", "stop", and "start" commands (in that order). @@ -114,14 +139,17 @@ Changed Functionality - File analysis * Removed ``fa_file`` record's ``mime_type`` and ``mime_types`` - fields. The events ``file_mime_type`` and ``file_mime_types`` - have been added which contain the same information. The - ``mime_type`` field of ``Files::Info`` also still has this info. + fields. The event ``file_sniff`` has been added which provides + the same information. The ``mime_type`` field of ``Files::Info`` + also still has this info. * The earliest point that new mime type information is available is - in the ``file_mime_type`` event which comes after the ``file_new`` - and ``file_over_new_connection`` events. Scripts which inspected - mime type info within those events will need to be adapted. + in the ``file_sniff`` event which comes after the ``file_new`` and + ``file_over_new_connection`` events. Scripts which inspected mime + type info within those events will need to be adapted. (Note: for + users that worked w/ versions of Bro from git, for a while there was + also an event called ``file_mime_type`` which is now replaced with + the ``file_sniff`` event). * Removed ``Files::add_analyzers_for_mime_type`` function. @@ -130,10 +158,22 @@ Changed Functionality reassembly for non-sequential files, "offset" can be obtained with other information already available -- adding together ``seen_bytes`` and ``missed_bytes`` fields of the ``fa_file`` - record gives the how many bytes have been written so far (i.e. + record gives how many bytes have been written so far (i.e. the "offset"). -- has_valid_octets: now uses a string_vec parameter instead of +- The SSH changes come with a few incompatibilities. The following + events have been renamed: + + * ``SSH::heuristic_failed_login`` to ``SSH::ssh_auth_failed`` + * ``SSH::heuristic_successful_login`` to ``SSH::ssh_auth_successful`` + + The ``SSH::Info`` status field has been removed and replaced with + the ``auth_success`` field. This field has been changed from a + string that was previously ``success``, ``failure`` or + ``undetermined`` to a boolean. a boolean that is ``T``, ``F``, or + unset. + +- The has_valid_octets function now uses a string_vec parameter instead of string_array. - conn.log gained a new field local_resp that works like local_orig, @@ -176,6 +216,25 @@ Changed Functionality - BroControl now sends all normal command output (i.e., not error messages) to stdout. Error messages are still sent to stderr, however. +- The capability of processing NetFlow input has been removed for the + time being. Therefore, the -y/--flowfile and -Y/--netflow command-line + options have been removed, and the netflow_v5_header and netflow_v5_record + events have been removed. + +- The -D/--dfa-size command-line option has been removed. + +- The -L/--rule-benchmark command-line option has been removed. + +- The -O/--optimize command-line option has been removed. + +- The deprecated fields "hot" and "addl" have been removed from the + connection record. Likewise, the functions append_addl() and + append_addl_marker() have been removed. + +- Log files now escape non-printable characters consistently as "\xXX'. + Furthermore, backslashes are escaped as "\\", making the + representation fully reversible. + Deprecated Functionality ------------------------ @@ -185,7 +244,7 @@ Deprecated Functionality concatenation/extraction functions. Note that the new functions use 0-based indexing, rather than 1-based. - The full list of now deprecation functions is: + The full list of now deprecated functions is: * split: use split_string instead. diff --git a/VERSION b/VERSION index 3e69beb37a..0a8901319c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.3-722 +2.4-beta diff --git a/aux/binpac b/aux/binpac index 544330932e..4f33233aef 160000 --- a/aux/binpac +++ b/aux/binpac @@ -1 +1 @@ -Subproject commit 544330932e7cd4615d6d19f63907e8aa2acebb9e +Subproject commit 4f33233aef5539ae4f12c6d0e4338247833c3900 diff --git a/aux/bro-aux b/aux/bro-aux index 462e300bf9..a2d290a832 160000 --- a/aux/bro-aux +++ b/aux/bro-aux @@ -1 +1 @@ -Subproject commit 462e300bf9c37dcc39b70a4c2d89d19f7351c804 +Subproject commit a2d290a832c35ad11f3fabb19812bcae2ff089cd diff --git a/aux/broccoli b/aux/broccoli index 45276b39a9..74bb4bbd94 160000 --- a/aux/broccoli +++ b/aux/broccoli @@ -1 +1 @@ -Subproject commit 45276b39a946d70095c983753cd321ad07dcf285 +Subproject commit 74bb4bbd949e61e099178f8a97499d3f1355de8b diff --git a/aux/broctl b/aux/broctl index e864a0949e..97c17d2172 160000 --- a/aux/broctl +++ b/aux/broctl @@ -1 +1 @@ -Subproject commit e864a0949e52a797f4000194b5c2980cf3618deb +Subproject commit 97c17d21725e42b36f4b49579077ecdc28ddb86a diff --git a/aux/broker b/aux/broker index 0c25c1daa7..b02fefd5cf 160000 --- a/aux/broker +++ b/aux/broker @@ -1 +1 @@ -Subproject commit 0c25c1daa7dcf885dd16cc1b725295dc36decafe +Subproject commit b02fefd5cf78c1576e59c106f5211ce5ae47cfdd diff --git a/aux/btest b/aux/btest index d69df586c9..80b42ee3e4 160000 --- a/aux/btest +++ b/aux/btest @@ -1 +1 @@ -Subproject commit d69df586c91531db0c3abe838b10a429dda4fa87 +Subproject commit 80b42ee3e4503783b6720855b28e83ff1658c22b diff --git a/aux/plugins b/aux/plugins index 7a14085394..e1ea9f67cf 160000 --- a/aux/plugins +++ b/aux/plugins @@ -1 +1 @@ -Subproject commit 7a14085394e54a950e477eb4fafb3827ff8dbdc3 +Subproject commit e1ea9f67cfe3d6a81e0c1479ced0b9aa73e77c87 diff --git a/cmake b/cmake index 2fd35ab6a6..6406fb79d3 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 2fd35ab6a6245a005828c32f0aa87eb21698c054 +Subproject commit 6406fb79d30df8d7956110ce65a97d18e4bc8c3b diff --git a/doc/frameworks/broker/connecting-connector.bro b/doc/frameworks/broker/connecting-connector.bro index 017f88f214..a7e621e4a6 100644 --- a/doc/frameworks/broker/connecting-connector.bro +++ b/doc/frameworks/broker/connecting-connector.bro @@ -1,5 +1,5 @@ -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; redef BrokerComm::endpoint_name = "connector"; diff --git a/doc/frameworks/broker/connecting-listener.bro b/doc/frameworks/broker/connecting-listener.bro index 2732bed760..c37af3ae4d 100644 --- a/doc/frameworks/broker/connecting-listener.bro +++ b/doc/frameworks/broker/connecting-listener.bro @@ -1,5 +1,5 @@ -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; redef BrokerComm::endpoint_name = "listener"; diff --git a/doc/frameworks/broker/events-connector.bro b/doc/frameworks/broker/events-connector.bro index fc0e48769b..1ad458c245 100644 --- a/doc/frameworks/broker/events-connector.bro +++ b/doc/frameworks/broker/events-connector.bro @@ -1,4 +1,4 @@ -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; redef BrokerComm::endpoint_name = "connector"; global my_event: event(msg: string, c: count); diff --git a/doc/frameworks/broker/events-listener.bro b/doc/frameworks/broker/events-listener.bro index 09a99b7c97..aa6ea9ee4e 100644 --- a/doc/frameworks/broker/events-listener.bro +++ b/doc/frameworks/broker/events-listener.bro @@ -1,5 +1,5 @@ -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; redef BrokerComm::endpoint_name = "listener"; global msg_count = 0; diff --git a/doc/frameworks/broker/logs-connector.bro b/doc/frameworks/broker/logs-connector.bro index cdd50b7140..6089419cab 100644 --- a/doc/frameworks/broker/logs-connector.bro +++ b/doc/frameworks/broker/logs-connector.bro @@ -1,6 +1,6 @@ @load ./testlog -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; redef BrokerComm::endpoint_name = "connector"; redef Log::enable_local_logging = F; diff --git a/doc/frameworks/broker/logs-listener.bro b/doc/frameworks/broker/logs-listener.bro index 788d459cc8..5c807f08b7 100644 --- a/doc/frameworks/broker/logs-listener.bro +++ b/doc/frameworks/broker/logs-listener.bro @@ -1,6 +1,6 @@ @load ./testlog -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; redef BrokerComm::endpoint_name = "listener"; diff --git a/doc/frameworks/broker/printing-connector.bro b/doc/frameworks/broker/printing-connector.bro index 9135f8f4c4..2a504ffba0 100644 --- a/doc/frameworks/broker/printing-connector.bro +++ b/doc/frameworks/broker/printing-connector.bro @@ -1,4 +1,4 @@ -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; redef BrokerComm::endpoint_name = "connector"; diff --git a/doc/frameworks/broker/printing-listener.bro b/doc/frameworks/broker/printing-listener.bro index 12abf9131e..080d09e8f5 100644 --- a/doc/frameworks/broker/printing-listener.bro +++ b/doc/frameworks/broker/printing-listener.bro @@ -1,5 +1,5 @@ -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; redef BrokerComm::endpoint_name = "listener"; global msg_count = 0; diff --git a/doc/frameworks/broker/stores-connector.bro b/doc/frameworks/broker/stores-connector.bro index 82fb54dcdb..5db8657a68 100644 --- a/doc/frameworks/broker/stores-connector.bro +++ b/doc/frameworks/broker/stores-connector.bro @@ -1,4 +1,4 @@ -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; global h: opaque of BrokerStore::Handle; diff --git a/doc/frameworks/broker/stores-listener.bro b/doc/frameworks/broker/stores-listener.bro index 0a8dc85e13..454e41a8c2 100644 --- a/doc/frameworks/broker/stores-listener.bro +++ b/doc/frameworks/broker/stores-listener.bro @@ -1,4 +1,4 @@ -const broker_port: port &redef; +const broker_port: port = 9999/tcp &redef; redef exit_only_after_terminate = T; global h: opaque of BrokerStore::Handle; diff --git a/doc/frameworks/file_analysis_02.bro b/doc/frameworks/file_analysis_02.bro index 141b11fca6..fd4f0e775e 100644 --- a/doc/frameworks/file_analysis_02.bro +++ b/doc/frameworks/file_analysis_02.bro @@ -1,7 +1,8 @@ -event file_mime_type(f: fa_file, mime_type: string) +event file_sniff(f: fa_file, meta: fa_metadata) { + if ( ! meta?$mime_type ) return; print "new file", f$id; - if ( mime_type == "text/plain" ) + if ( meta$mime_type == "text/plain" ) Files::add_analyzer(f, Files::ANALYZER_MD5); } diff --git a/doc/httpmonitor/file_extraction.bro b/doc/httpmonitor/file_extraction.bro index 3860cb361e..c387156b62 100644 --- a/doc/httpmonitor/file_extraction.bro +++ b/doc/httpmonitor/file_extraction.bro @@ -7,15 +7,18 @@ global mime_to_ext: table[string] of string = { ["text/html"] = "html", }; -event file_mime_type(f: fa_file, mime_type: string) +event file_sniff(f: fa_file, meta: fa_metadata) { if ( f$source != "HTTP" ) return; - if ( mime_type !in mime_to_ext ) + if ( ! meta?$mime_type ) return; - local fname = fmt("%s-%s.%s", f$source, f$id, mime_to_ext[mime_type]); + if ( meta$mime_type !in mime_to_ext ) + return; + + local fname = fmt("%s-%s.%s", f$source, f$id, mime_to_ext[meta$mime_type]); print fmt("Extracting file %s", fname); Files::add_analyzer(f, Files::ANALYZER_EXTRACT, [$extract_filename=fname]); - } \ No newline at end of file + } diff --git a/doc/install/install.rst b/doc/install/install.rst index a3531f70c3..18bacd7758 100644 --- a/doc/install/install.rst +++ b/doc/install/install.rst @@ -68,7 +68,7 @@ that ``bash`` and ``python`` are in your ``PATH``): .. console:: - sudo pkg_add -r bash cmake swig bison python perl + sudo pkg_add -r bash cmake swig bison python perl py27-sqlite3 * Mac OS X: @@ -113,19 +113,15 @@ Using Pre-Built Binary Release Packages ======================================= See the `bro downloads page`_ for currently supported/targeted -platforms for binary releases. +platforms for binary releases and for installation instructions. -* RPM +* Linux Packages - .. console:: - - sudo yum localinstall Bro-*.rpm - -* DEB - - .. console:: - - sudo gdebi Bro-*.deb + Linux based binary installations are usually performed by adding + information about the Bro packages to the respective system packaging + tool. Theen the usual system utilities such as ``apt``, ``yum`` + or ``zyppper`` are used to perforn the installation. By default, + installations of binary packages will go into ``/opt/bro``. * MacOS Disk Image with Installer @@ -133,8 +129,6 @@ platforms for binary releases. Everything installed by the package will go into ``/opt/bro``. The primary install prefix for binary packages is ``/opt/bro``. -Non-MacOS packages that include BroControl also put variable/runtime -data (e.g. Bro logs) in ``/var/opt/bro``. Installing from Source ========================== diff --git a/doc/scripting/index.rst b/doc/scripting/index.rst index 11c2119df9..2b5cfbb49c 100644 --- a/doc/scripting/index.rst +++ b/doc/scripting/index.rst @@ -363,7 +363,7 @@ decrypted from HTTP streams is stored in excerpt from :doc:`/scripts/base/protocols/http/main.bro` below. .. btest-include:: ${BRO_SRC_ROOT}/scripts/base/protocols/http/main.bro - :lines: 9-11,20-22,121 + :lines: 9-11,20-22,125 Because the constant was declared with the ``&redef`` attribute, if we needed to turn this option on globally, we could do so by adding the diff --git a/scripts/base/files/pe/__load__.bro b/scripts/base/files/pe/__load__.bro new file mode 100644 index 0000000000..0098b81a7a --- /dev/null +++ b/scripts/base/files/pe/__load__.bro @@ -0,0 +1,2 @@ +@load ./consts +@load ./main \ No newline at end of file diff --git a/scripts/base/files/pe/consts.bro b/scripts/base/files/pe/consts.bro new file mode 100644 index 0000000000..35ad9c3c61 --- /dev/null +++ b/scripts/base/files/pe/consts.bro @@ -0,0 +1,184 @@ + +module PE; + +export { + const machine_types: table[count] of string = { + [0x00] = "UNKNOWN", + [0x1d3] = "AM33", + [0x8664] = "AMD64", + [0x1c0] = "ARM", + [0x1c4] = "ARMNT", + [0xaa64] = "ARM64", + [0xebc] = "EBC", + [0x14c] = "I386", + [0x200] = "IA64", + [0x9041] = "M32R", + [0x266] = "MIPS16", + [0x366] = "MIPSFPU", + [0x466] = "MIPSFPU16", + [0x1f0] = "POWERPC", + [0x1f1] = "POWERPCFP", + [0x166] = "R4000", + [0x1a2] = "SH3", + [0x1a3] = "SH3DSP", + [0x1a6] = "SH4", + [0x1a8] = "SH5", + [0x1c2] = "THUMB", + [0x169] = "WCEMIPSV2" + } &default=function(i: count):string { return fmt("unknown-%d", i); }; + + const file_characteristics: table[count] of string = { + [0x1] = "RELOCS_STRIPPED", + [0x2] = "EXECUTABLE_IMAGE", + [0x4] = "LINE_NUMS_STRIPPED", + [0x8] = "LOCAL_SYMS_STRIPPED", + [0x10] = "AGGRESSIVE_WS_TRIM", + [0x20] = "LARGE_ADDRESS_AWARE", + [0x80] = "BYTES_REVERSED_LO", + [0x100] = "32BIT_MACHINE", + [0x200] = "DEBUG_STRIPPED", + [0x400] = "REMOVABLE_RUN_FROM_SWAP", + [0x800] = "NET_RUN_FROM_SWAP", + [0x1000] = "SYSTEM", + [0x2000] = "DLL", + [0x4000] = "UP_SYSTEM_ONLY", + [0x8000] = "BYTES_REVERSED_HI" + } &default=function(i: count):string { return fmt("unknown-%d", i); }; + + const dll_characteristics: table[count] of string = { + [0x40] = "DYNAMIC_BASE", + [0x80] = "FORCE_INTEGRITY", + [0x100] = "NX_COMPAT", + [0x200] = "NO_ISOLATION", + [0x400] = "NO_SEH", + [0x800] = "NO_BIND", + [0x2000] = "WDM_DRIVER", + [0x8000] = "TERMINAL_SERVER_AWARE" + } &default=function(i: count):string { return fmt("unknown-%d", i); }; + + const windows_subsystems: table[count] of string = { + [0] = "UNKNOWN", + [1] = "NATIVE", + [2] = "WINDOWS_GUI", + [3] = "WINDOWS_CUI", + [7] = "POSIX_CUI", + [9] = "WINDOWS_CE_GUI", + [10] = "EFI_APPLICATION", + [11] = "EFI_BOOT_SERVICE_DRIVER", + [12] = "EFI_RUNTIME_
DRIVER", + [13] = "EFI_ROM", + [14] = "XBOX" + } &default=function(i: count):string { return fmt("unknown-%d", i); }; + + const directories: table[count] of string = { + [0] = "Export Table", + [1] = "Import Table", + [2] = "Resource Table", + [3] = "Exception Table", + [4] = "Certificate Table", + [5] = "Base Relocation Table", + [6] = "Debug", + [7] = "Architecture", + [8] = "Global Ptr", + [9] = "TLS Table", + [10] = "Load Config Table", + [11] = "Bound Import", + [12] = "IAT", + [13] = "Delay Import Descriptor", + [14] = "CLR Runtime Header", + [15] = "Reserved" + } &default=function(i: count):string { return fmt("unknown-%d", i); }; + + const section_characteristics: table[count] of string = { + [0x8] = "TYPE_NO_PAD", + [0x20] = "CNT_CODE", + [0x40] = "CNT_INITIALIZED_DATA", + [0x80] = "CNT_UNINITIALIZED_DATA", + [0x100] = "LNK_OTHER", + [0x200] = "LNK_INFO", + [0x800] = "LNK_REMOVE", + [0x1000] = "LNK_COMDAT", + [0x8000] = "GPREL", + [0x20000] = "MEM_16BIT", + [0x40000] = "MEM_LOCKED", + [0x80000] = "MEM_PRELOAD", + [0x100000] = "ALIGN_1BYTES", + [0x200000] = "ALIGN_2BYTES", + [0x300000] = "ALIGN_4BYTES", + [0x400000] = "ALIGN_8BYTES", + [0x500000] = "ALIGN_16BYTES", + [0x600000] = "ALIGN_32BYTES", + [0x700000] = "ALIGN_64BYTES", + [0x800000] = "ALIGN_128BYTES", + [0x900000] = "ALIGN_256BYTES", + [0xa00000] = "ALIGN_512BYTES", + [0xb00000] = "ALIGN_1024BYTES", + [0xc00000] = "ALIGN_2048BYTES", + [0xd00000] = "ALIGN_4096BYTES", + [0xe00000] = "ALIGN_8192BYTES", + [0x1000000] = "LNK_NRELOC_OVFL", + [0x2000000] = "MEM_DISCARDABLE", + [0x4000000] = "MEM_NOT_CACHED", + [0x8000000] = "MEM_NOT_PAGED", + [0x10000000] = "MEM_SHARED", + [0x20000000] = "MEM_EXECUTE", + [0x40000000] = "MEM_READ", + [0x80000000] = "MEM_WRITE" + } &default=function(i: count):string { return fmt("unknown-%d", i); }; + + const os_versions: table[count, count] of string = { + [10,0] = "Windows 10", + [6,4] = "Windows 10 Technical Preview", + [6,3] = "Windows 8.1 or Server 2012 R2", + [6,2] = "Windows 8 or Server 2012", + [6,1] = "Windows 7 or Server 2008 R2", + [6,0] = "Windows Vista or Server 2008", + [5,2] = "Windows XP x64 or Server 2003", + [5,1] = "Windows XP", + [5,0] = "Windows 2000", + [4,90] = "Windows Me", + [4,10] = "Windows 98", + [4,0] = "Windows 95 or NT 4.0", + [3,51] = "Windows NT 3.51", + [3,50] = "Windows NT 3.5", + [3,2] = "Windows 3.2", + [3,11] = "Windows for Workgroups 3.11", + [3,10] = "Windows 3.1 or NT 3.1", + [3,0] = "Windows 3.0", + [2,11] = "Windows 2.11", + [2,10] = "Windows 2.10", + [2,0] = "Windows 2.0", + [1,4] = "Windows 1.04", + [1,3] = "Windows 1.03", + [1,1] = "Windows 1.01", + [1,0] = "Windows 1.0", + } &default=function(i: count, j: count):string { return fmt("unknown-%d.%d", i, j); }; + + const section_descs: table[string] of string = { + [".bss"] = "Uninitialized data", + [".cormeta"] = "CLR metadata that indicates that the object file contains managed code", + [".data"] = "Initialized data", + [".debug$F"] = "Generated FPO debug information", + [".debug$P"] = "Precompiled debug types", + [".debug$S"] = "Debug symbols", + [".debug$T"] = "Debug types", + [".drective"] = "Linker options", + [".edata"] = "Export tables", + [".idata"] = "Import tables", + [".idlsym"] = "Includes registered SEH to support IDL attributes", + [".pdata"] = "Exception information", + [".rdata"] = "Read-only initialized data", + [".reloc"] = "Image relocations", + [".rsrc"] = "Resource directory", + [".sbss"] = "GP-relative uninitialized data", + [".sdata"] = "GP-relative initialized data", + [".srdata"] = "GP-relative read-only data", + [".sxdata"] = "Registered exception handler data", + [".text"] = "Executable code", + [".tls"] = "Thread-local storage", + [".tls$"] = "Thread-local storage", + [".vsdata"] = "GP-relative initialized data", + [".xdata"] = "Exception information", + } &default=function(i: string):string { return fmt("unknown-%s", i); }; + +} diff --git a/scripts/base/files/pe/main.bro b/scripts/base/files/pe/main.bro new file mode 100644 index 0000000000..b2723e4138 --- /dev/null +++ b/scripts/base/files/pe/main.bro @@ -0,0 +1,137 @@ +module PE; + +@load ./consts.bro + +export { + redef enum Log::ID += { LOG }; + + type Info: record { + ## Current timestamp. + ts: time &log; + ## File id of this portable executable file. + id: string &log; + ## The target machine that the file was compiled for. + machine: string &log &optional; + ## The time that the file was created at. + compile_ts: time &log &optional; + ## The required operating system. + os: string &log &optional; + ## The subsystem that is required to run this file. + subsystem: string &log &optional; + ## Is the file an executable, or just an object file? + is_exe: bool &log &default=T; + ## Is the file a 64-bit executable? + is_64bit: bool &log &default=T; + ## Does the file support Address Space Layout Randomization? + uses_aslr: bool &log &default=F; + ## Does the file support Data Execution Prevention? + uses_dep: bool &log &default=F; + ## Does the file enforce code integrity checks? + uses_code_integrity: bool &log &default=F; + ## Does the file use structured exception handing? + uses_seh: bool &log &default=T; + ## Does the file have an import table? + has_import_table: bool &log &optional; + ## Does the file have an export table? + has_export_table: bool &log &optional; + ## Does the file have an attribute certificate table? + has_cert_table: bool &log &optional; + ## Does the file have a debug table? + has_debug_data: bool &log &optional; + ## The names of the sections, in order. + section_names: vector of string &log &optional; + }; + + ## Event for accessing logged records. + global log_pe: event(rec: Info); + + ## A hook that gets called when we first see a PE file. + global set_file: hook(f: fa_file); +} + +redef record fa_file += { + pe: Info &optional; +}; + +const pe_mime_types = { "application/x-dosexec" }; + +event bro_init() &priority=5 + { + Files::register_for_mime_types(Files::ANALYZER_PE, pe_mime_types); + Log::create_stream(LOG, [$columns=Info, $ev=log_pe, $path="pe"]); + } + +hook set_file(f: fa_file) &priority=5 + { + if ( ! f?$pe ) + f$pe = [$ts=network_time(), $id=f$id]; + } + +event pe_dos_header(f: fa_file, h: PE::DOSHeader) &priority=5 + { + hook set_file(f); + } + +event pe_file_header(f: fa_file, h: PE::FileHeader) &priority=5 + { + hook set_file(f); + + f$pe$machine = machine_types[h$machine]; + f$pe$compile_ts = h$ts; + f$pe$is_exe = ( h$optional_header_size > 0 ); + + for ( c in h$characteristics ) + { + if ( file_characteristics[c] == "32BIT_MACHINE" ) + f$pe$is_64bit = F; + } + } + +event pe_optional_header(f: fa_file, h: PE::OptionalHeader) &priority=5 + { + hook set_file(f); + + # Only EXEs have optional headers + if ( ! f$pe$is_exe ) + return; + + f$pe$os = os_versions[h$os_version_major, h$os_version_minor]; + f$pe$subsystem = windows_subsystems[h$subsystem]; + + for ( c in h$dll_characteristics ) + { + if ( dll_characteristics[c] == "DYNAMIC_BASE" ) + f$pe$uses_aslr = T; + if ( dll_characteristics[c] == "FORCE_INTEGRITY" ) + f$pe$uses_code_integrity = T; + if ( dll_characteristics[c] == "NX_COMPAT" ) + f$pe$uses_dep = T; + if ( dll_characteristics[c] == "NO_SEH" ) + f$pe$uses_seh = F; + } + + f$pe$has_export_table = (|h$table_sizes| > 0 && h$table_sizes[0] > 0); + f$pe$has_import_table = (|h$table_sizes| > 1 && h$table_sizes[1] > 0); + f$pe$has_cert_table = (|h$table_sizes| > 4 && h$table_sizes[4] > 0); + f$pe$has_debug_data = (|h$table_sizes| > 6 && h$table_sizes[6] > 0); + } + +event pe_section_header(f: fa_file, h: PE::SectionHeader) &priority=5 + { + hook set_file(f); + + # Only EXEs have section headers + if ( ! f$pe$is_exe ) + return; + + if ( ! f$pe?$section_names ) + f$pe$section_names = vector(); + f$pe$section_names[|f$pe$section_names|] = h$name; + } + +event file_state_remove(f: fa_file) &priority=-5 + { + if ( f?$pe && f$pe?$machine ) + Log::write(LOG, f$pe); + } + diff --git a/scripts/base/files/x509/main.bro b/scripts/base/files/x509/main.bro index a810132f8d..c097b84560 100644 --- a/scripts/base/files/x509/main.bro +++ b/scripts/base/files/x509/main.bro @@ -47,6 +47,9 @@ redef record Files::Info += { event x509_certificate(f: fa_file, cert_ref: opaque of x509, cert: X509::Certificate) &priority=5 { + if ( ! f$info?$mime_type ) + f$info$mime_type = "application/pkix-cert"; + f$info$x509 = [$ts=f$info$ts, $id=f$id, $certificate=cert, $handle=cert_ref]; } diff --git a/scripts/base/frameworks/files/magic/__load__.bro b/scripts/base/frameworks/files/magic/__load__.bro index c6ee799a53..34115f0a55 100644 --- a/scripts/base/frameworks/files/magic/__load__.bro +++ b/scripts/base/frameworks/files/magic/__load__.bro @@ -1,3 +1,9 @@ +@load-sigs ./archive +@load-sigs ./audio +@load-sigs ./font @load-sigs ./general +@load-sigs ./image @load-sigs ./msoffice -@load-sigs ./libmagic +@load-sigs ./video + +@load-sigs ./libmagic \ No newline at end of file diff --git a/scripts/base/frameworks/files/magic/archive.sig b/scripts/base/frameworks/files/magic/archive.sig new file mode 100644 index 0000000000..9b95f33b25 --- /dev/null +++ b/scripts/base/frameworks/files/magic/archive.sig @@ -0,0 +1,176 @@ + +signature file-tar { + file-magic /^[[:print:]\x00]{100}([[:digit:]\x20]{7}\x00){3}([[:digit:]\x20]{11}\x00){2}([[:digit:]\x00\x20]{7}[\x20\x00])[0-7\x00]/ + file-mime "application/x-tar", 100 +} + +# This is low priority so that files using zip as a +# container will be identified correctly. +signature file-zip { + file-mime "application/zip", 10 + file-magic /^PK\x03\x04.{2}/ +} + +# Multivolume Zip archive +signature file-multi-zip { + file-mime "application/zip", 10 + file-magic /^PK\x07\x08PK\x03\x04/ +} + +# RAR +signature file-rar { + file-mime "application/x-rar", 70 + file-magic /^Rar!/ +} + +# GZIP +signature file-gzip { + file-mime "application/x-gzip", 100 + file-magic /\x1f\x8b/ +} + +# Microsoft Cabinet +signature file-ms-cab { + file-mime "application/vnd.ms-cab-compressed", 110 + file-magic /^MSCF\x00\x00\x00\x00/ +} + +# Mac OS X DMG files +signature file-dmg { + file-magic /^(\x78\x01\x73\x0D\x62\x62\x60|\x78\xDA\x63\x60\x18\x05|\x78\x01\x63\x60\x18\x05|\x78\xDA\x73\x0D|\x78[\x01\xDA]\xED[\xD0-\xD9])/ + file-mime "application/x-dmg", 100 +} + +# XAR (eXtensible ARchive) format. +# Mac OS X uses this for the .pkg format. +signature file-xar { + file-magic /^xar\!/ + file-mime "application/x-xar", 100 +} + +# RPM +signature file-magic-auto352 { + file-mime "application/x-rpm", 70 + file-magic /^(drpm|\xed\xab\xee\xdb)/ +} + +# StuffIt +signature file-stuffit { + file-mime "application/x-stuffit", 70 + file-magic /^(SIT\x21|StuffIt)/ +} + +# Archived data +signature file-x-archive { + file-mime "application/x-archive", 70 + file-magic /^!?/ +} + +# ARC archive data +signature file-arc { + file-mime "application/x-arc", 70 + file-magic /^[\x00-\x7f]{2}[\x02-\x0a\x14\x48]\x1a/ +} + +# EET archive +signature file-eet { + file-mime "application/x-eet", 70 + file-magic /^\x1e\xe7\xff\x00/ +} + +# Zoo archive +signature file-zoo { + file-mime "application/x-zoo", 70 + file-magic /^.{20}\xdc\xa7\xc4\xfd/ +} + +# LZ4 compressed data (legacy format) +signature file-lz4-legacy { + file-mime "application/x-lz4", 70 + file-magic /(\x02\x21\x4c\x18)/ +} + +# LZ4 compressed data +signature file-lz4 { + file-mime "application/x-lz4", 70 + file-magic /^\x04\x22\x4d\x18/ +} + +# LRZIP compressed data +signature file-lrzip { + file-mime "application/x-lrzip", 1 + file-magic /^LRZI/ +} + +# LZIP compressed data +signature file-lzip { + file-mime "application/x-lzip", 70 + file-magic /^LZIP/ +} + +# Self-extracting PKZIP archive +signature file-magic-auto434 { + file-mime "application/zip", 340 + file-magic /^MZ.{28}(Copyright 1989\x2d1990 PKWARE Inc|PKLITE Copr)\x2e/ +} + +# LHA archive (LZH) +signature file-lzh { + file-mime "application/x-lzh", 80 + file-magic /^.{2}-(lh[ abcdex0-9]|lz[s2-8]|lz[s2-8]|pm[s012]|pc1)-/ +} + +# WARC Archive +signature file-warc { + file-mime "application/warc", 50 + file-magic /^WARC\x2f/ +} + +# 7-zip archive data +signature file-7zip { + file-mime "application/x-7z-compressed", 50 + file-magic /^7z\xbc\xaf\x27\x1c/ +} + +# XZ compressed data +signature file-xz { + file-mime "application/x-xz", 90 + file-magic /^\xfd7zXZ\x00/ +} + +# LHa self-extracting archive +signature file-magic-auto436 { + file-mime "application/x-lha", 120 + file-magic /^MZ.{34}LH[aA]\x27s SFX/ +} + +# ARJ archive data +signature file-arj { + file-mime "application/x-arj", 50 + file-magic /^\x60\xea/ +} + +# Byte-swapped cpio archive +signature file-bs-cpio { + file-mime "application/x-cpio", 50 + file-magic /(\x71\xc7|\xc7\x71)/ +} + +# CPIO archive +signature file-cpio { + file-mime "application/x-cpio", 50 + file-magic /^(\xc7\x71|\x71\xc7)/ +} + +# Compress'd data +signature file-compress { + file-mime "application/x-compress", 50 + file-magic /^\x1f\x9d/ +} + +# LZMA compressed data +signature file-lzma { + file-mime "application/x-lzma", 71 + file-magic /^\x5d\x00\x00/ +} + diff --git a/scripts/base/frameworks/files/magic/audio.sig b/scripts/base/frameworks/files/magic/audio.sig new file mode 100644 index 0000000000..efba99ed0d --- /dev/null +++ b/scripts/base/frameworks/files/magic/audio.sig @@ -0,0 +1,13 @@ + +# MPEG v3 audio +signature file-mpeg-audio { + file-mime "audio/mpeg", 20 + file-magic /^\xff[\xe2\xe3\xf2\xf3\xf6\xf7\xfa\xfb\xfc\xfd]/ +} + +# MPEG v4 audio +signature file-m4a { + file-mime "audio/m4a", 70 + file-magic /^....ftyp(m4a)/ +} + diff --git a/scripts/base/frameworks/files/magic/font.sig b/scripts/base/frameworks/files/magic/font.sig new file mode 100644 index 0000000000..8f2857f6e3 --- /dev/null +++ b/scripts/base/frameworks/files/magic/font.sig @@ -0,0 +1,41 @@ + +# Web Open Font Format +signature file-woff { + file-magic /^wOFF/ + file-mime "application/font-woff", 70 +} + +# TrueType font +signature file-ttf { + file-mime "application/x-font-ttf", 80 + file-magic /^\x00\x01\x00\x00\x00/ +} + +signature file-embedded-opentype { + file-mime "application/vnd.ms-fontobject", 50 + file-magic /^.{34}LP/ +} + +# X11 SNF font +signature file-snf { + file-mime "application/x-font-sfn", 70 + file-magic /^(\x04\x00\x00\x00|\x00\x00\x00\x04).{100}(\x04\x00\x00\x00|\x00\x00\x00\x04)/ +} + +# OpenType font +signature file-opentype { + file-mime "application/vnd.ms-opentype", 70 + file-magic /^OTTO/ +} + +# FrameMaker Font file +signature file-maker-screen-font { + file-mime "application/x-mif", 190 + file-magic /^\x3cMakerScreenFont/ +} + +# >0 string,=SplineFontDB: (len=13), ["Spline Font Database "], swap_endian=0 +signature file-spline-font-db { + file-mime "application/vnd.font-fontforge-sfd", 160 + file-magic /^SplineFontDB\x3a/ +} diff --git a/scripts/base/frameworks/files/magic/general.sig b/scripts/base/frameworks/files/magic/general.sig index 500c4f7be0..eb38d39c8c 100644 --- a/scripts/base/frameworks/files/magic/general.sig +++ b/scripts/base/frameworks/files/magic/general.sig @@ -1,18 +1,87 @@ # General purpose file magic signatures. +# Plaintext +# (Including BOMs for UTF-8, 16, and 32) signature file-plaintext { - file-magic /^([[:print:][:space:]]{10})/ - file-mime "text/plain", -20 + file-mime "text/plain", -20 + file-magic /^(\xef\xbb\xbf|(\x00\x00)?\xfe\xff|\xff\xfe(\x00\x00)?)?[[:space:]\x20-\x7E]{10}/ } -signature file-tar { - file-magic /^[[:print:]\x00]{100}([[:digit:]\x20]{7}\x00){3}([[:digit:]\x20]{11}\x00){2}([[:digit:]\x00\x20]{7}[\x20\x00])[0-7\x00]/ - file-mime "application/x-tar", 100 +signature file-json { + file-mime "text/json", 1 + file-magic /^(\xef\xbb\xbf)?[\x0d\x0a[:blank:]]*\{[\x0d\x0a[:blank:]]*(["][^"]{1,}["]|[a-zA-Z][a-zA-Z0-9\\_]*)[\x0d\x0a[:blank:]]*:[\x0d\x0a[:blank:]]*(["]|\[|\{|[0-9]|true|false)/ } -signature file-zip { - file-mime "application/zip", 10 - file-magic /^PK\x03\x04.{2}/ +signature file-json2 { + file-mime "text/json", 1 + file-magic /^(\xef\xbb\xbf)?[\x0d\x0a[:blank:]]*\[[\x0d\x0a[:blank:]]*(((["][^"]{1,}["]|[0-9]{1,}(\.[0-9]{1,})?|true|false)[\x0d\x0a[:blank:]]*,)|\{|\[)[\x0d\x0a[:blank:]]*/ +} + +# Match empty JSON documents. +signature file-json3 { + file-mime "text/json", 0 + file-magic /^(\xef\xbb\xbf)?[\x0d\x0a[:blank:]]*(\[\]|\{\})[\x0d\x0a[:blank:]]*$/ +} + +signature file-xml { + file-mime "application/xml", 10 + file-magic /^(\xef\xbb\xbf)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*<\?xml / +} + +signature file-xhtml { + file-mime "text/html", 100 + file-magic /^(\xef\xbb\xbf)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*(<\?xml .*\?>)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*<(![dD][oO][cC][tT][yY][pP][eE] {1,}[hH][tT][mM][lL]|[hH][tT][mM][lL]|[mM][eE][tT][aA] {1,}[hH][tT][tT][pP]-[eE][qQ][uU][iI][vV])/ +} + +signature file-html { + file-mime "text/html", 49 + file-magic /^(\xef\xbb\xbf)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*(<\?xml .*\?>)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*)?[\x0d\x0a[:blank:]]*)*(<\?xml .*\?>)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*<([hH][eE][aA][dD]|[hH][tT][mM][lL]|[tT][iI][tT][lL][eE]|[bB][oO][dD][yY])/ +} + +signature file-rss { + file-mime "text/rss", 90 + file-magic /^(\xef\xbb\xbf)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*(<\?xml .*\?>)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*<[rR][sS][sS]/ +} + +signature file-atom { + file-mime "text/atom", 100 + file-magic /^(\xef\xbb\xbf)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*(<\?xml .*\?>)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*<([rR][sS][sS][^>]*xmlns:atom|[fF][eE][eE][dD][^>]*xmlns=["']?http:\/\/www.w3.org\/2005\/Atom["']?)/ +} + +signature file-soap { + file-mime "application/soap+xml", 49 + file-magic /^(\xef\xbb\xbf)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*(<\?xml .*\?>)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*<[sS][oO][aA][pP](-[eE][nN][vV])?:[eE][nN][vV][eE][lL][oO][pP][eE]/ +} + +signature file-cross-domain-policy { + file-mime "text/x-cross-domain-policy", 49 + file-magic /^([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*(<\?xml .*\?>)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*)?[\x0d\x0a[:blank:]]*)*(<\?xml .*\?>)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*<[cC][rR][oO][sS][sS]-[dD][oO][mM][aA][iI][nN]-[pP][oO][lL][iI][cC][yY]/ +} + +signature file-xmlrpc { + file-mime "application/xml-rpc", 49 + file-magic /^(\xef\xbb\xbf)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*(<\?xml .*\?>)?([\x0d\x0a[:blank:]]*()?[\x0d\x0a[:blank:]]*)*<[mM][eE][tT][hH][oO][dD][rR][eE][sS][pP][oO][nN][sS][eE]>/ +} + +signature file-coldfusion { + file-mime "magnus-internal/cold-fusion", 20 + file-magic /^([\x0d\x0a[:blank:]]*()?)*<(CFPARAM|CFSET|CFIF)/ +} + +# Microsoft LNK files +signature file-lnk { + file-mime "application/x-ms-shortcut", 49 + file-magic /^\x4C\x00\x00\x00\x01\x14\x02\x00\x00\x00\x00\x00\xC0\x00\x00\x00\x00\x10\x00\x00\x00\x46/ } signature file-jar { @@ -21,8 +90,20 @@ signature file-jar { } signature file-java-applet { - file-magic /^\xca\xfe\xba\xbe...[\x2e-\x34]/ file-mime "application/x-java-applet", 71 + file-magic /^\xca\xfe\xba\xbe...[\x2d-\x34]/ +} + +# OCSP requests over HTTP. +signature file-ocsp-request { + file-magic /^.{11,19}\x06\x05\x2b\x0e\x03\x02\x1a/ + file-mime "application/ocsp-request", 71 +} + +# OCSP responses over HTTP. +signature file-ocsp-response { + file-magic /^.{11,19}\x06\x09\x2B\x06\x01\x05\x05\x07\x30\x01\x01/ + file-mime "application/ocsp-response", 71 } # Shockwave flash @@ -37,12 +118,6 @@ signature file-tnef { file-mime "application/vnd.ms-tnef", 100 } -# Mac OS X DMG files -signature file-dmg { - file-magic /^(\x78\x01\x73\x0D\x62\x62\x60|\x78\xDA\x63\x60\x18\x05|\x78\x01\x63\x60\x18\x05|\x78\xDA\x73\x0D|\x78[\x01\xDA]\xED[\xD0-\xD9])/ - file-mime "application/x-dmg", 100 -} - # Mac OS X Mach-O executable signature file-mach-o { file-magic /^[\xce\xcf]\xfa\xed\xfe/ @@ -55,13 +130,6 @@ signature file-mach-o-universal { file-mime "application/x-mach-o-executable", 100 } -# XAR (eXtensible ARchive) format. -# Mac OS X uses this for the .pkg format. -signature file-xar { - file-magic /^xar\!/ - file-mime "application/x-xar", 100 -} - signature file-pkcs7 { file-magic /^MIME-Version:.*protocol=\"application\/pkcs7-signature\"/ file-mime "application/pkcs7-signature", 100 @@ -79,16 +147,6 @@ signature file-jnlp { file-mime "application/x-java-jnlp-file", 100 } -signature file-ico { - file-magic /^\x00\x00\x01\x00/ - file-mime "image/x-icon", 70 -} - -signature file-cur { - file-magic /^\x00\x00\x02\x00/ - file-mime "image/x-cursor", 70 -} - signature file-pcap { file-magic /^(\xa1\xb2\xc3\xd4|\xd4\xc3\xb2\xa1)/ file-mime "application/vnd.tcpdump.pcap", 70 @@ -119,7 +177,58 @@ signature file-python { file-mime "text/x-python", 60 } +signature file-awk { + file-mime "text/x-awk", 60 + file-magic /^\x23\x21[^\n]{1,15}bin\/(env[[:space:]]+)?(g|n)?awk/ +} + +signature file-tcl { + file-mime "text/x-tcl", 60 + file-magic /^\x23\x21[^\n]{1,15}bin\/(env[[:space:]]+)?(wish|tcl)/ +} + +signature file-lua { + file-mime "text/x-lua", 49 + file-magic /^\x23\x21[^\n]{1,15}bin\/(env[[:space:]]+)?lua/ +} + +signature file-javascript { + file-mime "application/javascript", 60 + file-magic /^\x23\x21[^\n]{1,15}bin\/(env[[:space:]]+)?node(js)?/ +} + +signature file-javascript2 { + file-mime "application/javascript", 60 + file-magic /^[\x0d\x0a[:blank:]]*<[sS][cC][rR][iI][pP][tT][[:blank:]]+([tT][yY][pP][eE]|[lL][aA][nN][gG][uU][aA][gG][eE])=['"]?([tT][eE][xX][tT]\/)?[jJ][aA][vV][aA][sS][cC][rR][iI][pP][tT]/ +} + +signature file-javascript3 { + file-mime "application/javascript", 60 + # This seems to be a somewhat common idiom in javascript. + file-magic /^[\x0d\x0a[:blank:]]*for \(;;\);/ +} + +signature file-javascript4 { + file-mime "application/javascript", 60 + file-magic /^[\x0d\x0a[:blank:]]*document\.write(ln)?[:blank:]?\(/ +} + +signature file-javascript5 { + file-mime "application/javascript", 60 + file-magic /^\(function\(\)[[:blank:]\n]*\{/ +} + +signature file-javascript6 { + file-mime "application/javascript", 60 + file-magic /^[\x0d\x0a[:blank:]]*