Sign in to follow this  
Followers 0
Kilhian

Steganography

12 posts in this topic

#1 ·  Posted (edited)

Hi,

Definition

I have discobvered autoit middle of december... please be indulgent :)

Big thanks to JPam and Nordwind (Prospeed Team) ;)

This my first open-source script :D

the aim of this script is to embed a file in a bitmap file

tab Encrypt:

input1:select the file you want to hide (*.doc, pdf, zip... what you want)

input2:select the *.bmp file who will host the future hidden file

then launch

tab decrypt

input1:select the file you want to decrypt

prospeed.au3 need prospeed.dll

they can be found here

bmp.au3 is no more needed

if you don't have prospeed.dll in prospeed.au3 dir you will get error type aVector

#include <String.au3>
#include <Array.au3>
#include <Prospeed.au3>
#include <GUIConstants.au3>
HotKeySet("{ESC}", "Terminate")
Opt("GUIOnEventMode", 1)

$X_Gui = 193
$Y_Gui = 125
$Gui_Width = 208
$Gui_Heigth = 224

$Main_Form = GUICreate("Stégano-Crypt", $Gui_Width, $Gui_Heigth, $X_Gui, $Y_Gui)
$tab = GUICtrlCreateTab(0, 0, $Gui_Width, $Gui_Heigth)
;Onglet 1
$tab0 = GUICtrlCreateTabItem("Encrypt")
GUICtrlCreateLabel("File to Crypt", 4, 28, 79, 17)
GUICtrlCreateLabel("Decoy File", 4, 76, 75, 17)
GUICtrlCreateLabel("Save as...", 4, 124, 79, 17)
$File2encrypt = GUICtrlCreateInput("", 4, 48, 121, 21)
$File_Mask = GUICtrlCreateInput("", 4, 96, 121, 21)
$File2save = GUICtrlCreateInput("", 4, 144, 121, 21)
$Browse1 = GUICtrlCreateButton("Browse...", 128, 48, 75, 25, 0)
$Browse2 = GUICtrlCreateButton("Browse...", 128, 96, 75, 25, 0)
$Browse3 = GUICtrlCreateButton("Browse...", 128, 144, 75, 25, 0)
$Launch_encrypt = GUICtrlCreateButton("Launch", 68, 188, 75, 25, 0)
;Onglet 2
$tab1 = GUICtrlCreateTabItem("Decrypt")
$File2decrypt = GUICtrlCreateInput("", 4, 48, 121, 21)
$Browse4 = GUICtrlCreateButton("Browse...", 128, 48, 75, 25, 0)
$Launch_decrypt = GUICtrlCreateButton("Launch", 68, 188, 75, 25, 0)

GUICtrlCreateTabItem(""); end tabitem definition
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
GUICtrlSetOnEvent($Browse1, "Browse")
GUICtrlSetOnEvent($Browse2, "Browse")
GUICtrlSetOnEvent($Browse3, "Browse")
GUICtrlSetOnEvent($Browse4, "Browse")
GUICtrlSetOnEvent($Launch_encrypt, "Launch_encrypt")
GUICtrlSetOnEvent($Launch_decrypt, "Launch_decrypt")


While 1
    
    Sleep(100)
WEnd

Func Browse()
    ;MsgBox(0, "", @GUI_CtrlHandle & @CRLF & @GUI_CtrlId)
    $message = "Choisissez un fichier..."
    If @error <> 1 Then
        Switch @GUI_CtrlId
            Case 11
                $Filename = FileOpenDialog($message, '', 'All files (*.*)', 8)
                GUICtrlSetData($File2encrypt, $Filename)
                $name = StringSplit($Filename, ".")
                If GUICtrlRead($File_Mask) = "" Then
                    GUICtrlSetData($File2save, $name[1] & "-crypted")
                Else
                    $ext = StringSplit(GUICtrlRead($File_Mask), ".")
                    GUICtrlSetData($File2save, $name[1] & "-crypted" & "." & $ext[2])
                EndIf
            Case 12
                $Filename = FileOpenDialog($message, '', 'Bitmap (*.bmp)|(*.jpg)|All files (*.*)', 8)
                GUICtrlSetData($File_Mask, $Filename)
                $name = StringSplit($Filename, ".")
                If GUICtrlRead($File2encrypt) = "" Then
                    GUICtrlSetData($File2save, "." & $name[2])
                Else
                    GUICtrlSetData($File2save, GUICtrlRead($File2save) & "." & $name[2])
                EndIf
            Case 13
                $Filename = FileOpenDialog($message, '', 'Bitmap (*.bmp)|(*.jpg)|All files (*.*)', 8)
                GUICtrlSetData($File2save, $Filename)
            Case 17
                $Filename = FileOpenDialog($message, '', 'Bitmap (*.bmp)|(*.jpg)|All files (*.*)', 8)
                GUICtrlSetData($File2decrypt, $Filename)
        EndSwitch
    EndIf
EndFunc   ;==>Browse


