Saturday, December 31, 2016

Boot Kali Linux Rolling to CLI instead of GUI via systemd

Most of the tools I use in Kali are command line tools, and rarely need a full GUI, so in order to boot straight to CLI and get the maximum performance available on my system, I used this systemd command:
systemctl set-default multi-user.target

If you want to start a GUI, then type this command:
startx

Friday, December 30, 2016

Porting Kali NetHunter to LG G3 US990 with Cyanogenmod 13 Oct-OS-M ROM Android 6.0.1 Marshmallow

My latest project is trying to port Kali NetHunter to the LG G3 Running the latest OCT-OS-M CM13-based ROM (Android 6.0.1 Marshmallow).
I have yet to get the custom kernel to boot without the secure boot error, and am almost out of ideas, so if you can help, please drop me a line.
On your Android device:
Step 1. Root your phone.
Step 2. Unlock your bootloader and install TWRP.
Step 3. Install latest OCT-OS-M ROM.
On your Linux machine:
Step 4. Install Android toolchain as per kali wiki: here. (Note: An x86-64 machine is needed)
Step 5. Clone the OCT-OS kernel source github project named: platform_kernel_lge_us990
Step 6. Make kernel modifications and apply patches as per kali wiki: here. (Note: I had to disable Bluetooth USB HCI in order for the kernel to compile).
Step 7. Clone Kali NetHunter Source: here.
Step 8. Clone cbump source and cross-compile: here.
Step 9. Add cbump binary to kali-nethunter/nethunter-installer/boot-patcher/arch/armhf/tools/cbump
Step 10. Add
"$bin/cbump" boot-new.img || abort "Bumping boot image failed"
to kali-nethunter/nethunter-installer/boot-patcher/boot-patcher.sh (last line of build_boot() function.
Step 11. Add your device and build your zip as per wiki: here, and the README.md file in kali-nethunter/nethunter-installer/devices
In kali-nethunter/nethunter-installer/devices/devices.cfg add:
# LG G3 us990 for Cyanogenmod 13
[us990cm]
author = "mcraze123"
version = "1.0"
devicenames = us990
Copy your compiled and patched kernel image zImage to kali-nethunter/nethunter-installer/devices/marshmallow/us990cm
mkdir -p kali-nethunter/nethunter-installer/devices/marshmallow/us990cm
cp platform_kernel_lge_us990/kImage kali-nethunter/nethunter-install/devices/marshmallow/us990cm/
To get the lates apk's run:
python build.py -f
Then to build the zip, run:
python build.py -d us990cm -m
On Android:
boot into twrp, mount as mtp, copy zip to device, install zip

UPDATE:
I have managed to get past the secure boot error by flashing this zip, and removing the cross compiled version of cbump and modifications to boot-patcher.sh. Now the device recognizes on my mac as a keyboard but goes into a boot loop. I'm going to start with a known working kernel, then add features one by one in order to find what is causing the issues. Nethunter should be coming to the LG G3 US990 soon!

Wednesday, December 21, 2016

How to Install Asterisk and FreePBX on Ubuntu Server 16.04 Xenial with a MySQL root Password

So FreePBX "recommends" to not set a password for your MySQL root user, and leave it blank. I'm not sure how anyone could justify that leaving a password blank is a good recommendation. I don't care if your server is only listening on localhost or (hopefully not) facing the internet, this is a horrible recommendation, and it really makes me concerned with the quality the FreePBX code. Well, I decided to try out FreePBX anyway and had a lot of trouble figuring out how to configure it to use a password for mysql. I started grepping through the source code and finally hit pay dirt after using this command:
grep -R "Database Root" .
This told me that the code checking for connectivity to the database is in the file:
./installlib/installcommand.class.php
After opening this file, I was presented with the code where it stores its database settings
I changed line 33 to use my root database password:
'dbpass' => array(
'default' => 'your_mysql_root_password_goes_here',
'description' => 'Database password',
After re-running:
sudo ./install -n
It failed. damnit! But this time, it gives shows me all the flags that the install script accepts:
--dbuser Database username (default: "root")
--dbpass Database password (default: "")
Aha! And to see a full list of command line options, you can run the install script like so:
./install -h
Now to try again:
./install -n --dbuser="root" --dbpass="your_db_password_goes_here"
Annnnd... it worked!
I didn't notice anything in the documentation talking about the install scripts help or config flags, so I thought I'd post them here:
PHP Warning: Declaration of FreePBX\Install\FreePBXHelpCommand::setCommand(FreePBX\Install\FreePBXInstallCommand $command) should be compatible with Symfony\Component\Console\Command\HelpCommand::setCommand(Symfony\Component\Console\Command\Command $command) in /opt/freepbx/installlib/installhelpcommand.class.php on line 15
______ _____ ______ __
| ____| | __ \| _ \ \ / /
| |__ _ __ ___ ___| |__) | |_) \ V /
| __| '__/ _ \/ _ \ ___/| _ < > <
| | | | | __/ __/ | | |_) / . \
|_| |_| \___|\___|_| |____/_/ \_\
Usage:
install [--dbengine="..."] [--dbname="..."] [--cdrdbname="..."] [--dbuser="..."] [--dbpass="..."] [--user="..."] [--group="..."] [--dev-links] [--webroot="..."] [--astetcdir="..."] [--astmoddir="..."] [--astvarlibdir="..."] [--astagidir="..."] [--astspooldir="..."] [--astrundir="..."] [--astlogdir="..."] [--ampbin="..."] [--ampsbin="..."] [--ampcgibin="..."] [--ampplayback="..."] [-r|--rootdb] [-f|--force]

