From 3d2493ddf3f5692893741eddf409457740911dae Mon Sep 17 00:00:00 2001 From: Svenne Krap Date: Sat, 30 Jun 2012 20:40:38 +0200 Subject: [PATCH] initial version --- LICENSE.txt | 15 ++++++ README.txt | 2 + mkpwd | 116 +++++++++++++++++++++++++++++++++++++++++++ newmac | 16 ++++++ save_firefox_urls.py | 58 ++++++++++++++++++++++ securenote | 36 ++++++++++++++ 6 files changed, 243 insertions(+) create mode 100644 LICENSE.txt create mode 100644 README.txt create mode 100755 mkpwd create mode 100755 newmac create mode 100755 save_firefox_urls.py create mode 100755 securenote diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..3cf006b --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,15 @@ +Copyright 2012, Svenne Krap +svenne@krap.dk + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..948733e --- /dev/null +++ b/README.txt @@ -0,0 +1,2 @@ +This git repository contains various small scripts and utilities done over the +years..... diff --git a/mkpwd b/mkpwd new file mode 100755 index 0000000..7161189 --- /dev/null +++ b/mkpwd @@ -0,0 +1,116 @@ +#!/usr/bin/python + +# Copyright 2012, Svenne Krap +# svenne@krap.dk +# +# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + +import sys +import random +from math import log +ok = True +strength = 0 +if len(sys.argv) != 2: ok = False + +if not ok: + print ("mkpasswd ") + print (" - spec = ") + print (" -num = length of password" ) + print (" -type = charset to use:") + print (" - c(ase) insensitive") + print (" - n(ormal) ") + print (" - e(xtended) charset") + print (" - i(nteger) charset") + print (" - example: mkpasswd 24e") + sys.exit() + +def ngetchar(): + global strength + strength = 60 + x = random.randint(0,59) + if x < 10: + return str(x) + elif x >= 10 and x < 35: + return chr(ord('a') + (x - 10)) + elif x >= 35 and x < 60: + return chr(ord('A') + (x - 35)) + else: + print ("ERR : " + str(x)) + return "!" + +def cgetchar(): + global strength + strength = 34 + x = random.randint(0,33) + if x < 10: + return str(x) + elif x >= 10 and x < 35: + return chr(ord('a') + (x - 10)) + else: + print ("ERR : " + str(x)) + return "!" + +def egetchar(): + global strength + strength = 95 + x = random.randint(0,94) + return chr(32 + x) + +def hgetchar(): + global strength + strength = 16 + x = random.randint(0,15) + if x < 10: + return str(x) + elif x >= 10 and x < 16: + return chr(ord('a') + (x -10) ) + else: + print ("ERR : " + str(x)) + return "!" + +def igetchar(): + global strength + strength = 10 + x = random.randint(0,9) + if x < 10: + return str(x) + else: + print ("ERR : " + str(x)) + return "!" + +generators = {} +generators["c"] = cgetchar +generators["n"] = ngetchar +generators["e"] = egetchar +generators["i"] = igetchar +generators["h"] = hgetchar + +if sys.argv[1]=="-": + mode = "14n" +elif sys.argv[1]==".": + mode = "14e" +elif sys.argv[1]=="!": + mode = "40e" +else: + mode = sys.argv[1] + +cs = mode[-1:] +if not cs in generators: + print ( "Error" + cs + " is a unknown generator") + sys.exit() + +len = mode[:-1] +if not len.isdigit(): + print( "Error" + len + " is not a number") + sys.exit() + +res = str() +for i in range(int(len)): + c = generators[cs]() + res += c + +strengthres = int(log(strength ** int(len)) / log(2)) +print ("Password id \"" + res + "\"\n\nStrength is estimated to " + str( strengthres ) + " bits.") diff --git a/newmac b/newmac new file mode 100755 index 0000000..aa567c4 --- /dev/null +++ b/newmac @@ -0,0 +1,16 @@ +#!/bin/bash + + +# Copyright 2012, Svenne Krap +# # svenne@krap.dk +# # +# # Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +# # +# # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + + +# this script generates valid mac-addresses (radomly) in the "locally administered" address-space +# see: http://en.wikipedia.org/wiki/Mac_address + +echo -n C0:FF:EE ; for i in `seq 1 3` ; do echo -n `echo ":$RANDOM$RANDOM" | cut -n -c -3` ;done; echo diff --git a/save_firefox_urls.py b/save_firefox_urls.py new file mode 100755 index 0000000..82dcd1c --- /dev/null +++ b/save_firefox_urls.py @@ -0,0 +1,58 @@ +#!/usr/bin/python3 + +# Copyright 2012, Svenne Krap +# svenne@krap.dk +# +# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +# This script enables you to save all tabs in a (single-window) firefox sessions to a text file + +import json +import os +import os.path +import sys +import time + +ts = time.strftime("%Y-%m-%d-%H:%M:%S") + +profile = "default" +basedir = os.environ['HOME'] + "/.mozilla/firefox/" +histdir = os.environ['HOME'] + "/mozhistory"; +if not os.path.exists(histdir): + os.mkdir(histdir) +outfile = histdir + "/" + profile + "-" + ts + +os.chdir(basedir) +files = os.listdir(".") + +thefile = None + +for fil in files: + if not fil.endswith("." + profile): continue + thefile = fil + +if thefile == None: + print("cant find profile") + sys.exit() + +data = open(thefile + "/sessionstore.js",'r').read() +j = json.loads(data) +fields = ["title","url"] +tabs = len(j['windows'][0]["tabs"]) +outfp = open(outfile,"w") + +for t in range(tabs): + try: + title = j['windows'][0]["tabs"][t]["entries"][0]["title"] + except: + title = ""; + try: + url = j['windows'][0]["tabs"][t]["entries"][0]["url"] + except: + continue + outfp.write( str(t) + " " + title + " " + url + "\n") + +outfp.close() +print ("Saved as " + outfile) diff --git a/securenote b/securenote new file mode 100755 index 0000000..fbf440b --- /dev/null +++ b/securenote @@ -0,0 +1,36 @@ +#!/bin/bash + +# Copyright 2012, Svenne Krap +# # svenne@krap.dk +# # +# # Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. +# # +# # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + + + + + +# This tool allows you to easily and safely to encrypt text for yourself +# PLEASE remember to change path, mymail, mykey below! +# +path=~/securenotes/ +mymail=svenne@krap.dk +mykey=0x9bef4442 +if [ $# -ne 1 ]; then + echo "securenote "; + exit; +fi +fn=$1.gpg +ffn=$path$fn +if [ ! -d $path ]; then + echo "cannot find path" + exit; +fi + +if [ -f $path$fn ]; then + echo "file exists"; + exit; +fi +/usr/bin/gpg -a -e -s -u $mykey -r $mykey >$ffn -- 2.36.1