Func Launch_encrypt()
    $File_name_path = GUICtrlRead($File2encrypt)
    $File_name_path_array = StringSplit($File_name_path, "\")
    ;_ArrayDelete($File_name_path_array,"0")
    $File_name_string = $File_name_path_array[$File_name_path_array[0]]
    ;MsgBox(0,"$File_name_string ",$File_name_string)
    $File_content = FileRead($File_name_path)
    $File_content &= "#^0" & $File_name_string & "#^1"
    
    $File_lengh = StringLen($File_content)
    $File_char = StringSplit($File_content, "");store each char of the file in an array
    _ArrayDelete($File_content, 0)
    ;MsgBox(0, "", $File_lengh & @CRLF & UBound($File_char))
    $bmp_hnd = LoadExtImage(GUICtrlRead($File_Mask)); picture use as mask
    $bmp_width = GetBmpWidth($bmp_hnd)
    $bmp_height = GetBmpHeight($bmp_hnd)
    $array = InitExtFX($bmp_hnd)
    $arrayInfos = DllStructCreate("long;long;long;dword;dword;long;long;long;long;long;long;long", $array)
    $biSizeImage = DllStructGetData($arrayInfos, 6)
    $Pointer = DllStructGetData($arrayInfos, 11)

    $a = $biSizeImage / 4
    $z = $Pointer
    $Offset = 0

    popup($bmp_width, $bmp_height)
    GetHDC()
    CopyArray($hdc, 10, 30, $array)
    $Form2_pos = WinGetPos("Preview")
    $Form2_size = WinGetClientSize("Preview")
    ; Byte Arrays contain 3 bytes (BGR)
    ProgressOn("Progress Meter", "", "0 percent", $Form2_pos[0], $Form2_pos[0], $Form2_pos[0] + $Form2_size[1]+40)
    For $i = 0 To (UBound($File_char) - 1);$a
        $getByte = GetAByte($z + $Offset)
        $color = Encrypt_Color(Hex($getByte, 6), $File_char[$i])
        SetAByte($z + $Offset, Dec(StringMid($color, 1, 2))) ; 1 byte Blue
        SetAByte($z + $Offset + 1, Dec(StringMid($color, 3, 2))) ; 1 byte Green
        SetAByte($z + $Offset + 2, Dec(StringMid($color, 5, 2))) ; 1 byte Red
        $Offset = $Offset + 3 ; offset +3 for next Byte arrays
        ProgressSet(Int($i * 100 / UBound($File_char)), Int($i * 100 / UBound($File_char)) & " percent")
    Next
    ProgressSet(100, "Done", "Complete")
    ProgressOff()
    $bitmap2 = CreateExtBmp($bmp_width, $bmp_height)
    CopyArray($hdc, $bmp_width + 20, 30, $array)
    CopyArray($bitmap2, 0, 0, $array)
    MsgBox(0, "", "done!")
    SaveExtImage($bitmap2, GUICtrlRead($File2save), 0, 10)
EndFunc   ;==>Launch_encrypt

Func Launch_decrypt()
    $File_name_path = GUICtrlRead($File2decrypt)
    $File_name_path_array = StringSplit($File_name_path, "\")
    $File_Path=""
    _ArrayDelete($File_name_path_array, "0")
    For $i = 0 To (UBound($File_name_path_array) - 2)
        If $File_Path="" Then
            $File_Path &= $File_name_path_array[$i]
        Else
            $File_Path &= "\"&$File_name_path_array[$i]
        EndIf
    Next
    $bmp_hnd = LoadExtImage($File_name_path); picture use as mask
    $bmp_width = GetBmpWidth($bmp_hnd)
    $bmp_height = GetBmpHeight($bmp_hnd)
    $array = InitExtFX($bmp_hnd)
    $arrayInfos = DllStructCreate("long;long;long;dword;dword;long;long;long;long;long;long;long", $array)
    $biSizeImage = DllStructGetData($arrayInfos, 6)
    $Pointer = DllStructGetData($arrayInfos, 11)

    $a = $biSizeImage / 4
    $z = $Pointer
    $Offset = 0
    $Decrypt_Char = ""
    ProgressOn("Progress Meter", "", "0 percent")
    While StringInStr($Decrypt_Char,"#^1")=""
        $getByte = GetAByte($z + $Offset)
        $Decrypt_Char &= Decrypt_Color(Hex($getByte, 6))
        $Offset = $Offset + 3 ; offset +3 for next Byte arrays
        ProgressSet(Int($i * 100 / $a), Int($i * 100 / $a) & " percent")
    WEnd
    ProgressSet(100, "Done", "Complete")
    ProgressOff()
    $Decrypt_Char = StringTrimLeft($Decrypt_Char,1)
    $File = StringSplit($Decrypt_Char, "#^0",1)
    _ArrayDelete($File,"0")
    ;_ArrayDisplay($File)
    $File_Name = StringReplace($File[1], "#^1", "")
    $File_Name_array = StringSplit($File_Name, ".")
    _ArrayDelete($File_Name_array ,"0")
    $save_path=$File_Path & "\" & $File_Name_array[0] & "-decrypted." & $File_Name_array[1]
    $File2save=FileOpen($save_path,9)
    FileWrite($File2save, $File[0])
    FileClose($File2save)
    MsgBox(0, "", "done!")
EndFunc   ;==>Launch_decrypt

Func Encrypt_Color($color, $Char)
    $Char = AscW($Char)
    $Rcolor = Dec(StringMid($color, 1, 2))
    $Vcolor = Dec(StringMid($color, 3, 2))
    $Bcolor = Dec(StringMid($color, 5, 2))
    $r = 248
    $v = 248
    $b = 252
    $rc = 7
    $vc = 56
    $bc = 192
    $En_R = BitOR(BitAND($Rcolor, $r), BitAND($Char, $rc))
    $En_V = BitOR(BitAND($Vcolor, $v), _Dec("000" & StringTrimRight(_bin(BitAND($Char, $vc)), 3)))
    $En_B = BitOR(BitAND($Bcolor, $B), _Dec("000000" & StringTrimRight(_bin(BitAND($Char, $bc)), 6)))
    $En_Color = Hex($En_B, 2) & Hex($En_V, 2) & Hex($En_R, 2)
    Return $En_Color
EndFunc   ;==>Encrypt_Color

Func Decrypt_Color($En_Color)
    $En_Rcolor = Dec(StringMid($En_Color, 1, 2))
    $En_Vcolor = Dec(StringMid($En_Color, 3, 2))
    $En_Bcolor = Dec(StringMid($En_Color, 5, 2))
    $er = 7
    $ev = 7
    $eb = 3
    $De_R = BitAND($En_Rcolor, $er)
    $De_V = _Dec(StringTrimLeft(_bin(BitAND($En_Vcolor, $ev)), 3) & "000")
    $De_B = _Dec(StringTrimLeft(_bin(BitAND($En_Bcolor, $eb)), 6) & "000000")
    $De_Char = ChrW(BitOR($De_B, $De_V, $De_R))
    Return $De_Char
EndFunc   ;==>Decrypt_Color

Func _bin($decimal)
    Local $retVal, $startVal = String($decimal), $work, $work2
    For $i = 7 To 0 Step -1
        $retVal &= Int(Mod($decimal, 2))
        $decimal = $decimal / 2
    Next
    Return _StringReverse($retVal)
EndFunc   ;==>_bin

Func _Dec($bin)
    Local $retVal, $startVal = StringSplit($bin, "")
    _ArrayDelete($startVal, 0)
    _ArrayReverse($startVal)
    For $i = 7 To 0 Step -1
        $retVal += $startVal[$i] * (2 ^ $i)
    Next
    Return ($retVal)
EndFunc   ;==>_Dec

Func popup($bmp_width, $bmp_height)
    $Form2 = GUICreate("Preview", $bmp_width * 2 + 30, $bmp_height + 40, $X_Gui + $Gui_Width + 10, $Y_Gui) ;  Créé la fenetre générale
    $Label_titre1 = GUICtrlCreateLabel("Original picture", 10, 10, $bmp_width, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label_titre2 = GUICtrlCreateLabel("Crypted picture", $bmp_width + 20, 10, $bmp_width, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
    GUISetState(@SW_SHOW)
EndFunc   ;==>popup
Func close()
    $hnd2close = WinGetHandle("[active]", "")
    GUIDelete($hnd2close)
EndFunc   ;==>close

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Coming soon:

- Data source encryption

- Multi picture format file

Kilhian

Edited by Kilhian

Share this post


Link to post
Share on other sites



Ok, so after gathering prospeed.au3 and bmp.au3 and commenting out the [Global Const $WM_PAINT=0x000F] I am getting some AVector errors and not even sure what this is supposed to do or if it is something I want to keep fixing errors.. LOL Can you elaborate on what it is for me? :)

Share this post


Link to post
Share on other sites

main post edited...

More details

Share this post


Link to post
Share on other sites

That's exactly what I was making one year ago :) at least what I tried!

lol...since now i didn't know that actually had a name! damn it ;)

But I got some Errors like missing Functions (GetAByte on line 133).

Do I need the newest Beta?

Or is this just something left of the Bitmap.au3?

Share this post


Link to post
Share on other sites

Func GetABit is declared in the latest prospeedl.au3 and so dll

Share this post


Link to post
Share on other sites

I'm getting an error running this... =/

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Pressing F5 and

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\אלון\שולחן העבודה\AutoIt v3 Script חדש (4).au3"  
C:\Documents and Settings\????\????? ??????\AutoIt v3 Script ??? (4).au3 (3) : ==> Error opening the file.: 
#include <Prospeed.au3> 

>Exit code: 1   Time: 0.328

Share this post


Link to post
Share on other sites

the easiest way, put prospeed.au3 and prospeed.dll in your include folder

Share this post


Link to post
Share on other sites

Hi Kilhian,

Really nice script.

However when I run decoder on a 16 Bit color desktop I get the following -console debug- output

$Decrypt_Char = ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

$En_Rcolor = 255

$En_Vcolor = 255

$En_Bcolor = 255

On 32bit color desktop its ok.

Could you please let me what I might be doing wrong.

Regards,

Steven

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0