Options:
--dbengine Database engine (default: "mysql")
--dbname Database name (default: "asterisk")
--cdrdbname CDR Database name (default: "asteriskcdrdb")
--dbuser Database username (default: "root")
--dbpass Database password (default: "")
--user File owner user (default: "asterisk")
--group File owner group (default: "asterisk")
--dev-links Make links to files in the source directory instead of copying (developer option)
--webroot Filesystem location from which FreePBX files will be served (default: "/var/www/html")
--astetcdir Filesystem location from which Asterisk configuration files will be served (default: "/etc/asterisk")
--astmoddir Filesystem location for Asterisk modules (default: "/usr/lib/asterisk/modules")
--astvarlibdir Filesystem location for Asterisk lib files (default: "/var/lib/asterisk")
--astagidir Filesystem location for Asterisk agi files (default: "/var/lib/asterisk/agi-bin")
--astspooldir Location of the Asterisk spool directory (default: "/var/spool/asterisk")
--astrundir Location of the Asterisk run directory (default: "/var/run/asterisk")
--astlogdir Location of the Asterisk log files (default: "/var/log/asterisk")
--ampbin Location of the FreePBX command line scripts (default: "/var/lib/asterisk/bin")
--ampsbin Location of the FreePBX (root) command line scripts (default: "/usr/sbin")
--ampcgibin Location of the Apache cgi-bin executables (default: "/var/www/cgi-bin")
--ampplayback Directory for FreePBX html5 playback files (default: "/var/lib/asterisk/playback")
--rootdb (-r) Database Root Based Install. Will create the database user and password automatically along with the databases
--force (-f) Force an install. Rewriting all databases with default information
--help (-h) Display this help message
--quiet (-q) Do not output any message
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction (-n) Do not ask any interactive question

Monday, December 5, 2016

Configure OpenVAS Vulnerability Scanner on Ubuntu Server 16.04 to Listen on Local LAN

To configure OpenVAS to listen on your local LAN and not just localhost on Ubuntu Server 16.04, issue these commands:
/etc/init.d/openvas-scanner stop
gsad --listen=0.0.0.0 --port=8080
/etc/init.d/openvas-scanner start

Fixing mysqltuner ERROR 1054 on Ubuntu Server 16.04

