Posts

How to install TAPIRE for Assisting Protocol Inference and Reverse Engineering

First, you need to install netgoblin as tapire dependence:

cd /tmp
git clone https://github.com/conix-security/netgoblin
cd netgoblin
git checkout develop
cd netzob
apt install python3-pip
pip3 install -r requirements.txt
python3 setup.py install
cd /tmp
git clone https://github.com/conix-security/TAPIRE
git checkout develop
pip3 install -r requirements.txt
./tapire.py 
Warning: FastBinaryTree not available, using Python version BinaryTree.
Warning: FastAVLTree not available, using Python version AVLTree.
Warning: FastRBTree not available, using Python version RBTree.
Traceback (most recent call last):
  File "./tapire.py", line 8, in <module>
    from menus.mainmenu import main_menu
  File "/home/nboettcher/Downloads/TAPIRE/menus/mainmenu.py", line 5, in <module>
    from netzob.all import *
  File "/usr/local/lib/python3.6/dist-packages/Netzob-1.0.2-py3.6-linux-x86_64.egg/netzob/all.py", line 36, in <module>
    from netzob.Import.all import *
ModuleNotFoundE…

An example to read a NetCDF file with Python

Image
For this post I'm going to use this post and the following files as reference.

NetCDF files:  air.sig995.2012.nc air.departure.sig995.2012.nc darwin_2012.nc Source code:  netcdf_example.py

If you want to see air.sig995.2012.nc content you can try with Integrated Data Viewer (IDV).
To download just execute:

wget https://www.unidata.ucar.edu/downloads/idv/current/ftp/idv_5_5_linux64_installer.sh
bash idv_5_5_linux64_installer.sh


Now, execute the python example file:
python netcdf_example.py
You probably will get the following errors:
ImportError: No module named functools_lru_cache ImportError: No module named basemap
You can install modules from pip, but in my case I can't solve the issue. To fix it install them from apt as follows:
sudo apt install python-backports.functools-lru-cache  python-mpltoolkits.basemap
Enjoy it!


How to convert a NetCDF file TIFF to import in QGIS 3.x

NetCDF is a data format and library designed to store multidimensional arrays of scientific data.
If you try to load it in Qgis, probably you will get the following message:

Invalid Layer: GDAL provider Cannot open GDAL dataset file.nc' not recognized as a supported file format. Raster layer Provider is not valid (provider: gdal, URI: file.nc

In QGIS 2.x you can use NetCDF plugin to load the layer, but it not exist yet in QGIS 3.x
To import the layer you need to convert the .nc file to another like .tiff

To do it, you can use gdal toolkit as follows:

gdal_translate file.nc file.tiff 
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Input file contains subdatasets. Please, select one of them for reading.

This issue is because the .nc contains subdatasets and you must specify only one.

To see the subdatasets names just execute the following sentence in your terminal:

gdalinfo file.nc

Subdatasets:
  SUBDATASET_1_NAME=NETCDF:"FWI.GPM.LATE.v5.Monthly.Default.201903.nc":GPM.LATE…

ERROR (internal_error): Operation on mixed SRID geometries

I got this issue when I tried to optimize a pgsql code with postgis.
See the following example that works with if you join it with other sentence:

SELECT ST_SetSRID(ST_MakeLine(ST_MakePoint(4.51, 52.2), ST_MakePoint(23.42, 37.58)),4326)

But, if you only replace ST_MakePoint by a geom selection you will have an error:

SELECT ST_SetSRID(ST_MakeLine( (select point from nodes where name='3'), (select point from nodes where name='20')) ,4326)

ERROR: Operation on mixed SRID geometries SQL state: XX000

To solve it just delete ST_SetSRID as follows:

SELECT ST_MakeLine( (select point from nodes where name='3'), (select point from nodes where name='20'))

Now it works
Enjoy it!

ERROR: GetProj4StringSPI: Cannot find SRID (4326) in spatial_ref_sys

If you are using postgis and a cleaner in your database, maybe you could have this error:

ERROR:  GetProj4StringSPI: Cannot find SRID (4326) in spatial_ref_sys
SQL state: XX000

This error means that your spatial_ref_sys table is empty
To fix it, just restore the information that postgis generate when you create this extension in your database.
To do it execute the following sentence:

psql -d $database_name -f $PATH/spatial_ref_sys.sql

where the PATH is the path to spatial_ref_sys.sql
For postgres 11 and postgis 2.5 the PATH is /usr/share/postgresql/11/contrib/postgis-2.5/

Other way to execute the same command is:

PGPASSWORD=postgres psql "host=localhost dbname=$database_name user=postgres" -f /usr/share/postgresql/11/contrib/postgis-2.5/spatial_ref_sys.sql

Enjoy it!

command not found: pip3

This is a common issue. If you try to execute pip3 you probably will get:

Command 'pip3' not found, but can be installed with:
sudo apt install python3-pip
or
pip3
zsh: command not found: pip3

although you install it, anyway the same error appears
To solve it, you can reinstall it:

sudo apt-get remove python3-pip
sudo apt-get install python3-pip

or execute pip3 as python module:

sudo python3 -m pip

Enjoy it!


How to send files throught bluetooth from nautilus

The best option is to use an extension to enable this option.

sudo apt install python-nautilus nautilus bluez gnome-bluetooth python3
cd ~/.local/share/nautilus-python/extension
wget https://raw.githubusercontent.com/TheWeirdDev/nautilus-send-to-bluetooth/master/SendToBluetooth.py
nautilus -q

HINT: Also you can use /usr/share/nautilus-python/extensions/ to store your extensions

Enjoy it!

Source: https://github.com/TheWeirdDev/nautilus-send-to-bluetooth