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: Sat, 30 Jul 2016 18:40:24
Message-Id: 1469903982.b8057deaa4ba505c9eb3be8e0481b5a632725f84.zerochaos@gentoo
1 commit: b8057deaa4ba505c9eb3be8e0481b5a632725f84
2 Author: Zero_Chaos <zerochaos <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jul 30 18:39:20 2016 +0000
4 Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org>
5 CommitDate: Sat Jul 30 18:39:42 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b8057dea
7
8 net-analyzer/metasploit: new snapshot, woo
9
10 Package-Manager: portage-2.3.0
11
12 net-analyzer/metasploit/Manifest | 1 +
13 net-analyzer/metasploit/metasploit-4.12.16.ebuild | 317 ++++++++++++++++++++++
14 2 files changed, 318 insertions(+)
15
16 diff --git a/net-analyzer/metasploit/Manifest b/net-analyzer/metasploit/Manifest
17 index ee44860..96303df 100644
18 --- a/net-analyzer/metasploit/Manifest
19 +++ b/net-analyzer/metasploit/Manifest
20 @@ -1 +1,2 @@
21 +DIST metasploit-4.12.16.tar.gz 23258256 SHA256 082f4109da2368fc4ec25a64ceae7655da80b3a46f650f86ff52d9bfac05c584 SHA512 6a95ddc848b95069bc425dd65ba4ed19be981d613cdb13d998ff1222f2ceddaf8b55c355243d69094b691e2a2d7580053284969c9a5133b2328c7d1743055101 WHIRLPOOL 70aa40de2c2b8884b3705e9d150f1b30a8477acc9c79ac1e491a0d9f15aa13b4d64697cf5e7e712173862ab96ecc76636b92cbc24ea228a5d14b9a4a420ac064
22 DIST metasploit-4.12.7.tar.gz 23335841 SHA256 30d3fe6f0e3626e86d1497beb21f4ed304fb2f5f375823a5b91f5cbc9d762bae SHA512 6927876b577e1d2421eeabdd1abab90ac99aef02703c0b431eb664c855008639081af64dd82426b87114c8460ecd31ecb46cc89af1edf4f65a2e79b30d99675a WHIRLPOOL add23aad4f5f916510c1e879d25b182651c2bd22e10311ebf43347c8a5fc5056a1f9ee13906791754585bfea4ab742a005564347de7dabaa62f987301b4c0332
23
24 diff --git a/net-analyzer/metasploit/metasploit-4.12.16.ebuild b/net-analyzer/metasploit/metasploit-4.12.16.ebuild
25 new file mode 100644
26 index 0000000..ca5514d
27 --- /dev/null
28 +++ b/net-analyzer/metasploit/metasploit-4.12.16.ebuild
29 @@ -0,0 +1,317 @@
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 ~arm"
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.2.6:4.2
70 + >=dev-ruby/actionpack-4.2.6:4.2
71 + >=dev-ruby/activerecord-4.2.6:4.2
72 + dev-ruby/bcrypt-ruby
73 + dev-ruby/bit-struct
74 + dev-ruby/builder:3
75 + dev-ruby/bundler
76 + dev-ruby/filesize
77 + dev-ruby/jsobfu:0.3.0
78 + dev-ruby/json:*
79 + dev-ruby/kissfft
80 + dev-ruby/metasm:1.0.2
81 + >=dev-ruby/metasploit_data_models-2.0.0
82 + dev-ruby/meterpreter_bins:0.0.22
83 + dev-ruby/metasploit-payloads:1.1.13
84 + dev-ruby/metasploit_payloads-mettle:0.0.6
85 + >=dev-ruby/metasploit-credential-2.0.0
86 + >=dev-ruby/metasploit-concern-2.0.0
87 + >=dev-ruby/metasploit-model-2.0.0
88 + dev-ruby/msgpack
89 + dev-ruby/net-ssh:*
90 + dev-ruby/nokogiri
91 + dev-ruby/octokit
92 + dev-ruby/openssl-ccm:1.2.1
93 + dev-ruby/patch_finder
94 + dev-ruby/recog:2.0.14
95 + dev-ruby/redcarpet
96 + =dev-ruby/rkelly-remix-0.0.6
97 + dev-ruby/rex-arch
98 + dev-ruby/rex-java
99 + dev-ruby/rex-ole
100 + dev-ruby/rex-powershell
101 + dev-ruby/rex-random_identifier
102 + dev-ruby/rex-registry
103 + dev-ruby/rex-struct2
104 + dev-ruby/rex-text
105 + dev-ruby/rex-zip
106 + dev-ruby/sqlite3
107 + >=dev-ruby/pg-0.11
108 + dev-ruby/packetfu:1.1.11
109 + >=dev-ruby/rubyzip-1.1
110 + dev-ruby/rb-readline-r7
111 + dev-ruby/robots
112 + dev-ruby/sshkey
113 + dev-ruby/tzinfo:*
114 + java? ( dev-ruby/rjb )
115 + oracle? ( dev-ruby/ruby-oci8 )
116 + pcap? ( dev-ruby/pcaprub:*
117 + dev-ruby/network_interface )
118 + development? ( dev-ruby/fivemat
119 + dev-ruby/pry
120 + dev-ruby/redcarpet
121 + dev-ruby/yard
122 + >=dev-ruby/rake-10.0.0
123 + >=dev-ruby/factory_girl-4.1.0 )"
124 + #lorcon doesn't support ruby21
125 + #lorcon? ( net-wireless/lorcon[ruby] )
126 +ruby_add_bdepend "${RUBY_COMMON_DEPEND}
127 + test? ( >=dev-ruby/factory_girl-4.1.0
128 + dev-ruby/fivemat
129 + dev-ruby/database_cleaner
130 + >=dev-ruby/rspec-2.12
131 + dev-ruby/shoulda-matchers
132 + dev-ruby/timecop
133 + >=dev-ruby/rake-10.0.0 )"
134 +ruby_add_rdepend "${RUBY_COMMON_DEPEND}"
135 +
136 +COMMON_DEPEND="dev-db/postgresql[server]
137 + >=app-crypt/johntheripper-1.7.9-r1[-minimal]
138 + net-analyzer/nmap"
139 +RDEPEND+=" ${COMMON_DEPEND}
140 + >=app-eselect/eselect-metasploit-0.16"
141 +
142 +RESTRICT="strip"
143 +
144 +QA_PREBUILT="
145 + usr/lib*/${PN}${SLOT}/data/templates/template_x86_linux.bin
146 + usr/lib*/${PN}${SLOT}/data/templates/template_armle_linux.bin
147 + usr/lib*/${PN}${SLOT}/data/templates/template_x86_solaris.bin
148 + usr/lib*/${PN}${SLOT}/data/templates/template_x64_linux.bin
149 + usr/lib*/${PN}${SLOT}/data/templates/template_x64_linux_dll.bin
150 + usr/lib*/${PN}${SLOT}/data/templates/template_x86_bsd.bin
151 + usr/lib*/${PN}${SLOT}/data/templates/template_x64_bsd.bin
152 + usr/lib*/${PN}${SLOT}/data/templates/template_mipsbe_linux.bin
153 + usr/lib*/${PN}${SLOT}/data/templates/template_mipsle_linux.bin
154 + usr/lib*/${PN}${SLOT}/data/meterpreter/msflinker_linux_x86.bin
155 + usr/lib*/${PN}${SLOT}/data/meterpreter/ext_server_sniffer.lso
156 + usr/lib*/${PN}${SLOT}/data/meterpreter/ext_server_networkpug.lso
157 + usr/lib*/${PN}${SLOT}/data/meterpreter/ext_server_stdapi.lso
158 + usr/lib*/${PN}${SLOT}/data/exploits/CVE-2013-2171.bin
159 + usr/lib*/${PN}${SLOT}/data/exploits/CVE-2014-3153.elf
160 + usr/lib*/${PN}${SLOT}/data/android/libs/x86/libndkstager.so
161 + usr/lib*/${PN}${SLOT}/data/android/libs/mips/libndkstager.so
162 + usr/lib*/${PN}${SLOT}/data/android/libs/armeabi/libndkstager.so
163 + "
164 +
165 +pkg_setup() {
166 + if use test; then
167 + su postgres -c "dropdb msf_test_database" #this is intentionally allowed to fail
168 + su postgres -c "createuser msf_test_user -d -S -R"
169 + if [ $? -ne 0 ]; then
170 + su postgres -c "dropuser msf_test_user" || die
171 + su postgres -c "createuser msf_test_user -d -S -R" || die
172 + fi
173 + su postgres -c "createdb --owner=msf_test_user msf_test_database" || die
174 + fi
175 + ruby-ng_pkg_setup
176 +}
177 +
178 +all_ruby_unpack() {
179 + if [[ ${PV} == "9999" ]] ; then
180 + git-r3_src_unpack
181 + else
182 + default_src_unpack
183 +# mv "${WORKDIR}"/all/msf3/* "${WORKDIR}"/all
184 +# rm -r msf3
185 + #msf_version=$(grep --color=never "CURRENT_VERSION =" ${S}/spec/lib/msf/core/framework_spec.rb)
186 + #msf_version=${msf_version#*=}
187 + fi
188 +}
189 +
190 +all_ruby_prepare() {
191 + # add psexec patch from pull request 2657 to allow custom exe templates from any files, bypassing most AVs
192 + #epatch "${FILESDIR}/agix_psexec_pull-2657.patch"
193 + epatch_user
194 +
195 + #remove random "cpuinfo" binaries which a only needed to detect which bundled john to run
196 + rm -r data/cpuinfo
197 +
198 + #remove random oudated collected garbage
199 + rm -r external
200 +
201 + #remove unneeded ruby bundler versioning files
202 + #Gemfile.lock contains the versions tested by the msf team but not the hard requirements
203 + #we regen this file in each_ruby_prepare
204 + rm Gemfile.lock
205 + #The Gemfile contains real known deps
206 + #add our dep on upstream rb-readline instead of bundled one
207 + #and then they broke it...
208 + #sed -i "/gem 'packetfu'/a #use upstream readline instead of bundled\ngem 'rb-readline'" Gemfile || die
209 + sed -i "/gem 'fivemat'/s/, '1.2.1'//" Gemfile || die
210 + #remove the bundled readline
211 + #https://github.com/rapid7/metasploit-framework/pull/3105
212 + #this PR was closed due to numerous changes to their local fork, almost entirely for non-linux
213 + #but now we have to go back to bundled readline because otherwise it's broken
214 + #rm lib/rbreadline.rb
215 + #now we edit the Gemfile based on use flags
216 + #even if we pass --without=blah bundler still calculates the deps and messes us up
217 + if ! use pcap; then
218 + sed -i -e "/^group :pcap do/,/^end$/d" Gemfile || die
219 + fi
220 + if ! use development; then
221 + sed -i -e "/^group :development do/,/^end$/d" Gemfile || die
222 + fi
223 + if ! use test; then
224 + sed -i -e "/^group :test/,/^end$/d" Gemfile || die
225 + fi
226 + if ! use test && ! use development; then
227 + sed -i -e "/^group :development/,/^end$/d" Gemfile || die
228 + fi
229 + #We don't need simplecov
230 + sed -i -e "/^group :coverage/,/^end$/d" Gemfile || die
231 + sed -i -e "s#require 'simplecov'##" spec/spec_helper.rb || die
232 +
233 + #we need to edit the gemspec too, since it tries to call git instead of anything sane
234 + #probably a better way to fix this... if I care at some point
235 + sed -i -e "/^ spec.files/,/^ }/d" metasploit-framework.gemspec || die
236 +
237 + #https://bugs.gentoo.org/show_bug.cgi?id=584522 no tzinfo-data by choice in gentoo
238 + sed -i '/tzinfo-data/d' metasploit-framework.gemspec
239 +
240 + #let's bogart msfupdate
241 + rm msfupdate
242 + echo "#!/bin/sh" > msfupdate
243 + echo "echo \"[*]\"" >> msfupdate
244 + echo "echo \"[*] Attempting to update the Metasploit Framework...\"" >> msfupdate
245 + echo "echo \"[*]\"" >> msfupdate
246 + echo "echo \"\"" >> msfupdate
247 + if [[ ${PV} == "9999" ]] ; then
248 + echo "if [ -x /usr/bin/smart-live-rebuild ]; then" >> msfupdate
249 + echo " smart-live-rebuild -f net-analyzer/metasploit" >> msfupdate
250 + echo "else" >> msfupdate
251 + echo " echo \"Please install app-portage/smart-live-rebuild for a better experience.\"" >> msfupdate
252 + echo "emerge --oneshot \"=${CATEGORY}/${PF}\"" >> msfupdate
253 + echo "fi" >> msfupdate
254 + else
255 + echo "echo \"Unable to update tagged version of metasploit.\"" >> msfupdate
256 + echo "echo \"If you want the latest please install and eselect the live version (metasploit9999)\"" >> msfupdate
257 + echo "echo \"emerge metasploit:9999 -vat && eselect metasploit set metasploit9999\"" >> msfupdate
258 + fi
259 + #this is set executable in src_install
260 +
261 + #install our database.yml file before tests are run
262 + cp "${FILESDIR}"/database.yml config/
263 +
264 +}
265 +
266 +each_ruby_prepare() {
267 + MSF_ROOT="." BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle install --local || die
268 + MSF_ROOT="." BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle check || die
269 +
270 + #force all metasploit executables to use desired ruby version
271 + #https://dev.metasploit.com/redmine/issues/8357
272 + for file in $(ls -1 msf*)
273 + do
274 + #poorly adapted from python.eclass
275 + 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"
276 + done
277 +}
278 +
279 +each_ruby_test() {
280 + #review dev-python/pymongo for ways to make the test compatible with FEATURES=network-sandbox
281 +
282 + #we bogart msfupdate so no point in trying to test it
283 + rm spec/msfupdate_spec.rb || die
284 + #we don't really want to be uploading to virustotal during the tests
285 + rm spec/tools/virustotal_spec.rb || die
286 +
287 + # https://dev.metasploit.com/redmine/issues/8425
288 + BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle exec rake db:create || die
289 + BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle exec rake db:migrate || die
290 +
291 + MSF_DATABASE_CONFIG=config/database.yml BUNDLE_GEMFILE=Gemfile ${RUBY} -S bundle exec rake || die
292 + su postgres -c "dropuser msf_test_user" || die "failed to cleanup msf_test-user"
293 +}
294 +
295 +each_ruby_install() {
296 + #Tests have already been run, we don't need this stuff
297 + rm -r spec || die
298 + rm -r test || die
299 + rm Gemfile.lock || die
300 +
301 + #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.
302 + # should be as simple as copying everything into the target...
303 + dodir /usr/$(get_libdir)/${PN}${SLOT}
304 + cp -R * "${ED}"/usr/$(get_libdir)/${PN}${SLOT} || die "Copy files failed"
305 + rm -Rf "${ED}"/usr/$(get_libdir)/${PN}${SLOT}/documentation "${ED}"/usr/$(get_libdir)/${PN}${SLOT}/README.md
306 + fowners -R root:0 /
307 +
308 +}
309 +
310 +all_ruby_install() {
311 + # do not remove LICENSE, bug #238137
312 + dodir /usr/share/doc/${PF}
313 + cp -R {documentation,README.md} "${ED}"/usr/share/doc/${PF} || die
314 + dosym /usr/share/doc/${PF}/documentation /usr/$(get_libdir)/${PN}${SLOT}/documentation
315 +
316 + fperms +x /usr/$(get_libdir)/${PN}${SLOT}/msfupdate
317 +
318 + #tell revdep-rebuild to ignore binaries meant for the target
319 + dodir /etc/revdep-rebuild
320 + cat <<-EOF > "${ED}"/etc/revdep-rebuild/99-metasploit${SLOT}
321 + #These dirs contain prebuilt binaries for running on the TARGET not the HOST
322 + SEARCH_DIRS_MASK="/usr/lib*/${PN}${SLOT}/data/meterpreter"
323 + SEARCH_DIRS_MASK="/usr/lib*/${PN}${SLOT}/data/exploits"
324 + EOF
325 +}
326 +
327 +pkg_postinst() {
328 + elog "Before use you should run 'env-update' and '. /etc/profile'"
329 + elog "otherwise you may be missing important environmental variables."
330 +
331 + elog "You need to prepare the database by running:"
332 + elog "emerge --config postgresql"
333 + elog "/etc/init.d/postgresql-<version> start"
334 + elog "emerge --config =metasploit-${PV}"
335 +
336 + "${EROOT}"/usr/bin/eselect metasploit set --use-old ${PN}${SLOT}
337 +
338 + einfo
339 + elog "Adjust /usr/lib/${PN}${SLOT}/config/database.yml if necessary"
340 +}
341 +
342 +pkg_config() {
343 + einfo "If the following fails, it is likely because you forgot to start/config postgresql first"
344 + su postgres -c "createuser msf_user -D -S -R"
345 + su postgres -c "createdb --owner=msf_user msf_database"
346 +}