recog-intrigue 2.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
  4. data/.github/ISSUE_TEMPLATE/fingerprint_request.md +27 -0
  5. data/.github/PULL_REQUEST_TEMPLATE +24 -0
  6. data/.gitignore +14 -0
  7. data/.rbenv-gemset +1 -0
  8. data/.rspec +3 -0
  9. data/.ruby-gemset +1 -0
  10. data/.ruby-version +1 -0
  11. data/.travis.yml +25 -0
  12. data/.yardopts +1 -0
  13. data/CONTRIBUTING.md +171 -0
  14. data/COPYING +23 -0
  15. data/Gemfile +10 -0
  16. data/LICENSE +7 -0
  17. data/README.md +85 -0
  18. data/Rakefile +22 -0
  19. data/bin/recog_export +81 -0
  20. data/bin/recog_match +55 -0
  21. data/bin/recog_standardize +118 -0
  22. data/bin/recog_verify +64 -0
  23. data/cpe-remap.yaml +134 -0
  24. data/features/data/failing_banners_fingerprints.xml +20 -0
  25. data/features/data/matching_banners_fingerprints.xml +23 -0
  26. data/features/data/multiple_banners_fingerprints.xml +32 -0
  27. data/features/data/no_tests.xml +3 -0
  28. data/features/data/sample_banner.txt +2 -0
  29. data/features/data/successful_tests.xml +18 -0
  30. data/features/data/tests_with_failures.xml +20 -0
  31. data/features/data/tests_with_warnings.xml +17 -0
  32. data/features/match.feature +36 -0
  33. data/features/support/aruba.rb +3 -0
  34. data/features/support/env.rb +6 -0
  35. data/features/verify.feature +48 -0
  36. data/identifiers/README.md +47 -0
  37. data/identifiers/os_architecture.txt +20 -0
  38. data/identifiers/os_device.txt +52 -0
  39. data/identifiers/os_family.txt +160 -0
  40. data/identifiers/os_product.txt +199 -0
  41. data/identifiers/service_family.txt +185 -0
  42. data/identifiers/service_product.txt +255 -0
  43. data/identifiers/software_class.txt +26 -0
  44. data/identifiers/software_family.txt +91 -0
  45. data/identifiers/software_product.txt +333 -0
  46. data/identifiers/vendor.txt +405 -0
  47. data/lib/recog.rb +4 -0
  48. data/lib/recog/db.rb +78 -0
  49. data/lib/recog/db_manager.rb +31 -0
  50. data/lib/recog/fingerprint.rb +280 -0
  51. data/lib/recog/fingerprint/regexp_factory.rb +56 -0
  52. data/lib/recog/fingerprint/test.rb +18 -0
  53. data/lib/recog/formatter.rb +51 -0
  54. data/lib/recog/match_reporter.rb +77 -0
  55. data/lib/recog/matcher.rb +94 -0
  56. data/lib/recog/matcher_factory.rb +14 -0
  57. data/lib/recog/nizer.rb +347 -0
  58. data/lib/recog/verifier.rb +39 -0
  59. data/lib/recog/verifier_factory.rb +13 -0
  60. data/lib/recog/verify_reporter.rb +86 -0
  61. data/lib/recog/version.rb +3 -0
  62. data/misc/convert_mysql_err +61 -0
  63. data/misc/order.xsl +17 -0
  64. data/recog-intrigue.gemspec +45 -0
  65. data/requirements.txt +2 -0
  66. data/spec/data/best_os_match_1.yml +17 -0
  67. data/spec/data/best_os_match_2.yml +17 -0
  68. data/spec/data/best_service_match_1.yml +17 -0
  69. data/spec/data/smb_native_os.txt +25 -0
  70. data/spec/data/test_fingerprints.xml +36 -0
  71. data/spec/data/verification_fingerprints.xml +86 -0
  72. data/spec/data/whitespaced_fingerprint.xml +5 -0
  73. data/spec/lib/fingerprint_self_test_spec.rb +174 -0
  74. data/spec/lib/recog/db_spec.rb +98 -0
  75. data/spec/lib/recog/fingerprint/regexp_factory_spec.rb +73 -0
  76. data/spec/lib/recog/fingerprint_spec.rb +112 -0
  77. data/spec/lib/recog/formatter_spec.rb +69 -0
  78. data/spec/lib/recog/match_reporter_spec.rb +91 -0
  79. data/spec/lib/recog/nizer_spec.rb +330 -0
  80. data/spec/lib/recog/verify_reporter_spec.rb +113 -0
  81. data/spec/spec_helper.rb +82 -0
  82. data/update_cpes.py +186 -0
  83. data/xml/apache_modules.xml +1911 -0
  84. data/xml/apache_os.xml +273 -0
  85. data/xml/architecture.xml +36 -0
  86. data/xml/dns_versionbind.xml +761 -0
  87. data/xml/fingerprints.xsd +128 -0
  88. data/xml/ftp_banners.xml +1553 -0
  89. data/xml/h323_callresp.xml +603 -0
  90. data/xml/hp_pjl_id.xml +358 -0
  91. data/xml/html_title.xml +1630 -0
  92. data/xml/http_cookies.xml +411 -0
  93. data/xml/http_servers.xml +3195 -0
  94. data/xml/http_wwwauth.xml +595 -0
  95. data/xml/imap_banners.xml +245 -0
  96. data/xml/ldap_searchresult.xml +711 -0
  97. data/xml/mdns_device-info_txt.xml +1796 -0
  98. data/xml/mdns_workstation_txt.xml +15 -0
  99. data/xml/mysql_banners.xml +1649 -0
  100. data/xml/mysql_error.xml +871 -0
  101. data/xml/nntp_banners.xml +82 -0
  102. data/xml/ntp_banners.xml +1223 -0
  103. data/xml/operating_system.xml +629 -0
  104. data/xml/pop_banners.xml +499 -0
  105. data/xml/rsh_resp.xml +76 -0
  106. data/xml/rtsp_servers.xml +76 -0
  107. data/xml/sip_banners.xml +359 -0
  108. data/xml/sip_user_agents.xml +221 -0
  109. data/xml/smb_native_lm.xml +62 -0
  110. data/xml/smb_native_os.xml +662 -0
  111. data/xml/smtp_banners.xml +1690 -0
  112. data/xml/smtp_debug.xml +39 -0
  113. data/xml/smtp_ehlo.xml +49 -0
  114. data/xml/smtp_expn.xml +82 -0
  115. data/xml/smtp_help.xml +157 -0
  116. data/xml/smtp_mailfrom.xml +20 -0
  117. data/xml/smtp_noop.xml +44 -0
  118. data/xml/smtp_quit.xml +29 -0
  119. data/xml/smtp_rcptto.xml +25 -0
  120. data/xml/smtp_rset.xml +26 -0
  121. data/xml/smtp_turn.xml +26 -0
  122. data/xml/smtp_vrfy.xml +89 -0
  123. data/xml/snmp_sysdescr.xml +6507 -0
  124. data/xml/snmp_sysobjid.xml +430 -0
  125. data/xml/ssh_banners.xml +1968 -0
  126. data/xml/telnet_banners.xml +1595 -0
  127. data/xml/x11_banners.xml +232 -0
  128. data/xml/x509_issuers.xml +134 -0
  129. data/xml/x509_subjects.xml +1268 -0
  130. metadata +304 -0
