Skip to content

Commit

Permalink
DoS fix / regex performance tuning (#368)
Browse files Browse the repository at this point in the history
* Regex performance tuning

* additional regex changes

* additional regex changes

* additional regex changes

* additional regex changes

* Fix old typo in description
  • Loading branch information
tsellers-r7 authored Aug 2, 2021
1 parent 5551694 commit bde25e6
Show file tree
Hide file tree
Showing 15 changed files with 249 additions and 246 deletions.
2 changes: 1 addition & 1 deletion xml/apache_os.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<param pos="0" name="os.cpe23" value="cpe:/o:canonical:ubuntu_linux:-"/>
</fingerprint>

<fingerprint pattern=".*(?:Sun )?Cobalt \(Unix\)?.*">
<fingerprint pattern=".{0,512}(?:Sun )?Cobalt \(Unix\)?.*">
<description>Sun Cobalt RaQ (Red Hat based Linux)</description>
<param pos="0" name="os.vendor" value="Sun"/>
<param pos="0" name="os.family" value="Linux"/>
Expand Down
84 changes: 42 additions & 42 deletions xml/ftp_banners.xml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions xml/html_title.xml
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
<param pos="0" name="os.cpe23" value="cpe:/o:watchguard:fireware:-"/>
</fingerprint>

<fingerprint pattern="^(.*).nbsp;-.nbsp;Synology.nbsp;DiskStation$">
<fingerprint pattern="^(.{0,512}).nbsp;-.nbsp;Synology.nbsp;DiskStation$">
<description>Synology DiskStation</description>
<example host.name="DiskStation">DiskStation&amp;nbsp;-&amp;nbsp;Synology&amp;nbsp;DiskStation</example>
<example host.name="DS218">DS218&amp;nbsp;-&amp;nbsp;Synology&amp;nbsp;DiskStation</example>
Expand Down Expand Up @@ -699,7 +699,7 @@
<param pos="0" name="hw.product" value="Prosafe Plus"/>
</fingerprint>

<fingerprint pattern="^(.*).nbsp;Configuration and Management$">
<fingerprint pattern="^(.{0,256}).nbsp;Configuration and Management$">
<description>Digi Terminal Servers</description>
<example hw.product="Digi One SP">Digi One SP&amp;nbsp;Configuration and Management</example>
<example hw.product="PortServer TS 4">PortServer TS 4&amp;nbsp;Configuration and Management</example>
Expand Down Expand Up @@ -820,7 +820,7 @@
<param pos="0" name="hw.product" value="Rack PDU Card"/>
</fingerprint>

<fingerprint pattern="^(.*) IntelliSlot Web(?:/\d+)? Card?$">
<fingerprint pattern="^(.{0,256}) IntelliSlot Web(?:/\d+)? Card?$">
<description>Emerson Network Power IntelliSlot Web Card and rebrands</description>
<example hw.vendor="Emerson Network Power">Emerson Network Power IntelliSlot Web Card</example>
<example hw.vendor="Emerson Network Power">Emerson Network Power IntelliSlot Web/485 Card</example>
Expand Down Expand Up @@ -1038,7 +1038,7 @@
<param pos="0" name="hw.product" value="OpenManage Switch"/>
</fingerprint>

<fingerprint pattern="^(\S+)\s+-\s+ProCurve Switch (\S+) \((.*)\)$">
<fingerprint pattern="^(\S{1,512})\s{1,8}-\s{1,8}ProCurve Switch (\S+) \((.*)\)$">
<description>HPE ProCurve Switch w/Hostname</description>
<example host.name="SW1" hw.product="4204vl" procurve.model="J8770A">SW1 - ProCurve Switch 4204vl (J8770A)</example>
<param pos="0" name="hw.vendor" value="HPE"/>
Expand Down Expand Up @@ -1681,7 +1681,7 @@
<param pos="0" name="service.cpe23" value="cpe:/a:realvnc:realvnc:-"/>
</fingerprint>

<fingerprint pattern="^.* \[Jenkins\]$">
<fingerprint pattern="^.{0,1024} \[Jenkins\]$">
<description>Jenkins Customized Dashboard</description>
<example>Continuous Integrations [Jenkins]</example>
<example>Dashboard [Jenkins]</example>
Expand Down Expand Up @@ -2344,7 +2344,7 @@
<param pos="0" name="service.product" value="SonarQube"/>
</fingerprint>

<fingerprint pattern="^(\S+) - Opengear Management Console$">
<fingerprint pattern="^(\S{1,512}) - Opengear Management Console$">
<description>Opengear Management Console</description>
<example host.name="server01">server01 - Opengear Management Console</example>
<param pos="0" name="service.vendor" value="Opengear"/>
Expand Down Expand Up @@ -2610,7 +2610,7 @@
<param pos="0" name="service.cpe23" value="cpe:/a:zabbix:zabbix:-"/>
</fingerprint>

<fingerprint pattern="^(\S+) \(build (\S+)\) - Info$">
<fingerprint pattern="^(\S{1,512}) \(build (\S+)\) - Info$">
<description>DD-WRT</description>
<example host.name="SubTerraVia-NUC" os.version="36104" os.build="36104">SubTerraVia-NUC (build 36104) - Info</example>
<example host.name="DD-WRT" os.version="35030M" os.build="35030M">DD-WRT (build 35030M) - Info</example>
Expand Down
20 changes: 10 additions & 10 deletions xml/http_servers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@
</fingerprint>

<fingerprint pattern="^UOS$">
<description>HTTP Server that appears unique to Managment Console on HP TippingPoint IPS Devices</description>
<description>HTTP Server that appears unique to Management Console on HP TippingPoint IPS Devices</description>
<example>UOS</example>
<param pos="0" name="service.vendor" value="HP"/>
<param pos="0" name="service.product" value="HTTP"/>
Expand Down Expand Up @@ -878,10 +878,10 @@
<param pos="0" name="service.cpe23" value="cpe:/a:acme:mini_httpd:-"/>
</fingerprint>

<fingerprint pattern="^LiteSpeed\/?(:?[\d.]+)?(?: \S+)?">
<fingerprint pattern="^LiteSpeed\/?([\d.]+)?(?: \S+)?">
<description>LiteSpeed</description>
<example>LiteSpeed</example>
<example>LiteSpeed/5.2.8 Enterprise</example>
<example service.version="5.2.8">LiteSpeed/5.2.8 Enterprise</example>
<param pos="0" name="service.vendor" value="LiteSpeed Technologies"/>
<param pos="0" name="service.product" value="LiteSpeed Web Server"/>
<param pos="1" name="service.version"/>
Expand All @@ -897,7 +897,7 @@
<param pos="1" name="service.version"/>
</fingerprint>

<fingerprint pattern="^openresty\/?(:?[\d.]+)?$">
<fingerprint pattern="^openresty\/?([\d.]+)?$">
<description>OpenResty OpenResty</description>
<example>openresty</example>
<example service.version="1.13.6.2">openresty/1.13.6.2</example>
Expand Down Expand Up @@ -1000,7 +1000,7 @@
<param pos="0" name="service.cpe23" value="cpe:/a:varnish-cache:varnish:-"/>
</fingerprint>

<fingerprint pattern="^Tengine\/?(:?[\d.]+)?$">
<fingerprint pattern="^Tengine\/?([\d.]+)?$">
<description>Tengine</description>
<example>Tengine</example>
<example service.version="2.0.0">Tengine/2.0.0</example>
Expand Down Expand Up @@ -1492,7 +1492,7 @@
<param pos="0" name="service.cpe23" value="cpe:/a:nginx:nginx:-"/>
</fingerprint>

<fingerprint pattern="^nginx\/?(:?[\d.]+)?">
<fingerprint pattern="^nginx\/?([\d.]+)?">
<description>nginx with version info and/or mods</description>
<example service.version="0.8.53">nginx/0.8.53 + Phusion Passenger 3.0.0 (mod_rails/mod_rack)</example>
<example>nginx/0.8.53</example>
Expand Down Expand Up @@ -2651,7 +2651,7 @@
<param pos="1" name="service.version"/>
</fingerprint>

<fingerprint pattern="^Embedthis-(?:Appweb|http)\/?(:?[\d.]+)?$">
<fingerprint pattern="^Embedthis-(?:Appweb|http)\/?([\d.]+)?$">
<description>Embedthis AppWeb</description>
<example service.version="3.2.3">Embedthis-Appweb/3.2.3</example>
<example>Embedthis-http</example>
Expand Down Expand Up @@ -3284,7 +3284,7 @@
<param pos="0" name="service.product" value="Node"/>
</fingerprint>

<fingerprint pattern="(?i)^(.*) UPnP/[\d\.]+\s+AVM FRITZ!(.*) ([\d\.]+)$">
<fingerprint pattern="(?i)^(.{0,256}) UPnP/[\d\.]+\s+AVM FRITZ!(.*) ([\d\.]+)$">
<description>AVM FRITZ! devices of various types</description>
<example host.name="some thing" os.product="WLAN Repeater 1750E" os.version="134.07.01">some thing UPnP/1.0 AVM FRITZ!WLAN Repeater 1750E 134.07.01</example>
<param pos="0" name="os.vendor" value="AVM"/>
Expand Down Expand Up @@ -3681,7 +3681,7 @@
<param pos="0" name="service.cpe23" value="cpe:/a:miniupnp_project:miniupnpd:{service.version}"/>
</fingerprint>

<fingerprint pattern="^(\S+) \d+/Service Pack \d+, UPnP/[\d\.]+, TVersity Media Server$">
<fingerprint pattern="^(\S{1,16}) \d+/Service Pack \d+, UPnP/[\d\.]+, TVersity Media Server$">
<description>TVersity Media Server UPnP Server with Service Pack</description>
<example>5.2.3790 2/Service Pack 1, UPnP/1.0, TVersity Media Server</example>
<example>5.1.2600 2/Service Pack 3, UPnP/1.0, TVersity Media Server</example>
Expand All @@ -3690,7 +3690,7 @@
<param pos="1" name="service.version"/>
</fingerprint>

<fingerprint pattern="^(\S+) 2/, UPnP/\S+, TVersity Media Server$">
<fingerprint pattern="^(\S{1,16}) 2/, UPnP/\S+, TVersity Media Server$">
<description>TVersity Media Server UPnP Server</description>
<example>6.2.8400 2/, UPnP/1.0, TVersity Media Server</example>
<example>6.2.9200 2/, UPnP/1.0, TVersity Media Server</example>
Expand Down
6 changes: 3 additions & 3 deletions xml/http_wwwauth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -419,23 +419,23 @@
<param pos="0" name="service.product" value="SWAT"/>
</fingerprint>

<fingerprint pattern="^.*(?:Basic|Digest) realm=&quot;SPIP Configuration&quot;.*$">
<fingerprint pattern="^.{0,1024}(?:Basic|Digest) realm=&quot;SPIP Configuration&quot;.*$">
<description>SPIP publishing system (www.spip.net)</description>
<example>Basic realm="SPIP Configuration", Digest realm="SPIP Configuration", nonce="116761147", algorithm="MD5"</example>
<param pos="0" name="service.vendor" value="SPIP"/>
<param pos="0" name="service.product" value="SPIP"/>
<param pos="0" name="service.cpe23" value="cpe:/a:spip:spip:-"/>
</fingerprint>

<fingerprint pattern="^.*(?:Basic|Digest) .*realm=&quot;HP ISEE @ ([^&quot;]+)&quot;.*$">
<fingerprint pattern="^.{0,1024}(?:Basic|Digest) .*realm=&quot;HP ISEE @ ([^&quot;]+)&quot;.*$">
<description>HP Instant Support Enterprise Edition with a hostname</description>
<example host.name="blah">Basic realm="HP ISEE @ blah"</example>
<param pos="0" name="service.vendor" value="HP"/>
<param pos="0" name="service.product" value="ISEE"/>
<param pos="1" name="host.name"/>
</fingerprint>

<fingerprint pattern="^.*(?:Basic|Digest) .*realm=&quot;BIG-IP&quot;.*$">
<fingerprint pattern="^.{0,1024}(?:Basic|Digest) .*realm=&quot;BIG-IP&quot;.*$">
<description>Generic F5 Big-IP</description>
<example>Basic realm="BIG-IP"</example>
<param pos="0" name="service.vendor" value="F5"/>
Expand Down
10 changes: 5 additions & 5 deletions xml/imap_banners.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
<param pos="0" name="service.product" value="Courier IMAP"/>
</fingerprint>

<fingerprint pattern="^(\S+) CallPilot IMAP4rev1 v(\S+) server ready\.?$">
<fingerprint pattern="^(\S{1,512}) CallPilot IMAP4rev1 v(\S+) server ready\.?$">
<description>Nortel CallPilot</description>
<example>nottest.localdomain CallPilot IMAP4rev1 v42.02.05.22 server ready.</example>
<example>test.localdomain CallPilot IMAP4rev1 v43.03.19.22 server ready.</example>
Expand All @@ -177,7 +177,7 @@
<param pos="1" name="host.name"/>
</fingerprint>

<fingerprint pattern="^(\S+) Zimbra IMAP4rev1 server ready\.?$">
<fingerprint pattern="^(\S{1,512}) Zimbra IMAP4rev1 server ready\.?$">
<description>VMware Zimbra IMAP</description>
<example host.name="foo.bar">foo.bar Zimbra IMAP4rev1 server ready</example>
<param pos="0" name="service.vendor" value="VMware"/>
Expand All @@ -186,7 +186,7 @@
<param pos="1" name="host.name"/>
</fingerprint>

<fingerprint pattern="^(\S+) Zimbra (\S+) IMAP4rev1 server ready\.?$">
<fingerprint pattern="^(\S{1,512}) Zimbra (\S+) IMAP4rev1 server ready\.?$">
<description>VMware Zimbra IMAP with service version</description>
<example host.name="foo.bar" service.version="7.0.0_GA_3079">foo.bar Zimbra 7.0.0_GA_3079 IMAP4rev1 server ready</example>
<param pos="0" name="service.vendor" value="VMware"/>
Expand All @@ -196,7 +196,7 @@
<param pos="1" name="host.name"/>
</fingerprint>

<fingerprint pattern="^(.+) Cyrus IMAP4 v(\d+\.\d+.*)-OS X(?: Server)? ([\d\.]+).* server ready$">
<fingerprint pattern="^(\S{1,512}) Cyrus IMAP4 v(\d+\.\d+.*)-OS X(?: Server)? ([\d\.]+).* server ready$">
<description>CMU Cyrus IMAP on Mac OS X</description>
<example host.name="example.com" service.version="2.2.12" os.version="10.4.0">example.com Cyrus IMAP4 v2.2.12-OS X 10.4.0 server ready</example>
<example host.name="example.com" service.version="2.3.8" os.version="10.5">example.com Cyrus IMAP4 v2.3.8-OS X Server 10.5: 9A562 server ready</example>
Expand All @@ -213,7 +213,7 @@
<param pos="1" name="host.name"/>
</fingerprint>

<fingerprint pattern="^(.+) Cyrus IMAP4? (?:\S+ )?v(\d+\.\d+.*) server ready$">
<fingerprint pattern="^(\S{1,512}) Cyrus IMAP4? (?:\S+ )?v(\d+\.\d+.*) server ready$">
<description>CMU Cyrus IMAP</description>
<example host.name="example.com" service.version="2.3.7">example.com Cyrus IMAP4 v2.3.7 server ready</example>
<example host.name="example.com" service.version="2.4.8-Invoca-RPM-2.4.8-1">example.com Cyrus IMAP Murder v2.4.8-Invoca-RPM-2.4.8-1 server ready</example>
Expand Down
2 changes: 1 addition & 1 deletion xml/nntp_banners.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<param pos="0" name="service.product" value="CCProxy"/>
</fingerprint>

<fingerprint pattern="^(\S+) Lyris ListManager NNTP Service ready">
<fingerprint pattern="^(\S{1,512}) Lyris ListManager NNTP Service ready">
<description>Lyris Listmanager</description>
<example host.name="blah">blah Lyris ListManager NNTP Service ready (posting ok).</example>
<param pos="0" name="service.vendor" value="Lyris"/>
Expand Down
2 changes: 1 addition & 1 deletion xml/ntp_banners.xml
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
<param pos="0" name="os.cpe23" value="cpe:/o:apple:mac_os_x:10.10"/>
</fingerprint>

<fingerprint pattern="^.*version=&quot;ntpd ([^ p]+)(:?p[^ &quot;]+)?[^&quot;]+&quot;,.*processor=&quot;([^ ]+)&quot;,.*system=&quot;FreeBSD/?(?:[^ ]+-NETSCALER-([^ ]+))&quot;" flags="REG_DOT_NEWLINE,REG_ICASE">
<fingerprint pattern="^.*version=&quot;ntpd ([^ p]+)(p[^ &quot;]+)?[^&quot;]+&quot;,.*processor=&quot;([^ ]+)&quot;,.*system=&quot;FreeBSD/?(?:[^ ]+-NETSCALER-([^ ]+))&quot;" flags="REG_DOT_NEWLINE,REG_ICASE">
<description>ntpd running on Citrix Netscaler, which is based on FreeBSD</description>
<example service.version="4.2.6" service.version.version="p2@1.2194" os.arch="i386" os.version="9.3">
version="ntpd 4.2.6p2@1.2194 Wed Nov 24 15:54:11 UTC 2010 (1)",
Expand Down
8 changes: 4 additions & 4 deletions xml/operating_system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@

<!-- Vendor-based distribution catch-call -->

<fingerprint pattern="^(?i:(.*)\sLinux?\s(.*))$">
<fingerprint pattern="(?i)^(\S{0,256})\s{1,8}Linux\s+([\w.-]*)$">
<description>Vendor-based Linux catch-all</description>
<example os.vendor="Aurox" os.version="10.2">Aurox Linux 10.2</example>
<param pos="0" name="os.family" value="Linux"/>
Expand All @@ -409,7 +409,7 @@

<!-- Linux catch-all goes at the bottom-->

<fingerprint pattern="^(?i:.*Linux?\s?(\d+?(?:\.\d+?)*?)?)$">
<fingerprint pattern="(?i)^.{0,1024}Linux?\s?(\d+?(?:\.\d+?)*?)?$">
<description>Linux catch-all</description>
<example os.version="2.42.6">Linux 2.42.6</example>
<param pos="0" name="os.vendor" value="Linux"/>
Expand Down Expand Up @@ -588,7 +588,7 @@

<!-- BSD begin -->

<fingerprint pattern="^(?i:(.*?BSD)\s?(\d+?(?:\.\d+?)*?(?:[\-\/_ ]?\w+?)?(?:-[a-z]\d+?)?)?)$">
<fingerprint pattern="(?i)^(.{0,256}?BSD)\s?(\d+?(?:\.\d+?)*?(?:[\-\/_ ]?\w+?)?(?:-[a-z]\d+?)?)?$">
<description>Many BSD family OSes</description>
<example os.version="10.3-RELEASE" os.product="FreeBSD">FreeBSD 10.3-RELEASE</example>
<example os.version="10.3-RELEASE-p4" os.product="FreeBSD">FreeBSD 10.3-RELEASE-p4</example>
Expand All @@ -605,7 +605,7 @@

<!-- Other Unix-likes begin -->

<fingerprint pattern="^(?i:(?:Oracle|Sun)?\s?OpenSolaris\s?(\d+?(?:\.\d+?)*?)?)$">
<fingerprint pattern="(?i)^(?:Oracle|Sun)?\s?OpenSolaris\s?(\d+?(?:\.\d+?)*?)?$">
<description>OpenSolaris</description>
<example os.version="2009.06">OpenSolaris 2009.06</example>
<param pos="0" name="os.vendor" value="Sun"/>
Expand Down
8 changes: 4 additions & 4 deletions xml/pop_banners.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
matched against these patterns to fingerprint POP3 servers.
-->

<fingerprint pattern="^([^ ]+) +Cyrus POP3 v(\d+\.\d+.*)-OS X(?: Server)? ([\d\.]+).* server ready">
<fingerprint pattern="^([^ ]{1,512}) +Cyrus POP3 v(\d+\.\d+.*)-OS X(?: Server)? ([\d\.]+).* server ready">
<description>OSX Cyrus POP</description>
<example host.domain="8.8.8.8" service.version="2.3.8" os.version="10.5">8.8.8.8 Cyrus POP3 v2.3.8-OS X Server 10.5: 9A562 server ready &lt;1999107648.1324502155@8.8.8.8&gt;</example>
<param pos="0" name="service.vendor" value="Carnegie Mellon University"/>
Expand All @@ -20,7 +20,7 @@
<param pos="1" name="host.domain"/>
</fingerprint>

<fingerprint pattern="^([^ ]+) +Cyrus POP3 v([\d\.]+)">
<fingerprint pattern="^([^ ]{1,512}) +Cyrus POP3 v([\d\.]+)">
<description>CMU Cyrus POP</description>
<example host.domain="foo" service.version="2.3">foo Cyrus POP3 v2.3</example>
<example host.domain="foo" service.version="2.3.14">foo Cyrus POP3 v2.3.14 server ready &lt;13087751828270990591.1301068892@foo&gt;</example>
Expand Down Expand Up @@ -229,7 +229,7 @@
<param pos="0" name="hw.product" value="Raspberry Pi"/>
</fingerprint>

<fingerprint pattern="^(\S+) Zimbra POP3 server ready\.?$">
<fingerprint pattern="^(\S{1,512}) Zimbra POP3 server ready\.?$">
<description>VMware Zimbra POP</description>
<example host.name="foo.bar">foo.bar Zimbra POP3 server ready</example>
<param pos="0" name="service.vendor" value="VMware"/>
Expand All @@ -238,7 +238,7 @@
<param pos="1" name="host.name"/>
</fingerprint>

<fingerprint pattern="^(\S+) Zimbra (\S+) POP3 server ready\.?$">
<fingerprint pattern="^(\S{1,512}) Zimbra (\S+) POP3 server ready\.?$">
<description>VMware Zimbra POP with version</description>
<example host.name="foo.bar">foo.bar Zimbra 7.0.0_GA_3079 POP3 server ready</example>
<param pos="0" name="service.vendor" value="VMware"/>
Expand Down
4 changes: 2 additions & 2 deletions xml/sip_banners.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

<!-- The next few Linksys fingerprints could be merged but are split to enable CPEs -->

<fingerprint pattern="^(?:[\dA-F]+ )?Linksys/RT31P2-([\d.]+)\(\w+\)$">
<fingerprint pattern="^(?:[\dA-F]{1,64} )?Linksys/RT31P2-([\d.]+)\(\w+\)$">
<description>Linksys RT31P2</description>
<example os.version="3.1.9">Linksys/RT31P2-3.1.9(LId)</example>
<example os.version="3.1.6">Linksys/RT31P2-3.1.6(LI)</example>
Expand Down Expand Up @@ -418,7 +418,7 @@
<param pos="1" name="hw.product"/>
</fingerprint>

<fingerprint pattern="^(?:Audiocodes-Sip-Gateway-)?(\S+) FX[A-Z_]+/v.(\S+)$">
<fingerprint pattern="^(?:Audiocodes-Sip-Gateway-)?(\S{1,64}) FX[A-Z_]+/v.(\S+)$">
<description>Audiocodes-Sip-Gateway</description>
<example hw.product="MP-124" os.version="6.00A.034.003">Audiocodes-Sip-Gateway-MP-124 FXS/v.6.00A.034.003</example>
<example hw.product="MP-124" os.version="6.60A.342.003">MP-124 FXS/v.6.60A.342.003</example>
Expand Down
Loading

0 comments on commit bde25e6

Please sign in to comment.