Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/parser/retina_xml.rb
Views: 11780
# -*- coding: binary -*-12module Rex3module Parser4# XXX - Retina XML does not include ANY service/port information export5class RetinaXMLStreamParser6attr_accessor :on_found_host78def initialize(on_found_host = nil)9reset_state10self.on_found_host = on_found_host if on_found_host11end1213def reset_state14@state = :generic_state15@host = { 'vulns' => [] }16reset_audit_state17end1819def reset_audit_state20@audit = { 'refs' => [] }21end2223def tag_start(name, attributes)24@state = "in_#{name.downcase}".intern25end2627def text(str)28return if str.to_s.strip.empty?2930case @state31when :in_ip32@host["address"] = str33when :in_dnsname34@host["hostname"] = str.split(/\s+/).first35when :in_netbiosname36@host["netbios"] = str37when :in_mac38@host["mac"] = str.split(/\s+/).first39when :in_os40@host["os"] = str41when :in_rthid42@audit['refs'].push(['RETINA', str])43when :in_cve44str.split(",").each do |cve|45cve = cve.to_s.strip46next if cve.empty?47pre,val = cve.split('-', 2)48next if not val49next if pre != "CVE"50@audit['refs'].push( ['CVE', val] )51end52when :in_name53@audit['name'] = str54when :in_description55@audit['description'] = str56when :in_risk57@audit['risk'] = str58when :in_cce59@audit['cce'] = str60when :in_date61@audit['data'] = str62when :in_context63@audit['proto'], @audit['port'] = str.split(/\s+/).first.split(':')64end65end6667def tag_end(name)68case name69when "host"70on_found_host.call(@host) if on_found_host71reset_state72when "audit"73@host['vulns'].push @audit74reset_audit_state75end76end7778# We don't need these methods, but they're necessary to keep REXML happy79def xmldecl(version, encoding, standalone); end80def cdata; end81def comment(str); end82def instruction(name, instruction); end83def attlist; end84end85end86end8788=begin Old XML format89<scanJob>90<hosts>91<host>92<ip>10.2.79.98</ip>93<netBIOSName>bsmith-10156B07C</netBIOSName>94<dnsName>bsmith-10156b07c.core.testcorp.com random.testcorp.com</dnsName>95<mac>00:02:29:0E:38:2B</mac>96<os>Windows Server 2003 (X64), Service Pack 2</os>97<audit>98<rthID>7851</rthID>99<cve>CVE-2009-0089,CVE-2009-0550,CVE-2009-0086</cve>100<cce>N/A</cce>101<name>Microsoft Windows HTTP Services Multiple Vulnerabilities (960803)</name>102<description>Microsoft Windows HTTP Services contains multiple vulnerabilities when handling ..</description>103<date>09/15/2010</date>104<risk>Low</risk>105<pciLevel>5 (Urgent)</pciLevel>106<cvssScore>10 [AV:N/AC:L/Au:N/C:C/I:C/A:C]</cvssScore>107<fixInformation>....</fixInformation>108</audit>109</host>110</hosts>111</scanJob>112=end Old XML format113114=begin New XML format115<?xml version="1.0" encoding="utf-8"?>116<scanJob>117<hosts>118<host>119<ip>[redacted]</ip>120<netBIOSName>[redacted]</netBIOSName>121<dnsName>[redacted]</dnsName>122<mac></mac>123<os>[redacted]</os>124<cpe>[redacted]</cpe>125<audit>126<cve>[redacted]</cve>127<cce>N/A</cce>128<name>TLS/SSL Weak Protocol Version Supported</name>129<description>A targeted service that accepts connections for cryptographically weak SSL protocol versions (eg SSLv2, SSLv3, TLSv1.0) has been detected. Such protocols are known to have cryptographic weaknesses as well as other exploitable vulnerabilities.</description>130<date>[redacted]</date>131<risk>Medium</risk>132<pciLevel>Medium</pciLevel>133<pciReason>PCI DSS 4.1 - SSL Weakness</pciReason>134<pciPassFail>Fail</pciPassFail>135<cvssScore>4.3 [AV:N/AC:M/Au:N/C:P/I:N/A:N]</cvssScore>136<cvssScoreV3>6.8 [AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N]</cvssScoreV3>137<fixInformation>Ensure that applications or services are configured to reject SSLv3, SSLv2 and TLSv1.0 communications. Disabling weak protocols is a defense-in-depth measure against vulnerabilities that could allow SSL version downgrade attacks (e.g. CVE-2014-3566).</fixInformation>138<exploit>No</exploit>139<context>TCP:443 ([redacted]), SHA256[=][redacted], Serial[=][redacted]</context>140<testedValue>Accepted SSL Method: (SSLv[23]|TLSv1(\.0)?)$</testedValue>141<foundValue>[redacted]</foundValue>142<cwe>CWE-310</cwe>143</audit>144</host>145</hosts>146</scanJob>147=end New XML format148149150