All Projects → unrelentingtech → pysectools

unrelentingtech / pysectools

Licence: Unlicense license
A small Python library that contains various security things

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pysectools

Xo
Command line utility that composes regular expression matches.
Stars: ✭ 184 (+1214.29%)
Mutual labels:  unix
Fcat
A 3x faster implementation of cat, using splice
Stars: ✭ 196 (+1300%)
Mutual labels:  unix
Ventoy
A new bootable USB solution.
Stars: ✭ 29,413 (+209992.86%)
Mutual labels:  unix
Ctf Tools
Useful CTF Tools
Stars: ✭ 190 (+1257.14%)
Mutual labels:  unix
Frosted
Frosted: Free POSIX OS for tiny embedded devices
Stars: ✭ 194 (+1285.71%)
Mutual labels:  unix
Survey
A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
Stars: ✭ 2,843 (+20207.14%)
Mutual labels:  unix
Azpainter
Full color painting software for Unix-like systems for illustration drawing. This is un-official little fixed repository for package maintainers of image editor AzPainter (based on "mlib" toolkit). Official repository - http://azsky2.html.xdomain.jp/arc/download.html
Stars: ✭ 179 (+1178.57%)
Mutual labels:  unix
The Art Of Command Line
Master the command line, in one page
Stars: ✭ 100,482 (+717628.57%)
Mutual labels:  unix
Twf
Standalone tree view file explorer, inspired by fzf.
Stars: ✭ 196 (+1300%)
Mutual labels:  unix
Geo
🌎 A Bash utility for easy wan, lan, router, dns, mac address, and geolocation output, with clean stdout for piping
Stars: ✭ 225 (+1507.14%)
Mutual labels:  unix
Botany
command line virtual plant buddy
Stars: ✭ 192 (+1271.43%)
Mutual labels:  unix
Aaru
Aaru Data Preservation Suite
Stars: ✭ 193 (+1278.57%)
Mutual labels:  unix
Gammy
Adaptive screen brightness/temperature for Windows, Linux, FreeBSD
Stars: ✭ 220 (+1471.43%)
Mutual labels:  unix
Emacs History
Historical Emacs Software Preservation
Stars: ✭ 184 (+1214.29%)
Mutual labels:  unix
Cproc
C11 compiler (mirror)
Stars: ✭ 238 (+1600%)
Mutual labels:  unix
Build Your Own Shell
Guidance for mollusks (WIP)
Stars: ✭ 181 (+1192.86%)
Mutual labels:  unix
Dotfiles
My lovely dotfiles. Chocolate and unicorns.
Stars: ✭ 199 (+1321.43%)
Mutual labels:  unix
dot-elvish
My configuration files for elvish - mirrored from GitLab
Stars: ✭ 43 (+207.14%)
Mutual labels:  unix
Lightdm Webkit2 Theme Glorious
A sleek, modern and glorified LightDM webkit2 theme
Stars: ✭ 236 (+1585.71%)
Mutual labels:  unix
Xv6 Book Chinese
MIT操作系统工程的教学操作系统Xv6的源码剖析中文翻译项目,使用ANSI标准C重新在riscv架构上实现Unix v6;
Stars: ✭ 223 (+1492.86%)
Mutual labels:  unix

on PyPI Unlicense

pysectools

A small Python library that contains various security things.

Usage

import pysectools

Prevent secrets from leaking out of your process's memory:

pysectools.disallow_swap()
pysectools.disallow_core_dumps()

Drop privileges:

pysectools.drop_privileges('username', 'groupname')

Securely erase a secret from memory (only on CPython):

password = 'correct horse battery staple'
pysectools.zero(password)
# password == '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
# \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Enter a Capsicum sandbox (works out of the box on FreeBSD 10.0 and newer):

b = open('before.txt', 'w')
pysectools.cap_enter()
b.write('hello from the sandbox!') # ok
open('after.txt', 'w').write('new file!') # IOError: [Errno 94] Not permitted in capability mode: 'after.txt'

Get a password safely using pinentry (usually comes with GnuPG) or getpass if there's no pinentry:

from pysectools.pinentry import Pinentry
pinentry = Pinentry(pinentry_path="/usr/local/bin/pinentry",
                    fallback_to_getpass=True)
# all parameters are optional
pass = pinentry.ask(prompt="Enter your passphrase: ",
                    description="Launching the nuclear rocket",
                    validator=lambda x: x.startswith("correct horse"))
pinentry.close()
rocket.authorize(pass)
pysectools.zero(pass)
rocket.launch()

Generate a cryptographically secure pseudorandom byte string (tries /dev/urandom/CryptGenRandom then libcrypto (LibreSSL) arc4random then libc arc4random):

pysectools.goodrandom(32) # size in bytes
# check the return value! it's False if there's something wrong

Resources

License

This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].