Various

ASCII Table

[ source : http://www.asciitable.com ]

alt text

US Keyboard

[ source :https://fr.wikipedia.org/wiki/QWERTY#/media/File:KB_USA-standard.svg ]

alt text

Fix captive portal issue

When the device not trigger the portal webpage correctly

http://neverssl.com/

TMUX

~/.tmux.conf

Replace prefix CTRL+B with CTRL+A

# remap prefix from 'C-b' to 'C-a'
# to go to the beginning of line CA CA
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# split panes using | and -
bind v split-window -h
bind h split-window -v
unbind '"'
unbind %

# reload tmux configuration
bind r source-file ~/.tmux.conf \; display "Config Reloaded!"

# switch panes using Alt-arrow 
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# enable mouse interaction
set -g mouse on

# don't rename windows automatically
# use "," to permanently rename title 
set-option -g allow-rename off

setw -g mode-keys vi
set -g history-limit 10000

run-shell /opt/tmux-logging

Installation of tmux-logging

git clone https://github.com/tmux-plugins/tmux-logging.git /opt/tmux-logging

shortcuts

  • Alt + . : history of paramaeters of commande
  • Zoom view : z
  • Split horizontaly / verticaly : h / v

  • VI mode

    • [ : enter in vi mode
    • in vi mode
    • space to select
    • enter to copy
    • ] to paste
  • Logging : ALT+SHIFT+P

Linux usefull commands

Show a 4-way scrollable process tree with full details

ps awwfux | less -S

Find files that have been modified in the past 60 minutes

find / -mmin 60 -type f 

Find all files larger than 20M

find / -type f -size +20M 

Find duplicate files (based on MD5 hash)

find -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 33

Annotate tail -f with timestamps

tail -f file | while read ; do echo "$(date +%T.%N) $REPLY" ; done

Add substring in string at position

Before :

37            AAA                     ASCII adjust AL after addition
D5 0A         AAD                     ASCII adjust AX before division
D4 0A         AAM                     ASCII adjust AX after multiplication

After :

# sed -r -e 's/^.{5}/&|/' tab.txt
37   |         AAA                     ASCII adjust AL after addition
D5 0A|         AAD                     ASCII adjust AX before division
D4 0A|         AAM                     ASCII adjust AX after multiplication
3F   |         AAS                     ASCII adjust AL after subtraction

Add string at the begining of the line

Before :

37            AAA                     ASCII adjust AL after addition
D5 0A         AAD                     ASCII adjust AX before division
D4 0A         AAM                     ASCII adjust AX after multiplication

After :

# sed 's/^/| /' tab.txt
| 37            AAA                     ASCII adjust AL after addition
| D5 0A         AAD                     ASCII adjust AX before division
| D4 0A         AAM                     ASCII adjust AX after multiplication

Convert dos line ending file (/bin/sh^M : bad interpreter )

# sed -i -e ‘s/\r$//’ <script name> 

RDP on Kali

apt-get install xrdp 
service xrdp start
service xrdp-sesman start
update-rc.d xrdp enable
apt-get remove gnome-core
apt-get install lxde-core lxde kali-defaults kali-root-login desktop-base
update-alternatives --config x-session-manager (select startlxde)

Using dynamic mount with autofs

sudo apt install autofs cifs-utils

in /etc/auto.master add

/mount/nas   /etc/auto.nas --timeout 300 --ghost 
  • timeout 300 after 300 seconds the share is unmount
  • ghost the directory is prevent even though the mount is not up

or create a dedicated config file in /etc/auto.master.d

in /etc/auto.nas add

commun  -fstype=cifs,rw,uid=1000,gid=1000,credentials=/home/username/.autofs_creds ://x.x.x.x/commun
  • commun : name of the mount point so we have /mount/nas/commun
  • uid / gid : id of account use to mount the share

in /home/username/.autofs_creds add

username=nas-user
password=nas-password
domain=WORKGROUP

protect the configuration

chmod 600 /home/eric/.autofs_creds
sudo chmod 0644 /etc/auto.nas

Restart :

systemctl restart autofs

To debug :

sudo automount -f -v -d

Screenshot a region and save to a file

gnome-screenshot -a -f /tmp/$(date +%F_%H%M_%S).png 

Remote TCPDump

ssh user@x.x.x.x "/usr/bin/tcpdump -i lo -U -s0 -w - 'not port 22'" | wireshark -k -i -