Giovanni Bassetti Immagine
 Blog personale di Nanni Bassetti... di Admin
 
"
Un computer sicuro è un computer spento e gettato in fondo al mare, con l'hard disk sbriciolato

N.B.
"
 

\\ Home Page : Articolo
NBSTEGO - bash script for steganography
Di Admin (del 19/12/2008 @ 20:30:34, in Computer Forensics, linkato 5228 volte)

Non so perchè, ma mi sono dedicato all'evoluzione di BrutalStego, ho scritto, infatti, un nuovo bash script, che fa realmente una steganografia di un testo, lo cripta in AES256 e lo nasconde in esadecimale nel file vettore.

La cosa che mi interessava era poter criptare il testo, nasconderlo e poterlo rilevare tramite immissione di password, insomma un tool di steganografia reale!

Strumenti usati:
grep, awk, dd, bc, wc, xxd, openssl

In sostanza funziona così:
si inserisce il nome del file vettore, si inserisce il nome del nuovo file (quello contenente il messaggio segreto), si inserisce il messaggio ed infine si inserisce la password.
Dopo questi input, il programmino cripta con OpenSSL in AES256 il messaggio segreto, poi lo converte in esadecimale e lo posiziona all'interno del nuovo file vettore.
L'ho testato sulle JPG e sugli MP3 e non si nota alcuna perturbazione.
Rilanciando il programmino, si può andare a svelare il messaggio segreto, inserendo il nome del file vettore e la password ; - )

Ecco lo script:

#!/bin/bash
# NBStego - by Nanni Bassetti - http://www.nannibassetti.com - nannib@libero.it
# a simple steganographic tool for Linux. Tested on  JPG, MP3, AVI
# It uses AES256 algorithm by openssl

hid ()
{

echo "Insert the message to hide:"
read ms
echo $ms>ptext
echo "Insert the file where to hide:"
read fl
echo "Insert the file name of the new file:"
read nfl
echo "Insert your password:"
read pw
# here it crypts the plaintext in cyphered text by aes25 and save it into steg.bin
openssl aes-256-cbc -in ptext -out steg.bin
# password length
lenpw=$(expr length "$pw")
lenpw_mod=$(echo 0 + 10 | bc)
# temp1.bin is the head of the new file
dd if=$fl of=temp1.bin bs=1c count=$lenpw_mod
# temp2.bin is a 10 bytes file filled of zeroes to store the secret message length
dd if=$fl of=temp2.bin bs=1c skip=$lenpw_mod count=10
# temp2.bin is the end of the new file
dd if=$fl of=temp3.bin bs=1c skip=$(echo $lenpw_mod + 10 | bc)
dd if=/dev/zero of=temp2.bin count=10 bs=1c
# hex conversion of steg.bin
cat steg.bin | xxd -p > steghex.bin
# len is the length of the steghex.bin file
len=$(wc -c steghex.bin|awk '{print $1 }')
# hex conversion of len
echo $len | xxd -p > l.bin
# it builts the new file
cat temp1.bin l.bin temp2.bin steghex.bin temp3.bin > $nfl
rm temp1.bin
rm temp2.bin
rm temp3.bin
rm steg.bin
rm steghex.bin
rm ptext
rm l.bin
echo " "
echo " -------------------------- "
echo " "

}
#-----End Hide-----


reveal ()
{
echo "Insert the file name containing the secret message:"
read nfl
echo "Insert the password:"
read pw
lenpw=$(expr length "$pw")
lenpw_mod=$(echo 0 + 10 | bc)
len=$(dd if=$nfl skip=$lenpw_mod bs=1c count=10 | xxd -r -p)
# it finds the openssl aes256 signanture into the target file and it takes the offset
sk=$(grep -iaob -m 1 "53616c746564" $nfl | awk -F ":" '{print $1}')
dd if=$nfl bs=1c skip=$sk count=$len status=noxfer | xxd -r -p | openssl aes-256-cbc -d -out text.txt -k $pw
cat text.txt
}

echo "NBSTEGO by Nanni Bassetti - 2008-12"
echo "Choose if you want to hide or to reveal:"
echo "1) Hide"
echo "2) Reveal"
read answ1
case $answ1 in
     1)  hid ;;
     2)  reveal ;;
     *)  echo "Wrong answer! Write 1 or 2"
      echo " ";;
    esac
exit

 Clicca qui per il DOWNLOAD

Articolo Articolo  Storico Storico Stampa Stampa
Ci sono 2 persone collegate

< marzo 2024 >
L
M
M
G
V
S
D
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
             

Cerca per parola chiave