Wednesday 18 September 2013

Be your own cloud provider and kick out Google Calendar, Dropbox and co. - Part 1 Calendar

Hey there,

I want to make a little experiment to get as much data in my own cloud and not using services like Google Calendar or iCloud. Especially because of all the things regarding Edward Snowden disclosed confirmed all our paranoid thoughts about a big brother scenario and total surveillance and I want to try to be the master of my data as much as possible now. And of course I'm curious what can be done with services like OwnCloud.

What I want is to be my own cloud provider by using my own root-server and all my devices (laptop, smartphone and tablet) can use this server to sync their data. Actually I've used such cloud services like Google Calendar or Dropbox, but never trusted those services and I always felt uncomfortable and thats why I  didn't use cloud services e.g. for syncing my contacts. I've always synced my contacts directly via my laptop to my other devices.

My goal is to get as much data on my own server so it's under my control and not stored on some server or on a server somewhere in the US that will be monitored by some agency. Of course this server will be the single point of failure, and if it get's hacked all my data will be disclosed or compromised, but hey, at least I'm responsible now for my data.

First thing I've done is installing OwnCloud on my Debian server, see the link here for further installation instructions. Afterwards you can navigate to your web server by adding /owncloud to your URL, e.g. https://www.dummy.org/owncloud for further configuration.

I wanted to use the MySQL service as database for OwnCloud, as it is already running on my server:

1. Connect to MySQL and create a database for OwnCloud:
root@kali # mysql -u root -p
mysql> create database owncloud;

2. Create a user for the new database owncloud and grant all privileges to him
mysql> GRANT ALL PRIVILEGES
    -> ON owncloud.*
    -> TO 'owncloudUser'@'localhost'
    -> IDENTIFIED BY '<your password here>'
    -> WITH GRANT OPTION;
3. Now you can go again to https://www.dummy.org/owncloud and type in the name of the database you want to use for OwnCloud and the user and password for it. Also an administrator user will be created for the web interface.
Afterwards you can finish the installation and your OwnCloud is ready. You should also use SSL for your OwnCloud, so that your communication channel is encrypted. If you don't use SSL now and you don't want to spend money for an SSL certificate you should consider to create a server certificate at CAcert. Don't forget to import the root Certificate of CAcert into your browser and devices that want to use OwnCloud, so you have a trusted connection to your server.

So what can you do now by using OwnCloud? After logging into your OwnCloud you have the opportunity to share a calendar, contacts, data, pictures and music.

I just wanted to use the calendar service for now. To synchronize the calendar with your iOS device, just follow the manual at owncloud.org. You can also synchronize it with iCal on OS X and also with Lightning in Thunderbird. In Lightning you need the CalDav link that points directly to your calendar. You can find that link in OwnCloud 5 if you navigate to calendar, click on the settings symbol in the right corner and click on the little earth symbol in the row of your calendar. Then the CalDav link will appear. In Lightning you just need to create a new calendar, choose network, select CalDav as format and paste the URL in the address field. Then you just need to fill in the credentials in the login dialog that will pop-up and you have also the OwnCloud calendar in Thunderbird Lightning.

You can also sync the calendar with Android devices, but you need a 3rd party app like Card-Dav Sync. As I've got no Android device, I could not test it, so if there are better apps or if it is supported by the OS by now, feel free to leave a comment.

For me this setup is working fine now. I'm using it on OS X in iCal, on my iPhone, iPad and also another Windows Laptop has access to the calendar via Thunderbird Lightning and all via SSL. First step is done to get your own secure datastore.

For backup purposes here is a little hint what you want to backup on another machine to restore your data in OwnCloud, if the server crashes.

Cheers.

Sunday 15 September 2013

Raspberry Pi and Nano USB WiFi (EDIMAX EW-7811Un) on Kali Linux

Hey there,

yesterday my order arrived. An Wireless USB Adapter for my Raspberry Pi. Right after plugging it into the Pi and booting it up, it was found:
root@kali:~# dmesg
...
usb 1-1.2: new high-speed USB device number 4 using dwc_otg
usb 1-1.2: New USB device found, idVendor=7392, idProduct=7811
usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.2: Product: 802.11n WLAN Adapter
usb 1-1.2: Manufacturer: Realtek
usb 1-1.2: SerialNumber: 00e04c000001
You can also list the usb devices via lsusb, to make sure the device is recognized:
root@kali:~# lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
I'm using Kali 1.0.5 with the original kernel which is 3.6.11-cutdown:
root@kali:~# uname -r
3.6.11-cutdown
I've read that the since kernel 3.0 and higher a driver called rtl8192cu should be available that is supporting the chipset RTL8188CUS. After searching for "*8192*" I've found the module in kali:
root@kali:~# find / -name "*8192*" -print
/sys/bus/usb/drivers/rtl8192cu
/sys/module/8192cu
/sys/module/8192cu/drivers/usb:rtl8192cu
/opt/metasploit/apps/pro/ui/db/migrate/20130208192816_add_hidden_to_task_chain.rb
/lib/modules/3.6.11-cutdown/kernel/drivers/net/wireless/rtl8192cu
/lib/modules/3.6.11-cutdown/kernel/drivers/net/wireless/rtl8192cu/8192cu.ko
/lib/firmware/rtlwifi/rtl8192defw.bin
/lib/firmware/rtlwifi/rtl8192cfwU.bin
/lib/firmware/rtlwifi/rtl8192cfw.bin
/lib/firmware/rtlwifi/rtl8192cfwU_B.bin
/lib/firmware/rtlwifi/rtl8192cufw.bin
/lib/firmware/rtlwifi/rtl8192sefw.bin
/lib/firmware/RTL8192E
/usr/share/exploitdb/platforms/php/webapps/18192.txt
As no driver was loaded automatically, I've tried to load the module manually:
root@kali:~# modprobe 8192cu 
root@kali:~# lsmod
Module                  Size  Used by
ipv6                  207600  12
8192cu                411588  0
leds_gpio               1668  0
led_class               1788  1 leds_gpio
So the driver is loaded and now we can bring up the interface:
root@kali:~# ifconfig wlan0 up
root@kali:~# ifconfig wlan0
wlan0     Link encap:Ethernet  Hardware Adresse 80:1f:02:b3:50:8b
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metrik:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
You can make a quick scan of available wifi networks via:
root@kali:~# iwlist wlan0 scan
Now you can either use the graphical WiFi manager or you can configure your WiFi via terminal, which is what I did. Just add the following lines to your /etc/network/interfaces:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid <your SSID here>
wpa-psk <your wlan-key here>
After restarting the network you should have a working wifi connection.
root@kali:~# service networking restart


Note:
If you're using a hidden SSID you should read the following thread.