Saturday, December 31, 2016

Making Free Phone Calls Using Asterisk and Google Voice

After installing the latest asterisk from source and configuring your dialplan extensions, you can use google voice to make and receive calls for free. Follow this guide to add google voice to your dialplan: Asterisk With Google Voice.
Then add the following to extensions.conf:
[outgoing-motif]
exten => _1XXXXXXXXXX,1,Dial(Motif/google/${EXTEN}@voice.google.com,,r)
[local]
include => incoming-motif
include => outgoing-motif
Now just dial 1+area_code+phone_number to dial a number or change:
exten => _1XXXXXXXXXX,1,Dial(Motif/google/${EXTEN}@voice.google.com,,r)
to
exten => _XXXXXXXXXX,1,Dial(Motif/google/${EXTEN}@voice.google.com,,r)
in order to just dial area_code+phone_number

Start screen on Boot in Kali Rolling, Ubuntu, or Debian Linux

After booting straight to CLI in Kali Rolling, Ubuntu, or Debian, I also wanted to have a screen session started on boot to use for my window manager. In order to do this, I had to edit /etc/rc.local and add this command:
/usr/bin/screen -c /root/.screenrc -dmU -h 10000 -S kali_screen_session

Then add the next command to ~/.bashrc:
export HOME="/root"

Then add these lines to ~/.screenrc (the most important being the shell line):
#don't display the copyright page
startup_message off

activity "%C -> %n%f %t activity!"
bell "%C -> %n%f %t bell!~"
pow_detach_msg "BYE"

#visable bell
vbell_msg "*beep*"

# Change scrollback to 100000 lines
defscrollback 100000

# fix the scrollback problem in putty (for windows users)
termcapinfo xterm ti@:te@

shell bash
# Uncomment the following line in Kali Linux in order to start new windows in ~ instead of /
#chdir /root

# programs to auto start
screen -t htop 0 htop

# status line at the bottom
hardstatus on
hardstatus alwayslastline
hardstatus string '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}][%{Y}%l%{g}]%{=b C}[ %d/%m/%y %c ]%{W}'

Now to create a new terminal window press control+a then c.
To switch between windows press control+a control+a

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.