initial version
authorSvenne Krap <svenne@krap.dk>
Sat, 30 Jun 2012 18:40:38 +0000 (20:40 +0200)
committerSvenne Krap <svenne@krap.dk>
Sat, 30 Jun 2012 18:40:38 +0000 (20:40 +0200)
LICENSE.txt [new file with mode: 0644]
README.txt [new file with mode: 0644]
mkpwd [new file with mode: 0755]
newmac [new file with mode: 0755]
save_firefox_urls.py [new file with mode: 0755]
securenote [new file with mode: 0755]

diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644 (file)
index 0000000..3cf006b
--- /dev/null
@@ -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 (file)
index 0000000..948733e
--- /dev/null
@@ -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 (executable)
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  <spec>")
+    print (" - spec = <num><type>")
+    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 (executable)
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 (executable)
index 0000000..82dcd1c
--- /dev/null
@@ -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 = "<unknown>";
+    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 (executable)
index 0000000..fbf440b
--- /dev/null
@@ -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 <notename>";
+    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