Proper fonts in the MAC version of Wireshark

I switched to MAC in the last months. Everything is going great so far, except for the fact of some OpenSource programs that -although they have a MAC version- the graphical environment GTK doesn’t work as good as it used to work with my old Debian. I’m talking about Gimp, Inkscape… and Wireshark.

Here is a trick to set the Wireshark fonts smaller to have a great user experience while working with it on Mac:

sed -i -e 's/gtk-font-name="Lucida Grande 12"/gtk-font-name="Lucida Grande 9"/g' /Applications/Wireshark.app/Contents/Resources/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/pre_gtkrc 

sed -i -e 's/gtk-icon-sizes = "gtk-menu=16,16:gtk-dialog=48,48:gtk-dnd=32,32:gtk-button=20,20:gtk-large-toolbar=24,24:gtk-small-toolbar=16,16:inkscape-decoration=12,12"/gtk-icon-sizes = "gtk-menu=16,16:gtk-dialog=24,24:gtk-dnd=32,32:gtk-button=20,20:gtk-large-toolbar=16,16:gtk-small-toolbar=10,10:inkscape-decoration=6,6"/g' /Applications/Wireshark.app/Contents/Resources/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/pre_gtkrc

Thanks tp.org.

Pjsua installation script

Basic installation of the pjsua client (based on the PJSIP library)

#!/bin/bash
wget http://www.pjsip.org/release/2.0.1/pjproject-2.0.1.tar.bz2
tar xvjf pjproject-2.0.1.tar.bz2
cd pjproject-2.0.1/
sudo apt-get install gcc build-essential make g++ gpp
./configure
make dep
make
sudo make install
cd
ln -s pjproject-2.0.1/pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu

baresip installation script

baresip is very promising command-line SIP client. This is a basic bash script which compiles its dependencies and itself.

#!/bin/bash

WEB=http://www.creytiv.com/pub/
ARRAY=( re-0.4.2 rem-0.4.2 baresip-0.4.3 )

# Installing some stuff
sudo apt-get install emacs tshark gcc gpp python make
sudo apt-get install alsa-utils alsa-oss linux-sound-base
sudo adduser `whoami` audio

alsamixer

for i in "${ARRAY[@]}"
do
	wget $WEB$i.tar.gz
	tar -zxvf $i.tar.gz
	cd $i/
	make
	sudo make install
done

# Updating shared libs
sudo ldconfig

echo 'execute baresip'

Sharing the “history” between some terminals

This solves the problem of sharing the history command list between different terminals at the same time in the same box. To add to your .bashrc file.

export HISTCONTROL=ignoredups:erasedups  # no duplicate entries
export HISTSIZE=100000                   # big big history
export HISTFILESIZE=100000               # big big history
shopt -s histappend                      # append to history, don't overwrite it

# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

Thanks stackexchange, especially kch user.

Converting a rtpproxy recording to .wav

These commands were used to split the RTP recorded by the rtpproxy (with -P option) into raw data and later convert it to a .wav audio file.

rtpbreak -W -g -f -r 2186643f2ee35b7229b833733ed24423@10.22.22.100:5060-0=0611a3b9ab1398418c54d232c57477d2.o.rtp
rtpbreak -W -g -f -r 2186643f2ee35b7229b833733ed24423@10.22.22.100:5060-0=0611a3b9ab1398418c54d232c57477d2.a.rtp
sox --combine merge -r 8k -e u-law rtp.0.0.raw  -r 8k -e u-law rtp.1.0.raw -t wavpcm -s output.wav
# This script will do this conversion for all the files in a given folder
# Little dirty, just works. lmartin 
rm -frv *.txt *.raw
for f in *.a.rtp; do 
    f2="${f%.*}"
    filename="${f2%.*}"
    rtpbreak -W -g -f -r $filename".o.rtp"
    rtpbreak -W -g -f -r $filename".a.rtp"
    sox --combine merge -r 8k -e u-law rtp.0.0.raw  -r 8k -e u-law rtp.1.0.raw -t wavpcm -s $filename.wav
    rm -frv *.txt *.raw
done

Thanks here.

@TODO. Good idea from jbcrash to reset the sox command to record both ways of the RTP in different channels.

Installing rtpbreak on Ubuntu

Pretty straight-forward.

sudo apt-get install libnet1 libnet1-* pcaputils libpcap-dev libpcap0.8*    
wget http://dallachiesa.com/code/rtpbreak/rtpbreak-1.3a.tgz
tar xzvf rtpbreak-1.3a.tgz
cd rtpbreak-1.3a/; make
cd /usr/sbin; sudo ln -s /home/vagrant/rtpbreak-1.3a/src/rtpbreak

Announcements with Freepbx 2.10 Asterisk1.8 – Ubuntu natty

