From ef415e75e074c0e91a1736984d73a1e27cab3a7f Mon Sep 17 00:00:00 2001 From: Rachael Carder Date: Wed, 30 Mar 2022 12:35:07 -0500 Subject: [PATCH 01/10] Update HTML tag parsing to work with Acunetix 360 --- CHANGELOG.md | 3 +++ lib/acunetix/concerns/cleanup.rb | 5 ++++- lib/dradis/plugins/acunetix/gem_version.rb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbcde66..7ece16e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +v4.3.0 (XXXX 2022) + - Update HTML tag parsing for Acunetix 360 + v4.2.0 (February 2022) - No changes diff --git a/lib/acunetix/concerns/cleanup.rb b/lib/acunetix/concerns/cleanup.rb index 13c50d8..ad149ee 100644 --- a/lib/acunetix/concerns/cleanup.rb +++ b/lib/acunetix/concerns/cleanup.rb @@ -16,10 +16,13 @@ def cleanup_html(source) result.gsub!(/(.*?)<\/b>/) { "*#{$1.strip}*" } result.gsub!(//, "\n") result.gsub!(/|<\/div>/, '') + + result.gsub!(/<\/i>(.*?)<\/a>/m) { "\"#{$4}\":#{$2}" } result.gsub!(/(.*?)<\/a>/m, '\1') result.gsub!(/(.*?)<\/font>/m, '\1') result.gsub!(/

(.*?)<\/h2>/) { "*#{$1.strip}*" } result.gsub!(/(.*?)<\/i>/, '\1') + result.gsub!(/(.*?)<\/em>/) { "_#{$1.strip}_" } result.gsub!(/(.*?)<\/p>/) { "p. #{$1.strip}\n" } result.gsub!(/(.*?)<\/pre><\/code>/m){|m| "\n\nbc.. #{$1.strip}\n\np. \n" } result.gsub!(/(.*?)<\/code>/) { "\n\nbc. #{$1.strip}\n\n" } @@ -67,7 +70,7 @@ def format_table(str) # Some of the values have embedded HTML conent that we need to strip def tags_with_html_content - [:details, :description, :detailed_information, :impact, :recommendation] + [:details, :description, :detailed_information, :impact, :recommendation, :remedial_actions, :remedial_procedure, :external_references] end def tags_with_commas diff --git a/lib/dradis/plugins/acunetix/gem_version.rb b/lib/dradis/plugins/acunetix/gem_version.rb index 01f1680..62adf16 100644 --- a/lib/dradis/plugins/acunetix/gem_version.rb +++ b/lib/dradis/plugins/acunetix/gem_version.rb @@ -9,7 +9,7 @@ def self.gem_version module VERSION MAJOR = 4 MINOR = 2 - TINY = 0 + TINY = 1 PRE = nil STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") From 183f34ac79013cfad6ac776459165788578f6d4d Mon Sep 17 00:00:00 2001 From: Sean Yeoh Date: Thu, 21 Apr 2022 20:28:51 +0800 Subject: [PATCH 02/10] Add specs --- spec/fixtures/files/acunetix_360.xml | 101 +++++++++++++++++++++++++++ spec/upload_acunetix_360_spec.rb | 46 ++++++++++++ templates/vulnerability_360.template | 9 +++ 3 files changed, 156 insertions(+) create mode 100644 spec/fixtures/files/acunetix_360.xml create mode 100644 spec/upload_acunetix_360_spec.rb diff --git a/spec/fixtures/files/acunetix_360.xml b/spec/fixtures/files/acunetix_360.xml new file mode 100644 index 0000000..8522029 --- /dev/null +++ b/spec/fixtures/files/acunetix_360.xml @@ -0,0 +1,101 @@ + + + + scan id + www.google.com/ + 06/01/2022 + 00:00:50.9910251 + + + + d202b64e-8451-407c-3680-abdc02f0038f + http://aspnet.testsparker.com/blog/%27))%20WAITFOR%20DELAY%20%270%3a0%3a25%27--/ + ConfirmedBlindSqlInjection + Blind SQL Injection + Critical + 100 + True + Present + 6/16/2020 1:41:23 PM +00:00 + 6/16/2020 1:41:23 PM +00:00 + + A1 + 19 + 89 + 66 + 6.5.1 + 164.306(a), 164.308(a) + + A.14.2.5 + + + + CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N + + + Base + 8.6 + High + + + Temporal + 8.6 + High + + + Environmental + 8.6 + High + + + + + + + + CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N + + + Base + 8.6 + High + + + Temporal + 8.6 + High + + + Environmental + 8.6 + High + + + + + + Acunetix 360 identified a Blind SQL Injection, which occurs when data input by a user is interpreted as an SQL command rather than as normal data by the backend database.

+

This is an extremely common vulnerability and its successful exploitation can have critical implications.

+

Acunetix 360 confirmed the vulnerability by executing a test SQL query on the backend database. In these tests, SQL injection was not obvious, but the different responses from the page based on the injection test allowed us to identify and confirm the SQL injection.

]]>
+ Depending on the backend database, the database connection settings, and the operating system, an attacker can mount one or more of the following attacks successfully: +
    +
  • Reading, updating and deleting arbitrary data or tables from the database
  • +
  • Executing commands on the underlying operating system
  • +
