Cryptography Steganography Encoding Decoding
Cryptography Steganography Encoding Decoding
https://www.boxentriq.com/code-
breaking/cipher-identifier
OpenSSL
Deciphering an encrypted file with
OpenSSL
https://github.com/jeroennijhof/vncpwd
Compile it
Run it
Vigenere Ciphers
Decrypting Vigenere Ciphers
To decrypt a vigenere message, we need the
cipher text and the key used to decrypt it. Then we
can use the below online service
http://rumkin.com/tools/cipher/vigenere-
keyed.php
Another resource
https://www.boxentriq.com/code-
breaking/vigenere-cipher
cookie: auth=[encrypted-value]
https://github.com/AonCyberLabs/PadBuster
#Usage
https://quipqiup.com/
Elliptic Curve Cryptography
Algorithm
ECC algoritim is a kind of public key cryptography
that allows for smaller keys and low power
requirements. So it works by generating a public
and private keys. The public key is used in
encrypting your message and to decrypt it you
need your private key.
Example of generating a keypair
$ seccure-key
seccure-decrypt -i encrypted.msg
import seccure
cipher = "\x01\xd3\xe1\xf2\x17T
\xd0\x8a\xd6\xe2\xbd\x9e\x9e~P(\xf7\xe9\xa
5\xc1KT\x9aI\xdd\\!\x95t\xe1\xd6p\xaa\"u2\
xc2\x85F\x1e\xbc\x00\xb9\x17\x97\xb8\x0b\x
c5y\xec<K-
gp9\xa0\xcb\xac\x9et\x89z\x13\x15\x94Dn\xe
b\x95\x19[\x80\xf1\xa8,\x82G`\xee\xe8C\xc1
\x15\xa1~T\x07\xcc{\xbd\xda\xf0\x9e\x1bh\'
QU\xe7\x163\xd4F\xcc\xc5\x99w"
RSA Encryption
Decrypting a basic private key
id_rsa.crypt
Note that you can use RSACTFtool] as
alternative method to the below one
In RSA, there is the public key which is two number
[n] and [e] and there is the private key which is
also two numbers [n] and [d]. [n] is the product of
two large prime numbers [p] and [q]. In decrypting
private keys, we need to calculate the [d].
In python, you can do that with the [pow] function
as below
This will give you the password for the private RSA
key.
Encrypting a password/message
from an input text file using python
and sage library
The below script takes the text in [plaintext.txt file]
and using mathmetical calculations with [sage]
library it calculates the encrypted text and stores it
in [cipertext.txt]
nbits = 1024
password =
open("plaintext.txt").read().strip()
enc_pass = open("ciphertext.txt","w")
debug = open("log.txt","w")
m =
Integer(int(password.encode('hex'),16))
p = random_prime(2^floor(nbits/2)-1,
lbound=2^floor(nbits/2-1), proof=False)
q = random_prime(2^floor(nbits/2)-1,
lbound=2^floor(nbits/2-1), proof=False)
n = p*q
phi = (p-1)*(q-1)
e = ZZ.random_element(phi)
while gcd(e, phi) != 1:
e = ZZ.random_element(phi)
c = pow(m, e, n)
enc_pass.write('Encrypted Text:
'+str(c)+'\n')
debug.write(str(p)+'\n')
debug.write(str(q)+'\n')
debug.write(str(e)+'\n')
#!/usr/bin/python
p =
0xa6055ec186de51800ddd6fcbf0192384ff42d707
a55f57af4fcfb0d1dc7bd97055e8275cd4b78ec63c
5d592f567c66393a061324aa2e6a8d8fc2a910cbee
1ed9
q =
0xfa0f9463ea0a93b929c099320d31c277e0b0dbc6
5b189ed76124f5a1218f5d91fd0102a4c8de11f28b
e5e4d0ae91ab319f4537e97ed74bc663e972a4a911
9307
e =
0x6d1fdab4ce3217b3fc32c9ed480a31d067fd57d9
3a9ab52b472dc393ab7852fbcb11abbebfd6aaae80
32db1316dc22d3f7c3d631e24df13ef23d3b381a1c
3e04abcc745d402ee3a031ac2718fae63b240837b4
f657f29ca4702da9af22a3a019d68904a969ddb01b
cf941df70af042f4fae5cbeb9c2151b324f387e525
094c41
ct =
0x7fe1a4f743675d1987d25d38111fae0f78bbea68
52cba5beda47db76d119a3efe24cb04b9449f53bec
d43b0b46e269826a983f832abb53b7a7e24a43ad15
378344ed5c20f51e268186d24c76050c1e73647523
bd5f91d9b6ad3e86bbf9126588b1dee21e6997372e
36c3e74284734748891829665086e0dc523ed23c38
6bb520
while a != 0:
q, r = b//a, b%a
m, n = x-u*q, y-v*q
gcd = b
return gcd, x, y
d = a #a is decryption key
out = hex(d)
pt = pow(ct, d, n)
out = hex(pt)
out = str(out[2:-1])
print "flag"
print out.decode("hex")
Don't forget to replace [p,q,e] with the values you
have. For [ct] it's the cipher text which needs
decryption.
root@kali:./RsaCtfTool.py --publickey
/root/Desktop/key.pub --uncipherfile
/root/Desktop/pass.crypt
https://github.com/unode/firefox_decrypt
Then run it after specifying the path of the profile
ROT13 Algorithm
Manual encryption and decryption
Encrypt a string [test]
Using Tools
https://rot13.com/
Steganography
Image steganography
Decoding payloads in JPEG,WAV or
AU files
https://futureboy.us/stegano/decinput.html
binwalk image.png
binwalk -e image.png
https://29a.ch/photo-forensics/#strings
https://futureboy.us/stegano/decinput.html
Note
Sometimes the image is protected by a passphrase
which you need to supply in order to extract the
hidden information.
You can use the below script to brute force the
password and reveal the hidden files
Audio Steganography
Images can be encoded inside audio files with a
technique called [spectrogram]. Using Audio
visualizer] or [Sonic Visualizer] we can decode
images encoded inside Audio files.
Before doing that lets first understand the process
of Spectrology] which is converting or encoding
images to audio files. The python script below can
be used to encode images into audio files. Script
author is
[https://github.com/solusipse/spectrology]
#!/usr/bin/env python
'''
Spectrology
License: MIT
Website:
https://github.com/solusipse/spectrology
'''
from PIL import Image, ImageOps
def parser():
parser = argparse.ArgumentParser()
parser.add_argument("INPUT", help="Name of
the image to be convected.")
parser.add_argument("-r", "--rotate",
help="Rotate image 90 degrees for
waterfall spectrographs.",
action='store_true')
parser.add_argument("-i", "--invert",
help="Invert image colors.",
action='store_true')
parser.add_argument("-o", "--output",
help="Name of the output wav file. Default
value: out.wav).")
parser.add_argument("-b", "--bottom",
help="Bottom frequency range. Default
value: 200.", type=int)
parser.add_argument("-t", "--top",
help="Top frequency range. Default value:
20000.", type=int)
parser.add_argument("-p", "--pixels",
help="Pixels per second. Default value:
30.", type=int)
parser.add_argument("-s", "--sampling",
help="Sampling rate. Default value:
44100.", type=int)
args = parser.parse_args()
minfreq = 200
maxfreq = 20000
wavrate = 44100
pxs = 30
output = "out.wav"
rotate = False
invert = False
if args.output:
output = args.output
if args.bottom:
minfreq = args.bottom
if args.top:
maxfreq = args.top
if args.pixels:
pxs = args.pixels
if args.sampling:
wavrate = args.sampling
if args.rotate:
rotate = True
if args.invert:
invert = True
img = Image.open(inpt).convert('L')
if rotate:
img = img.rotate(90)
if invert:
img = ImageOps.invert(img)
data = array.array('h')
tm = timeit.default_timer()
for x in range(img.size[0]):
row = []
for y in range(img.size[1]):
yinv = img.size[1] - y - 1
amp = img.getpixel((x,y))
for i in range(fpx):
for j in row:
try:
except(IndexError):
except(OverflowError):
if j[i] > 0:
else:
data[i + x * fpx] = -32768
sys.stdout.write("Conversion progress:
%d%% \r" % (float(x) / img.size[0]*100) )
sys.stdout.flush()
output.writeframes(data.tostring())
output.close()
tms = timeit.default_timer()
a = []
for i in range(samples):
x = math.sin(float(cycles) * 2 * math.pi *
i / float(samples)) * float(amplitude)
a.append(int(math.floor(x)))
return a
if __name__ == '__main__':
inpt = parser()
convert(*inpt)
https://www.dcode.fr/ook-language
The Brainfuck
+++++ +++++ [->++ +++++ +++<] >++++ +.---
--.++ +++++ .<+++ [->++ +<]>+ ++.<+ ++[->
---<] >---- --.-- ----- .<+++ +[->+ +++<]
>+++. <+++[ ->--- <]>-- .<+++ [->++ +<]>+
.---. <+++[ ->--- <]>-- ----. <++++ [->++
++<]> ++..<
Decode with
https://copy.sh/brainfuck/
https://www.dcode.fr/ook-language
Resources
Encoding and Decoding
https://gchq.github.io/CyberChef/
https://www.dcode.fr/en
Hashing
MD5
Generating md5 checksum for a file
md5sum file
SHA1
Generating SHA1 checksum for a file
$ sha1sum file
$ shasum file
$ shasum file