====== BerryLocky2_(BYKY2) ====== {{:ie0117_proyectos_ii_2013:montaje_mora.png?100 }}\\ \\ \\ By: \\ [[mailto:jeilinj@gmail.com|Jeilin Crawford Warren.]]\\ [[mailto:PABLO.HURTADO@ucr.ac.cr|Pablo Hurtado Granados.]] ===== Description ===== The present project seeks to build an electric latchkey, based on the BYKY prototype realized last semester by Apú, Eduarte and Rincón. This new proposal is divided in two stages. Stage one consist in the foreground analysis of BYKY original version, where the system will access a database through a barcode lector, in addition to that this method will also realize facial recognition (by using open.cv) and RFID. On the other hand, stage two consist in creating graphical applications for computers and cellphones, by using ARCOS-Lab server with internet protocol TCP to enable the data base, additionally a watchdog will be implemented to guard the correct functioning of the system. ===== Objectives ===== ==== General ==== Study access methods and determine which one is more reliable and apply that system to develop a robust final product to comply with requirements requested. ==== Specifics ==== * Create the database with MySQL, that holds the user data and their authorized schedule.\\ * Try the BYKY prototype with barcode access and implement BYKY with facial recognition (by using open.cv) and RFID. -Choose the best method of the three- * Create an access control method based on Wi-Fi.\\ * Use ARCOS-Lab server with internet protocol TCP to enable the data base.\\ * Implement the physical assembly of the latchkey. ===== Justification ===== The realization of this project will provide a modern, reliable and effective opening system for the ARCOS-Lab of Escuela de Ingeniería Eléctrica of Universidad de Costa Rica. ===== What is RapberryPi? ===== Raspberry Pi is a credit card size computer that can connect to a TV or a keyboard. It is a miniature PC with ARM processor that can be used for many of the things that a desktop PC can do, such as spreadsheets, word processor and video games. In addition, you can play high definition videos. Models A and B are provided solely as plates and exclude OS, power supply, keyboard, casing or cables. The Raspberry Pi has a Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZF-S 700 MHz processor (The firmware includes a number of "Turbo" modes so that the user can attempt overclocking, up to 1 GHz, without affecting the warranty), VideoCore IV GPU, and was originally shipped with 256 megabytes of RAM, later upgraded to 512 MB. It does not include a built-in hard disk or solid-state drive, but uses an SD card for booting and long-term storage. \\ The Raspberry Pi has a 26-pin General Purpose Input/Output (GPIO) connector and this carries a set of signals and buses. There are 8 general purpose digital I/O pins – these can be programmed as either digital outputs or inputs. One of these pins can be designated for PWM output too. Additionally there is a 2-wire I2C interface and a 4-wire SPI interface (with a 2nd select line, making it 5 pins in total) and the serial UART with a further 2 pins. ==== Installing Raspbian ==== *Download Raspbian "wheezy" image from the official site http://www.raspberrypi.org/downloads *Unzip the image and write it on a empty SD card charging 4Gb or more. *Extract image (Assuming that the discharge goes to the Downloads directory). unzip ~/Downloads/2012-12-16-wheezy-raspbian.zip *Make sure the devices are mounted. The SD appear as "/ dev/sdd1" or similar df-h *dismount umount / dev/sdd1 *Write the image to the SD with dd sudo dd bs = 4M if = ~ / Downloads/2012-12-16-wheezy-raspbian.img of = / dev / sdd ==== RaspberryPi Settings ==== The configuration of the raspberrypi is very simple if you have already install raspbian, when you start your Pi the display shows the output from each of the start-up scripts. If starting for the first time using a new image you are logged in as a root user, and the raspi-config menu will then appear. It can also be started at any time from the command line:\\ $ sudo raspi-config info Information about this tool expand_rootfs Expand root partition to fill SD card overscan Change overscan configure_keyboard Set keyboard layout change_pass Change password for 'pi' user change_locale Set locale change_timezone Set timezone memory_split Change memory split ssh Enable or disable ssh server boot_behaviour Start desktop on boot? update Try to upgrade raspi-config Password Olvide mi contraseña
Deseo registrarme BerryLocky2 Te result of the previous code is show in the next image: {{ :ie0117_proyectos_ii_2013:login.jpg?200 |}} ===Validate user=== This file is in charge of receiving data from the index.php file and compares them against those who are in the database:
===Database conection=== Connection data local variables defined in the conectar_bd () function and then these variables are used as parameters to call the mysql_connect () function, which is what makes the request to connect to the dbms. the function mysql_connect () returns a link that represents the established connection to dbms with this link saved in the variable $conexio the DB to use is selected. ===Homepage=== This file is the screen that the user sees when logging correctly.
.:: Inicio ::. Pagina Principal
Bienvenido Cerrar sesión


Bienvenido

Recuerde cerrar su sesión!

BerryLocky2
The result is shown in the picture below: {{ :ie0117_proyectos_ii_2013:home.jpg?200 |}} ===Close Session=== This file is pointed to by the link "Cerrar Sesión" that is beside the user name (once you have logged). This file will destroy all session variables and end the session, all this is done with PHP functions. ===Forgot My Password=== On the login page the link that says "Olvidé mi contraseña" sends us to recuperarPassword.php file. This file allows you to send a new password to the user, the user should only write the email address and a new nine characters password automatically will be generated and will be sent to this email. .:: Recuperar Password ::.

