aboutsummaryrefslogtreecommitdiffstats
path: root/jsaccess
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2013-06-18 22:18:24 +0200
committerLaurent Ghigonis <laurent@p1sec.com>2013-06-18 22:18:24 +0200
commitd34f168ab9e0f5a337f2153024312ba244da49c9 (patch)
tree5f3e7f4280335a6a5968ba0ba94cfb8774731e52 /jsaccess
parentjsaccess: select first file by default (diff)
downloadlaurent-tools-d34f168ab9e0f5a337f2153024312ba244da49c9.tar.xz
laurent-tools-d34f168ab9e0f5a337f2153024312ba244da49c9.zip
jsaccess: hability to store and not encrypt some files
Diffstat (limited to 'jsaccess')
-rw-r--r--jsaccess/README.txt3
-rw-r--r--jsaccess/jsa/jsa.js24
-rw-r--r--jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/caf3eefc85fc7c4ee06d38ea679318114b21d88d30
-rw-r--r--jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/index.txt4
-rwxr-xr-xjsaccess/jstore.sh31
5 files changed, 63 insertions, 29 deletions
diff --git a/jsaccess/README.txt b/jsaccess/README.txt
index 3d3cb52..d9c29c2 100644
--- a/jsaccess/README.txt
+++ b/jsaccess/README.txt
@@ -3,6 +3,9 @@ jsaccess - private web file sharing using client side crypto
Store files encrypted with symetric key (AES-256) and it will seemlessly be
decrypted in the user web-browser on download.
+Files list cannot be accessed without the correct passphrase.
+It's possible to store files but not encrypt them with jsaccess, for example
+for files already PGP encrypted.
No htaccess, https, or any server side configuration required, as it will just
serve static pre-encrypted files.
diff --git a/jsaccess/jsa/jsa.js b/jsaccess/jsa/jsa.js
index 8c0eb81..eb34204 100644
--- a/jsaccess/jsa/jsa.js
+++ b/jsaccess/jsa/jsa.js
@@ -113,7 +113,11 @@ function _showfiles(data, pass, hash) {
$.each(lines,
function( idx, obj ){
obj = obj.trim();
- var btn = $('<label><input type="radio" name="file" value="'+obj+'">'+obj+'</input></label><br/>');
+ var filename = obj.substring(0, obj.lastIndexOf(" "));
+ var crypt = obj.split(" ").pop();
+ if (crypt == '(nocrypt)')
+ filename += ' (n)';
+ var btn = $('<label><input type="radio" name="file" value="'+obj+'">'+filename+'</input></label><br/>');
btn.appendTo('#files');
});
$("input:radio[name=file]:first").attr('checked', true);
@@ -123,8 +127,10 @@ function _dl(file, pass) {
var RMD160 = new Hashes.RMD160;
var dirhash = RMD160.hex(pass);
- var path = 'store/' + dirhash + '/' + RMD160.hex(dirhash + file);
- _status("Downloading \""+file+"\" ...");
+ var crypt = file.split(" ").pop();
+ var filename = file.substring(0, file.lastIndexOf(" "));
+ var path = 'store/' + dirhash + '/' + RMD160.hex(dirhash + filename);
+ _status("Downloading \""+filename+"\" ...");
dlreq = $.ajax({
url: path,
@@ -132,8 +138,16 @@ function _dl(file, pass) {
xhr.overrideMimeType("application/base64");
},
success: function ( data ) {
- _status("Download complete, decrypting ...",
- function() { _decrypt(data, pass, file); });
+ switch (crypt) {
+ case '(base64+aes256)':
+ _status("Download complete, decrypting ...",
+ function() { _decrypt(data, pass, filename); });
+ break;
+ case '(nocrypt)':
+ _status("Download complete, saving ...");
+ _save(data, filename);
+ break;
+ }
},
error: function (xhr, opts, err) {
_status("Dowload failed (status="+xhr.status+")");
diff --git a/jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/caf3eefc85fc7c4ee06d38ea679318114b21d88d b/jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/caf3eefc85fc7c4ee06d38ea679318114b21d88d
index e736127..f7d0ab5 100644
--- a/jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/caf3eefc85fc7c4ee06d38ea679318114b21d88d
+++ b/jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/caf3eefc85fc7c4ee06d38ea679318114b21d88d
@@ -1,15 +1,15 @@
-U2FsdGVkX1+FvE/p8efuYcbdBiVHSB1NJ+SDRoDzjwrF4MoYvhzeec1VthznLPE6
-1a41mflJ5zv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+xfrEzOEjnXBJB2pAycdKwIu5bj4+A1L1Ue1HS1yWQEkmyy39Bx+kF+kuo
+kDKlWwW50rJ7pMn5qMJ1q21zqFz+RWncBGQ++aGA26GRiCVWgkKg1qfnW8bwppcH
+NEYs5+z9FQ9UvMaj0xWeMMTYDi/7b4FuxlBDHS/RoOXqebGA1bRNQuyTmyQMCXh7
+zkGD28Yu0wlf8y02ZEDU/HIWsZ6kUvCKrIYb9sQeuOn8Q+4VNFtyrZgvDDdYsXqJ
+1dHt+T29a0/ngJZDxEgkX+fWckZgXhhdpK9g6sP9rIHlN5/hfjTOl1TYcy7nmA1E
+NBwxHzB9jEeSLZMKVqokhK+AiFEh2lFTnnL/KJFTGqD7uwFIY0pMlAUK/ehU11O3
+qEUn7260sl9OQt7OXCVDCLqC9o1blfSboRTQRTMhALJYum5Hw2Qw0Nm4ot3K7DRR
+HP3gYYpecFr5/Xsi0bsMtEUJe+D36wx8kv2NE1Ez7Q5lCwsITDW8i0VENUKneGJP
+E9RqWZ1u4kcQC/jMQhyrRgfDLsnnqZJamm5xWC4YINhcZUNp5OvCIyUb5EwO2rjE
+VaTtvGBrJ8I5gWkHWJTJSyI4xIcfo2ZRDYhIG/NfKweZAbRaiIfjAgjZhEs6uTlR
+hPBtJH2Y8fUB9Dr4SATj8s15ECBke4VqYcjBnfWAngJTV9bkMrTDk6w3mwe4BwRQ
+xVBx/d4OplnE7kXbfxIa9g==
diff --git a/jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/index.txt b/jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/index.txt
index bfb1efb..c43e7ab 100644
--- a/jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/index.txt
+++ b/jsaccess/jsa/store/af022cd820fdad6cbcac8e15ac565c639a47dab0/index.txt
@@ -1,2 +1,2 @@
-U2FsdGVkX197wflbwP/s09qNGf0tb2Wtl0hgXLEZAkUH45d0fkwYZaONMAo8YauS
-WHu6vrUw1I5eXUx4cC1Pnw==
+U2FsdGVkX1+Kt0ICwMcy3hkq8z55z2I1qc1FJ8kM6V+ZN/1xBsmX8iIcMFmhNwFb
+br0WP++7VbGQo8R7qw4MWnvhIERToOUPlvs/VS9QKRM=
diff --git a/jsaccess/jstore.sh b/jsaccess/jstore.sh
index 4bb40df..72e9550 100755
--- a/jsaccess/jstore.sh
+++ b/jsaccess/jstore.sh
@@ -25,7 +25,8 @@ usage_exit() {
echo
echo "actions on local store for a given passphrase:"
echo " ls [store] # default action if no arguments"
- echo " add <file_to_share> [store] # default action if one argument"
+ echo " add <file> [store] # default action if one argument"
+ echo " add-nocrypt <file> [store]"
echo " rm <file_in_store> [store]"
echo " rmall [store]"
echo
@@ -126,14 +127,19 @@ __file_get_encname() {
_file_add() {
clear_path=$1
clear_name=$2
+ do_crypt=$3
__file_get_encname $clear_name
if [ ! -d $enc_path ]; then
mkdir -p $enc_path
touch $enc_path/index.html
echo "CREATED directory $enc_path (new passphrase)"
fi
- base64 -w0 $clear_path > $tmp ||clean_exit 2
- echo -n $pass |openssl enc -e -a -aes-256-cbc -in $tmp -out $enc_path/$enc_name -pass stdin ||clean_exit 2
+ if [ $do_crypt -eq 1 ]; then
+ base64 -w0 $clear_path > $tmp ||clean_exit 2
+ echo -n $pass |openssl enc -e -a -aes-256-cbc -in $tmp -out $enc_path/$enc_name -pass stdin ||clean_exit 2
+ else
+ cp $clear_path $enc_path/$enc_name
+ fi
echo "CREATED file $enc_path/$enc_name"
}
@@ -172,16 +178,22 @@ action_ls() {
action_add() {
clear_path=$1
+ do_crypt=$2
clear_name=`basename $clear_path`
_pass_read
_index_decrypt
if [ `egrep -c "^$clear_name$" $tmp` -ne 0 ]; then
- echo "File already encrypted with this passphrase"
+ echo "File already present with this passphrase"
clean_exit 1
fi
- _file_add $clear_path $clear_name
+ _file_add $clear_path $clear_name $do_crypt
_index_decrypt
- echo $clear_name >> $tmp
+ if [ $do_crypt -eq 0 ]; then
+ index_text="$clear_name (nocrypt)"
+ else
+ index_text="$clear_name (base64+aes256)"
+ fi
+ echo $index_text >> $tmp
_index_encrypt
}
@@ -273,7 +285,12 @@ ls)
add)
[ $# -ne 2 -a $# -ne 3 ] && usage_exit
_store_get $3
- action_add $2
+ action_add $2 1
+ ;;
+add-nocrypt)
+ [ $# -ne 2 -a $# -ne 3 ] && usage_exit
+ _store_get $3
+ action_add $2 0
;;
rm)
[ $# -ne 2 -a $# -ne 3 ] && usage_exit