Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-eselect/eselect-metasploit/files: metasploit.eselect-0.13 msfrpcd.initd 91metasploit msfrpcd.confd msfloader-0.16
Date: Tue, 31 Mar 2015 16:51:21
Message-Id: 20150331165115.788DC14EDE@oystercatcher.gentoo.org
1 ulm 15/03/31 16:51:15
2
3 Added: metasploit.eselect-0.13 msfrpcd.initd 91metasploit
4 msfrpcd.confd msfloader-0.16
5 Log:
6 Move package from app-admin to app-eselect category.
7
8 (Portage version: 2.2.18/cvs/Linux x86_64, RepoMan options: --force, signed Manifest commit with key 9433907D693FB5B8!)
9
10 Revision Changes Path
11 1.1 app-eselect/eselect-metasploit/files/metasploit.eselect-0.13
12
13 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/metasploit.eselect-0.13?rev=1.1&view=markup
14 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/metasploit.eselect-0.13?rev=1.1&content-type=text/plain
15
16 Index: metasploit.eselect-0.13
17 ===================================================================
18 # -*-eselect-*- vim: ft=eselect
19 # Copyright 2005-2015 Gentoo Foundation
20 # Distributed under the terms of the GNU General Public License v2 or later
21 # $
22
23 DESCRIPTION="Control which metaploit version is active"
24 MAINTAINER="zerochaos@××××××.ch"
25
26 ###WARNING: don't even think of using this insanity for a reference (but it works,mostly)
27 #base idea from kernel.eselect, get_libdir from php.eselect with --use-old from opencl.eselect
28 #all modified randomly until it worked, entropy is wonderful
29 ###/WARNING
30
31 inherit multilib
32
33 get_libdir() {
34 local dir
35 if has lib64 $(list_libdirs); then
36 echo lib64
37 return
38 fi
39 echo lib
40 }
41
42 MSFPATH="/usr/$(get_libdir)/metasploit"
43
44 # find a list of metasploit symlink targets and sort them
45 find_targets() {
46 local f
47 for f in "${EROOT}${MSFPATH}"[[:digit:]]*; do
48 [[ -d ${f} ]] && basename "${f}"
49 done | LC_ALL=C sort
50 }
51
52 # remove the metasploit symlink
53 remove_symlink() {
54 for i in $(qlist metasploit | grep $(canonicalise "${EROOT}${MSFPATH}")/msf)
55 do
56 if [ -L /usr/bin/$(echo ${i} | awk -F'/' '{print $5}') ]; then
57 unlink /usr/bin/$(echo ${i} | awk -F'/' '{print $5}') || die -q "failed to unlink ${i}"
58 fi
59 done
60 if [ -L ${EROOT}${MSFPATH} ]; then
61 unlink "${EROOT}${MSFPATH}" || die -q "failed to unlink ${EROOT}${MSFPATH}"
62 elif [ -e ${EROOT}${MSFPATH} ]; then
63 die -q "${EROOT}${MSFPATH} exists but is not a symlink"
64 fi
65 }
66
67 # set the metasploit symlink
68 set_symlink() {
69 local target=$1
70
71 if is_number "${target}"; then
72 local targets=( $(find_targets) )
73 target=${targets[target-1]}
74 fi
75
76 if [[ -z ${target} ]]; then
77 die -q "Target \"$1\" doesn't appear to be valid!"
78 elif [[ -d ${EROOT}/usr/$(get_libdir)/${target} ]]; then
79 ln -s "${target}" "${EROOT}${MSFPATH}"
80 for i in $(qlist metasploit | grep /usr/$(get_libdir)/${target}/msf)
81 do
82 ln -s /usr/bin/msfloader /usr/bin/$(echo ${i} | awk -F'/' '{print $5}')
83 done
84 #this elif looks like it is trying to support setting by slot only,
85 #but that isn't supported by the rest of the script... fix or remove?
86 elif [[ -d ${EROOT}${MSFPATH}${target} ]]; then
87 ln -s "metasploit${target}" "${EROOT}${MSFPATH}"
88 for i in $(qlist metasploit | grep /usr/$(get_libdir)/${target}/msf)
89 do
90 ln -s /usr/bin/msfloader /usr/bin/$(echo ${i} | awk -F'/' '{print $5}')
91 done
92 else
93 die -q "Target \"$1\" doesn't appear to be valid!"
94 fi
95 }
96
97 # wrapper to safely set the symlink
98 set_symlink_safe() {
99 if [[ -L ${EROOT}${MSFPATH} ]]; then
100 # existing symlink
101 remove_symlink || die -q "Couldn't remove existing symlink"
102 set_symlink "$1" || die -q "Couldn't set a new symlink"
103 #um, why is there an env-update here?
104 env-update
105 elif [[ -e ${EROOT}${MSFPATH} ]]; then
106 # we have something strange
107 die -q "${EROOT}${MSFPATH} exists but is not a symlink"
108 else
109 set_symlink "$1" || die -q "Couldn't set a new symlink"
110 fi
111 }
112
113 ### show action ###
114
115 describe_show() {
116 echo "Show the current metasploit symlink"
117 }
118
119 do_show() {
120 write_list_start "Current metasploit symlink:"
121 if [[ -L ${EROOT}${MSFPATH} ]]; then
122 local metasploit=$(canonicalise "${EROOT}${MSFPATH}")
123 write_kv_list_entry "${metasploit%/}" ""
124 else
125 write_kv_list_entry "(unset)" ""
126 fi
127 }
128
129 ### list action ###
130
131 describe_list() {
132 echo "List available metasploit symlink targets"
133 }
134
135 do_list() {
136 local i targets=( $(find_targets) )
137
138 write_list_start "Available metasploit symlink targets:"
139 for (( i = 0; i < ${#targets[@]}; i++ )); do
140 [[ ${targets[i]} = \
141 $(basename "$(canonicalise "${EROOT}${MSFPATH}")") ]] \
142 && targets[i]=$(highlight_marker "${targets[i]}")
143 done
144 write_numbered_list -m "(none found)" "${targets[@]}"
145 }
146
147 ### set action ###
148
149 describe_set() {
150 echo "Set a new metasploit symlink target"
151 }
152
153 describe_set_parameters() {
154 echo "<target>"
155 }
156
157 describe_set_options() {
158 echo "<target> : Target name or number (from 'list' action)"
159 echo "--use-old : If an implementation is already set, use that one instead"
160 }
161
162 do_set() {
163 local action="error"
164 local current=$(basename "$(canonicalise "${EROOT}${MSFPATH}")")
165 local available=( $(find_targets) )
166 local new
167 local opt
168
169 while [[ ${#@} -gt 0 ]] ; do
170 opt=$1
171 shift
172 case ${opt} in
173 --use-old)
174 if [[ -n "${current}" ]] && has "${current}" "${available[@]}"; then
175 action="old-implementation"
176 fi
177 ;;
178 metasploit*)
179 if [[ "${action}" != "old-implementation" ]] ; then
180 action="set-implementation"
181 fi
182
183 if has ${opt} ${available[@]}; then
184 new="${opt}"
185 else
186 echo "You need to emerge ${opt} before you try to eselect it"
187 fi
188 ;;
189 *)
190 if [[ "${action}" != "old-implementation" ]] ; then
191 action="set-implementation"
192 fi
193
194 if is_number ${opt} ; then
195 #targets=( $(get_implementations) )
196 new=${available[opt - 1]}
197 if [[ -z ${new} ]] ; then
198 die -q "Unrecognized option: ${opt}"
199 fi
200 else
201 die -q "Unrecognized option: ${opt}"
202 fi
203 ;;
204 esac
205 done
206
207 case ${action} in
208 old-implementation)
209 set_symlink_safe ${current}
210 return $?
211 ;;
212 set-implementation)
213 if [[ -n ${new} ]] ; then
214 set_symlink_safe ${new}
215 return $?
216 else
217 die -q "Please specify an implementation to set"
218 fi
219 ;;
220 *)
221 die -q "Invalid usage of set action."
222 ;;
223 esac
224 }
225
226
227
228 1.1 app-eselect/eselect-metasploit/files/msfrpcd.initd
229
230 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/msfrpcd.initd?rev=1.1&view=markup
231 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/msfrpcd.initd?rev=1.1&content-type=text/plain
232
233 Index: msfrpcd.initd
234 ===================================================================
235 #!/sbin/runscript
236 # Copyright 1999-2015 Gentoo Foundation
237 # Distributed under the terms of the GNU General Public License v2
238 # $Header: /var/cvsroot/gentoo-x86/app-eselect/eselect-metasploit/files/msfrpcd.initd,v 1.1 2015/03/31 16:51:15 ulm Exp $
239
240 VERSION=
241 PIDFILE=/var/run/msfrpcd${VERSION}.pid
242
243 start() {
244 ebegin "Starting msfrpcd"
245 start-stop-daemon --start --quiet --background \
246 --exec /usr/bin/msfrpcd \
247 --pidfile ${PIDFILE} \
248 --make-pidfile -- -f ${MSF_OPTS}
249 eend $?
250 }
251
252 stop() {
253 ebegin "Stopping msfrpcd"
254 start-stop-daemon --stop --quiet -s 9 --pidfile ${PIDFILE}
255 eend $?
256 }
257
258
259
260 1.1 app-eselect/eselect-metasploit/files/91metasploit
261
262 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/91metasploit?rev=1.1&view=markup
263 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/91metasploit?rev=1.1&content-type=text/plain
264
265 Index: 91metasploit
266 ===================================================================
267 MSF_DATABASE_CONFIG=/usr/lib/metasploit/config/database.yml
268
269 # needed because MSF ships an old version of metasm
270 # which isn't compatible with the new one
271 MSF_LOCAL_LIB="/usr/lib/metasploit/lib/metasm"
272
273 # needed because MSF doesn't know where it is since the alzheimer's
274 MSF_ROOT=/usr/lib/metasploit
275
276
277
278 1.1 app-eselect/eselect-metasploit/files/msfrpcd.confd
279
280 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/msfrpcd.confd?rev=1.1&view=markup
281 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/msfrpcd.confd?rev=1.1&content-type=text/plain
282
283 Index: msfrpcd.confd
284 ===================================================================
285 # Config file for /etc/init.d/metasploit
286
287 # Bind to the following IP instead of the loopback address
288 IPADDR=127.0.0.1
289
290 # Bind to the following TCP port instead of default 55555
291 PORT=55553
292
293 # Use the following username instead of msf
294 USER="msf"
295
296 # Use the following password instead of msf
297 PASS="secure"
298
299 # All options
300 MSF_OPTS="-U $USER -P $PASS -S -a $IPADDR -p $PORT"
301
302
303
304 1.1 app-eselect/eselect-metasploit/files/msfloader-0.16
305
306 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/msfloader-0.16?rev=1.1&view=markup
307 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-metasploit/files/msfloader-0.16?rev=1.1&content-type=text/plain
308
309 Index: msfloader-0.16
310 ===================================================================
311 #!/bin/sh
312
313 #todo:
314 #add in optional auto starting/stopping of postgres
315
316 #read the desired version of ruby from the eselected version of msf
317 header="$(head -n1 /usr/lib/metasploit/msfconsole)"
318 ruby="${header:2}"
319
320 #normally msf makes this dir, however, this script runs first
321 if [ ! -d ~/.msf4 ]; then
322 mkdir ~/.msf4
323 fi
324
325 #we cannot control if msf* exits normally so always start with cleanup
326 if [ -f ~/.msf4/Gemfile ]; then
327 rm ~/.msf4/Gemfile
328 fi
329 if ls -A ~/.msf4/*.gemspec > /dev/zero 2>&1; then
330 rm ~/.msf4/*.gemspec
331 fi
332
333 #fetch the latest Gemfile and gemspecsfrom the selected version of msf
334 cp /usr/lib/metasploit/Gemfile ~/.msf4/
335 if ls -A /usr/lib/metasploit/*.gemspec > /dev/zero 2>&1; then
336 cp /usr/lib/metasploit/*.gemspec ~/.msf4/
337 fi
338
339 #ensure Gemfile.lock is up to date
340 BUNDLE_GEMFILE=~/.msf4/Gemfile ${ruby} -S bundle check > /dev/null 2>&1
341 if [ "$?" != "0" ]; then
342 if [ -f ~/.msf4/Gemfile.lock ]; then
343 rm ~/.msf4/Gemfile.lock
344 else
345 echo "Something went wrong, please open a bug for metasploit on https://bugs.gentoo.org"
346 fi
347 fi
348
349 #ready to go
350 BUNDLE_GEMFILE=~/.msf4/Gemfile ${ruby} -S bundle exec /usr/lib/metasploit/$(basename $0) "$@"
351 #profit