id_usuario; //Servira para actualizar el pw $nombre = $fila->tx_nombre." ".$fila->tx_apellidoPaterno; $nick = $fila->tx_username; // Generacion de un nuevo Password $pasw = ""; $abecedario = array("A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","R","S","T", "U","V","W","a","b","c","d","e","f","g","h","j","k","l","m","n","o","p","q","r","s","t","u","v","w"); $simbolos = array(",","}","{","-","|","!","#","$","%","&","/","(",")","=","?","¡", "*","]","[","_",":",";","+"); for($i=0;$i<3; $i++) { $md = rand(1,2); $pasw .= (($md%2)==0) ? $abecedario[rand(0,43)] : rand(0,9); $md = rand(1,2); $pasw .= (($md%2)==0) ? rand(0,9) : $simbolos[rand(0,23)]; $md = rand(1,2); $pasw .= (($md%2)==0) ? $simbolos[rand(0,23)] : $abecedario[rand(0,43)] ; } // Le Envio por correo electronico su nuevo password $seEnvio; //Para determinar si se envio o no el correo $destinatario = $elcorreo; //A quien se envia $nomAdmin = 'Administración'; //Quien envia $mailAdmin = 'fruiz@eie.ucr.ac.cr'; //Mail de quien envia $urlAccessLogin = 'http://localhost/autenticar_usuarios/'; //Url de la pantalla de login $elmensaje = ""; $asunto = "Nueva contraseña para ".$nick; $cuerpomsg ='

.::Recuperar Password::.

A peticion de usted; se le ha asignado un nuevo password, utilice los siguientes datos para acceder al sistema

Recuperar Password


Nuevos datos de acceso para '.$urlAccessLogin.'
Nombre '.$nombre.'
Username '.$nick.'
Password '.$pasw.'
'; date_default_timezone_set('America/Mexico_City'); //Establecer cabeceras para la funcion mail() //version MIME $cabeceras = "MIME-Version: 1.0\r\n"; //Tipo de info $cabeceras .= "Content-type: text/html; charset=iso-8859-1\r\n"; //direccion del remitente $cabeceras .= "From: ".$nomAdmin." <".$mailAdmin.">"; $resEnvio = 0; //Si se envio el email if(mail($destinatario,$asunto,$cuerpomsg,$cabeceras)) { //Actualizar el pwd en la BD $sql_updt = "UPDATE tbl_users SET tx_password = '".md5($pasw)."' WHERE (id_usuario = ".$idusr.") AND (tx_correo = '".$elcorreo."')"; $res_updt = mysql_query($sql_updt); $resEnvio = 1; } //Cerrrar conexion a la BD mysql_close($conexio); // Mostrar resultado de envio (en esta misma pagina) ?> Escriba su correo electrónico con el que se ha registrado, se le enviará un nuevo password a su correo electrónico:

Correo electrónico: Confirme Correo electrónico:
El correo electronico no pertenece a ningun usuario registrado.
"; } else if( isset($_GET['enviado']) && isset($_GET['elcorreo']) ) { //Si se envio correctamente el nuevo password if( $_GET['enviado']==1 ) echo "
Su nueva contraseña ha sido enviada a ".$_GET['elcorreo'].".
"; else if( $_GET['enviado']==0 ) echo "
Por el momento la nueva contraseña no pudo ser enviada a ".$_GET['elcorreo'].".
Intente de nuevo más tarde.
"; } ?>

    
===== RFID Access Method ===== In this case we used RDM6300 125KHz cardreader((You can download the datasheet from here: [[https://www.dropbox.com/s/df8hoknwnugrip0/RDM630-Spec..pdf|RDM630-Spec]])), this mini-module is designed for reading code from 125KHz card compatible read-only tags and read/write card . It can be applied in office/home security, personal identification, access control, anti-forgery, interactive toy and production control systems etc. For reading the tags we used te following code #!/usr/bin/env python import serial import re, sys, signal, os, time, datetime import RPi.GPIO as GPIO BITRATE = 9600 GPIO.setmode(GPIO.BOARD) CARDS = [ '060090840715', '840034BD3E33', ] def signal_handler(signal, frame): print "Cerrando" GPIO.output(7, GPIO.LOW) # Unlock the door on program exit GPIO.cleanup() ser.close() sys.exit(0) if __name__ == '__main__': buffer = '' ser = serial.Serial('/dev/ttyAMA0', BITRATE, timeout=0) rfidPattern = re.compile(b'[\W_]+') signal.signal(signal.SIGINT, signal_handler) while True: # Read data from RFID reader buffer = buffer + ser.readline() if '\n' in buffer: lines = buffer.split('\n') last_received = lines[-2] match = rfidPattern.sub('', last_received) if match: print match if match in CARDS: print 'card authorized' else: print 'unauthorized card' # Clear buffer buffer = '' lines = '' time.sleep(0.1) ===== Results & Conclusions ===== *It is possible to connect to a database using python for querying and information to authenticate users. *It is possible to develop an identification system based on RFID RDM6300 using the module, which is necessary to change the default settings of the UART RaspberryPi pin to be used as general UART pins. *It is possible to develop a method of identifying users through web page using php functions to make queries to the database, in this case it is important to develop a security system to prevent dangerous intrusions, for example prevent a malicious user enter directly to the main page by typing the address directly into your browser.