Showing posts with label software. Show all posts
Showing posts with label software. Show all posts

Saturday, 28 September 2013

Sending encrypted (7z AES-256) files to/from your Dropbox

Protecting your important files that you still want to have easily accessible on Dropbox can be done in multiple ways. There are quite some services out there that offer encryption on top of the existing Dropbox service, but most of them require installing additional software, or have some kind of limitations while using them on multiple OS/devices.
However using an open source utility souch as 7-zip enables you to do it a bit more multi OS capable, for no financial fee at all. It does however require you to utilise a set of scripts, which can be used for sending (encrypting) files to Dropbox and decrypting them when you want to access their content.

The article here by Anil Avadhani, describes how to create a set of scripts to utilise the above premisis - sending/encrypting and receiving/decrypting files on your Dropbox. It is focused on Windows OS (windows 7 to be precise), but with little shell scripting knowledge you can do the same on many varieties of GNU/Linux or BSD* OSs, probably also on Macs (I am not an expert on the latter). There are also utillities available for Android (I use ZArchiver) and iPhone that enable you to open files encrypted in such manner, so even if you are trying to access them via your mobile device you should be still able to do it.

What I have done here is changed a little bit of the scripts by Anil Avadhani, since his implementation uses password stored in plaintext inside the script itself, which is not up to my liking.

So I have created two simple scripts, one in PowerShell and one (a lot simpler) in WScript. You can utilise them by simple changing Anil's scripts in the following manner.
Anils original scripts (.bat files) conaint the following lines:
REM Set default password for encryption
SET keyphrase=Enter_Your_Password_Here_Using_Alphabets_And_Digits_Only


just change that to (add REM in front of the SET keyphrase=... line):
REM Set default password for encryption
REM SET keyphrase=Enter_Your_Password_Here_Using_Alphabets_And_Digits_Only


and add the following lines after it (uncommend - remove REM in front of the code you would like to use - WSCript - if you lack PowerShell or leave as it is to use PowerShell):
REM If your computer does not have PowerShell installed or if your execution policy is too restrictive use
REM the following VBS script, (less secure)
REM Read vbs script output and store it into a variable
REM for /f "tokens=*" %%i in ('cscript //nologo %~dp0Read_Pass.vbs') do set keyphrase=%%i
REM for computers with PowerShell use the following line
for /f "tokens=*" %%i in ('powershell -ExecutionPolicy Bypass -File %~dp0Read_Pass.ps1') do set keyphrase=%%i


You will of course need to add the two files to the same directory you have created Anils .bat files in. In my case I just put everything on the Dropbox folder and that way I don't have to recreate scripts on each computer I use them on, I just have to add the shortcuts to them to the "Send to" menu. Anils blog discribes the method on how to do it on Vista/Windows 7. To find the Send To folder on windows 8 just paste the following command into the run dialog:
shell:sendto


Here are the actual code for the PowerShell part (just copy/paste-it into a new file with a .ps1 extension):
## BEGIN PowerShell SCRIPT HERE
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Enter Password"
$objForm.Size = New-Object System.Drawing.Size(280,150)  #the size in px of the window length, height
$objForm.StartPosition = "CenterScreen" #loads the window in the center of the screen

$MaskedTextBox1 = New-Object System.Windows.Forms.MaskedTextBox
$MaskedTextBox1.PasswordChar = '*'
$MaskedTextBox1.Top = 40
$MaskedTextBox1.Left = 20
$objForm.Controls.Add($MaskedTextBox1)

$MaskedTextBox2 = New-Object System.Windows.Forms.MaskedTextBox
$MaskedTextBox2.PasswordChar = '*'
$MaskedTextBox2.Top = 60
$MaskedTextBox2.Left = 20
$objForm.Controls.Add($MaskedTextBox2)

$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") 
{SubmitPWD}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") 
    {$objForm.Close()}})

$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(15,85)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({SubmitPWD})
$objForm.Controls.Add($OKButton)

$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(90,85)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)