After installing mysql-server and mysqltuner through the default repositories on my Ubuntu Server 16.04 machine, I got this error:
ERROR 1054 (42S22) at line 1: Unknown column 'password' in 'where clause'
This is a known bug that was introduced when mysql changed the name of the 'password' column. There has been a bug report on mysqltuner's github page and the appropriate fixes have been committed, however the debian package still has not been updated to reflect the current changes. To fix this I cloned the current git source and symlinked /usr/bin/mysqltuner to my source tree's mysqltuner.pl. This has the added benefit of when the package is updated, it will replace the symlink and not mess with any file installed by the package.
To do this, type the following commands:
cd /opt
git clone https://github.com/major/MySQLTuner-perl.git
cd MySQLTuner-perl
sudo mv /usr/bin/mysqltuner /usr/bin/mysqltuner.bak # back up the file just in case we mess up
sudo ln -s /opt/MySQLTuner-perl/mysqltuner.pl /usr/bin/mysqltuner

Sunday, December 4, 2016

How to Run Your Perl and Python Scripts From a Portable USB Thumb Drive On Multiple Computers You Are Repairing Without Having to Install the Full Interpreter on the Host

I have a lot of Perl and Python scripts I wrote to speed up the computer repair tasks I've had to perform in the past, such as: http://crazesweb.blogspot.com/2016/07/a-perl-script-to-search-hard-drive-for.html and http://crazesweb.blogspot.com/2016/07/a-perl-script-to-search-hard-drive-for_2.html

This guide will show you how to put these types of scripts on a flash drive and use a portable interpreter so that you don't have to install perl or python on every machine that you work on.

First you will need to download the portable versions of your interpreters, for Perl, download Strawberry Perl portable x86. For python, download the portable python x86. Now copy these executables to your flash drive along with your scripts for repairing. Next download Pstart, which is like a start menu for your portable thumb drive programs. Edit your pstart menu to execute your script using the appropriate interpreter for the script you choose. An alternative way is to create a batch script for each script that uses the portable interpreter to execute the given script.

Thursday, November 24, 2016

Installing Latest Kali Linux Rolling with All Packages on Any Android Device From Scratch With Latest LinuxDeploy Source

Before going through all of these steps, it might interest you to know that most Android devices usually do not have wireless drivers patched for injection, that being said, Kali still has many other useful tools that don't require patched drivers, i.e. metasploit. So, if you were wanting Kali on Android for wifi penetration testing, then you should look into Offensive Security's NetHunter, which includes patched drivers, but is only supported on a very limited set of Android devices. I'm currently looking into porting NetHunter to my LG G3 US990, and from what I can tell, is possible and encouraged. -Installing Linux on your Android device requires root, but anyone that's reading this probably has root already, right? -Get a 32GB class 10 microsd card, put it in your phone and choose to use it for Android only (format in ext4)
-Install Android Studio for your OS
-Clone latest LinuxDeploy source (git clone https://github.com/meefik/linuxdeploy.git)
-Open and build LinuxDeploy
-Install APK (adb install linuxdeploy.apk)
-Open LinuxDeploy, Go to settings, select: lock screen, lock wifi, wake lock, network trigger, enable cli
-Hit bottom right download button, select:
distribution: kali linux
installation type: directory
username: root
password: your_password
init: enable
init system: run-parts
mounts: enable
mount points: /store/emulated and /data
ssh: enable
-Menu -> install
-Menu -> configure
-Start
-Install VNC app, and connect to localhost:5900
-Open Terminal
-apt-get update
-apt-get install kali-linux-all # This installs like 3GB of packages, so be prepaired to wait
leave mysql password blank (default in kali and by default only listens on localhost)
set macchanger prompt to no
setuid root for kismet? -> No
set sslh to standalone
set wireshark to no
-To install only certain categories of tools (like to remove wifi or install password tools only):
apt-cache search kali-linux
apt-get remove --purge kali-linux-wifi
apt-get install kali-linux-pwtools
-Then to install openvas and tor:
apt-get install tor privoxy openvas