Tag: mysql

Apache, Linux, MySQL, PHP, Ubuntu Server

Install LAMP stack on Ubuntu 16.04

Update system sudo apt-get update && sudo apt-get dist-upgradesudo apt-get update && sudo apt-get dist-upgrade Install Apache sudo apt-get install apache2sudo apt-get install apache2 Install MySQL sudo apt-get install mysql-serversudo apt-get install mysql-server Install PHP sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-mbstring php-gettextsudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-mbstring php-gettext Install PHPMyAdmin sudo …

MySQL

Copying MySQL database to another server

* Export database from old server: mysqldump -u[username] -p[password] db_name > db_backupmysqldump -u[username] -p[password] db_name > db_backup * Copy backup to new server: scp db_backup [username]@[ip_address_or_hostname]:/home/[username]/db_backupscp db_backup [username]@[ip_address_or_hostname]:/home/[username]/db_backup * Import database to new server: mysql -u [username] -p -h localhost db_name < db_backupmysql -u [username] -p -h localhost db_name < db_backup

XAMPP

How to upgrade XAMPP in Windows

> Open XAMPP Control Panel (run as administrator!). > Stop services and uninstall them from services list if any. > Close XAMPP Control Panel. > Keep backup of htdocs, mysql\data directories and phpmyadmin\config.inc.php file. > Delete C:\xampp directory. > Download new XAMPP installer. > Install XAMPP to the same location (C:\xampp). > Copy your websites …

MySQL, SQL

Create Function in MySQL

Let’s see an example: DELIMITER $$ CREATE FUNCTION `countonline`(`dtstart` DATETIME, `dtend` DATETIME) RETURNS BIGINT(20) LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA SQL SECURITY INVOKER COMMENT ‘my comment’ BEGIN DECLARE cc BIGINT(20); SELECT COUNT(id) INTO cc FROM users WHERE lastseen BETWEEN dtstart AND dtend; RETURN cc; END$$   DELIMITER ;DELIMITER $$ CREATE FUNCTION `countonline`(`dtstart` DATETIME, `dtend` …

CakePHP, PHP

Get MySQL version in CakePHP 3

You need to import ConnectionManager: use CakeDatasourceConnectionManager;use CakeDatasourceConnectionManager; $stmt = ConnectionManager::get(’default’)->query(’SELECT version() as v’); $stmt->execute(); echo $stmt->fetch(’assoc’)[’v’];$stmt = ConnectionManager::get(‘default’)->query(‘SELECT version() as v’); $stmt->execute(); echo $stmt->fetch(‘assoc’)[‘v’]; More on executing CakePHP custom queries, here.

Databases, Frameworks, Kohana, MySQL, SQL

Kohana MySQL Database Schema

Kohana 3.3 MySQL Database Schema github CREATE TABLE IF NOT EXISTS `roles` ( `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(32) NOT NULL, `description` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uniq_name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;   INSERT INTO `roles` (`id`, `name`, `description`) VALUES(1, ‘login’, ‘Login privileges, granted after account confirmation’); INSERT INTO …

Metasploit, Phishing

Let’s go Phishing

Phishing is an attempt to steal sensitive information by impersonating a well known organization or website. In the same manner you can trick a user to steal her MySQL credentials. One of the abilities of Metasploit is this, mimic known services and capture user credentials. Among the various capture modules there is a module called …

Cracking, John the Ripper, Metasploit, MySQL

Cracking MySQL passwords with John The Ripper

Dump MySQL Password Hashes mysql_hashdump extracts the usernames and encrypted password hashes from a MySQL server. You can then use jtr_mysql_fast module to crack them. The module is located in auxiliary/scanner/mysql. To use it set RHOSTS option to your target’s ip address and increase THREADS value. If you have managed to reveal root password then …