Low cost software and hardware creates the opportunity to bring empowering technology to people with low-budget. In this project I hope the people learn to install an operating system and the software needed to design a website using a raspberry pi. Prototyped source code to design the website will be tested in advance to be re-used during the session. The structure of the code will be modular and flexible to incorporate people ideas.
We expect that the audience take this exercise as a initial step to think about how to create secure websites and which tools exist to prevent hacks. After having an introduction to the vulnerabilities of websites we could discuss how sites with sensitive data protect themselves in the cyberspace.
Raspberry Pi is a small and affordable computer that you can use to learn programming.
https://www.raspberrypi.org/
Flask is a Python web framework built with a small core and easy-to-extend philosophy.
http://flask.pocoo.org/
https://www.youtube.com/watch?v=zRwy8gtgJ1A
Developer site: https://github.com/bradtraversy/myflaskapp
Code edited: https://github.com/cihernand/myflaskapp
sudo apt-get install git
git clone https://github.com/cihernand/myflaskapp
https://www.youtube.com/watch?v=N5vscPTWKOk
sudo apt-get install python3-dev
sudo apt-get install libmysqlclient-dev mysql-server
sudo apt install virtualenv
Create Virtual Environment
virtualenv myapp -p [insert path to python3]
source myapp/bin/activate
pip install Flask
pip install mysql-python
pip install mysqlclient
pip install flask-mysqldb
pip install wtforms
pip install passlib
pip install --upgrade setuptools
pip freeze > requirements.txt
mysqladmin -u root [insert password]
mysql -u [insert username] -p [insert password]
If the instructions above do not work try:
sudo mysql -u root
Change the plugin for user root from unix_socket into mysql_native_password:
SELECT User, Host, plugin FROM mysql.user;
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';
FLUSH PRIVILEGES;
Once you can login to MySQL create the Database myflaskapp with the following commands:
SHOW DATABASES;
CREATE DATABASE myflaskapp;
USE myflaskapp;
CREATE TABLE users( id INT(11) AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100), email VARCHAR (100) ,username VARCHAR(30), password VARCHAR (100),
register_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
SHOW TABLES;
DESCRIBE users;
CREATE TABLE articles( id INT(11) AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255), author VARCHAR (100) , body TEXT,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
SHOW TABLES;
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'INSERT YOUR MYSQL USERNAME HERE'
app.config['MYSQL_PASSWORD'] = 'INSERT YOUR MYSQL PASSWORD HERE'
python app.py
https://www.go4expert.com/articles/complete-mysql-injection-newbies-t20438/
# SELECT DATABASE NAME
USE myflaskapp;
# GET MYSQL VERSION
SELECT @@version;
# TEST EXAMPLE INJECTION INSIDE MYSQL
SELECT * from users WHERE username='a' or 1=1; -- AND password=''
SELECT * from users WHERE username='a' or 1=1;
[Hints:]
username:' or 1='1 password:' or 1='1
username:' or '1'='1' password:' or '1'='1'
username:or 1=1 password:or 1=1
Identify the flask modules that remove special characters from the MYSQL injection.
Identify what do passlib and sha256_crypt do with the passwords from the users.
Hack the site.