+ ]]>
+ +
    +
  1. See the remedy for solution.
  2. +
  3. If you are not using a database access layer (DAL), consider using one. This will help you centralize the issue. You can also use ORM (object relational mapping). Most of the ORM systems use only parameterized queries and this can solve the whole SQL injection problem.
  4. +
  5. Locate the all dynamically generated SQL queries and convert them to parameterized queries. (If you decide to use a DAL/ORM, change all legacy code to use these new libraries.)
  6. +
  7. Use your weblogs and application logs to see if there were any previous but undetected attacks to this resource.
  8. +
+ ]]>
+ There are numerous freely available tools to exploit SQL injection vulnerabilities. This is a complex area with many dependencies; however, it should be noted that the numerous resources available in this area have raised both attacker awareness of the issues and their ability to discover and leverage them. SQL injection is one of the most common web application vulnerabilities.]]> + A robust method for mitigating the threat of SQL injection-based vulnerabilities is to use parameterized queries (prepared statements). Almost all modern languages provide built-in libraries for this. Wherever possible, do not create dynamic SQL queries or SQL queries with string concatenation.]]> +
]]> + ]]> + + + + diff --git a/spec/upload_acunetix_360_spec.rb b/spec/upload_acunetix_360_spec.rb new file mode 100644 index 0000000..75295ba --- /dev/null +++ b/spec/upload_acunetix_360_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' +require 'ostruct' +require 'byebug' +module Dradis::Plugins + describe 'Acunetix upload plugin' do + before(:each) do + templates_dir = File.expand_path('../../templates', __FILE__) + expect_any_instance_of(Dradis::Plugins::TemplateService) + .to receive(:default_templates_dir).and_return(templates_dir) + + plugin = Dradis::Plugins::Acunetix + + @content_service = Dradis::Plugins::ContentService::Base.new(plugin: plugin) + + allow(@content_service).to receive(:create_note) do |args| + OpenStruct.new(args) + end + allow(@content_service).to receive(:create_node) do |args| + OpenStruct.new(args) + end + allow(@content_service).to receive(:create_issue) do |args| + OpenStruct.new(args) + end + allow(@content_service).to receive(:create_evidence) do |args| + OpenStruct.new(args) + end + + @importer = plugin::Importer.new( + content_service: @content_service + ) + end + + describe "Source HTML parsing" do + it "parses links in tag" do + + expect(@content_service).to receive(:create_issue) do |args| + expect(args[:text]).to include('"Link 1":https://link1.com') + expect(args[:text]).to include('"Link 2":https://link2.com') + OpenStruct.new(args) + end.once + + @importer.import(file: 'spec/fixtures/files/acunetix_360.xml') + end + end + end +end diff --git a/templates/vulnerability_360.template b/templates/vulnerability_360.template index ff6510f..fcf6841 100644 --- a/templates/vulnerability_360.template +++ b/templates/vulnerability_360.template @@ -72,3 +72,12 @@ #[CVSS3Environmental]# %vulnerability_360.cvss31_environmental% + +#[Remedial Actions]# +%vulnerability_360.remedial_actions% + +#[Remedial Procedure]# +%vulnerability_360.remedial_procedure% + +#[References]# +%vulnerability_360.external_references% From 221f46eb98a9827078dc0f25d4cfdbebe0404e4b Mon Sep 17 00:00:00 2001 From: Rachael Carder Date: Thu, 21 Apr 2022 13:22:18 -0500 Subject: [PATCH 03/10] Add more cleanup actions that were previously missed --- lib/acunetix/concerns/cleanup.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/acunetix/concerns/cleanup.rb b/lib/acunetix/concerns/cleanup.rb index ad149ee..88473a8 100644 --- a/lib/acunetix/concerns/cleanup.rb +++ b/lib/acunetix/concerns/cleanup.rb @@ -14,8 +14,10 @@ def cleanup_html(source) result.gsub!(/>/, '>') result.gsub!(/(.*?)<\/b>/) { "*#{$1.strip}*" } - result.gsub!(//, "\n") + result.gsub!(/|
/, "\n") result.gsub!(/|<\/div>/, '') + result.gsub!(/(.*?)<\/span>/m){"#{$1.strip}\n"} + result.gsub!(/|<\/span>/, '') #repeating again to deal with nested/empty/incomplete span tags result.gsub!(/<\/i>(.*?)<\/a>/m) { "\"#{$4}\":#{$2}" } result.gsub!(/(.*?)<\/a>/m, '\1') @@ -24,18 +26,17 @@ def cleanup_html(source) result.gsub!(/(.*?)<\/i>/, '\1') result.gsub!(/(.*?)<\/em>/) { "_#{$1.strip}_" } result.gsub!(/(.*?)<\/p>/) { "p. #{$1.strip}\n" } - result.gsub!(/(.*?)<\/pre><\/code>/m){|m| "\n\nbc.. #{$1.strip}\n\np. \n" } + result.gsub!(/(.*?)<\/pre><\/code>/m){|m| "\n\nbc.. #{$1.strip}\n\np.\s\s\s\n" } result.gsub!(/(.*?)<\/code>/) { "\n\nbc. #{$1.strip}\n\n" } - result.gsub!(/(.*?)<\/pre>/m){|m| "\n\nbc.. #{$1.strip}\n\np. \n" } + result.gsub!(/(.*?)<\/pre>/) { "\n\nbc. #{$1.strip}\n\n" } + result.gsub!(/(.*?)<\/pre>/m){|m| "\n\nbc.. #{$1.strip}\n\np.\s\s\s\n" } result.gsub!(/([\s\S]*?)<\/li>/m){"\n* #{$1.strip}"} result.gsub!(/