Handy bash command collection – Part 28534

Converting a string into a series of hex with printf

This is a handy command-line when pen-testing SQL Injection:


$ a='or 3=3; --'; for ((i=0;i<${#a};i++));do printf '%%%02X' \'${a:$i:1};done; printf '\n'

%6F%72%00%33%3D%33%3B%00%2D%2D

Build-in ASCII/DEC/OCT/HEX table: man ascii

Handy command-line when pen-testing SQL Injection and you are to lazy to type the command above :)


$ man ascii
:
Oct Dec Hex Char Oct Dec Hex Char
------------------------------------------------------------------------
000 0 00 NUL '\0' 100 64 40 @
001 1 01 SOH (start of heading) 101 65 41 A
002 2 02 STX (start of text) 102 66 42 B
003 3 03 ETX (end of text) 103 67 43 C
:

Calculate SHA hash values of text


$ echo -n thisisaninputstring | shasum -a 256

Note: Consider avoiding to have this command stored in bash history.

Prevent commands from being logged in history

After a:

  export HISTCONTROL=ignorespace 

Any command that is preceded by a space is not stored in shell command history:

 ls test/     # ⇒ NOT stored in shell history
ls test/      # ⇒ stored in shell history

(Note: this is a short note. There is more behind command histories in Linux.)

List of available packages (Fedora)

yum list available

List of commands, aliases, keywords (Debian)

# All commands available to you
compgen -c 

# All aliases available to you
compgen -a 

# All build-ins available to you
compgen -b 

# All keywords available to you
compgen -k 

# All functions available to you
compgen -A function 

# Everything you can run
compgen -A function -abck 

Retrieving the GIT client proxy settings

When a PC is located behind a authenticating proxy, the pass-thru username and password can be retrieved from the git client:

$ git config --global --get https.proxy
https://proxyusername:proxypassword@proxyip:proxyport

$ git config --global --get http.proxy
http://proxyusername:proxypassword@proxyip:proxyport

# To set the proxy info:
$ git config --global https://proxyusername:proxypassword@proxyip:proxyport

Retrieving ….

$ git config --system --get http.sslcainfo
/bin/curl-ca-bundle.crt

Note: Make sure you look your PC when AFK :)

Obtaining list of MTAs registered to domain

root@dune:~# nslookup -q=mx hotmail.com
Server:         127.0.0.1
Address:        127.0.0.1#53
 
Non-authoritative answer:
hotmail.com     mail exchanger = 5 mx2.hotmail.com.
hotmail.com     mail exchanger = 5 mx3.hotmail.com.
hotmail.com     mail exchanger = 5 mx4.hotmail.com.
hotmail.com     mail exchanger = 5 mx1.hotmail.com.
 
Authoritative answers can be found from:
hotmail.com     nameserver = ns3.msft.net.
hotmail.com     nameserver = ns2.msft.net.
hotmail.com     nameserver = ns1.msft.net.
hotmail.com     nameserver = ns4.msft.net.
mx1.hotmail.com internet address = 134.170.2.199
mx1.hotmail.com internet address = 207.46.8.167
mx1.hotmail.com internet address = 207.46.8.199
:
:

Leave a Reply

Your email address will not be published. Required fields are marked *