@@ -0,0 +1,22 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.pattern = "spec/**/*_spec.rb"
6
+ end
7
+
8
+ require 'yard'
9
+ require 'yard/rake/yardoc_task'
10
+ YARD::Rake::YardocTask.new do |t|
11
+ t.files = ['lib/**/*.rb', '-', 'README.md']
12
+ end
13
+
14
+ require 'cucumber'
15
+ require 'cucumber/rake/task'
16
+
17
+ Cucumber::Rake::Task.new(:features) do |t|
18
+ t.cucumber_opts = "features --format pretty"
19
+ end
20
+
21
+ task :default => [ :tests, :yard ]
22
+ task :tests => [ :spec, :features ]
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
4
+ require 'optparse'
5
+ require 'ostruct'
6
+ require 'recog'
7
+
8
+ def squash_lines(str)
9
+ str.split(/\n/).join(' ').gsub(/\s+/, ' ')
10
+ end
11
+
12
+ def export_text(options)
13
+ end
14
+
15
+ def export_ruby(options)
16
+ $stdout.puts "# Recog fingerprint database export [ #{File.basename(options.xml_file)} ] on #{Time.now.to_s}"
17
+ $stdout.puts "fp_str = '' # Set this value to the match string"
18
+ $stdout.puts "fp_match = {} # Match results are stored here"
19
+ $stdout.puts ""
20
+ $stdout.puts "case fp_str"
21
+ options.db.fingerprints.each do |fp|
22
+ puts " # #{squash_lines fp.name}"
23
+ puts " when /#{fp.regex.to_s}/"
24
+ fp.tests.each do |test|
25
+ puts " # Example: #{squash_lines test}"
26
+ end
27
+ fp.params.each_pair do |k,v|
28
+ if v[0] == 0
29
+ puts " fp_match[#{k.inspect}] = #{v[1].inspect}"
30
+ else
31
+ puts " fp_match[#{k.inspect}] = $#{v[0].to_s}"
32
+ end
33
+ end
34
+ puts ""
35
+ end
36
+ $stdout.puts "end"
37
+ end
38
+
39
+
40
+ options = OpenStruct.new(etype: :ruby)
41
+
42
+ option_parser = OptionParser.new do |opts|
43
+ opts.banner = "Usage: #{$0} [options] XML_FINGERPRINTS_FILE"
44
+ opts.separator "Exports an XML fingerprint database to another format."
45
+ opts.separator ""
46
+ opts.separator "Options"
47
+
48
+ opts.on("-t", "--type type",
49
+ "Choose a type of export.",
50
+ " [r]uby (default - export a ruby case statement with regular expressions)",
51
+ " [t]ext (export a text description of the fingerprints)") do |etype|
52
+ case etype.downcase
53
+ when /^r/
54
+ options.etype = :ruby
55
+ when /^t/
56
+ options.etype = :text
57
+ end
58
+ end
59
+
60
+ opts.on("-h", "--help", "Show this message.") do
61
+ puts opts
62
+ exit
63
+ end
64
+ end
65
+ option_parser.parse!(ARGV)
66
+
67
+ if ARGV.count != 1
68
+ puts option_parser
69
+ exit
70
+ end
71
+
72
+ options.xml_file = ARGV.shift
73
+ options.db = Recog::DB.new(options.xml_file)
74
+
75
+ case options.etype
76
+ when :ruby
77
+ export_ruby(options)
78
+ when :text
79
+ export_text(options)
80
+ end
81
+
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
4
+ require 'optparse'
5
+ require 'ostruct'
6
+ require 'recog'
7
+ require 'recog/matcher_factory'
8
+
9
+ options = OpenStruct.new(color: false, detail: false, fail_fast: false, multi_match: false)
10
+
11
+ option_parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: #{$0} [options] XML_FINGERPRINT_FILE [BANNERS_FILE]"
13
+ opts.separator "Identifies the matches and misses between the fingerprints and the banners file or STDIN"
14
+ opts.separator ""
15
+ opts.separator "Options"
16
+
17
+ opts.on("-f", "--format FORMATTER",
18
+ "Choose a formatter.",
19
+ " [s]ummary (default - failure/match msgs)",
20
+ " [d]etail (msgs with total counts)") do |format|
21
+ if format.start_with? 'd'
22
+ options.detail = true
23
+ end
24
+ end
25
+
26
+ opts.on("--fail-fast [NUM]",
27
+ "Stop after number of failures (default: 10).") do |num|
28
+ options.fail_fast = true
29
+ options.stop_after = (num.to_i == 0) ? 10 : num.to_i
30
+ end
31
+
32
+ opts.on("-c", "--color", "Enable color in the output.") do
33
+ options.color = true
34
+ end
35
+
36
+ opts.on("--[no-]multi-match", "Enable or disable multiple matches (defaults to disabled)") do |o|
37
+ options.multi_match = o
38
+ end
39
+
40
+ opts.on("-h", "--help", "Show this message.") do
41
+ puts opts
42
+ exit
43
+ end
44
+ end
45
+ option_parser.parse!(ARGV)
46
+
47
+ if ARGV.count != 1 && ARGV.count != 2
48
+ puts option_parser
49
+ exit(1)
50
+ end
51
+
52
+ ndb = Recog::DB.new(ARGV.shift)
53
+ options.fingerprints = ndb.fingerprints
54
+ matcher = Recog::MatcherFactory.build(options)
55
+ matcher.match_banners(ARGV.shift || "-")
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
4
+ require 'optparse'
5
+ require 'ostruct'
6
+ require 'recog'
7
+
8
+ def load_identifiers(path)
9
+ res = {}
10
+ File.readlines(path).map{|line| line.strip}.each do |ident|
11
+ res[ident] = true
12
+ end
13
+ return res
14
+ end
15
+
16
+ def write_identifiers(vals, path)
17
+ res = []
18
+ vals.each_pair do |k,v|
19
+ res = res.push(k)
20
+ end
21
+ res = res.sort.uniq
22
+ File.write(path, res.join("\n") + "\n")
23
+ end
24
+
25
+ bdir = File.expand_path(File.join(File.dirname(__FILE__), "..", "identifiers"))
26
+
27
+ options = OpenStruct.new(write: false)
28
+ option_parser = OptionParser.new do |opts|
29
+ opts.banner = "Usage: #{$0} [options] XML_FINGERPRINT_FILE1 ..."
30
+ opts.separator "Verifies that each fingerprint asserts known identifiers."
31
+ opts.separator ""
32
+ opts.separator "Options"
33
+
34
+ opts.on("-w", "--write") do
35
+ options.write = true
36
+ end
37
+
38
+ opts.on("-h", "--help", "Show this message.") do
39
+ puts opts
40
+ exit
41
+ end
42
+ end
43
+ option_parser.parse!(ARGV)
44
+
45
+ if ARGV.empty?
46
+ $stderr.puts 'Missing XML fingerprint files'
47
+ puts option_parser
48
+ exit(1)
49
+ end
50
+
51
+ # Load the unique identifiers
52
+ vendors = load_identifiers(File.join(bdir, "vendor.txt"))
53
+ os_arch = load_identifiers(File.join(bdir, "os_architecture.txt"))
54
+ os_prod = load_identifiers(File.join(bdir, "os_product.txt"))
55
+ os_family = load_identifiers(File.join(bdir, "os_family.txt"))
56
+ os_device = load_identifiers(File.join(bdir, "os_device.txt"))
57
+ svc_prod = load_identifiers(File.join(bdir, "service_product.txt"))
58
+ svc_family = load_identifiers(File.join(bdir, "service_family.txt"))
59
+
60
+ ARGV.each do |arg|
61
+ Dir.glob(arg).each do |file|
62
+ ndb = Recog::DB.new(file)
63
+ ndb.fingerprints.each do |f|
64
+ f.params.each do |k,v|
65
+ paramIndex, val = v
66
+ next if paramIndex != 0
67
+ case k
68
+ when "os.vendor", "service.vendor", "service.component.vendor", "hw.vendor"
69
+ if ! vendors[val]
70
+ puts "VENDOR MISSING: #{val}"
71
+ vendors[val] = true
72
+ end
73
+ when "os.product"
74
+ if ! os_prod[val]
75
+ puts "OS PRODUCT MISSING: #{val}"
76
+ os_prod[val] = true
77
+ end
78
+ when "os.arch"
79
+ if ! os_arch[val]
80
+ puts "OS ARCH MISSING: #{val}"
81
+ os_arch[val] = true
82
+ end
83
+ when "os.family"
84
+ if ! os_family[val]
85
+ puts "OS FAMILY MISSING: #{val}"
86
+ os_family[val] = true
87
+ end
88
+ when "os.device"
89
+ if ! os_device[val]
90
+ puts "OS DEVICE MISSING: #{val}"
91
+ os_device[val] = true
92
+ end
93
+ when "service.product"
94
+ if ! svc_prod[val]
95
+ puts "SERVICE PRODUCT MISSING: #{val}"
96
+ svc_prod[val] = true
97
+ end
98
+ when "service.family"
99
+ if ! svc_family[val]
100
+ puts "SERVICE FAMILY MISSING: #{val}"
101
+ svc_family[val] = true
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ exit if ! options.write
110
+
111
+ # Write back the unique identifiers
112
+ write_identifiers(vendors, File.join(bdir, "vendor.txt"))
113
+ write_identifiers(os_arch, File.join(bdir, "os_architecture.txt"))
114
+ write_identifiers(os_prod, File.join(bdir, "os_product.txt"))
115
+ write_identifiers(os_family, File.join(bdir, "os_family.txt"))
116
+ write_identifiers(os_device, File.join(bdir, "os_device.txt"))
117
+ write_identifiers(svc_prod, File.join(bdir, "service_product.txt"))
118
+ write_identifiers(svc_family, File.join(bdir, "service_family.txt"))
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
4
+ require 'optparse'
5
+ require 'ostruct'
6
+ require 'recog'
7
+ require 'recog/verifier_factory'
8
+
9
+ options = OpenStruct.new(color: false, detail: false, quiet: false, warnings: true)
10
+
11
+ option_parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: #{$0} [options] XML_FINGERPRINT_FILE1 ..."
13
+ opts.separator "Verifies that each fingerprint passes its internal tests."
14
+ opts.separator ""
15
+ opts.separator "Options"
16
+
17
+ opts.on("-f", "--format FORMATTER",
18
+ "Choose a formatter.",
19
+ " [s]ummary (default - failure/warning msgs and summary)",
20
+ " [q]uiet (configured failure/warning msgs only)",
21
+ " [d]etail (fingerprint name with tests and expanded summary)") do |format|
22
+ if format.start_with? 'd'
23
+ options.detail = true
24
+ end
25
+ if format.start_with? 'q'
26
+ options.quiet = true
27
+ end
28
+ end
29
+
30
+ opts.on("-c", "--color", "Enable color in the output.") do
31
+ options.color = true
32
+ end
33
+
34
+ opts.on("--[no-]warnings", "Track warnings") do |o|
35
+ options.warnings = o
36
+ end
37
+
38
+ opts.on("-h", "--help", "Show this message.") do
39
+ puts opts
40
+ exit
41
+ end
42
+ end
43
+ option_parser.parse!(ARGV)
44
+
45
+ if ARGV.empty?
46
+ $stderr.puts 'Missing XML fingerprint files'
47
+ puts option_parser
48
+ exit(1)
49
+ end
50
+
51
+ warnings = 0
52
+ failures = 0
53
+ ARGV.each do |arg|
54
+ Dir.glob(arg).each do |file|
55
+ ndb = Recog::DB.new(file)
56
+ options.fingerprints = ndb.fingerprints
57
+ verifier = Recog::VerifierFactory.build(options)
58
+ verified = verifier.verify
59
+ failures += verifier.reporter.failure_count
60
+ warnings += verifier.reporter.warning_count
61
+ end
62
+ end
63
+
64
+ exit failures + warnings
@@ -0,0 +1,134 @@
1
+ mappings:
2
+ apache:
3
+ vendor: apache
4
+ products:
5
+ httpd: http_server
6
+ apple:
7
+ products:
8
+ ios: iphone_os
9
+ alt-n:
10
+ vendor: altn
11
+ bea:
12
+ vendor: bea
13
+ products:
14
+ weblogic: weblogic_server
15
+ blue_coat:
16
+ vendor: bluecoat
17
+ centos:
18
+ vendor: centos
19
+ products:
20
+ linux: centos
21
+ check_point:
22
+ vendor: checkpoint
23
+ cisco:
24
+ vendor: cisco
25
+ products:
26
+ adaptive_security_appliance: adaptive_security_appliance_software
27
+ pix: pix_firewall_software
28
+ telepresence: telepresence_video_communication_server_software
29
+ debian:
30
+ vendor: debian
31
+ products:
32
+ linux: debian_linux
33
+ f5:
34
+ vendor: f5
35
+ products:
36
+ big-ip: big-ip_local_traffic_manager
37
+ big-ip_ltm: big-ip_local_traffic_manager
38
+ hp:
39
+ vendor: hp
40
+ products:
41
+ ilo: integrated_lights_out
42
+ lotus_domino: lotus_domino_server
43
+ tru64_unix: tru64
44
+ ibm:
45
+ vendor: ibm
46
+ products:
47
+ lotus_domino: lotus_domino_server
48
+ juniper:
49
+ vendor: juniper
50
+ products:
51
+ junos_os: junos
52
+ linux:
53
+ vendor: linux
54
+ products:
55
+ linux: linux_kernel
56
+ mailenable:
57
+ vendor: mailenable
58
+ products:
59
+ mail_server: mailenable
60
+ microsoft:
61
+ vendor: microsoft
62
+ products:
63
+ active_directory_controller: active_directory
64
+ exchange_server_5.5: exchange_server
65
+ exchange_2000_server: exchange_server
66
+ exchange_2003_server: exchange_server
67
+ exchange_2007_server: exchange_server
68
+ lightweight_directory_server: active_directory_lightweight_directory_service
69
+ windows_server_2003_datacenter_edition: windows_server_2003
70
+ windows_server_2003_r2: windows_server_2003
71
+ windows_2008_r2: windows_server_2008
72
+ windows_server_2008_datacenter_edition: windows_server_2008
73
+ windows_server_2008_r2: windows_server_2008
74
+ windows_server_2008_r2_datacenter_edition: windows_server_2008
75
+ windows_server_2012_r2: windows_server_2012
76
+ nt: windows_nt
77
+ windows_nt_desktop: windows_nt
78
+ windows_nt_server: windows_nt
79
+ windows_server_2000: windows_2000
80
+ windows_2000_server: windows_2000
81
+ windows_2000_datacenter_server: windows_2000
82
+ pws: personal_web_server
83
+ mod_ssl:
84
+ vendor: modssl
85
+ mod_wsgi:
86
+ vendor: modwsgi
87
+ mort_bay:
88
+ vendor: mortbay
89
+ net-snmp:
90
+ vendor: net-snmp
91
+ products:
92
+ snmp_agent: net-snmp
93
+ palo_alto_networks:
94
+ vendor: paloaltonetworks
95
+ products:
96
+ pa_firewall: pan-os
97
+ proftpd_project:
98
+ vendor: proftpd
99
+ realvnc_ltd.:
100
+ vendor: realvnc
101
+ red_hat:
102
+ vendor: redhat
103
+ products:
104
+ cygwin_x_server_project: cygwin
105
+ fedora_core_linux: fedora_core
106
+ jboss_as: jboss_wildfly_application_server
107
+ jboss_eap: jboss_enterprise_application_platform
108
+ jbossweb: jboss_web_framework_kit
109
+ red_hat_directory_server: directory_server
110
+ squid_cache:
111
+ vendor: squid-cache
112
+ sun:
113
+ vendor: sun
114
+ products:
115
+ solaris: sunos
116
+ ubuntu:
117
+ vendor: canonical
118
+ products:
119
+ linux: ubuntu_linux
120
+ vandyke_software:
121
+ vendor: vandyke
122
+ vmware:
123
+ vendor: vmware
124
+ products:
125
+ photon_linux: photon_os
126
+ zimbra: zimbra_desktop
127
+ vmware_esx_server: esx
128
+ vmware_esxi_server: esxi
129
+ wind_river:
130
+ vendor: windriver
131
+ x.org:
132
+ vendor: x.org
133
+ products:
134
+ x.org_x11: x11