Merge pull request #4 from rwinkhart/ext-manager

Merge ext-manager into main
This commit is contained in:
Randall Winkhart
2023-07-06 13:27:55 -04:00
committed by GitHub
15 changed files with 24 additions and 389 deletions
+9 -12
View File
@@ -1,20 +1,17 @@
# sshyp-labs
Experimental extensions for the sshyp password manager.
Extensions for the [sshyp password manager](https://github.com/rwinkhart/sshyp).
sshyp-labs is currently the home of sshyp-mfa and password-pasture (sshyp-gui).
When new functionality is desired that goes outside of sshyp's primary goals or requires venturing outside of the Python standard library, said functionality is implemented as an extension.
# Installation
For sshyp v1.5.0+, sshyp extensions should be installed from the `sshyp tweak` menu's "extension management" option.
**Do NOT use the packages from the releases page! These are only for older, unsupported releases of sshyp!**
# Available Extensions
sshyp-mfa - [installation and usage instructions](https://github.com/rwinkhart/sshyp-labs/wiki/sshyp-mfa)
[sshyp-mfa](https://github.com/rwinkhart/sshyp-labs/wiki/sshyp-mfa): read mfa data from sshyp entries to generate and copy totp keys to the clipboard (optional Steam support)
sshyp-mfa is a unique approach to generating multi-factor authentication keys. Upon running `sshyp </entry name> copy -m`,
an MFA key will be generated and copied to your clipboard. sshyp-mfa will continue to run in the background and copy a
new key to your clipboard every time the actively copied one expires. Never worry about a TOTP timer expiring again!
At any time, sshyp-mfa can be closed with ctrl+c to stop this process.
password-pasture - [installation and usage instructions](https://github.com/rwinkhart/sshyp-labs/wiki/password-pasture)
password-pasture is an incredibly experimental GTK4 GUI interface for sshyp. It is currently not in a usable state
and has not been updated since sshyp v1.1.X. Development is set to resume after sshyp is more feature-complete.
[password-pasture](https://github.com/rwinkhart/sshyp-labs/wiki/password-pasture): a HIGHLY experimental GTK4 sshyp GUI - very incomplete (last updated for sshyp v1.1.x)
# Acknowledgements
sshyp-mfa relies on [ValvePython/steam](https://github.com/ValvePython/steam) for Steam support.
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/sh
git add -f extra password-pasture sshyp-mfa LICENSE README.md version commit.sh .gitignore
git add -f LICENSE README.md commit.sh extensions extra pointers .gitignore
git commit -m "$1"
git push
+3
View File
@@ -0,0 +1,3 @@
[config]
input = copy -m
output = /usr/lib/sshyp/sshyp-mfa
@@ -68,8 +68,12 @@ if __name__ == '__main__':
if copied is None:
copied = 1
if mfa_data[0] == 'steam':
from steam.guard import generate_twofactor_code as steam_totp
_mfa_key = steam_totp(b32decode(mfa_data[1]))
try:
from steam.guard import generate_twofactor_code as steam_totp
_mfa_key = steam_totp(b32decode(mfa_data[1]))
except ModuleNotFoundError:
print('\n\u001b[38;5;9merror: steam module not found\n\ninstall with "pip install -U \'steam[client]\'"\u001b[0m\n')
s_exit(6)
else:
_mfa_key = totp(mfa_data[1], mfa_data[2], mfa_data[3], mfa_data[4])
if 'WSL_DISTRO_NAME' in environ: # WSL clipboard detection
+5
View File
@@ -0,0 +1,5 @@
[sshyp-mfa]
desc = read mfa data from sshyp entries to generate and copy totp keys to the clipboard (optional Steam support)
usage = sshyp /<entry name> copy -m
exe = https://raw.githubusercontent.com/rwinkhart/sshyp-labs/ext-manager/extensions/sshyp-mfa/sshyp-mfa.py
ini = https://raw.githubusercontent.com/rwinkhart/sshyp-labs/ext-manager/extensions/sshyp-mfa/sshyp-mfa.ini
-44
View File
@@ -1,44 +0,0 @@
.TH sshyp-mfa 1 "04 March 2023" "v1.4.0.1" "sshyp-mfa man page"
.SH NAME
sshyp-mfa \- An MFA (TOTP/Steam) key generator for the sshyp password manager.
.SH SYNOPSIS
Extension Usage: sshyp </entry name> copy -m
Direct Usage: sshyp-mfa </entry name>
.SH DESCRIPTION
sshyp-mfa is an extension for the sshyp password manager that reads MFA data from sshyp entries and generates generic TOTP and Steam keys.
.SH EXAMPLES
Generating and copying an MFA key for an existing entry saved as ~/.local/share/sshyp-mfa/development/github.gpg
sshyp /development/github copy -m
sshyp-mfa /development/github
.SH SETUP
sshyp-mfa requires a pre-existing functional sshyp setup.
MFA keys are generated off of MFA data placed in the second line of a sshyp entry's notes field. This data needs to be added manually, through sshyp, and must be in Authenticator backup format.
It might be easiest to import all of your MFA keys into Authenticator, export them into plain text, then add all of the exported MFA data into the second notes line in their respective sshyp entries.
.SH FORMAT
Format: otpauth://<OTP METHOD>/<ACCOUNT NAME, NOT USED>?secret=<SECRET>&issuer=<ISSUER, NOT USED>&algorithm=<ALGORITHM>&digits=<DIGITS>&period=<REFRESH PERIOD>
Help! What do I put in each of those spaces?
<OTP METHOD> is almost always 'totp', but in the case of Steam, it needs to be set to 'steam'.
<ACCOUNT NAME, NOT USED> is a part of the Authenticator backup format, but it is not used in sshyp-mfa. Set to anything.
<SECRET> refers to the secret used to generate your MFA key. This is usually directly provided by the issuer, but it is sometimes hidden and more easily retrieved by copying it from a QR-compatible MFA app (such as Aegis).
<ISSUER, NOT USED> is a part of the Authenticator backup format, but it is not used in sshyp-mfa. Set to anything.
<ALGORITHM> refers to the algorithm used to generate your MFA key based on your secret. This is almost always 'sha1'.
<DIGITS> refers to the intended length of your MFA key. This is almost always '6', but in the case of Steam, it needs to be set to '5'.
<REFRESH PERIOD> refers to the interval at which a new MFA key needs to be generated. This is almost always '30', for 30 seconds.
Example configuration (for most services, see above for differences regarding Steam):
otpauth://totp/MyNameIsBob?secret=YUGBSG65SG9SDBSDF56SBFVSC86SBVD6&issuer=Github&algorithm=sha1&digits=6&period=30
.SH AUTHOR
Randall Winkhart (https://github.com/rwinkhart)
-3
View File
@@ -1,3 +0,0 @@
[config]
input = copy -m
output = sshyp-mfa
-311
View File
@@ -1,311 +0,0 @@
#!/bin/sh
version=$(sed -n '1{p;q}' ../version)
if [ -z "$2" ]; then
revision=1
else
revision="$2"
fi
_create_generic() {
printf '\npackaging as generic...\n'
mkdir -p output/generictemp/usr/bin \
output/generictemp/usr/lib/sshyp \
output/generictemp/usr/share/man/man1
cp -r lib/. output/generictemp/usr/lib/sshyp/
ln -s /usr/lib/sshyp/sshyp-mfa.py output/generictemp/usr/bin/sshyp-mfa
cp -r share output/generictemp/usr/
cp extra/manpage output/generictemp/usr/share/man/man1/sshyp-mfa.1
gzip output/generictemp/usr/share/man/man1/sshyp-mfa.1
XZ_OPT=-e6 tar -C output/generictemp -cvJf output/GENERIC-sshyp-mfa-"$version".tar.xz usr/
rm -rf output/generictemp
sha512="$(sha512sum output/GENERIC-sshyp-mfa-"$version".tar.xz | awk '{print $1;}')"
printf '\ngeneric packaging complete\n\n'
} &&
_create_pkgbuild() {
printf '\ngenerating PKGBUILD...\n'
if [ "$1" = 'Deb' ]; then
local source='https://github.com/rwinkhart/sshyp-labs/releases/download/v"$pkgver"/UBUNTU-sshyp-mfa_"$pkgver"-"$pkgrel"_all.deb'
local decomp_target='data.tar.xz'
else
local source='https://github.com/rwinkhart/sshyp-labs/releases/download/v"$pkgver"/GENERIC-sshyp-mfa-"$pkgver".tar.xz'
local decomp_target='GENERIC-sshyp-"$pkgver".tar.xz'
fi
printf "# Maintainer: Randall Winkhart <idgr at tutanota dot com>
pkgname=sshyp-mfa
pkgver="$version"
pkgrel="$revision"
pkgdesc='An MFA (TOTP/Steam) key generator for the sshyp password manager'
url='https://github.com/rwinkhart/sshyp-labs'
arch=('any')
license=('GPL-3.0-only')
depends=(sshyp)
source=(\""$source"\")
sha512sums=('"$sha512"')
package() {
tar -xf $decomp_target -C "\"\${pkgdir}\""
}
" > output/PKGBUILD
printf '\nPKGBUILD generated\n\n'
} &&
_create_apkbuild() {
printf '\ngenerating APKBUILD...\n'
if [ "$1" = 'Deb' ]; then
local source="https://github.com/rwinkhart/sshyp-labs/releases/download/v\"\$pkgver\"/UBUNTU-sshyp-mfa_\"\$pkgver\"-"$revision"_all.deb"
local sumsname="UBUNTU-sshyp-mfa_\"\$pkgver\"-"$revision"_all.deb"
local processing='mkdir -p "$pkgdir"
7z x "$srcdir"/* -o"$srcdir"
tar -xf "$srcdir"/data.tar -C "$pkgdir"
else
local source='https://github.com/rwinkhart/sshyp-labs/releases/download/v"$pkgver"/GENERIC-sshyp-mfa-"$pkgver".tar.xz'
local sumsname='GENERIC-sshyp-"$pkgver".tar.xz'
local processing='mkdir -p "$pkgdir"
cp -r "$srcdir/usr/" "$pkgdir"'
fi
printf "# Maintainer: Randall Winkhart <idgr@tutanota.com>
pkgname=sshyp-mfa
pkgver="$version"
pkgrel="$((revision-1))"
pkgdesc='An MFA (TOTP/Steam) key generator for the sshyp password manager'
options=!check
url='https://github.com/rwinkhart/sshyp-labs'
arch='noarch'
license='GPL-3.0-only'
depends='sshyp'
source=\""$source"\"
package() {
$processing
}
sha512sums=\"
"$sha512" "$sumsname"
\"
" > output/APKBUILD
printf '\nAPKBUILD generated\n\n'
} &&
_create_hpkg() {
printf '\npackaging for Haiku...\n'
mkdir -p output/haikutemp/bin \
output/haikutemp/lib/sshyp \
output/haikutemp/documentation/man/man1 \
output/haikutemp/documentation/packages/sshyp-mfa
printf "name sshypmfa
version "$version"-"$revision"
architecture any
summary \"An MFA (TOTP/Steam) key generator for the sshyp password manager\"
description \"sshyp-mfa is an extension for the sshyp password manager that reads MFA data from sshyp entries and generates generic TOTP and Steam keys.\"
packager \"Randall Winkhart <idgr at tutanota dot com>\"
vendor \"Randall Winkhart\"
licenses {
\"GNU GPL v3\"
}
copyrights {
\"2021-2023 Randall Winkhart\"
}
provides {
sshypmfa = "$version"
cmd:sshypmfa
}
requires {
sshyp
}
urls {
\"https://github.com/rwinkhart/sshyp-labs\"
}
" > output/haikutemp/.PackageInfo
cp -r lib/. output/haikutemp/lib/sshyp/
sed -i '1 s/.*/#!\/bin\/env\ python3.10/' output/haikutemp/lib/sshyp/sshyp-mfa.py
ln -s /system/lib/sshyp/sshyp-mfa.py output/haikutemp/bin/sshyp-mfa
cp -r share/licenses/sshyp-mfa/. output/haikutemp/documentation/packages/sshyp-mfa/
cp extra/manpage output/haikutemp/documentation/man/man1/sshyp-mfa.1
gzip output/haikutemp/documentation/man/man1/sshyp-mfa.1
cd output/haikutemp
package create -b HAIKU-sshyp-mfa-"$version"-"$revision"_all.hpkg
package add HAIKU-sshyp-mfa-"$version"-"$revision"_all.hpkg bin lib documentation
cd ../..
mv output/haikutemp/HAIKU-sshyp-mfa-"$version"-"$revision"_all.hpkg output/
rm -rf output/haikutemp
printf "\nHaiku packaging complete\n\n"
} &&
_create_deb() {
printf '\npackaging for Debian/Ubuntu...\n'
mkdir -p output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/DEBIAN \
output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/usr/lib/sshyp \
output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/usr/bin \
output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/usr/share/man/man1
printf "Package: sshyp-mfa
Version: $version
Section: utils
Architecture: all
Maintainer: Randall Winkhart <idgr at tutanota dot com>
Description: An MFA (TOTP/Steam) key generator for the sshyp password manager
Depends: sshyp
Priority: optional
Installed-Size: 100
" > output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/DEBIAN/control
cp -r lib/. output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/usr/lib/sshyp/
ln -s /usr/lib/sshyp/sshyp-mfa.py output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/usr/bin/sshyp-mfa
cp -r share output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/usr/
cp extra/manpage output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/usr/share/man/man1/sshyp-mfa.1
gzip output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/usr/share/man/man1/sshyp-mfa.1
dpkg-deb --build --root-owner-group -z6 -Sextreme -Zxz output/debiantemp/sshyp-mfa_"$version"-"$revision"_all/
mv output/debiantemp/sshyp-mfa_"$version"-"$revision"_all.deb output/UBUNTU-sshyp_"$version"-"$revision"_all.deb
rm -rf output/debiantemp
sha512="$(sha512sum output/UBUNTU-sshyp-mfa_"$version"-"$revision"_all.deb | awk '{print $1;}')"
printf '\nDebian/Ubuntu packaging complete\n\n'
} &&
_create_termux() {
printf '\npackaging for Termux...\n'
mkdir -p output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/DEBIAN \
output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/lib/sshyp \
output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/bin \
output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/man/man1
printf "Package: sshyp-mfa
Version: $version
Section: utils
Architecture: all
Maintainer: Randall Winkhart <idgr at tutanota dot com>
Description: An MFA (TOTP/Steam) key generator for the sshyp password manager
Depends: sshyp
Priority: optional
Installed-Size: 100
" > output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/DEBIAN/control
cp -r lib/. output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/lib/sshyp/
ln -s /data/data/com.termux/files/usr/lib/sshyp/sshyp-mfa.py output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/bin/sshyp-mfa
cp -r share output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/
cp extra/manpage output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/man/man1/sshyp-mfa.1
gzip output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/data/data/com.termux/files/usr/share/man/man1/sshyp-mfa.1
dpkg-deb --build --root-owner-group output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux/
mv output/termuxtemp/sshyp-mfa_"$version"-"$revision"_all_termux.deb output/TERMUX-sshyp_"$version"-"$revision"_all.deb
rm -rf output/termuxtemp
printf '\nTermux packaging complete\n\n'
} &&
_create_rpm() {
printf '\npackaging for Fedora...\n'
rm -rf ~/rpmbuild
rpmdev-setuptree
mkdir -p output/fedoratemp/usr/bin \
output/fedoratemp/usr/lib/sshyp/extensions \
mkdir -p output/fedoratemp/usr/bin \
output/fedoratemp/usr/lib/sshyp \
output/fedoratemp/usr/share/man/man1
printf "Name: sshyp-mfa
Version: "$version"
Release: "$revision"
Summary: An MFA (TOTP/Steam) key generator for the sshyp password manager
BuildArch: noarch
License: GPL-3.0-only
URL: https://github.com/rwinkhart/sshyp-labs
Source0: GENERIC-FEDORA-sshyp-mfa-"$version".tar.xz
Requires: sshyp
%%description
sshyp-mfa is an extension for the sshyp password manager that reads MFA data from sshyp entries and generates generic TOTP and Steam keys.
%%install
tar xf %%{_sourcedir}/GENERIC-FEDORA-sshyp-mfa-"$version".tar.xz -C %%{_sourcedir}
cp -r %%{_sourcedir}/usr %%{buildroot}
%%files
/usr/bin/sshyp-mfa
/usr/lib/sshyp/sshyp-mfa.py
/usr/lib/sshyp/extensions/sshyp-mfa
%%license /usr/share/licenses/sshyp-mfa/license
%%doc /usr/share/man/man1/sshyp-mfa.1.gz
" > ~/rpmbuild/SPECS/sshyp-mfa.spec
ln -s /usr/lib/sshyp/sshyp-mfa.py output/fedoratemp/usr/bin/sshyp-mfa
cp -r share output/fedoratemp/usr/
cp extra/manpage output/fedoratemp/usr/share/man/man1/sshyp-mfa.1
gzip output/fedoratemp/usr/share/man/man1/sshyp-mfa.1
XZ_OPT=-e6 tar -C output/fedoratemp -cvJf output/GENERIC-FEDORA-sshyp-mfa-"$version".tar.xz usr/
rm -rf output/fedoratemp
cp output/GENERIC-FEDORA-sshyp-mfa-"$version".tar.xz ~/rpmbuild/SOURCES
rpmbuild -bb ~/rpmbuild/SPECS/sshyp-mfa.spec
mv ~/rpmbuild/RPMS/noarch/sshyp-mfa-"$version"-"$revision".noarch.rpm output/FEDORA-sshyp-mfa-"$version"-"$revision".noarch.rpm
rm -rf ~/rpmbuild
printf '\nFedora packaging complete\n\n'
} &&
_create_freebsd_pkg() {
printf '\npackaging for FreeBSD...\n'
mkdir -p output/freebsdtemp/usr/lib/sshyp \
output/freebsdtemp/usr/bin \
output/freebsdtemp/usr/share/man/man1
printf "name: sshyp-mfa
version: \""$version"\"
abi = \"FreeBSD:13:*\";
arch = \"freebsd:13:*\";
origin: security/sshyp-mfa
comment: \"a sshyp extension\"
desc: \"an MFA (TOTP/Steam) key generator for the sshyp password manager\"
maintainer: <idgr at tutanota dot com>
www: https://github.com/rwinkhart/sshyp-labs
prefix: /
\"deps\" : {
\"sshyp\" : {
\"origin\" : \"security/sshyp\"
},
},
" > output/freebsdtemp/+MANIFEST
printf "/usr/bin/sshyp-mfa
/usr/lib/sshyp/sshyp-mfa.py
/usr/lib/sshyp/extensions/sshyp-mfa
/usr/share/licenses/sshyp-mfa/license
/usr/share/man/man1/sshyp-mfa.1.gz
" > output/freebsdtemp/plist
cp -r lib/. output/freebsdtemp/usr/lib/sshyp/
ln -s /usr/lib/sshyp/sshyp-mfa.py output/freebsdtemp/usr/bin/sshyp-mfa
cp -r share output/freebsdtemp/usr/
cp extra/manpage output/freebsdtemp/usr/share/man/man1/sshyp-mfa.1
gzip output/freebsdtemp/usr/share/man/man1/sshyp-mfa.1
pkg create -m output/freebsdtemp/ -r output/freebsdtemp/ -p output/freebsdtemp/plist -o output/
mv output/sshyp-mfa-"$version".pkg output/FREEBSD-sshyp-mfa-"$version"-"$revision".pkg
rm -rf output/freebsdtemp
printf '\nFreeBSD packaging complete\n\n'
} &&
case "$1" in
pkgbuild)
_create_deb
_create_pkgbuild Deb
;;
apkbuild)
_create_deb
_create_apkbuild Deb
;;
haiku)
_create_hpkg
;;
debian)
_create_deb
;;
termux)
_create_termux
;;
fedora)
_create_rpm
;;
freebsd)
_create_freebsd_pkg
;;
buildable-arch)
_create_deb
_create_pkgbuild Deb
_create_apkbuild Deb
case "$(pacman -Q freebsd-pkg)" in
freebsd-pkg*)
_create_freebsd_pkg
;;
esac
;;
*)
printf '\nusage: package.sh [target] <revision>\n\ntargets:\n mainline: pkgbuild apkbuild fedora debian haiku freebsd\n experimental: termux\n groups: buildable-arch\n\n'
;;
esac
-1
View File
@@ -1 +0,0 @@
steam[client]
@@ -1,14 +0,0 @@
sshyp-mfa is a FOSS extension for the sshyp password manager.
Copyright (C) 2022-2023 Randall Winkhart idgr@tutanota.com
This program is free software: you can redistribute it and/or modify
it under the terms of version 3 (only) of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-1
View File
@@ -1 +0,0 @@
1.4.0.1