Skip to content

Commit

Permalink
PWN::Plugins::BlackDuckBinaryAnalysis module - implement connection r…
Browse files Browse the repository at this point in the history
…eattempts (3 max attempts) when arbitrary connection timeouts occur between rest client and protecode-sc.com
  • Loading branch information
ninp0 committed Feb 28, 2024
1 parent df28c3e commit e719b2b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ cd /opt/pwn
$ ./install.sh
$ ./install.sh ruby-gem
$ pwn
pwn[v0.5.41]:001 >>> PWN.help
pwn[v0.5.42]:001 >>> PWN.help
```

[![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](https://youtu.be/G7iLUY4FzsI)
Expand All @@ -52,7 +52,7 @@ $ rvm use ruby-3.3.0@pwn
$ gem uninstall --all --executables pwn
$ gem install --verbose pwn
$ pwn
pwn[v0.5.41]:001 >>> PWN.help
pwn[v0.5.42]:001 >>> PWN.help
```

If you're using a multi-user install of RVM do:
Expand All @@ -62,7 +62,7 @@ $ rvm use ruby-3.3.0@pwn
$ rvmsudo gem uninstall --all --executables pwn
$ rvmsudo gem install --verbose pwn
$ pwn
pwn[v0.5.41]:001 >>> PWN.help
pwn[v0.5.42]:001 >>> PWN.help
```

PWN periodically upgrades to the latest version of Ruby which is reflected in `/opt/pwn/.ruby-version`. The easiest way to upgrade to the latest version of Ruby from a previous PWN installation is to run the following script:
Expand Down
15 changes: 15 additions & 0 deletions lib/pwn/plugins/black_duck_binary_analysis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ module BlackDuckBinaryAnalysis
spinner = TTY::Spinner.new
spinner.auto_spin

max_request_attempts = 3
tot_request_attempts ||= 1

case http_method
when :delete, :get
headers[:params] = params
Expand Down Expand Up @@ -90,6 +93,18 @@ module BlackDuckBinaryAnalysis
end

raise e
rescue IO::TimeoutError => e
raise e if tot_request_attempts == max_request_attempts

puts "\nTCP Connection Unavailable."
puts "Attempt (#{tot_request_attempts} of #{max_request_attempts}) in 60s"
60.downto(1) do
print '.'
sleep 1
end
tot_request_attempts += 1

retry
rescue StandardError => e
case e.message
when '400 Bad Request', '404 Resource Not Found'
Expand Down
2 changes: 1 addition & 1 deletion lib/pwn/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module PWN
VERSION = '0.5.41'
VERSION = '0.5.42'
end

0 comments on commit e719b2b

Please sign in to comment.