Gentoo Archives: gentoo-commits

From: Richard Farina <zerochaos@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-analyzer/metasploit/
Date: Tue, 26 Jan 2016 21:20:46
Message-Id: 1453843203.344901ee1a35f7240694ba1fc1c03b17ace74fc4.zerochaos@gentoo
1 commit: 344901ee1a35f7240694ba1fc1c03b17ace74fc4
2 Author: Zero_Chaos <zerochaos <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jan 26 21:19:43 2016 +0000
4 Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org>
5 CommitDate: Tue Jan 26 21:20:03 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=344901ee
7
8 net-analyzer/metasploit: new snapshot
9
10 Package-Manager: portage-2.2.27
11
12 net-analyzer/metasploit/Manifest | 1 +
13 net-analyzer/metasploit/metasploit-4.11.7.ebuild | 297 +++++++++++++++++++++++
14 2 files changed, 298 insertions(+)
15
16 diff --git a/net-analyzer/metasploit/Manifest b/net-analyzer/metasploit/Manifest
17 index 2378313..8d977c2 100644
18 --- a/net-analyzer/metasploit/Manifest
19 +++ b/net-analyzer/metasploit/Manifest
20 @@ -1 +1,2 @@
21 DIST metasploit-4.11.5_p2015110401.tar.gz 35426390 SHA256 fd8ef85a1d935245892c618001d1f992d6be16baa449a61c358b64a306ec249c SHA512 57e6d09546b219023a2f0c5920f143cbda1736c274004e16533693bc25d4f3fc35458c0ddecc1d552e0db575a41a7c7dab5db0dd1fa14d48e8fd66dbf6c9a94c WHIRLPOOL 1c3e2683598f25ce89904c5d0e9e3cf85820a6f09a06ef6e62207cdd30fe48e793012391b44c82131bacf05fce62f0093704d193769ab86ea40b9577543980f1
22 +DIST metasploit-4.11.7.tar.gz 23163701 SHA256 1dbfc027dbcbb746858d36dda5ba9321cdc7d5dbc7538ceb20730a9de56d026b SHA512 cd84a4ba253e8ae38f93ba20316f0cb0aa5aeabfb345f07cb96791c5b7589572920b1723df624e26b4e07968fe8be55b04e1abc3c8828b5588bec62aca100d55 WHIRLPOOL c054e19f1c994c43230777a5f72d74b468f9de97b0f64edd17f4e9ef68fff3546d1311d9f80036d5aeccb6381c3c7f0200d5e3e33ce567e36f6ce58a9b97d4b3
23
24 diff --git a/net-analyzer/metasploit/metasploit-4.11.7.ebuild b/net-analyzer/metasploit/metasploit-4.11.7.ebuild
25 new file mode 100644
26 index 0000000..50a0658
27 --- /dev/null
28 +++ b/net-analyzer/metasploit/metasploit-4.11.7.ebuild
29 @@ -0,0 +1,297 @@
30 +# Copyright 1999-2016 Gentoo Foundation
31 +# Distributed under the terms of the GNU General Public License v2
32 +# $Id$
33 +
34 +EAPI="5"
35 +
36 +#never ever ever have more than one ruby in here
37 +USE_RUBY="ruby21"
38 +inherit eutils ruby-ng
39 +
40 +if [[ ${PV} == "9999" ]] ; then
41 + EGIT_REPO_URI="https://github.com/rapid7/metasploit-framework.git"
42 + EGIT_CHECKOUT_DIR="${WORKDIR}"/all
43 + inherit git-r3
44 + KEYWORDS=""
45 + SLOT="9999"
46 +else
47 + ##Tags https://github.com/rapid7/metasploit-framework/releases
48 + ##Releases https://github.com/rapid7/metasploit-framework/wiki/Downloads-by-Version
49 + #SRC_URI="https://github.com/rapid7/metasploit-framework/archive/${PV}.tar.gz -> ${P}.tar.gz"
50 + ##Snapshots
51 + MY_PV=${PV/_p/-}
52 + SRC_URI="https://github.com/rapid7/metasploit-framework/archive/${MY_PV}.tar.gz -> ${P}.tar.gz"
53 + KEYWORDS="~amd64 ~x86"
54 + RUBY_S="${PN}-framework-${MY_PV}"
55 + inherit versionator
56 + SLOT="$(get_version_component_range 1).$(get_version_component_range 2)"
57 +fi
58 +
59 +DESCRIPTION="Advanced framework for developing, testing, and using vulnerability exploit code"
60 +HOMEPAGE="http://www.metasploit.org/"
61 +LICENSE="BSD"
62 +IUSE="development +java oracle +pcap test"
63 +
64 +#multiple known bugs with tests reported upstream and ignored
65 +#http://dev.metasploit.com/redmine/issues/8418 - worked around (fix user creation when possible)
66 +RESTRICT="test"
67 +
68 +RUBY_COMMON_DEPEND="virtual/ruby-ssl
69 + >=dev-ruby/activesupport-4.0.9:4.0
70 + >=dev-ruby/actionpack-4.0.9:4.0
71 + >=dev-ruby/activerecord-4.0.9:4.0
72 + dev-ruby/bcrypt-ruby
73 + dev-ruby/builder:3
74 + dev-ruby/bundler
75 + dev-ruby/filesize
76 + dev-ruby/jsobfu:0.3.0
77 + dev-ruby/json
78 + dev-ruby/kissfft
79 + dev-ruby/metasm:1.0.2
80 + dev-ruby/metasploit_data_models:1.2.10
81 + dev-ruby/meterpreter_bins:0.0.22
82 + dev-ruby/metasploit-payloads:1.0.21
83 + dev-ruby/metasploit-credential:1.0.1
84 + >=dev-ruby/metasploit-concern-1.0.0:1.0
85 + >=dev-ruby/metasploit-model-1.0.0:1.0
86 + dev-ruby/msgpack
87 + dev-ruby/nokogiri
88 + dev-ruby/openssl-ccm:1.2.1
89 + dev-ruby/recog:2.0.14
90 + =dev-ruby/rkelly-remix-0.0.6
91 + dev-ruby/sqlite3
92 + >=dev-ruby/pg-0.11
93 + dev-ruby/packetfu:1.1.11
94 + >=dev-ruby/rubyzip-1.1
95 + dev-ruby/rb-readline-r7
96 + dev-ruby/robots
97 + java? ( dev-ruby/rjb )
98 + oracle? ( dev-ruby/ruby-oci8 )
99 + pcap? ( dev-ruby/pcaprub:*
100 + dev-ruby/network_interface )
101 + development? ( dev-ruby/fivemat
102 + dev-ruby/pry
103 + dev-ruby/redcarpet
104 + dev-ruby/yard
105 + >=dev-ruby/rake-10.0.0
106 + >=dev-ruby/factory_girl-4.1.0 )"
107 + #lorcon doesn't support ruby21
108 + #lorcon? ( net-wireless/lorcon[ruby] )
109 +ruby_add_bdepend "${RUBY_COMMON_DEPEND}
110 + test? ( >=dev-ruby/factory_girl-4.1.0
111 + dev-ruby/fivemat
112 + dev-ruby/database_cleaner
113 + >=dev-ruby/rspec-2.12
114 + dev-ruby/shoulda-matchers
115 + dev-ruby/timecop
116 + >=dev-ruby/rake-10.0.0 )"
117 +ruby_add_rdepend "${RUBY_COMMON_DEPEND}"
118 +
119 +COMMON_DEPEND="dev-db/postgresql[server]
120 + >=app-crypt/johntheripper-1.7.9-r1[-minimal]
121 + net-analyzer/nmap"
122 +RDEPEND+=" ${COMMON_DEPEND}
123 + >=app-eselect/eselect-metasploit-0.16"
124 +
125 +RESTRICT="strip"
126 +
127 +QA_PREBUILT="
128 + usr/lib*/${PN}${SLOT}/data/templates/template_x86_linux.bin
129 + usr/lib*/${PN}${SLOT}/data/templates/template_armle_linux.bin
130 + usr/lib*/${PN}${SLOT}/data/templates/template_x86_solaris.bin
131 + usr/lib*/${PN}${SLOT}/data/templates/template_x64_linux.bin
132 + usr/lib*/${PN}${SLOT}/data/templates/template_x64_linux_dll.bin
133 + usr/lib*/${PN}${SLOT}/data/templates/template_x86_bsd.bin
134 + usr/lib*/${PN}${SLOT}/data/templates/template_x64_bsd.bin
135 + usr/lib*/${PN}${SLOT}/data/templates/template_mipsbe_linux.bin
136 + usr/lib*/${PN}${SLOT}/data/templates/template_mipsle_linux.bin
137 + usr/lib*/${PN}${SLOT}/data/meterpreter/msflinker_linux_x86.bin
138 + usr/lib*/${PN}${SLOT}/data/meterpreter/ext_server_sniffer.lso
139 + usr/lib*/${PN}${SLOT}/data/meterpreter/ext_server_networkpug.lso
140 + usr/lib*/${PN}${SLOT}/data/meterpreter/ext_server_stdapi.lso
141 + usr/lib*/${PN}${SLOT}/data/exploits/CVE-2013-2171.bin
142 + usr/lib*/${PN}${SLOT}/data/exploits/CVE-2014-3153.elf
143 + usr/lib*/${PN}${SLOT}/data/android/libs/x86/libndkstager.so
144 + usr/lib*/${PN}${SLOT}/data/android/libs/mips/libndkstager.so
145 + usr/lib*/${PN}${SLOT}/data/android/libs/armeabi/libndkstager.so
146 + "
147 +
148 +pkg_setup() {
149 + if use test; then
150 + su postgres -c "dropdb msf_test_database" #this is intentionally allowed to fail
151 + su postgres -c "createuser msf_test_user -d -S -R"
152 + if [ $? -ne 0 ]; then
153 + su postgres -c "dropuser msf_test_user" || die
154 + su postgres -c "createuser msf_test_user -d -S -R" || die
155 + fi
156 + su postgres -c "createdb --owner=msf_test_user msf_test_database" || die
157 + fi
158 + ruby-ng_pkg_setup
159 +}
160 +
161 +all_ruby_unpack() {
162 + if [[ ${PV} == "9999" ]] ; then
163 + git-r3_src_unpack
164 + else
165 + default_src_unpack
166 +# mv "${WORKDIR}"/all/msf3/* "${WORKDIR}"/all
167 +# rm -r msf3
168 + #msf_version=$(grep --color=never "CURRENT_VERSION =" ${S}/spec/lib/msf/core/framework_spec.rb)
169 + #msf_version=${msf_version#*=}
170 + fi
171 +}
172 +
173 +all_ruby_prepare() {
174 + # add psexec patch from pull request 2657 to allow custom exe templates from any files, bypassing most AVs
175 + #epatch "${FILESDIR}/agix_psexec_pull-2657.patch"
176 + epatch_user
177 +
178 + #remove random "cpuinfo" binaries which a only needed to detect which bundled john to run
179 + rm -r data/cpuinfo
180 +
181 + #remove random oudated collected garbage
182 + rm -r external
183 +
184 + #remove unneeded ruby bundler versioning files
185 + #Gemfile.lock contains the versions tested by the msf team but not the hard requirements
186 + #we regen this file in each_ruby_prepare
187 + rm Gemfile.lock
188 + #The Gemfile contains real known deps
189 + #add our dep on upstream rb-readline instead of bundled one
190 + #and then they broke it...
191 + #sed -i "/gem 'packetfu'/a #use upstream readline instead of bundled\ngem 'rb-readline'" Gemfile || die
192 + sed -i "/gem 'fivemat'/s/, '1.2.1'//" Gemfile || die
193 + #remove the bundled readline
194 + #https://github.com/rapid7/metasploit-framework/pull/3105
195 + #this PR was closed due to numerous changes to their local fork, almost entirely for non-linux
196 + #but now we have to go back to bundled readline because otherwise it's broken
197 + #rm lib/rbreadline.rb
198 + #now we edit the Gemfile based on use flags
199 + #even if we pass --without=blah bundler still calculates the deps and messes us up
200 + if ! use pcap; then
201 + sed -i -e "/^group :pcap do/,/^end$/d" Gemfile || die
202 + fi
203 + if ! use development; then
204 + sed -i -e "/^group :development do/,/^end$/d" Gemfile || die
205 + fi
206 + if ! use test; then
207 + sed -i -e "/^group :test/,/^end$/d" Gemfile || die
208 + fi
209 + if ! use test && ! use development; then
210 + sed -i -e "/^group :development/,/^end$/d" Gemfile || die
211 + fi
212 + #We don't need simplecov
213 + sed -i -e "/^group :coverage/,/^end$/d" Gemfile || die
214 + sed -i -e "s#require 'simplecov'##" spec/spec_helper.rb || die
215 +
216 + #we need to edit the gemspec too, since it tries to call git instead of anything sane
217 + #probably a better way to fix this... if I care at some point
218 + sed -i -e "/^ spec.files/,/^ }/d" metasploit-framework.gemspec || die
219 +
220 + #let's bogart msfupdate
221 + rm msfupdate
222 + echo "#!/bin/sh" > msfupdate
223 + echo "echo \"[*]\"" >> msfupdate
224 + echo "echo \"[*] Attempting to update the Metasploit Framework...\"" >> msfupdate
225 + echo "echo \"[*]\"" >> msfupdate
226 + echo "echo \"\"" >> msfupdate
227 + if [[ ${PV} == "9999" ]] ; then
228 + echo "if [ -x /usr/bin/smart-live-rebuild ]; then" >> msfupdate
229 + echo " smart-live-rebuild -f net-analyzer/metasploit" >> msfupdate
230 + echo "else" >> msfupdate
231 + echo " echo \"Please install app-portage/smart-live-rebuild for a better experience.\"" >> msfupdate
232 + echo "emerge --oneshot \"=${CATEGORY}/${PF}\"" >> msfupdate
233 + echo "fi" >> msfupdate
234 + else
235 + echo "echo \"Unable to update tagged version of metasploit.\"" >> msfupdate
236 + echo "echo \"If you want the latest please install and eselect the live version (metasploit9999)\"" >> msfupdate
237 + echo "echo \"emerge metasploit:9999 -vat && eselect metasploit set metasploit9999\"" >> msfupdate
238 + fi
239 + #this is set executable in src_install
240 +
241 + #install our database.yml file before tests are run
242 + cp "${FILESDIR}"/database.yml config/
243 +
244 +}
245 +
246 +each_ruby_prepare() {
247 + MSF_ROOT="." BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle install --local || die
248 + MSF_ROOT="." BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle check || die
249 +
250 + #force all metasploit executables to use desired ruby version
251 + #https://dev.metasploit.com/redmine/issues/8357
252 + for file in $(ls -1 msf*)
253 + do
254 + #poorly adapted from python.eclass
255 + sed -e "1s:^#![[:space:]]*\([^[:space:]]*/usr/bin/env[[:space:]]\)\?[[:space:]]*\([^[:space:]]*/\)\?ruby\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?\(\$\|[[:space:]].*\):#!\1\2${RUBY}:" -i "${file}" || die "Conversion of shebang in '${file}' failed"
256 + done
257 +}
258 +
259 +each_ruby_test() {
260 + #review dev-python/pymongo for ways to make the test compatible with FEATURES=network-sandbox
261 +
262 + #we bogart msfupdate so no point in trying to test it
263 + rm spec/msfupdate_spec.rb || die
264 + #we don't really want to be uploading to virustotal during the tests
265 + rm spec/tools/virustotal_spec.rb || die
266 +
267 + # https://dev.metasploit.com/redmine/issues/8425
268 + BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle exec rake db:create || die
269 + BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle exec rake db:migrate || die
270 +
271 + MSF_DATABASE_CONFIG=config/database.yml BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle exec rake || die
272 + su postgres -c "dropuser msf_test_user" || die "failed to cleanup msf_test-user"
273 +}
274 +
275 +each_ruby_install() {
276 + #Tests have already been run, we don't need this stuff
277 + rm -r spec || die
278 + rm -r test || die
279 + rm Gemfile.lock || die
280 +
281 + #I'm 99% sure that this will only work for as long as we only support one ruby version. Creativity will be needed if we wish to support multiple.
282 + # should be as simple as copying everything into the target...
283 + dodir /usr/$(get_libdir)/${PN}${SLOT}
284 + cp -R * "${ED}"/usr/$(get_libdir)/${PN}${SLOT} || die "Copy files failed"
285 + rm -Rf "${ED}"/usr/$(get_libdir)/${PN}${SLOT}/documentation "${ED}"/usr/$(get_libdir)/${PN}${SLOT}/README.md
286 + fowners -R root:0 /
287 +
288 +}
289 +
290 +all_ruby_install() {
291 + # do not remove LICENSE, bug #238137
292 + dodir /usr/share/doc/${PF}
293 + cp -R {documentation,README.md} "${ED}"/usr/share/doc/${PF} || die
294 + dosym /usr/share/doc/${PF}/documentation /usr/$(get_libdir)/${PN}${SLOT}/documentation
295 +
296 + fperms +x /usr/$(get_libdir)/${PN}${SLOT}/msfupdate
297 +
298 + #tell revdep-rebuild to ignore binaries meant for the target
299 + dodir /etc/revdep-rebuild
300 + cat <<-EOF > "${ED}"/etc/revdep-rebuild/99-metasploit${SLOT}
301 + #These dirs contain prebuilt binaries for running on the TARGET not the HOST
302 + SEARCH_DIRS_MASK="/usr/lib*/${PN}${SLOT}/data/meterpreter"
303 + SEARCH_DIRS_MASK="/usr/lib*/${PN}${SLOT}/data/exploits"
304 + EOF
305 +}
306 +
307 +pkg_postinst() {
308 + elog "Before use you should run 'env-update' and '. /etc/profile'"
309 + elog "otherwise you may be missing important environmental variables."
310 +
311 + elog "You need to prepare the database by running:"
312 + elog "emerge --config postgresql"
313 + elog "/etc/init.d/postgresql-<version> start"
314 + elog "emerge --config =metasploit-${PV}"
315 +
316 + "${EROOT}"/usr/bin/eselect metasploit set --use-old ${PN}${SLOT}
317 +
318 + einfo
319 + elog "Adjust /usr/lib/${PN}${SLOT}/config/database.yml if necessary"
320 +}
321 +
322 +pkg_config() {
323 + einfo "If the following fails, it is likely because you forgot to start/config postgresql first"
324 + su postgres -c "createuser msf_user -D -S -R"
325 + su postgres -c "createdb --owner=msf_user msf_database"
326 +}