mirror of
https://github.com/pentoo/pentoo-overlay
synced 2026-05-04 18:40:19 +02:00
eselect-metasploit: minor fix for after version removal
This commit is contained in:
parent
edeb4269a7
commit
9d729594e9
3 changed files with 245 additions and 0 deletions
|
|
@ -1,2 +1,4 @@
|
|||
AUX metasploit.eselect-0.9 5151 SHA256 4aefdeff8b266c1340466c6802334857e3842548340bb5903aa8757a211d3fb6 SHA512 592cb69435cf622a3d81851d9bb81030f4e76e8a595eea5fea53c0b4e76cfdd75eb6cbe7258acca8bb60f8f56a6579d865af6f386973a63f59c3841c344612ac WHIRLPOOL ef645ffd938141785465408b24f60b0883bb2dcf4b4864e6317e56d3abdc627c815f33d25d60f63c288440b61c6fdda5f4144dd1d60ab4d65d5ed821668617ef
|
||||
AUX metasploit.eselect-0.9-r1 5436 SHA256 53bcbc39711a8a49f5d36785612f42cd418f3b6d28c32ec8b32917fa87c4c07f SHA512 769f7ac62b4b22948fe3f0c2446426f2084c77ea8d03e587460443f3b7c508bd8e3b62f9fa385fa7196ae3a603586bb3d96e39af41ae54946e7ff6ed2442dc11 WHIRLPOOL a953f48d5c39706b88518a2dceebc2a089ef8d8a0f759ed71e7ef351c32905d313c31e2313bd9ff1c5fe412d7536842b0fea3a81e14dc6bb04a57507b79e7a7a
|
||||
EBUILD eselect-metasploit-0.9-r1.ebuild 653 SHA256 19a059e2264067f2bd2b94d82d287731e5ee07958cde0d4e4965a29280d1db47 SHA512 a2a0a542b98a87d52cf349dbad2365c9aac0db975cab07d74ee2297ca6574c0a09e78b4afec53fe0f977cdfcedc180c89afb4dc3a01d7d7a2297385a31a1a70b WHIRLPOOL a311675f4ccf90f0f03aa70783bbba49d402c77bfb31ca335ef266ee689408734620ce344eb817480ab48cec25ad5bcc3591a07d9ba8f16101b8082220e1fef3
|
||||
EBUILD eselect-metasploit-0.9.ebuild 650 SHA256 410adea739a778c037d5d91172d623d315808f62d31b72f2cfa62b98c39fa7cc SHA512 fbb0d87cc71a0c81334b900d2c2450f7c1408a70e19df744c414b8f2ebb57eb3eb74c53d4cfd6b390fe64e3e2b278151b6ef87dc826c17e8608edf9d0e356bd7 WHIRLPOOL c80c81113e0b926d865807df248e8034e2fd87d7c8ec5203b054e6866982664eee18e73dd1e4dbdb64711e320edce75cf9e687e80580ffe95a93974f2c780d64
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright 1999-2012 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
EAPI=4
|
||||
|
||||
DESCRIPTION="eselect module for metasploit"
|
||||
HOMEPAGE="http://www.pentoo.ch/"
|
||||
SRC_URI=""
|
||||
|
||||
LICENSE="GPL-2"
|
||||
SLOT="0"
|
||||
KEYWORDS="~amd64 ~arm ~x86"
|
||||
IUSE=""
|
||||
|
||||
DEPEND="app-admin/eselect"
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
S=${WORKDIR}
|
||||
|
||||
src_install() {
|
||||
insinto /usr/share/eselect/modules
|
||||
newins "${FILESDIR}/metasploit.eselect-${PV}-r1" metasploit.eselect
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
elog "To switch between installed slots, execute as root:"
|
||||
elog " # eselect metasploit set [slot number]"
|
||||
}
|
||||
214
app-admin/eselect-metasploit/files/metasploit.eselect-0.9-r1
Normal file
214
app-admin/eselect-metasploit/files/metasploit.eselect-0.9-r1
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
# -*-eselect-*- vim: ft=eselect
|
||||
# Copyright 2005-2011 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2 or later
|
||||
# $
|
||||
|
||||
DESCRIPTION="Control which metaploit version is active"
|
||||
MAINTAINER="zerochaos@pentoo.ch"
|
||||
SVN_DATE='$Date: 2011-09-25 15:27:36 +0200 (Sun, 25 Sep 2011) $'
|
||||
VERSION=$(svn_date_to_version "${SVN_DATE}")
|
||||
|
||||
###WARNING: don't even think of using this insanity for a reference (but it works)
|
||||
#base idea from kernel.eselect, get_libdir from php.eselect with --use-old from opencl.eselect
|
||||
#all modified randomly until it worked, entropy is wonderful
|
||||
###/WARNING
|
||||
|
||||
inherit multilib
|
||||
|
||||
get_libdir() {
|
||||
local dir
|
||||
if has lib64 $(list_libdirs); then
|
||||
echo lib64
|
||||
return
|
||||
fi
|
||||
echo lib
|
||||
}
|
||||
|
||||
MSFPATH="/usr/$(get_libdir)/metasploit"
|
||||
|
||||
# find a list of metasploit symlink targets and sort them
|
||||
find_targets() {
|
||||
local f
|
||||
for f in "${EROOT}${MSFPATH}"[[:digit:]]*; do
|
||||
[[ -d ${f} ]] && basename "${f}"
|
||||
done | LC_ALL=C sort
|
||||
}
|
||||
|
||||
# remove the metasploit symlink
|
||||
remove_symlink() {
|
||||
for i in $(qlist metasploit | grep $(canonicalise "${EROOT}${MSFPATH}")/msf)
|
||||
do
|
||||
unlink /usr/bin/$(echo ${i} | awk -F'/' '{print $5}')
|
||||
done
|
||||
if [ -L ${EROOT}${MSFPATH} ]; then
|
||||
unlink "${EROOT}${MSFPATH}" || die -q "failed to unlink ${EROOT}${MSFPATH}"
|
||||
elif [ -e ${EROOT}${MSFPATH} ]; then
|
||||
die -q "${EROOT}${MSFPATH} exists but is not a symlink"
|
||||
fi
|
||||
if [ -L /usr/bin/armitage ]; then
|
||||
unlink /usr/bin/armitage || die -q "failed to unlink /usr/bin/armitage"
|
||||
elif [ -e /usr/bin/armitage ]; then
|
||||
die -q "/usr/bin/armitage exists but is not a symlink"
|
||||
fi
|
||||
}
|
||||
|
||||
# set the metasploit symlink
|
||||
set_symlink() {
|
||||
local target=$1
|
||||
|
||||
if is_number "${target}"; then
|
||||
local targets=( $(find_targets) )
|
||||
target=${targets[target-1]}
|
||||
fi
|
||||
|
||||
if [[ -z ${target} ]]; then
|
||||
die -q "Target \"$1\" doesn't appear to be valid!"
|
||||
elif [[ -d ${EROOT}/usr/$(get_libdir)/${target} ]]; then
|
||||
ln -s "${target}" "${EROOT}${MSFPATH}"
|
||||
for i in $(qlist metasploit | grep /usr/$(get_libdir)/${target}/msf)
|
||||
do
|
||||
ln -s ${i} /usr/bin/$(echo ${i} | awk -F'/' '{print $5}')
|
||||
done
|
||||
if [ -e /usr/$(get_libdir)/${target}/armitage ]; then
|
||||
ln -s /usr/$(get_libdir)/${target}/armitage /usr/bin/armitage
|
||||
fi
|
||||
elif [[ -d ${EROOT}${MSFPATH}${target} ]]; then
|
||||
ln -s "metasploit${target}" "${EROOT}${MSFPATH}"
|
||||
for i in $(qlist metasploit | grep /usr/$(get_libdir)/${target}/msf)
|
||||
do
|
||||
ln -s ${i} /usr/bin/$(echo ${i} | awk -F'/' '{print $5}')
|
||||
done
|
||||
if [ -e /usr/$(get_libdir)/${target}/armitage ]; then
|
||||
ln -s /usr/$(get_libdir)/${target}/armitage /usr/bin/armitage
|
||||
fi
|
||||
else
|
||||
die -q "Target \"$1\" doesn't appear to be valid!"
|
||||
fi
|
||||
}
|
||||
|
||||
# wrapper to safely set the symlink
|
||||
set_symlink_safe() {
|
||||
if [[ -L ${EROOT}${MSFPATH} ]]; then
|
||||
# existing symlink
|
||||
remove_symlink || die -q "Couldn't remove existing symlink"
|
||||
set_symlink "$1" || die -q "Couldn't set a new symlink"
|
||||
elif [[ -e ${EROOT}${MSFPATH} ]]; then
|
||||
# we have something strange
|
||||
die -q "${EROOT}${MSFPATH} exists but is not a symlink"
|
||||
else
|
||||
set_symlink "$1" || die -q "Couldn't set a new symlink"
|
||||
fi
|
||||
}
|
||||
|
||||
### show action ###
|
||||
|
||||
describe_show() {
|
||||
echo "Show the current metasploit symlink"
|
||||
}
|
||||
|
||||
do_show() {
|
||||
write_list_start "Current metasploit symlink:"
|
||||
if [[ -L ${EROOT}${MSFPATH} ]]; then
|
||||
local metasploit=$(canonicalise "${EROOT}${MSFPATH}")
|
||||
write_kv_list_entry "${metasploit%/}" ""
|
||||
else
|
||||
write_kv_list_entry "(unset)" ""
|
||||
fi
|
||||
}
|
||||
|
||||
### list action ###
|
||||
|
||||
describe_list() {
|
||||
echo "List available metasploit symlink targets"
|
||||
}
|
||||
|
||||
do_list() {
|
||||
local i targets=( $(find_targets) )
|
||||
|
||||
write_list_start "Available metasploit symlink targets:"
|
||||
for (( i = 0; i < ${#targets[@]}; i++ )); do
|
||||
[[ ${targets[i]} = \
|
||||
$(basename "$(canonicalise "${EROOT}${MSFPATH}")") ]] \
|
||||
&& targets[i]=$(highlight_marker "${targets[i]}")
|
||||
done
|
||||
write_numbered_list -m "(none found)" "${targets[@]}"
|
||||
}
|
||||
|
||||
### set action ###
|
||||
|
||||
describe_set() {
|
||||
echo "Set a new metasploit symlink target"
|
||||
}
|
||||
|
||||
describe_set_parameters() {
|
||||
echo "<target>"
|
||||
}
|
||||
|
||||
describe_set_options() {
|
||||
echo "<target> : Target name or number (from 'list' action)"
|
||||
echo "--use-old : If an implementation is already set, use that one instead"
|
||||
}
|
||||
|
||||
do_set() {
|
||||
local action="error"
|
||||
local current=$(basename "$(canonicalise "${EROOT}${MSFPATH}")")
|
||||
local available=( $(find_targets) )
|
||||
local new
|
||||
local opt
|
||||
|
||||
while [[ ${#@} -gt 0 ]] ; do
|
||||
opt=$1
|
||||
shift
|
||||
case ${opt} in
|
||||
--use-old)
|
||||
if [[ -n "${current}" ]] && has "${current}" "${available[@]}"; then
|
||||
action="old-implementation"
|
||||
fi
|
||||
;;
|
||||
metasploit*)
|
||||
if [[ "${action}" != "old-implementation" ]] ; then
|
||||
action="set-implementation"
|
||||
fi
|
||||
|
||||
if has ${opt} ${available[@]}; then
|
||||
new="${opt}"
|
||||
else
|
||||
echo "You need to emerge ${opt} before you try to eselect it"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ "${action}" != "old-implementation" ]] ; then
|
||||
action="set-implementation"
|
||||
fi
|
||||
|
||||
if is_number ${opt} ; then
|
||||
#targets=( $(get_implementations) )
|
||||
new=${available[opt - 1]}
|
||||
if [[ -z ${new} ]] ; then
|
||||
die -q "Unrecognized option: ${opt}"
|
||||
fi
|
||||
else
|
||||
die -q "Unrecognized option: ${opt}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case ${action} in
|
||||
old-implementation)
|
||||
set_symlink_safe ${current}
|
||||
return $?
|
||||
;;
|
||||
set-implementation)
|
||||
if [[ -n ${new} ]] ; then
|
||||
set_symlink_safe ${new}
|
||||
return $?
|
||||
else
|
||||
die -q "Please specify an implementation to set"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
die -q "Invalid usage of set action."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
Loading…
Reference in a new issue