SHARE
TWEET

Untitled

a guest Aug 9th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #cs ----------------------------------------------------------------------------
  2.  Auteur      : iDuty
  3.  Function    :
  4.  this script has for purpose to transform one file, in hexadecimal code,
  5.  so that it can be included in a code. Like a bat file or au3 ...
  6. #ce ----------------------------------------------------------------------------
  7. #include <ButtonConstants.au3>
  8. #include <ComboConstants.au3>
  9. #include <GUIConstantsEx.au3>
  10. #include <ProgressConstants.au3>
  11. #include <StaticConstants.au3>
  12. #include <WindowsConstants.au3>
  13. #Include <Clipboard.au3>
  14. #include <GUIConstants.au3>
  15. #include <File.au3>
  16. #include <string.au3>
  17.  
  18. Global $Form1, $Button1, $Button2, $Button3, $Progress1, $sFile = Default, $Path = Default
  19. Global $Combo1, $Label1
  20. _CreatGui()
  21.  
  22. While 1
  23.    $nMsg = GUIGetMsg()
  24.       Switch $nMsg
  25.             Case $GUI_EVENT_CLOSE
  26.                Exit
  27.  
  28.             Case $Button1
  29.               $Path = FileOpenDialog("File to convert", @DesktopDir, "All Files (*.*)")
  30.               if not @error Then
  31.                 $sFile = _FileGetName($Path, 1)
  32.                 WinSetTitle($Form1, "", "<b style="color:#E89512">Bexa</b> v3.3  |" & $sFile & " --> "& guictrlread($Combo1))
  33.               EndIf
  34.  
  35.             Case $Button2
  36.               if $sFile <> Default then
  37.                 if GUICtrlRead($Combo1) = "Convertion vers fichiers batch" then _File_Bexa($Path, $sFile)
  38.                 if GUICtrlRead($Combo1) = "Convertion vers fichier autoit" then _File_Au3xa($Path, $sFile)
  39.                 if GUICtrlRead($Combo1) = "retourne l'Hexadecimal seulement" then _GetHexaDec($Path)
  40.               EndIf
  41.       EndSwitch
  42. WEnd
  43.  
  44.  
  45. Func _CreatGui()
  46.    #Region ### START Koda GUI section ### Form=
  47.       $Form1 = GUICreate("<b style="color:#E89512">Bexa</b> v3.3", 331, 74, 282, 208)
  48.       $Progress1 = GUICtrlCreateProgress(8, 40, 313, 25)
  49.       $Button1 = GUICtrlCreateButton("...", 8, 8, 57, 25)
  50.       GUICtrlSetTip($Button1, "Please, choose the file to convert...")
  51.       $Combo1 = GUICtrlCreateCombo("Convertion vers fichiers batch", 72, 10, 209, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE))
  52.       GUICtrlSetData($Combo1, "Convertion vers fichier autoit|retourne l'Hexadecimal seulement")
  53.       $Button2 = GUICtrlCreateButton("GO", 288, 8, 33, 25)
  54.       GUISetState(@SW_SHOW)
  55.    #EndRegion ### END Koda GUI section ###
  56. Endfunc
  57.  
  58.  
  59. func _FileGetName($sLien, $sExt=Default)
  60.    if not FileExists($sLien) then Exit
  61.    Local $sName = StringSplit($sLien, "\"), $without_E
  62.    $sName = $sName[$sName[0]]
  63.    if $sExt = Default then
  64.       Return $sName
  65.    elseif $sExt = 1 then
  66.       $without_E = StringSplit($sName, ".")
  67.       $without_E = $without_E[$without_E[0]-1]
  68.       Return $without_E
  69.    Endif
  70. Return
  71. Endfunc
  72.  
  73.  
  74. Func _File_Bexa($Path, $sFile="")
  75.    if not FileExists($Path) then exit
  76.    if $sFile = "" then Return
  77.      
  78.    Local $WithExt = _FileGetName($Path)
  79.    Local $sOp, $sRe, $sLi, $Ubound, $String
  80.    Local $FilCompress = StringTrimRight($WithExt, 1) & "_"
  81.    Local $PathCompress = stringreplace($path, $WithExt, $FilCompress)
  82.  
  83. ConsoleWrite($FilCompress&@CRLF)
  84.  
  85.    $sOp = FileOpen($Path, 16)
  86.       $sRe = FileRead($sOp)
  87.       FileClose($sOp)
  88.    $sLi = StringRegExp($sRe, "(.{1,64})", 3)
  89.       $Ubound = UBound($sLi)
  90.       $sLi[0] = StringTrimLeft($sLi[0], 2)
  91.  
  92.    If $Ubound = 1 Then
  93.  
  94.       $String &= '@echo off ' & @CRLF & ':' & $sFile & @CRLF & 'For %%b In (' & @CRLF & '"' & $sLi[0] & '"' & @CRLF
  95.       $String &= ') Do >> "' & $FilCompress & '" (Echo.For b=1 To len^(%%b^) Step 2' & @CRLF & 'Echo WScript.StdOut.Write Chr^(Clng^("&H"^&Mid^(%%b,b,2^)^)^) : Next)' & @CRLF & _
  96.       'Cscript /b /e:vbs "' & $FilCompress & '" > "' & $WithExt & '"' & @CRLF & 'Del "' & $FilCompress & '" >nul 2>&1'
  97.       GUICtrlSetData($Progress1, 100)
  98.       _ClipBoard_SetData($String)
  99.       FileDelete(@TempDir & "\BexaTmp.bat")
  100.       FileWrite(@TempDir & "\BexaTmp.bat", $String)
  101.       ShellExecute(@TempDir & "\BexaTmp.bat", '', '', "edit")
  102.  
  103.    elseif $Ubound > 1 Then
  104.  
  105.       $String &= '@echo off ' & @CRLF & ':"' & $sFile & '"' & @CRLF & 'For %%b In (' & @CRLF
  106.       For $i = 0 To $Ubound - 1 Step 1
  107.            $String &= '    "' & $sLi[$i] & '"' & @CRLF
  108.          GUICtrlSetData($Progress1, $i/(($Ubound - 2)/100))
  109.        Next
  110.       $String &= ') Do >> "' & $FilCompress & '" (Echo.For b=1 To len^(%%b^) Step 2' & @CRLF & _
  111.       'Echo WScript.StdOut.Write Chr^(Clng^("&H"^&Mid^(%%b,b,2^)^)^) : Next)' & @CRLF & _
  112.       'Cscript /b /e:vbs "' & $FilCompress & '" > "' & $WithExt & '"' & @CRLF & 'Del "' & $FilCompress & '" >nul 2>&1'
  113.       _ClipBoard_SetData($String)
  114.       FileDelete(@TempDir & "\BexaTmp.bat")
  115.       FileWrite(@TempDir & "\BexaTmp.bat", $String)
  116.       ShellExecute(@TempDir & "\BexaTmp.bat", '', '', "edit")
  117.       ;MsgBox(0, "<b style="color:#E89512">Bexa</b> v3.3", "Your file have been converted to hexadecimal and set in your batch file." & @CRLF & "ctrl + v if you want paste him")
  118.    Endif
  119.    FileRecycle($PathCompress)
  120. Endfunc
  121.  
  122.  
  123. Func _File_Au3xa($Path, $sFile="")
  124. if not FileExists($Path) then exit
  125. if $sFile = "" then Return
  126.  
  127. Local $sOp, $sRe, $sLi, $Ubound, $String
  128. Local $WithExt = _FileGetName($Path)
  129. Local $GetExtention = StringSplit($WithExt, ".")
  130. $GetExtention = $GetExtention[$GetExtention[0]]
  131. $WithExt = StringReplace($WithExt, ".", "_")
  132. $sOp = FileOpen($Path, 16)
  133. $sRe = FileRead($sOp)
  134. FileClose($sOp)
  135. $sLi = StringRegExp($sRe, "(.{1,128})", 3)
  136. $Ubound = UBound($sLi)
  137.  
  138. If $Ubound = 1 Then
  139.  
  140.    $String &= ';~ Local $Teste = _' & $sFile & '()' & @CRLF & ';~ _BinaryToFile(@DesktopDir & "\Teste.' &$GetExtention&'" , $Teste) ' & @CRLF
  141.    $String &= 'Func _' & $sFile & '()' & @CRLF
  142.    $String &= 'Local $FileName = ' & $WithExt & @CRLF
  143.    $String &= 'Local _' & @CRLF & '$File_' & $sFile & ' = "' & $sLi[0] & '"' & @CRLF
  144.    $String &= 'Return Binary(' & '$File_' & $sFile & ')' & @CRLF & 'Endfunc'
  145.    _ClipBoard_SetData($String)
  146.    GUICtrlSetData($Progress1, 100)
  147.  
  148. elseif $Ubound > 1 Then
  149.  
  150.    $String &= ';~ Local $Teste = _' & $sFile & '()' & @CRLF & ';~ _BinaryToFile(@DesktopDir & "\Teste.' &$GetExtention&'" , $Teste) ' & @CRLF
  151.    $String &= 'Func _' & $sFile & '()' & @CRLF
  152.    $String &= 'Local $FileName = "' & $WithExt & '"' & @CRLF
  153.    $String &= 'Local _' & @CRLF
  154.    $String &= '$File_' & $sFile & ' = "' & $sLi[0] & '"' & @CRLF
  155.  
  156.    For $i = 1 To $Ubound - 1 Step 1
  157.       $String &= '$File_' & $sFile & ' &= "' & $sLi[$i] & '"' & @CRLF
  158.       GUICtrlSetData($Progress1, $i/(($Ubound - 2)/100))
  159.     Next
  160.    $String &= 'Return Binary(' & '$File_' & $sFile & ')' & @CRLF & 'Endfunc' & @crlf & @crlf
  161.  
  162.    $String &= 'Func _BinaryToFile($Path=Default, $Binary=Default)' & @CRLF
  163.    $String &= 'if $Binary = Default or $Path = Default then Return' & @crlf
  164.    $String &= 'FileDelete($Path)' & @CRLF
  165.    $String &= 'FileWrite($Path, $Binary);~    ShellExecute($Path)' & @crlf & 'Return' & @CRLF & 'Endfunc'
  166.  
  167.  
  168.  
  169.    _ClipBoard_SetData($String)
  170.    FileDelete(@TempDir & "\BexaTmp.au3")
  171.    FileWrite(@TempDir & "\BexaTmp.au3", $String)
  172.    ShellExecute(@TempDir & "\BexaTmp.au3", '', '', "edit")
  173.  
  174.    MsgBox(0, "<b style="color:#E89512">Bexa</b> v3.2", "Your file have been converted to hexadecimal and set in your Au3 file." & @CRLF & "ctrl + v if you want paste him")
  175.    Return
  176. Endif
  177.  
  178. Endfunc
  179.  
  180.  
  181. Func _GetHexaDec($Path=Default)
  182.    if not FileExists($Path) then Return
  183.    Local $sOp, $sRe, $sLi, $Ubound, $String
  184.    $sOp = FileOpen($Path, 16)
  185.    $sRe = FileRead($sOp)
  186.    FileClose($sOp)
  187.    $sLi = StringRegExp($sRe, "(.{1,256})", 3)
  188.    $Ubound = UBound($sLi)
  189.    $sLi[0] = StringTrimLeft($sLi[0], 2)
  190.  
  191. if $Ubound = 1 Then
  192.    $String &= $sLi[0] & @CRLF
  193.    _ClipBoard_SetData($String)
  194.    GUICtrlSetData($Progress1, 100)
  195. ElseIf $Ubound > 1 Then
  196.    For $i = 0 To $Ubound - 1 Step 1
  197.       $String &= $sLi[$i] & @CRLF
  198.       GUICtrlSetData($Progress1, $i/(($Ubound - 2)/100))
  199.     Next
  200.    FileDelete(@TempDir&"\BexaTmp.txt")
  201.    FileWrite(@TempDir&"\BexaTmp.txt", $String)
  202.    ShellExecute(@TempDir&"\BexaTmp.txt", '', '', "edit")
  203. Endif
  204.  
  205. Endfunc
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top