Introduction


ownMdm is your own Mobile Device Manager, where you and only you, can remotely control your devices or your family devices and

It is Free.

It has 2 parts:

- Web: The web part is a php web that uses a mySql Database to send and receive commands to your registered devices.

- App: The App is a mobile administrator that works like others, with a simple screen, and a configuration screen, but it makes things transparently.

 

How does it work?

Once you have the web part installed and ready, you have to install the App in your devices and set at settings screen, the url of your own server and a key to send in order to check that the connections are from you.

Then, from the web, you select the devices and a Command from this list:

- Message: Send a notification to device. Enter your message below

- Lock: Will screen block the device

- Ring: The device will sound like a police car

- Enable Admin: The device will receive a popup to activate this App if it is not.

- Ping: The device will answer with a ping to check if is responding (check log)

- Location: The device will answer with its location at google maps and wifi networks (check log)

- Location Alarm: Send you alerts when the device go out or in the actual device location. Enter the number in meters below, for example 5000, (check log)

- Wipe: The device will be completely deleted, only if it is stolen and you can not recover it

- Lock with Key: This command will lock the device with your own PIN from console. Even if the mobile is rebooted the lock will work.

- Force update Model: Will get model data to console

- Record Audio: Will record a 20 seconds audio and will send it to your mail

- Take a Picture: The device will take a picture and will send it to your mail

- Take a Video: The device will take a short video and will send it to your mail (It will wait till Screen is On)

- Receive a Sms: Perfect for knowing the mobile number of the Imsi inserted in the device

- Track Device: The device will return location, sound and pictures every 3 minutes for 15 minutes

- Receive a File: The device will send you the file you set as a parameter


At main web page, you will see the device list with several important fields and a link to log.

At log web page you will see all history of that device, including the Apps that the device installs and removes.

Installing

This software requires apache2, php, mySql, curl.

You need to configure your own Server and it works perfectly on RaspBerry PI, even you can install it on a RaspBmc Image.

RaspBmc

The web part


sudo apt-get update
sudo apt-get install apache2 php5 libapache2-mod-php5

Change the 80 port to another one because 80 is in use by Xmbc, editing the apache 2 file ports.conf, for example port 81.

Start apache2 with this command sudo service apache2 start and put this command in your /etc/rc.local file to start at boot.

Next install Curl


sudo apt-get install php5-curl

and mySql


sudo apt-get install mysql-server mysql-client php5-mysql

and restart apache2


sudo service apache2 restart

It’s a good idea to install phpmyadmin as well


sudo apt-get install phpmyadmin

From there you must create a db executing this sql code:


SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE DATABASE `mdm` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `mdm`;
 
-- -------------------------------------------------------- 
 
-- 
-- Table structure for table `devices` 
-- 
 
CREATE TABLE IF NOT EXISTS `devices` (
  `imei` varchar(100) NOT NULL,
  `gcm` varchar(300) default NULL, 
  `location` varchar(200) default NULL,
  `dateLocation` timestamp NULL default NULL, 
  `enabled` tinyint(4) default NULL,
  `model` varchar(300) default NULL,
  `enabledDate` timestamp NULL default NULL,
  `disabledDate` timestamp NULL default NULL, 
  `ping` timestamp NULL default NULL, 
  PRIMARY KEY  (`imei`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
--   
-- Table structure for table `devices_log` 
--       
 
CREATE TABLE IF NOT EXISTS `devices_log` ( 
  `imei` varchar(100) NOT NULL,  
  `log` varchar(500) NOT NULL, 
  `dateLog` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,   
  KEY `imei` (`imei`)    
) ENGINE=MyISAM DEFAULT CHARSET=latin1;  

After that, you have to create the user ‘mdm’ with your own key, and grant privileges to this user to mdm db.


CREATE USER 'mdm'@'%' IDENTIFIED BY '***';  

GRANT ALL PRIVILEGES ON * . * TO 'mdm'@'%' IDENTIFIED BY '***' WITH GRANT OPTION
 MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 
 MAX_USER_CONNECTIONS 0 ; 

GRANT ALL PRIVILEGES ON `mdm` . * TO 'mdm'@'%'; 

Now, is time to put the code at /var/www/


sudo mkdir mdm

and change the owner of this directory


sudo chown pi mdm

pi@raspbmc:/var/www$ ls -la  
drwxr-xr-x  3 root root 4096 Jul 24 09:32 .     
drwxr-xr-x 11 root root 4096 Jul 24 08:15 ..    
drwxr-xr-x  2 pi   root 4096 Jul 24 09:32 mdm    

Copy the content of the mdm directory you have downloaded inside mdm directory

You must check that can access to this web from internet. Maybe you have to change the iptables of your raspberry pi installation and open your router to your open port (81).

Next: Now you must quit at apache2 conf the indexes view

Next: Put security in your mdm installation with a .htaccess file (included) that asks a password to the user.


mkdir -p /home/pi/     
htpasswd -c /home/pi/apasswords pacosal     

Make sure /home/pi/apasswords file is readable by Apache web server.

Now is time to edit the file /var/www/mdm/web/init.inc.php with nano and change the value mykey for the key that you will set at App Settings and the bd password for the user mdm. Set your own email to receive audios and pictures.

WARNING: Web version 1.4.0 and Up requires this bbdd change:


ALTER TABLE `devices` ADD `name` VARCHAR( 200 ) NULL AFTER `imei`

The Android App

Download the App from Google Play and open it. Go settings and press Server Data. At that screen set:

- Uri: for example: http://yourdomain:yourport

- Server key: The key

Ready

Go to http://yourdomain:yourport/web/mdm/index.php from a browser (chrome the best) and you must see a list of your devices.

Select one device and send a ‘ping’ command. After a while click on the device log and check that the device responds with a ping.