Getting some free .wav files from here. We will convert all the .wavs to .gsm format using this sox command:

for i in *.wav; do sox $i -r 8000 -c 1 $(basename $i .wav).gsm resample -ql; done

Then we just upload Asterisk 1.8 through Freepbx 2.10.

I faced this problem with the folder in Ubuntu:

[2012-11-20 15:35:08] WARNING[2170]: file.c:663 ast_openstream_full: File custom/Clapping does not exist in any format
[2012-11-20 15:35:08] WARNING[2170]: file.c:958 ast_streamfile: Unable to open custom/Clapping (format 0x4 (ulaw)): No such file or directory
[2012-11-20 15:35:08] WARNING[2170]: app_playback.c:475 playback_exec: ast_streamfile failed on SIP/10.22.22.110-00000000 for custom/Clapping,noanswer

I solved doing,

# Go to the folder where asterisk is looking for the recordings
cd /usr/share/asterisk/sounds
# Removing the custom folder. (Check that we are not screwing up!)
rm -r custom
# Make a symbolic link where we have our recordings
sudo ln -s /var/lib/asterisk/sounds/custom

Thanks to this and this website.

Installing Asterisk 1.8 and FreePBX 2.10 on Ubuntu natty

# Installing Asterisk 1.8 and FreePBX 2.10.0 on Ubuntu natty
# make sure the host is set properly
cat /etc/hostname
cat /etc/hosts
cat /etc/resolv.conf

#
#
# Note that if the <<PASSWORD>>
# contains an exclamation mark "!", we have to set the "" before it
#
#

# Installing basic desired packages in this box
sudo apt-get update
sudo apt-get install mysql-client mysql-common mysql-server # set your <<PASSWORD>> password
#select apache for the phpmyadmin
sudo apt-get install phpmyadmin emacs gcc python tshark python-software-properties

# Some repos
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 175E41DF
sudo add-apt-repository "deb http://packages.asterisk.org/deb `lsb_release -cs` main"

# Installing apache and asterisk packages
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install linux-headers-$(uname -r)
sudo apt-get install asterisk-1.8 asterisk-mysql apache2-mpm-itk php5-cli php-db php5-mysql
# set the country code 1 when prompted
sudo apt-get install asterisk-dahdi 
# optional
sudo apt-get install asterisk-core* asterisk-moh*  asterisk-mp3

# Final update and upgrade
sudo apt-get update
sudo apt-get upgrade

# Fixing the "Could not reliably determine the server’s fully qualified domain name" from apache
sudo /etc/init.d/apache2 restart
sudo sh -c "echo 'ServerName localhost' >> /etc/apache2/httpd.conf"
sudo /etc/init.d/apache2 restart

# Lets configure the mysql
mysql -u root -p <<< "create database asterisk;"
mysql -u root -p <<< "create database asteriskcdrdb;"
mysql -u root -p <<< "grant all on asterisk.* to freepbx@localhost identified by '<<PASSWORD>>';"
mysql -u root -p <<< "grant all on asteriskcdrdb.* to freepbx@localhost identified by '<<PASSWORD>>';"


# Getting freepbx
cd; wget http://mirror.freepbx.org/freepbx-2.10.0.tar.gz
cd; sudo tar zxvf freepbx-2.10.0.tar.gz -C /usr/src

# More sql stuff
mysql -p -u freepbx asterisk < /usr/src/freepbx-2.10.0/SQL/newinstall.sql
mysql -p -u freepbx asteriskcdrdb < /usr/src/freepbx-2.10.0/SQL/cdr_mysql_table.sql

# Installing freepbx...
# Set everything by default except the IP
cd /usr/src/freepbx-2.10.0/ ; sudo ./install_amp --username freepbx --password <<PASSWORD>>

# Permissions
sudo chown -R asterisk:asterisk /var/www/html/
sudo usermod -a -G asterisk root
sudo adduser www-data asterisk
sudo amportal chown

# Configuring apache
sudo sh -c "echo '''<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
	</Directory>
	<Directory /var/www/html/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride all
		Order allow,deny
		allow from all
        </Directory>
	ErrorLog ${APACHE_LOG_DIR}/freepbx-error.log
	LogLevel warn
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>''' > /etc/apache2/sites-available/default"

# restart apache
sudo /etc/init.d/apache2 restart

# amportal to rc.local
sudo emacs /etc/rc.local
# write this above exit 0
/usr/sbin/amportal start

# restart asterisk
sudo /etc/init.d/asterisk restart; sudo asterisk -vvvvvvvvvr

#
#
# go to the IP you set when running the ./install_amp freepbx installation script 
# The user/password would be admin/admin
#
#

Really helped by this post.

Sniffing MySQL

Sniffing some MySQL queries,

tshark -i any -d tcp.port==3306,mysql -T fields -e mysql.query 'port 3306'