$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(5,10) 
$objLabel.Size = New-Object System.Drawing.Size(250,30) 
$objLabel.Text = "Please enter the password into both fields and press OK to continue:"
$objForm.Controls.Add($objLabel)

$objForm.Topmost = $True

function SubmitPWD {
if ($MaskedTextBox1.Text -eq $MaskedTextBox2.Text)
{
Write-Host $MaskedTextBox1.Text
$objForm.Close()
} else {
$objLabel.Font = New-Object System.Drawing.Font("Verdana",10)
$objLabel.BackColor = [System.Drawing.Color]::Red
$objLabel.Text = "Password entry mismatch, please reenter passwords:"
$MaskedTextBox1.Text = ""
$MaskedTextBox2.Text = ""
$OKButton.Text = "Retry"
$MaskedTextBox1.Focus()
}
}

$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
## END PowerShell SCRIPT HERE

and for the WScript it is a bit simpler, just a couple of lines:
''' BEGIN WScript SCRIPT HERE
' Read_Pass.vbs
' Read password (input string) and echo it to console
' Sadly does not have any kind of text hashing without using external dll files
' you can improve it by using dll from: http://www.westmesatech.com/passdlg/
UserInput = InputBox( "Please enter the password (alphanumeric only): ", "Send to/from 7z AES/Dropbox PWD" )
WScript.Echo UserInput
''' END WScript SCRIPT HERE

And that should be it. If you find it usefull drop me a note. Big thanks to mr. Anil Avadhani for thinking of it and writing the instructions for the whole process in the first place.

Have fun...

Sunday, 11 March 2012

Compiling custom module from external patch in Ubuntu 11.10 (asm58 sensors patch)


The result of the following commands is that you gain a copy of the default ubuntu kernel packages, with just your patch added (one module and one help file).

  • Install the required packages (linux sources and required programs/files to build the new kernel package).
  • Install the dependencies required for building the kernel
$ apt-get build-dep linux kernel-wedge fakeroot makedumpfile
  • Install the kernel source code
$ apt-get install linux-source
  • Extract the current ubuntu kernel source (into an allready prepared directories - by linux-source package)
$ cd /usr/src/
$ tar -xjf linux-source-x.y.z.tar.bz2
$ cd linux-source-x.y.z
$ wget http://n.neonatus.net/files/asm58-linux-3.0.0.patch
patch -p1 <asm58-linux-3.0.0.patch
  • My builds always failed with the error of not being able to touch a certain file so for that reason I create a directory beforehand so that the build goes through without an error
$ mkdir debian/stamps
  • Prepare to build the source
$ fakeroot debian/rules clean
  • Build the kernel packages
$  AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binary-generic-pae
You could also use binary - to build binary packages for all flavours - or select your flavour according to your hardware - they are listed in the debian.master/config/$ARCH/ directory.
  • If you are lucky enough to have multiple cores or processors utilize them during build add "DEB_BUILD_OPTIONS=parallel=2" variable in front of the command where 2 is the number of cores/processors you have available to the OS like this:
$ DEB_BUILD_OPTIONS=parallel=2 AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binary-generic-pae
During the build the kernel configure script will ask you to define the following:
 Asus Mozart-2 (SENSORS_ASM58) [N/m/y/?] (NEW)
Enter the letter m and press enter, which signifies to build the object as module so you can load/unload it at need. 

Now we wait... and wait... (hope you have a fast computer, or you'll) wait some more...
When the compiling finishes you will be left with a couple of new *.deb packages in your /usr/src directory, which you can install with dpkg command.
$ dpkg -i ../linux-headers-3.0.0-16-generic-pae_3.0.0-16.29_i386.deb
$ dpkg -i ../linux-image-3.0.0-16-generic-pae_3.0.0-16.29_i386.deb
Reboot and (if not allready selected) select the new kernel in the grub boot menu.
Log into the newly booted system and verify if all is fine by loading the asm58 module:

$ modprobe asm58
and verify that it is loaded ok:
$ lsmod |grep asm58
asm58                  13122  0
Now you can use the functionality of the newly compiled module by configuring lm-sensors - run sensors-detect and afterwards verify that the command sensors returns values from the sensor.


Good luck, and write a comment if you need help ;)

