Skip to content

Commit f573a48

Browse files
author
Brent Cook
committed
Land rapid7#8689, Docker improvements
2 parents 535dfdf + 3c7d6c3 commit f573a48

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

docker/bin/msfvenom

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,9 @@ if [[ -z "$MSF_PATH" ]]; then
1717
MSF_PATH=$(dirname $(dirname $path))
1818
fi
1919

20+
if [[ -n "$MSF_BUILD" ]]; then
21+
docker-compose -f $MSF_PATH/docker-compose.yml build
22+
fi
23+
2024
cd $MSF_PATH
2125
docker-compose run --rm --service-ports ms ./msfvenom "$@"

docker/bin/msfvenom-dev

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#! /bin/bash
2+
3+
if [[ -z "$MSF_PATH" ]]; then
4+
path=`dirname $0`
5+
6+
# check for ./docker/msfconsole.rc
7+
if [[ ! -f $path/../msfconsole.rc ]] ; then
8+
9+
# we are not inside the project
10+
realpath --version > /dev/null 2>&1 || { echo >&2 "I couldn't find where metasploit is. Set \$MSF_PATH or execute this from the project root"; exit 1 ;}
11+
12+
# determine script path
13+
pushd $(dirname $(realpath $0)) > /dev/null
14+
path=$(pwd)
15+
popd > /dev/null
16+
fi
17+
MSF_PATH=$(dirname $(dirname $path))
18+
fi
19+
20+
cd $MSF_PATH
21+
22+
if [[ -n "$MSF_BUILD" ]]; then
23+
docker-compose -f $MSF_PATH/docker-compose.yml -f $MSF_PATH/docker/docker-compose.development.override.yml build
24+
fi
25+
26+
docker-compose -f $MSF_PATH/docker-compose.yml -f $MSF_PATH/docker/docker-compose.development.override.yml run --rm --service-ports ms ./msfvenom "$@"

lib/msf/util.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ module Util
2121

2222
# Executable generation and encoding
2323
require 'msf/util/exe'
24+
require 'msf/util/helper'

lib/msf/util/helper.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: binary -*-
2+
3+
module Msf
4+
module Util
5+
class Helper
6+
# Cross-platform way of finding an executable in the $PATH.
7+
#
8+
# which('ruby') #=> /usr/bin/ruby
9+
def self.which(cmd)
10+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
11+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
12+
exts.each { |ext|
13+
exe = File.join(path, "#{cmd}#{ext}")
14+
return exe if File.executable?(exe) && !File.directory?(exe)
15+
}
16+
end
17+
return nil
18+
end
19+
end
20+
end
21+
end

metasploit-framework.gemspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ end
1313
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
1414
require 'metasploit/framework/version'
1515
require 'metasploit/framework/rails_version_constraint'
16+
require 'msf/util/helper'
1617

1718
Gem::Specification.new do |spec|
1819
spec.name = 'metasploit-framework'
@@ -24,7 +25,8 @@ Gem::Specification.new do |spec|
2425
spec.homepage = 'https://www.metasploit.com'
2526
spec.license = 'BSD-3-clause'
2627

27-
if File.directory?(File.join(File.dirname(__FILE__), ".git"))
28+
# only do a git ls-files if the .git folder exists and we have a git binary in PATH
29+
if File.directory?(File.join(File.dirname(__FILE__), ".git")) && Msf::Util::Helper.which("git")
2830
spec.files = `git ls-files`.split($/).reject { |file|
2931
file =~ /^documentation|^external/
3032
}

0 commit comments

Comments
 (0)