Posts

Showing posts from 2019

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 <...

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.Defau...

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

How to run terminator with rigth click inside nautilus

Image
First, we need to install nautilus-python extension: sudo apt install python-nautilus Now, you need to create the extensions folder: mkdir ~/.local/share/nautilus-python cd ~/.local/share/nautilus-python mkdir extensions cd extensions To finish, download the extension to enable execute terminator in nautilus: wget  http://www.giuspen.com/software/nau3pyext/open-terminal-here.py Edit it and change the label variable "Open Terminal Here" by "Open Terminator" To restart nautilus, just execute: nautilus -q nautilus If you don't have terminator as your default terminal, it is enough to choose it when executing the following command: sudo update-alternatives --config x-terminal-emulator UPDATED In Ubuntu 20.10 the previous tutorial doesn't work. An alternative is to install a nautilus-extension for several terminals: pip3 install nautilus-open-any-terminal Edit ~/.local/share/nautilus-python/extensions/open_any_terminal_extension.py an...

How to run Matlab without root permissions

If you have issues with Matlab to run commands without root, probably you will see this: INFO: READ:  OnSendHeadersMessage{type=OnSendHeaders, uid=557, browserContextId=0, requestId=57, url=https://localhost:31515/messageservice/async, method=POST, headers=Origin: https://localhost:31515 X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.52 Safari/537.36 Content-Type: application/json Accept: */* Referer: https://localhost:31515/remote/proxy/1.5/iframeProxyRelease.html Accept-Encoding: gzip, deflate Accept-Language: en-us Cookie: JSESSIONID2=aUWOscLC3o6cqUdV; ssnc=24WR68u39rLEOyhW }, SocketInfo{channelId=0, browserId=-1, channelType=Main} To fix it, just add permissions to your user with: sudo chown -R $USER:$USER /usr/local/MATLAB/R2018b If you run Matlab again, you will see this: at com.mathworks.mlwidgets.shortcuts.ShortcutUtils.getShortcutsFile(ShortcutUtils.java:703)...

How to monitor your computer from your desktop

Image
UPDATED to Ubuntu 20.10 As you see, system-monitor is not more available in Ubuntu 18.10 For this reason, I search another utility to monitor my system and I find conky. It is a very personalizable tool that you can install with snap: sudo apt install conky Now, you need to configure it as you like, with you specific interfaces names, in /etc/conky/conky.conf Here is my first configuration: conky.config = {   use_spacer = 'left',   pad_percents = 3,   background = false,   double_buffer = true,   font = 'DejaVu Sans Mono:size=10',   use_xft = true,   alignment = 'top_right',   gap_x = 50,   gap_y = 200,   own_window_argb_visual = true,   own_window_argb_value = 0,   own_window_type = 'normal',   own_window_hints = 'undecorated,below,skip_taskbar,skip_pager,sticky',   own_window = true,   update_interval = 5.0, } conky.text = [[ #\${color orange}Hostname: \${color}\${nodename} ${color...

How to backup/restore your linux packages in Ubuntu 18.10

Image
If you need migrate your packages to another computer, the best choice is to restore the packages to avoid install all of them again manually. I'm going to describe three tools that I test to do it. apt-clone is a tool for backup all your packages installed through apt. To install it just execute: sudo apt install apt-clone sudo apt-clone clone path_to_save_backup Now, to restore the packages, just copy this file in your new station and execute the following: sudo apt-clone restore apt-clone-state-*.tar.gz It works very well, but some times you can get this error: Deja-dup is other tool to make backups and restore your packages. When I run it, I got this message: InvalidBackendURL: missing // - relative paths not supported for scheme invalid: invalid:// This bug was reported here  2 years ago, but still is not totally fixed Aptik is tyhe most functional tool with GUI. To install it just execute: sudo apt-add-repository -y ppa:teejee2008/ppa sudo apt-ge...

How to create a requirements.txt for python

First, you must to detect every python package that you need to your proyect. An option is to use the following sentence: grep import file_name.py Now, you need to create a file called requirements.in with every package per line as: julia networkx To finalize, the version of each package must be included in the file. To do it, just use: pip-compile requirements.in  The file requirements.txt was created.  To run it in other environment, execute the following sentence: pip install -r requirement.txt Enjoy it!

How to backup your Visual Studio Code extensions

If you want to avoid to use a github account to syncronize your extensions, you can do it fastly as follows: code --list-extensions | xargs -L 1 echo code --install-extension This sentence, you must write it in your terminal. It generates an output with a list of your extensions, like: code --install-extension rogalmic.bash-debug Now, when you would like to import the same extensions, just put the previous output in your terminal. Also, you can copy your extensions folder in ~/.vscode/extensions Enjoy it!

Webcam streaming throught VLC with YUY2 compatibility

If you try to stream your webcam throught VLC you probably will see the following issue: # vlc v4l2:///dev/video0 --sout '#rtp{mux=ts,sdp=rtsp://:8888/live.sdp}'  VLC media player 3.0.4 Vetinari (revision 3.0.4-0-gf615db6332) [000055c7620dd630] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. [00007ff730002fe0] main mux error: cannot add this stream [00007ff730001180] stream_out_rtp stream out error: cannot add this stream to the muxer [00007ff73000ff60] main decoder error: cannot create packetizer output (YUY2) [00007ff73000ff60] main decoder error: buffer deadlock prevented To fix it, you must enable the transcoding and run the following command: cvlc -vvv v4l2:///dev/video0:chroma=mp2v --v4l2-width 1280 --v4l2-height 720 --sout '#transcode{vcodec=mp2v,acodec=mpga,fps=30}:rtp{mux=ts,sdp=rtsp://:8888/live.sdp}' where chroma enables hardware video decoding. You can edit the resolution, codecs and frame ...

v4l2: open /dev/video0: Permission denied

If you try to stream using your webcam throught vlc or xawtv vlc v4l2:///dev/video0 or xawtv -c /dev/video0 probably you will have this issue. To solve it, you must add your user to the video group as follows: sudo adduser username video sudo usermod -a -G video username where username is your user (whoami) Now restart your computer Enjoy it!