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