#Links:

Monday, 22 December 2008

Sony Ericsson W910i and its "special" ways

Yes, special... (as in special needs).


After fiddling around with many (many, many, ...) options of how to make Album Art work in visualization options, I have figured out it supports ID3 v2.3 (and v2.4 but is faulty - read on) tags that can have embedded pictures in them. It supports only image/jpeg type files. After twiddling for quite some time I converted all the tags to version 2.4.0 and UTF-8 encoded them - BIG MISTAKE, the player displays all the artists, albums and song names incorrectly than. The names seem to be split in 2 or more characters - GO SE ;). So I had to convert them all back.




Here is the final coctail of Id3 tags, that does work and display all fields ok:
  • ID3 version 2.3.0
  • Picture field with image/jpeg type
  • ISO-8859-1 (latin-1) encoding
I use Kid3-qt tag editor for most jobs with tagging my audio files.

Another glitch I noticed was that the device did not correctly disconnect when umounting the phone (as a storage device) from the PC. I use Ubuntu as my desktop and what I needed to do was to use eject (or a variation of it) to get proper disconnect - so this is the concoction I brewed to make it work properly:
in ~/.gnome2/nautilus-scripts/ create a file called Eject with the following contents:

MNTPNT=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" |tr -d '\n')
gnome-eject --pseudonym "$MNTPNT"

When right clicking on the device icon on your desktop (the storage device that displays either the internal or the storage card of your W910i phone), navigate to Scripts->Eject, now the device should be ejected correctly and the phone will display the message that the storage session is finished.

Well hopefully someone else will stumble upon this post instead of wasting a weekend arranging their music files and discovering the tags have all gone beserk...

PS: The same procedure should work on older/other SE W(alkman) model phones/players.

Tuesday, 18 November 2008

Ubuntu, VirtualBox and suspend

Hey, I know, long time no write, well, long time no time left...

and allways running around requires me to suspend my laptop a lot, mainly when suspending it with VirtualBox running. Well after resuming the suspend VirtualBox froze most of the times. Killing the program and restarting it did not work, removing the module was impossible, so the only fix was the reboot. Well until smarter thought came ofcourse.

Create an pm script (in Ubuntu go to /etc/pm/sleep.d/) create a newfile named 90virtualbox with the following contents:


#!/bin/sh

USR_RNNG=$(ps aux |grep VirtualBox |grep -v grep |cut -f1 -d' ')
if [ "x$USR_RNNG" != "x" ]; then
if [ $(id -u) -eq 0 ]; then
su $USR_RNNG -c $0
else
for VMS in $(VBoxManage list runningvms |egrep "^[0-9]"); do
VBoxManage controlvm $VMS savestate
done
fi
fi
exit 0

Dont forget to make the script executable (chmod +x 90virtualbox).

Well that works for me, now before doing ACPI suspend the virtualbox machines are suspended nicely and afterwards you have to start them again, but they are up in a heartbeat (well 5 seconds in my case).

You can do that either by running VirtualBox gui and starting them or running:
VBoxManage start UUID|name_of_virtual_machine

Happy virtualizing...

Sunday, 29 June 2008

Depth of Field calculator for your mobile (s60)

I had some time on my hands and tried to spend it usefully (learning Python while actually doing something useful). So I wrote Depth of Field calculator that runs on Python enabled Symbian phones.
Ok so the usefulness part is so so, it is only useful if you are interested in photography and actually try to calculate the DoF instead of just going for it. While most of the time I just go for it, there are times when I can't really tell by the picture on the screen how much of it is actually sharp and where does the blur begin.

Here is what the result looks like on the phone screen:



The files are available here.

And if you want additional information on Depth of Field and formulas used in my prog look here.

If you like it - drop me a note - leave a post on the blog. If you want more/new/different features - please don't hesitate to ask - I'm sure there is more to it than just what I did.

PS: the code is my first try of actually doing some Symbian stuff in Python so please keep the comments objective ;)