Sign in to follow this  
Followers 0
Kilhian

Steganography

5 posts in this topic

#1 ·  Posted (edited)

I've found an old library from Evilertoaster

so i developped this:

#Include <String.au3>
#Include <Array.au3>
#include <BMP.au3>

HotKeySet("{ESC}", "Terminate")

$File2encrypt=@ScriptDir&"\list.ini"
$File2save=@ScriptDir&"\list.bmp"; picture hosting file


$File_content=FileRead($File2encrypt)
$File_content&="#0"
$File_lengh=StringLen($File_content)
$File_char=StringSplit($File_content,"");store each char of the file in an array
_ArrayDelete($File_content,0)
Dim $Color_Encrypted[UBound($File_char)]

$bmp_hnd=_BMPOpen(@ScriptDir&"\Muestra1.bmp",1); picture use as mask
$bmp_width=_BMPGetWidth($bmp_hnd)
$bmp_height=_BMPGetHeight($bmp_hnd)
$nPixel=$bmp_width*$bmp_height
Dim $Store_Pixel[$nPixel]
If $File_lengh >$nPixel Then Terminate()

$i=0
For $y=0 to $bmp_height-1
    For $x=0 to $bmp_width-1
        $Store_Pixel[$i]=_PixelRead($bmp_hnd,$X,$Y);record each pixel in a array
        $i+=1
    Next
Next

For $i =0 to UBound($File_char)
    $Color_Encrypted[$i]=Encrypt_Color($Store_Pixel[$i],$File_char[$i]); crypt each char in color and return the new color
Next

$i=0
For $y=0 to $bmp_height-1
    For $x=0 to $bmp_width-1
            Select
                Case $i < UBound($File_char)
                    _PixelWrite($bmp_hnd,$X,$Y,$Color_Encrypted[$i]);replace origin pixel by crypted pixels
            EndSelect
        $i+=1
    Next
Next


_BMPWrite($bmp_hnd,$File2save);save the file
MsgBox(0,"",@error)

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_R,2)&Hex($En_V,2)&Hex($En_B,2)
Return $En_Color
Endfunc

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

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

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

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

function _BMPWrite is bugged :)

bmp.au3 is here

I prefer not using extra system dll (prospeed) if possible..

I didn' find anything with _gdiplus fonctions

Anyone have an idea to fix it?

edit: comment added in the code

Edited by Kilhian

Share this post


Link to post
Share on other sites



40 visits and no hint?

Share this post


Link to post
Share on other sites

Why not use Encrypt, Embeding file in JPG? the program works excellent:)


Never argue with an idiot, he will just bring you down to his own level and beat you with experience! :D

Share this post


Link to post
Share on other sites

Why not use Encrypt, Embeding file in JPG? the program works excellent:)

hi,

First, the code you suggest me only embed a file by a dos concatenation:

_RunDOS('copy /b ' & '"' & $configfilename & '"' & ' + ' & '"' & $compfilename & '" ' & '"' & $realoutput & '"')

2, how to deconcatenate it?

3, I like coding my solutions :)

Kilhian

Share this post


Link to post
Share on other sites

New Code Updated...

Save still not fixed

#Include <String.au3>
#Include <Array.au3>
#include <BMP.au3>
#include <GUIConstants.au3>
HotKeySet("{ESC}", "Terminate")
Opt("GUIOnEventMode", 1)
$Main_Form = GUICreate("Stégano-Crypt", 208, 224, 193, 125)
$tab = GUICtrlCreateTab(0, 0, 208, 224)
;Onglet 1
$tab0 = GUICtrlCreateTabItem("Encrypt")
GUICtrlCreateLabel("Fichier à crypter", 4, 28, 79, 17)
GUICtrlCreateLabel("Fichier masque", 4, 76, 75, 17)
GUICtrlCreateLabel("Enregistrer sous", 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("Parcourir", 128, 48, 75, 25, 0)
$Browse2 = GUICtrlCreateButton("Parcourir", 128, 96, 75, 25, 0)
$Browse3 = GUICtrlCreateButton("Parcourir", 128, 144, 75, 25, 0)
$Launch = GUICtrlCreateButton("Lancer", 68, 188, 75, 25, 0)
;Onglet 2
$tab1 = GUICtrlCreateTabItem("Decrypt")

GUICtrlCreateTabItem(""); end tabitem definition
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
;GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
;GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
;GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
GUICtrlSetOnEvent($Browse1, "Browse")
GUICtrlSetOnEvent($Browse2, "Browse")
GUICtrlSetOnEvent($Browse3, "Browse")
GUICtrlSetOnEvent($Launch, "Launch")


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,".")
                GUICtrlSetData($File2save, $name[1]&"-crypted.bmp")
            Case 12
                $Filename = FileOpenDialog($message, '', 'Fichier Bitmap (*.bmp)|All files (*.*)', 8)
                GUICtrlSetData($File_Mask, $Filename)
            Case 13
                $Filename = FileOpenDialog($message, '', 'Fichier Bitmap (*.bmp)|All files (*.*)', 8)
                GUICtrlSetData($File2save, $Filename)
        EndSwitch
    EndIf
EndFunc

Func Launch()
$File_content=FileRead(GUICtrlRead($File2encrypt))
$File_content&="#0"
$File_lengh=StringLen($File_content)
$File_char=StringSplit($File_content,"");store each char of the file in an array
_ArrayDelete($File_content,0)
Dim $Color_Encrypted[UBound($File_char)]

$bmp_hnd=_BMPOpen(GUICtrlRead($File_Mask),1); picture use as mask
;_ArrayDisplay($bmp_hnd)
$bmp_width=_BMPGetWidth($bmp_hnd)
$bmp_height=_BMPGetHeight($bmp_hnd)
$nPixel=$bmp_width*$bmp_height
Dim $Store_Pixel[$nPixel]
If $File_lengh >$nPixel Then Terminate()
Dim $error
$i=0
For $y=0 to $bmp_height-1
    For $x=0 to $bmp_width-1
        If $i<UBound($File_char)Then
            _PixelWrite($bmp_hnd,$X,$Y,Encrypt_Color(_PixelRead($bmp_hnd,$X,$Y),$File_char[$i])); crypt each char in color and return the new color
            $error&=@error
            $i+=1
        EndIf
    Next
Next
MsgBox(0,"",$error)
;_ArrayDisplay($bmp_hnd)
_BMPWrite($bmp_hnd,GUICtrlRead($File2save));save the file
MsgBox(0,"",@error)
EndFunc

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_R,2)&Hex($En_V,2)&Hex($En_B,2)
Return $En_Color
Endfunc

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

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

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

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

I finally will try it with prospeed..

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