Connexion
S'inscrire
Actualités
Quoi de neuf
Activités générales
Auteurs
Forums
Nouveaux messages
Rechercher un forum
Quoi de neuf
Nouveaux messages
Nouveaux messages de profil
Activités générales
Membres
Membres inscrits
Visiteurs actuels
Nouveaux messages de profil
Rechercher dans les messages des profils
Teams
Créé ton équipe
Quoi de neuf ?
Nouveaux messages
Rechercher un forum
Menu
Connexion
S'inscrire
Install the app
Install
Forums
Plateformes
PC et Serveurs
Linux
Problème d'execution script
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Vous utilisez un navigateur non à jour ou ancien. Il ne peut pas afficher ce site ou d'autres sites correctement.
Vous devez le mettre à jour ou utiliser un
navigateur alternatif
.
Répondre à la discussion
Message
<blockquote data-quote="ArKantiK" data-source="post: 7252915" data-attributes="member: 789619"><p style="text-align: center">Bonsoir <strong>[USER=527065]@Faruq[/USER]</strong>,</p> <p style="text-align: center"></p> <p style="text-align: center"></p> <p style="text-align: center">L'erreur signalé par le terminal pour le script que tu essaies de lancer dit simplement : "Le programme a rencontré une erreur de syntaxe dans le script (keepass2john.c) à la ligne 1."</p> <p style="text-align: center">Il semblerait que le script ne prenne pas en compte les commentaires (*/ /*) dans son code, ce qui l'empêche de démarrer.</p> <p style="text-align: center"></p> <p style="text-align: center">Essaie de modifier le fichier <strong>keepass2john.c</strong> dans le dossier "<strong>src</strong>" de JohnTheRipper de la manière suivante :</p> <p style="text-align: center"></p><p>[CODE]#if AC_BUILT</p><p>#include "autoconfig.h"</p><p>#endif</p><p></p><p>#include <stdarg.h></p><p>#include <stdio.h></p><p>#include <string.h></p><p>#include <stdlib.h></p><p>#include <stdint.h></p><p>#ifdef _MSC_VER</p><p>#include "missing_getopt.h"</p><p>#endif</p><p>#include <errno.h></p><p>// needs to be above sys/types.h and sys/stat.h for mingw, if -std=c99 used.</p><p>#include "jumbo.h"</p><p>#include <sys/stat.h></p><p>#include <sys/types.h></p><p>#if (!AC_BUILT || HAVE_UNISTD_H) && !_MSC_VER</p><p>#include <unistd.h> // getopt defined here for unix</p><p>#endif</p><p>#include "params.h"</p><p>#include "memory.h"</p><p>#include "memdbg.h"</p><p></p><p>#include "sha2.h"</p><p>#include "base64_convert.h"</p><p></p><p>const char *extension[] = {".kdbx"};</p><p>static char *keyfile = NULL;</p><p></p><p>// KeePass 1.x signature</p><p>uint32_t FileSignatureOld1 = 0x9AA2D903;</p><p>uint32_t FileSignatureOld2 = 0xB54BFB65;</p><p>/// <summary></p><p>/// File identifier, first 32-bit value.</p><p>/// </summary></p><p>uint32_t FileSignature1 = 0x9AA2D903;</p><p>/// <summary></p><p>/// File identifier, second 32-bit value.</p><p>/// </summary></p><p>uint32_t FileSignature2 = 0xB54BFB67;</p><p>// KeePass 2.x pre-release (alpha and beta) signature</p><p>uint32_t FileSignaturePreRelease1 = 0x9AA2D903;</p><p>uint32_t FileSignaturePreRelease2 = 0xB54BFB66;</p><p>uint32_t FileVersionCriticalMask = 0xFFFF0000;</p><p>/// <summary></p><p>/// File version of files saved by the current <c>Kdb4File</c> class.</p><p>/// KeePass 2.07 has version 1.01, 2.08 has 1.02, 2.09 has 2.00,</p><p>/// 2.10 has 2.02, 2.11 has 2.04, 2.15 has 3.00.</p><p>/// The first 2 bytes are critical (i.e. loading will fail, if the</p><p>/// file version is too high), the last 2 bytes are informational.</p><p>/// </summary></p><p>// uint32_t FileVersion32 = 0x00030000;</p><p>uint32_t FileVersion32 = 0x00040000;</p><p>uint32_t FileVersion32_4 = 0x00040000; // from KeePass 2.36 sources</p><p></p><p>// We currently support database formats up to KDBX v3.x. KDBX 4.x is not</p><p>// supported yet. See "KdbxFile.cs" in KeePass 2.36 for more information on</p><p>// KDBX 4.x format.</p><p></p><p>enum Kdb4HeaderFieldID</p><p>{</p><p> EndOfHeader = 0,</p><p> CipherID = 2,</p><p> MasterSeed = 4,</p><p> TransformSeed = 5, // KDBX 3.1, for backward compatibility only</p><p> TransformRounds = 6, // KDBX 3.1, for backward compatibility only</p><p> EncryptionIV = 7,</p><p> StreamStartBytes = 9, // KDBX 3.1, for backward compatibility only</p><p> KdfParameters = 11, // KDBX 4, superseding Transform*</p><p>};</p><p></p><p>static off_t get_file_size(char * filename)</p><p>{</p><p> struct stat sb;</p><p> if (stat(filename, & sb) != 0) {</p><p> fprintf(stderr, "! %s : stat failed, %s\n", filename, strerror(errno));</p><p> exit(-2);</p><p> }</p><p> return sb.st_size;</p><p>}</p><p></p><p>static void print_hex(unsigned char *str, int len)</p><p>{</p><p> int i;</p><p> for (i = 0; i < len; ++i)</p><p> printf("%02x", str[i]);</p><p>}</p><p></p><p>static uint64_t BytesToUInt64(unsigned char * s, const int s_size)</p><p>{</p><p> int i;</p><p> uint64_t v = 0;</p><p></p><p> for (i = 0; i < 8 && i < s_size; i++)</p><p> v |= (uint64_t)s[i] << 8 * i;</p><p> return v;</p><p>}</p><p></p><p>static uint32_t fget32(FILE * fp)</p><p>{</p><p> uint32_t v = fgetc(fp);</p><p> v |= fgetc(fp) << 8;</p><p> v |= fgetc(fp) << 16;</p><p> v |= fgetc(fp) << 24;</p><p> return v;</p><p>}</p><p></p><p>static uint16_t fget16(FILE * fp)</p><p>{</p><p> uint32_t v = fgetc(fp);</p><p> v |= fgetc(fp) << 8;</p><p> return v;</p><p>}</p><p></p><p>static void warn(const char *fmt, ...)</p><p>{</p><p> va_list ap;</p><p></p><p> va_start(ap, fmt);</p><p> if (fmt != NULL)</p><p> vfprintf(stderr, fmt, ap);</p><p> va_end(ap);</p><p> fprintf(stderr, "\n");</p><p></p><p> // exit(EXIT_FAILURE);</p><p>}</p><p></p><p>/* process KeePass 1.x databases */</p><p>static void process_old_database(FILE *fp, char* encryptedDatabase)</p><p>{</p><p> uint32_t enc_flag;</p><p> uint32_t version;</p><p> unsigned char final_randomseed[16];</p><p> unsigned char enc_iv[16];</p><p> unsigned char contents_hash[32];</p><p> unsigned char transf_randomseed[32];</p><p> uint32_t num_groups;</p><p> uint32_t num_entries;</p><p> uint32_t key_transf_rounds;</p><p> unsigned char *buffer;</p><p> int64_t filesize = 0;</p><p> int64_t datasize;</p><p> int algorithm = -1;</p><p> char *dbname;</p><p> FILE *kfp = NULL;</p><p></p><p> /* specific to keyfile handling */</p><p> int64_t filesize_keyfile = 0;</p><p> SHA256_CTX ctx;</p><p> unsigned char hash[32];</p><p> int counter;</p><p></p><p> enc_flag = fget32(fp);</p><p> version = fget32(fp);</p><p></p><p> if (fread(final_randomseed, 16, 1, fp) != 1) {</p><p> warn("%s: Error: read failed: %s.", encryptedDatabase,</p><p> strerror(errno));</p><p> return;</p><p> }</p><p> if (fread(enc_iv, 16, 1, fp) != 1) {</p><p> warn("%s: Error: read failed: %s.", encryptedDatabase,</p><p> strerror(errno));</p><p> return;</p><p> }</p><p></p><p> num_groups = fget32(fp);</p><p> num_entries = fget32(fp);</p><p> (void)num_groups;</p><p> (void)num_entries;</p><p></p><p> if (fread(contents_hash, 32, 1, fp) != 1) {</p><p> warn("%s: Error: read failed: %s.", encryptedDatabase,</p><p> strerror(errno));</p><p> return;</p><p> }</p><p> if (fread(transf_randomseed, 32, 1, fp) != 1) {</p><p> warn("%s: Error: read failed: %s.", encryptedDatabase,</p><p> strerror(errno));</p><p> return;</p><p> }</p><p></p><p> key_transf_rounds = fget32(fp);</p><p> /* Check if the database is supported */</p><p> if ((version & 0xFFFFFF00) != (0x00030002 & 0xFFFFFF00)) {</p><p> fprintf(stderr, "! %s : Unsupported file version (%u)!\n", encryptedDatabase, version);</p><p> return;</p><p> }</p><p> /* src/Kdb3Database.cpp from KeePass 0.4.3 is authoritative */</p><p> if (enc_flag & 2) {</p><p> algorithm = 0; // AES</p><p> } else if (enc_flag & 8) {</p><p> algorithm = 1; // Twofish</p><p> } else {</p><p> fprintf(stderr, "! %s : Unsupported file encryption (%u)!\n", encryptedDatabase, enc_flag);</p><p> return;</p><p> }</p><p></p><p> /* keyfile processing */</p><p> if (keyfile) {</p><p> kfp = fopen(keyfile, "rb");</p><p> if (!kfp) {</p><p> fprintf(stderr, "! %s : %s\n", keyfile, strerror(errno));</p><p> return;</p><p> }</p><p> filesize_keyfile = (int64_t)get_file_size(keyfile);</p><p> }</p><p></p><p> dbname = strip_suffixes(basename(encryptedDatabase), extension, 1);</p><p> filesize = (int64_t)get_file_size(encryptedDatabase);</p><p> datasize = filesize - 124;</p><p> if (datasize < 0) {</p><p> warn("%s: Error in validating datasize.", encryptedDatabase);</p><p> return;</p><p> }</p><p> // offset (124) field below is not used, we hijack it to convey the</p><p> // algorithm.</p><p> // printf("%s:$keepass$*1*%d*%d*", dbname, key_transf_rounds, 124);</p><p> printf("%s:$keepass$*1*%d*%d*", dbname, key_transf_rounds, algorithm);</p><p> print_hex(final_randomseed, 16);</p><p> printf("*");</p><p> print_hex(transf_randomseed, 32);</p><p> printf("*");</p><p> print_hex(enc_iv, 16);</p><p> printf("*");</p><p> print_hex(contents_hash, 32);</p><p></p><p> buffer = (unsigned char*)malloc(datasize * sizeof(char));</p><p></p><p> /* we inline the content with the hash */</p><p> fprintf(stderr, "Inlining %s\n", encryptedDatabase);</p><p> printf("*1*%"PRId64"*", datasize);</p><p> fseek(fp, 124, SEEK_SET);</p><p> if (fread(buffer, datasize, 1, fp) != 1) {</p><p> warn("%s: Error: read failed: %s.",</p><p> encryptedDatabase, strerror(errno));</p><p> MEM_FREE(buffer);</p><p> return;</p><p> }</p><p></p><p> print_hex(buffer, datasize);</p><p> MEM_FREE(buffer);</p><p></p><p> if (keyfile) {</p><p> buffer = (unsigned char*)malloc(filesize_keyfile * sizeof(char));</p><p> printf("*1*64*"); /* inline keyfile content */</p><p> if (fread(buffer, filesize_keyfile, 1, kfp) != 1) {</p><p> warn("%s: Error: read failed: %s.",</p><p> encryptedDatabase, strerror(errno));</p><p> return;</p><p> }</p><p></p><p> /* as in Keepass 1.x implementation:</p><p> * if filesize_keyfile == 32 then assume byte_array</p><p> * if filesize_keyfile == 64 then assume hex(byte_array)</p><p> * else byte_array = sha256(keyfile_content)</p><p> */</p><p></p><p> if (filesize_keyfile == 32)</p><p> print_hex(buffer, filesize_keyfile);</p><p> else if (filesize_keyfile == 64){</p><p> for (counter = 0; counter <64; counter++)</p><p> printf("%c", buffer[counter]);</p><p> }</p><p> else{</p><p> /* precompute sha256 to speed-up cracking */</p><p> SHA256_Init(&ctx);</p><p> SHA256_Update(&ctx, buffer, filesize_keyfile);</p><p> SHA256_Final(hash, &ctx);</p><p> print_hex(hash, 32);</p><p> }</p><p> MEM_FREE(buffer);</p><p> }</p><p> printf("\n");</p><p>}</p><p></p><p>// Synchronize with KdbxFile.Read.cs from KeePass 2.x</p><p>static void process_database(char* encryptedDatabase)</p><p>{</p><p> // long dataStartOffset;</p><p> unsigned long transformRounds = 0;</p><p> unsigned char *masterSeed = NULL;</p><p> int masterSeedLength = 0;</p><p> unsigned char *transformSeed = NULL;</p><p> int transformSeedLength = 0;</p><p> unsigned char *initializationVectors = NULL;</p><p> int initializationVectorsLength = 0;</p><p> unsigned char *expectedStartBytes = NULL;</p><p> int endReached, expectedStartBytesLength = 0;</p><p> uint32_t uSig1, uSig2, uVersion;</p><p> FILE *fp;</p><p> unsigned char out[32];</p><p> char *dbname;</p><p> long algorithm = 0; // 0 -> AES</p><p> size_t fsize = 0;</p><p></p><p> /* specific to keyfile handling */</p><p> unsigned char *buffer;</p><p> int64_t filesize_keyfile = 0;</p><p> char *p;</p><p> char *data;</p><p> char b64_decoded[128+1];</p><p> FILE *kfp = NULL;</p><p> SHA256_CTX ctx;</p><p> unsigned char hash[32];</p><p> int counter;</p><p></p><p> fp = fopen(encryptedDatabase, "rb");</p><p> if (!fp) {</p><p> fprintf(stderr, "! %s : %s\n", encryptedDatabase, strerror(errno));</p><p> return;</p><p> }</p><p> fseek(fp, 0, SEEK_END);</p><p> fsize = ftell(fp);</p><p> fseek(fp, 0, SEEK_SET);</p><p> uSig1 = fget32(fp);</p><p> uSig2 = fget32(fp);</p><p> if ((uSig1 == FileSignatureOld1) && (uSig2 == FileSignatureOld2)) {</p><p> process_old_database(fp, encryptedDatabase);</p><p> fclose(fp);</p><p> return;</p><p> }</p><p> if ((uSig1 == FileSignature1) && (uSig2 == FileSignature2)) {</p><p> }</p><p> else if ((uSig1 == FileSignaturePreRelease1) && (uSig2 == FileSignaturePreRelease2)) {</p><p> }</p><p> else {</p><p> fprintf(stderr, "! %s : Unknown format: File signature invalid\n", encryptedDatabase);</p><p> fclose(fp);</p><p> return;</p><p> }</p><p> uVersion = fget32(fp);</p><p> if ((uVersion & FileVersionCriticalMask) > (FileVersion32 & FileVersionCriticalMask)) {</p><p> fprintf(stderr, "! %s : Unknown format: File version '%x' unsupported\n", encryptedDatabase, uVersion);</p><p> fclose(fp);</p><p> return;</p><p> }</p><p> endReached = 0;</p><p> while (!endReached) {</p><p> int32_t uSize;</p><p> unsigned char btFieldID = fgetc(fp);</p><p> enum Kdb4HeaderFieldID kdbID = btFieldID;</p><p> unsigned char *pbData = NULL;</p><p></p><p> if (uVersion < FileVersion32_4)</p><p> uSize = fget16(fp);</p><p> else</p><p> uSize = fget32(fp);</p><p></p><p> if (uSize < 0) {</p><p> fprintf(stderr, "error validating uSize, is the database corrupt?\n");</p><p> goto bailout;</p><p> }</p><p> if (fsize * 64 < uSize) {</p><p> fprintf(stderr, "uSize too large, is the database corrupt?\n");</p><p> goto bailout;</p><p> }</p><p> if (uSize == 0 && (kdbID != EndOfHeader)) {</p><p> fprintf(stderr, "error validating uSize for EndOfHeader, is the database corrupt?\n");</p><p> goto bailout;</p><p> }</p><p> if (uSize > 0) {</p><p> pbData = (unsigned char*)malloc(uSize);</p><p> if (!pbData || fread(pbData, uSize, 1, fp) != 1) {</p><p> fprintf(stderr, "error allocating / reading pbData, is the database corrupt?\n");</p><p> MEM_FREE(pbData);</p><p> goto bailout;</p><p> }</p><p> }</p><p> switch (kdbID)</p><p> {</p><p> case EndOfHeader:</p><p> endReached = 1; // end of header</p><p> MEM_FREE(pbData);</p><p> break;</p><p></p><p> case MasterSeed:</p><p> if (masterSeed)</p><p> MEM_FREE(masterSeed);</p><p> masterSeed = pbData;</p><p> masterSeedLength = uSize;</p><p> break;</p><p></p><p> case TransformSeed: // Obsolete in FileVersion32_4; for backward compatibility only</p><p> if (transformSeed)</p><p> MEM_FREE(transformSeed);</p><p></p><p> transformSeed = pbData;</p><p> transformSeedLength = uSize;</p><p> break;</p><p></p><p> case TransformRounds: // Obsolete in FileVersion32_4; for backward compatibility only</p><p> if (uSize < 4) {</p><p> fprintf(stderr, "error validating uSize for TransformRounds, is the database corrupt?\n");</p><p> MEM_FREE(pbData);</p><p> goto bailout;</p><p> }</p><p> if (!pbData) {</p><p> fprintf(stderr, "! %s : parsing failed (pbData is NULL), please open a bug if target is valid KeepPass database.\n", encryptedDatabase);</p><p> goto bailout;</p><p> }</p><p> else {</p><p> transformRounds = BytesToUInt64(pbData, uSize);</p><p> MEM_FREE(pbData);</p><p> }</p><p> break;</p><p></p><p> case EncryptionIV:</p><p> if (initializationVectors)</p><p> MEM_FREE(initializationVectors);</p><p> initializationVectors = pbData;</p><p> initializationVectorsLength = uSize;</p><p> break;</p><p></p><p> case StreamStartBytes: // Not present in FileVersion32_4</p><p> if (expectedStartBytes)</p><p> MEM_FREE(expectedStartBytes);</p><p> expectedStartBytes = pbData;</p><p> expectedStartBytesLength = uSize;</p><p> break;</p><p></p><p> case CipherID:</p><p> // pbData == 31c1f2e6bf714350be5805216afc5aff => AES ("Standard" KDBX 3.1)</p><p> // pbData == d6038a2b8b6f4cb5a524339a31dbb59a => ChaCha20</p><p> // pbData == ad68f29f576f4bb9a36ad47af965346c => TwoFish</p><p> if (uSize < 4) {</p><p> fprintf(stderr, "error validating uSize for CipherID, is the database corrupt?\n");</p><p> MEM_FREE(pbData);</p><p> goto bailout;</p><p> }</p><p> if (memcmp(pbData, "\xd6\x03\x8a\x2b", 4) == 0) {</p><p> // fprintf(stderr, "! %s : ChaCha20 usage is not supported yet!\n", encryptedDatabase);</p><p> // MEM_FREE(pbData);</p><p> algorithm = 2;</p><p> // goto bailout;</p><p> }</p><p> /* if (memcmp(pbData, "\x31\xc1\xf2\xe6", 4) != 0) {</p><p> fprintf(stderr, "! %s : Unsupported CipherID found!\n", encryptedDatabase);</p><p> MEM_FREE(pbData);</p><p> goto bailout;</p><p> } */</p><p></p><p> default:</p><p> MEM_FREE(pbData);</p><p> break;</p><p> }</p><p> }</p><p> // dataStartOffset = ftell(fp);</p><p> if (transformRounds == 0 && uVersion < FileVersion32_4) {</p><p> fprintf(stderr, "! %s : transformRounds can't be 0\n", encryptedDatabase);</p><p> goto bailout;</p><p> }</p><p>#ifdef KEEPASS_DEBUG</p><p> fprintf(stderr, "%d, %d, %d, %d\n", masterSeedLength, transformSeedLength, initializationVectorsLength, expectedStartBytesLength);</p><p>#endif</p><p> if ((uVersion < FileVersion32_4) && (!masterSeed || !transformSeed || !initializationVectors || !expectedStartBytes)) {</p><p> fprintf(stderr, "! %s : parsing failed, please open a bug if target is valid KeepPass database.\n", encryptedDatabase);</p><p> goto bailout;</p><p> }</p><p></p><p> if (uVersion >= FileVersion32_4) {</p><p> fprintf(stderr, "! %s : File version '%x' is currently not supported!\n", encryptedDatabase, uVersion);</p><p> goto bailout;</p><p> }</p><p></p><p> if (keyfile) {</p><p> kfp = fopen(keyfile, "rb");</p><p> if (!kfp) {</p><p> fprintf(stderr, "! %s : %s\n", keyfile, strerror(errno));</p><p> return;</p><p> }</p><p> filesize_keyfile = (int64_t)get_file_size(keyfile);</p><p> }</p><p></p><p> dbname = strip_suffixes(basename(encryptedDatabase),extension, 1);</p><p> // printf("%s:$keepass$*2*%ld*%ld*", dbname, transformRounds, dataStartOffset);</p><p> printf("%s:$keepass$*2*%ld*%ld*", dbname, transformRounds, algorithm); // dataStartOffset field is now used to convey algorithm information</p><p> print_hex(masterSeed, masterSeedLength);</p><p> printf("*");</p><p> print_hex(transformSeed, transformSeedLength);</p><p> printf("*");</p><p> print_hex(initializationVectors, initializationVectorsLength);</p><p> printf("*");</p><p> print_hex(expectedStartBytes, expectedStartBytesLength);</p><p> if (fread(out, 32, 1, fp) != 1) {</p><p> fprintf(stderr, "error reading encrypted data!\n");</p><p> goto bailout;</p><p> }</p><p> printf("*");</p><p> print_hex(out, 32);</p><p></p><p> if (keyfile) {</p><p> buffer = (unsigned char*)malloc(filesize_keyfile * sizeof(char));</p><p> printf("*1*64*"); /* inline keyfile content */</p><p> if (fread(buffer, filesize_keyfile, 1, kfp) != 1) {</p><p> warn("%s: Error: read failed: %s.",</p><p> encryptedDatabase, strerror(errno));</p><p> return;</p><p> }</p><p></p><p> /* as in Keepass 2.x implementation:</p><p> * if keyfile is an xml, get <Data> content</p><p> * if filesize_keyfile == 32 then assume byte_array</p><p> * if filesize_keyfile == 64 then assume hex(byte_array)</p><p> * else byte_array = sha256(keyfile_content)</p><p> */</p><p></p><p> if (!memcmp((char *) buffer, "<?xml", 5)</p><p> && ((p = strstr((char *) buffer, "<Key>")) != NULL)</p><p> && ((p = strstr(p, "<Data>")) != NULL)</p><p> )</p><p> {</p><p> p += strlen("<Data>");</p><p> data = p;</p><p> p = strstr(p, "</Data>");</p><p> printf ("%s", base64_convert_cp(data, e_b64_mime, p - data, b64_decoded, e_b64_hex, sizeof(b64_decoded), flg_Base64_NO_FLAGS, 0));</p><p> }</p><p> else if (filesize_keyfile == 32)</p><p> print_hex(buffer, filesize_keyfile);</p><p> else if (filesize_keyfile == 64)</p><p> {</p><p> for (counter = 0; counter <64; counter++)</p><p> printf("%c", buffer[counter]);</p><p> }</p><p> else</p><p> {</p><p> /* precompute sha256 to speed-up cracking */</p><p></p><p> SHA256_Init(&ctx);</p><p> SHA256_Update(&ctx, buffer, filesize_keyfile);</p><p> SHA256_Final(hash, &ctx);</p><p> print_hex(hash, 32);</p><p> }</p><p> MEM_FREE(buffer);</p><p> }</p><p> printf("\n");</p><p></p><p>bailout:</p><p> MEM_FREE(masterSeed);</p><p> MEM_FREE(transformSeed);</p><p> MEM_FREE(initializationVectors);</p><p> MEM_FREE(expectedStartBytes);</p><p> fclose(fp);</p><p>}</p><p></p><p>#ifndef HAVE_LIBFUZZER</p><p>static int usage(char *name)</p><p>{</p><p> fprintf(stderr, "Usage: %s [-k <keyfile>] <.kdbx database(s)>\n", name);</p><p></p><p> return EXIT_FAILURE;</p><p>}</p><p></p><p>int main(int argc, char **argv)</p><p>{</p><p> int c;</p><p></p><p> errno = 0;</p><p> /* Parse command line */</p><p> while ((c = getopt(argc, argv, "k:")) != -1) {</p><p> switch (c) {</p><p> case 'k':</p><p> keyfile = (char *)malloc(strlen(optarg) + 1);</p><p> strcpy(keyfile, optarg);</p><p> break;</p><p> case '?':</p><p> default:</p><p> return usage(argv[0]);</p><p> }</p><p> }</p><p> argc -= optind;</p><p> if (argc == 0)</p><p> return usage(argv[0]);</p><p> argv += optind;</p><p></p><p> while(argc--)</p><p> process_database(*argv++);</p><p></p><p> MEMDBG_PROGRAM_EXIT_CHECKS(stderr);</p><p> return 0;</p><p>}</p><p>#endif</p><p></p><p>#ifdef HAVE_LIBFUZZER</p><p>int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)</p><p>{</p><p> int fd;</p><p> char name[] = "/tmp/libFuzzer-XXXXXX";</p><p></p><p> fd = mkstemp(name); // this approach is somehow faster than the fmemopen way</p><p> if (fd < 0) {</p><p> fprintf(stderr, "Problem detected while creating the input file, %s, aborting!\n", strerror(errno));</p><p> exit(-1);</p><p> }</p><p> write(fd, data, size);</p><p> close(fd);</p><p> process_database(name);</p><p> remove(name);</p><p></p><p> return 0;</p><p>}</p><p>#endif[/CODE]</p><p style="text-align: center"></p> <p style="text-align: center">Bonne soirée,</p> <p style="text-align: center"><a href="https://reality-gaming.fr/members/arkantik.789619/" target="_blank"><strong>ArKantiK</strong></a></p></blockquote><p></p>
[QUOTE="ArKantiK, post: 7252915, member: 789619"] [CENTER]Bonsoir [B][USER=527065]@Faruq[/USER][/B], L'erreur signalé par le terminal pour le script que tu essaies de lancer dit simplement : "Le programme a rencontré une erreur de syntaxe dans le script (keepass2john.c) à la ligne 1." Il semblerait que le script ne prenne pas en compte les commentaires (*/ /*) dans son code, ce qui l'empêche de démarrer. Essaie de modifier le fichier [B]keepass2john.c[/B] dans le dossier "[B]src[/B]" de JohnTheRipper de la manière suivante : [/CENTER] [CODE]#if AC_BUILT #include "autoconfig.h" #endif #include <stdarg.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #ifdef _MSC_VER #include "missing_getopt.h" #endif #include <errno.h> // needs to be above sys/types.h and sys/stat.h for mingw, if -std=c99 used. #include "jumbo.h" #include <sys/stat.h> #include <sys/types.h> #if (!AC_BUILT || HAVE_UNISTD_H) && !_MSC_VER #include <unistd.h> // getopt defined here for unix #endif #include "params.h" #include "memory.h" #include "memdbg.h" #include "sha2.h" #include "base64_convert.h" const char *extension[] = {".kdbx"}; static char *keyfile = NULL; // KeePass 1.x signature uint32_t FileSignatureOld1 = 0x9AA2D903; uint32_t FileSignatureOld2 = 0xB54BFB65; /// <summary> /// File identifier, first 32-bit value. /// </summary> uint32_t FileSignature1 = 0x9AA2D903; /// <summary> /// File identifier, second 32-bit value. /// </summary> uint32_t FileSignature2 = 0xB54BFB67; // KeePass 2.x pre-release (alpha and beta) signature uint32_t FileSignaturePreRelease1 = 0x9AA2D903; uint32_t FileSignaturePreRelease2 = 0xB54BFB66; uint32_t FileVersionCriticalMask = 0xFFFF0000; /// <summary> /// File version of files saved by the current <c>Kdb4File</c> class. /// KeePass 2.07 has version 1.01, 2.08 has 1.02, 2.09 has 2.00, /// 2.10 has 2.02, 2.11 has 2.04, 2.15 has 3.00. /// The first 2 bytes are critical (i.e. loading will fail, if the /// file version is too high), the last 2 bytes are informational. /// </summary> // uint32_t FileVersion32 = 0x00030000; uint32_t FileVersion32 = 0x00040000; uint32_t FileVersion32_4 = 0x00040000; // from KeePass 2.36 sources // We currently support database formats up to KDBX v3.x. KDBX 4.x is not // supported yet. See "KdbxFile.cs" in KeePass 2.36 for more information on // KDBX 4.x format. enum Kdb4HeaderFieldID { EndOfHeader = 0, CipherID = 2, MasterSeed = 4, TransformSeed = 5, // KDBX 3.1, for backward compatibility only TransformRounds = 6, // KDBX 3.1, for backward compatibility only EncryptionIV = 7, StreamStartBytes = 9, // KDBX 3.1, for backward compatibility only KdfParameters = 11, // KDBX 4, superseding Transform* }; static off_t get_file_size(char * filename) { struct stat sb; if (stat(filename, & sb) != 0) { fprintf(stderr, "! %s : stat failed, %s\n", filename, strerror(errno)); exit(-2); } return sb.st_size; } static void print_hex(unsigned char *str, int len) { int i; for (i = 0; i < len; ++i) printf("%02x", str[i]); } static uint64_t BytesToUInt64(unsigned char * s, const int s_size) { int i; uint64_t v = 0; for (i = 0; i < 8 && i < s_size; i++) v |= (uint64_t)s[i] << 8 * i; return v; } static uint32_t fget32(FILE * fp) { uint32_t v = fgetc(fp); v |= fgetc(fp) << 8; v |= fgetc(fp) << 16; v |= fgetc(fp) << 24; return v; } static uint16_t fget16(FILE * fp) { uint32_t v = fgetc(fp); v |= fgetc(fp) << 8; return v; } static void warn(const char *fmt, ...) { va_list ap; va_start(ap, fmt); if (fmt != NULL) vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); // exit(EXIT_FAILURE); } /* process KeePass 1.x databases */ static void process_old_database(FILE *fp, char* encryptedDatabase) { uint32_t enc_flag; uint32_t version; unsigned char final_randomseed[16]; unsigned char enc_iv[16]; unsigned char contents_hash[32]; unsigned char transf_randomseed[32]; uint32_t num_groups; uint32_t num_entries; uint32_t key_transf_rounds; unsigned char *buffer; int64_t filesize = 0; int64_t datasize; int algorithm = -1; char *dbname; FILE *kfp = NULL; /* specific to keyfile handling */ int64_t filesize_keyfile = 0; SHA256_CTX ctx; unsigned char hash[32]; int counter; enc_flag = fget32(fp); version = fget32(fp); if (fread(final_randomseed, 16, 1, fp) != 1) { warn("%s: Error: read failed: %s.", encryptedDatabase, strerror(errno)); return; } if (fread(enc_iv, 16, 1, fp) != 1) { warn("%s: Error: read failed: %s.", encryptedDatabase, strerror(errno)); return; } num_groups = fget32(fp); num_entries = fget32(fp); (void)num_groups; (void)num_entries; if (fread(contents_hash, 32, 1, fp) != 1) { warn("%s: Error: read failed: %s.", encryptedDatabase, strerror(errno)); return; } if (fread(transf_randomseed, 32, 1, fp) != 1) { warn("%s: Error: read failed: %s.", encryptedDatabase, strerror(errno)); return; } key_transf_rounds = fget32(fp); /* Check if the database is supported */ if ((version & 0xFFFFFF00) != (0x00030002 & 0xFFFFFF00)) { fprintf(stderr, "! %s : Unsupported file version (%u)!\n", encryptedDatabase, version); return; } /* src/Kdb3Database.cpp from KeePass 0.4.3 is authoritative */ if (enc_flag & 2) { algorithm = 0; // AES } else if (enc_flag & 8) { algorithm = 1; // Twofish } else { fprintf(stderr, "! %s : Unsupported file encryption (%u)!\n", encryptedDatabase, enc_flag); return; } /* keyfile processing */ if (keyfile) { kfp = fopen(keyfile, "rb"); if (!kfp) { fprintf(stderr, "! %s : %s\n", keyfile, strerror(errno)); return; } filesize_keyfile = (int64_t)get_file_size(keyfile); } dbname = strip_suffixes(basename(encryptedDatabase), extension, 1); filesize = (int64_t)get_file_size(encryptedDatabase); datasize = filesize - 124; if (datasize < 0) { warn("%s: Error in validating datasize.", encryptedDatabase); return; } // offset (124) field below is not used, we hijack it to convey the // algorithm. // printf("%s:$keepass$*1*%d*%d*", dbname, key_transf_rounds, 124); printf("%s:$keepass$*1*%d*%d*", dbname, key_transf_rounds, algorithm); print_hex(final_randomseed, 16); printf("*"); print_hex(transf_randomseed, 32); printf("*"); print_hex(enc_iv, 16); printf("*"); print_hex(contents_hash, 32); buffer = (unsigned char*)malloc(datasize * sizeof(char)); /* we inline the content with the hash */ fprintf(stderr, "Inlining %s\n", encryptedDatabase); printf("*1*%"PRId64"*", datasize); fseek(fp, 124, SEEK_SET); if (fread(buffer, datasize, 1, fp) != 1) { warn("%s: Error: read failed: %s.", encryptedDatabase, strerror(errno)); MEM_FREE(buffer); return; } print_hex(buffer, datasize); MEM_FREE(buffer); if (keyfile) { buffer = (unsigned char*)malloc(filesize_keyfile * sizeof(char)); printf("*1*64*"); /* inline keyfile content */ if (fread(buffer, filesize_keyfile, 1, kfp) != 1) { warn("%s: Error: read failed: %s.", encryptedDatabase, strerror(errno)); return; } /* as in Keepass 1.x implementation: * if filesize_keyfile == 32 then assume byte_array * if filesize_keyfile == 64 then assume hex(byte_array) * else byte_array = sha256(keyfile_content) */ if (filesize_keyfile == 32) print_hex(buffer, filesize_keyfile); else if (filesize_keyfile == 64){ for (counter = 0; counter <64; counter++) printf("%c", buffer[counter]); } else{ /* precompute sha256 to speed-up cracking */ SHA256_Init(&ctx); SHA256_Update(&ctx, buffer, filesize_keyfile); SHA256_Final(hash, &ctx); print_hex(hash, 32); } MEM_FREE(buffer); } printf("\n"); } // Synchronize with KdbxFile.Read.cs from KeePass 2.x static void process_database(char* encryptedDatabase) { // long dataStartOffset; unsigned long transformRounds = 0; unsigned char *masterSeed = NULL; int masterSeedLength = 0; unsigned char *transformSeed = NULL; int transformSeedLength = 0; unsigned char *initializationVectors = NULL; int initializationVectorsLength = 0; unsigned char *expectedStartBytes = NULL; int endReached, expectedStartBytesLength = 0; uint32_t uSig1, uSig2, uVersion; FILE *fp; unsigned char out[32]; char *dbname; long algorithm = 0; // 0 -> AES size_t fsize = 0; /* specific to keyfile handling */ unsigned char *buffer; int64_t filesize_keyfile = 0; char *p; char *data; char b64_decoded[128+1]; FILE *kfp = NULL; SHA256_CTX ctx; unsigned char hash[32]; int counter; fp = fopen(encryptedDatabase, "rb"); if (!fp) { fprintf(stderr, "! %s : %s\n", encryptedDatabase, strerror(errno)); return; } fseek(fp, 0, SEEK_END); fsize = ftell(fp); fseek(fp, 0, SEEK_SET); uSig1 = fget32(fp); uSig2 = fget32(fp); if ((uSig1 == FileSignatureOld1) && (uSig2 == FileSignatureOld2)) { process_old_database(fp, encryptedDatabase); fclose(fp); return; } if ((uSig1 == FileSignature1) && (uSig2 == FileSignature2)) { } else if ((uSig1 == FileSignaturePreRelease1) && (uSig2 == FileSignaturePreRelease2)) { } else { fprintf(stderr, "! %s : Unknown format: File signature invalid\n", encryptedDatabase); fclose(fp); return; } uVersion = fget32(fp); if ((uVersion & FileVersionCriticalMask) > (FileVersion32 & FileVersionCriticalMask)) { fprintf(stderr, "! %s : Unknown format: File version '%x' unsupported\n", encryptedDatabase, uVersion); fclose(fp); return; } endReached = 0; while (!endReached) { int32_t uSize; unsigned char btFieldID = fgetc(fp); enum Kdb4HeaderFieldID kdbID = btFieldID; unsigned char *pbData = NULL; if (uVersion < FileVersion32_4) uSize = fget16(fp); else uSize = fget32(fp); if (uSize < 0) { fprintf(stderr, "error validating uSize, is the database corrupt?\n"); goto bailout; } if (fsize * 64 < uSize) { fprintf(stderr, "uSize too large, is the database corrupt?\n"); goto bailout; } if (uSize == 0 && (kdbID != EndOfHeader)) { fprintf(stderr, "error validating uSize for EndOfHeader, is the database corrupt?\n"); goto bailout; } if (uSize > 0) { pbData = (unsigned char*)malloc(uSize); if (!pbData || fread(pbData, uSize, 1, fp) != 1) { fprintf(stderr, "error allocating / reading pbData, is the database corrupt?\n"); MEM_FREE(pbData); goto bailout; } } switch (kdbID) { case EndOfHeader: endReached = 1; // end of header MEM_FREE(pbData); break; case MasterSeed: if (masterSeed) MEM_FREE(masterSeed); masterSeed = pbData; masterSeedLength = uSize; break; case TransformSeed: // Obsolete in FileVersion32_4; for backward compatibility only if (transformSeed) MEM_FREE(transformSeed); transformSeed = pbData; transformSeedLength = uSize; break; case TransformRounds: // Obsolete in FileVersion32_4; for backward compatibility only if (uSize < 4) { fprintf(stderr, "error validating uSize for TransformRounds, is the database corrupt?\n"); MEM_FREE(pbData); goto bailout; } if (!pbData) { fprintf(stderr, "! %s : parsing failed (pbData is NULL), please open a bug if target is valid KeepPass database.\n", encryptedDatabase); goto bailout; } else { transformRounds = BytesToUInt64(pbData, uSize); MEM_FREE(pbData); } break; case EncryptionIV: if (initializationVectors) MEM_FREE(initializationVectors); initializationVectors = pbData; initializationVectorsLength = uSize; break; case StreamStartBytes: // Not present in FileVersion32_4 if (expectedStartBytes) MEM_FREE(expectedStartBytes); expectedStartBytes = pbData; expectedStartBytesLength = uSize; break; case CipherID: // pbData == 31c1f2e6bf714350be5805216afc5aff => AES ("Standard" KDBX 3.1) // pbData == d6038a2b8b6f4cb5a524339a31dbb59a => ChaCha20 // pbData == ad68f29f576f4bb9a36ad47af965346c => TwoFish if (uSize < 4) { fprintf(stderr, "error validating uSize for CipherID, is the database corrupt?\n"); MEM_FREE(pbData); goto bailout; } if (memcmp(pbData, "\xd6\x03\x8a\x2b", 4) == 0) { // fprintf(stderr, "! %s : ChaCha20 usage is not supported yet!\n", encryptedDatabase); // MEM_FREE(pbData); algorithm = 2; // goto bailout; } /* if (memcmp(pbData, "\x31\xc1\xf2\xe6", 4) != 0) { fprintf(stderr, "! %s : Unsupported CipherID found!\n", encryptedDatabase); MEM_FREE(pbData); goto bailout; } */ default: MEM_FREE(pbData); break; } } // dataStartOffset = ftell(fp); if (transformRounds == 0 && uVersion < FileVersion32_4) { fprintf(stderr, "! %s : transformRounds can't be 0\n", encryptedDatabase); goto bailout; } #ifdef KEEPASS_DEBUG fprintf(stderr, "%d, %d, %d, %d\n", masterSeedLength, transformSeedLength, initializationVectorsLength, expectedStartBytesLength); #endif if ((uVersion < FileVersion32_4) && (!masterSeed || !transformSeed || !initializationVectors || !expectedStartBytes)) { fprintf(stderr, "! %s : parsing failed, please open a bug if target is valid KeepPass database.\n", encryptedDatabase); goto bailout; } if (uVersion >= FileVersion32_4) { fprintf(stderr, "! %s : File version '%x' is currently not supported!\n", encryptedDatabase, uVersion); goto bailout; } if (keyfile) { kfp = fopen(keyfile, "rb"); if (!kfp) { fprintf(stderr, "! %s : %s\n", keyfile, strerror(errno)); return; } filesize_keyfile = (int64_t)get_file_size(keyfile); } dbname = strip_suffixes(basename(encryptedDatabase),extension, 1); // printf("%s:$keepass$*2*%ld*%ld*", dbname, transformRounds, dataStartOffset); printf("%s:$keepass$*2*%ld*%ld*", dbname, transformRounds, algorithm); // dataStartOffset field is now used to convey algorithm information print_hex(masterSeed, masterSeedLength); printf("*"); print_hex(transformSeed, transformSeedLength); printf("*"); print_hex(initializationVectors, initializationVectorsLength); printf("*"); print_hex(expectedStartBytes, expectedStartBytesLength); if (fread(out, 32, 1, fp) != 1) { fprintf(stderr, "error reading encrypted data!\n"); goto bailout; } printf("*"); print_hex(out, 32); if (keyfile) { buffer = (unsigned char*)malloc(filesize_keyfile * sizeof(char)); printf("*1*64*"); /* inline keyfile content */ if (fread(buffer, filesize_keyfile, 1, kfp) != 1) { warn("%s: Error: read failed: %s.", encryptedDatabase, strerror(errno)); return; } /* as in Keepass 2.x implementation: * if keyfile is an xml, get <Data> content * if filesize_keyfile == 32 then assume byte_array * if filesize_keyfile == 64 then assume hex(byte_array) * else byte_array = sha256(keyfile_content) */ if (!memcmp((char *) buffer, "<?xml", 5) && ((p = strstr((char *) buffer, "<Key>")) != NULL) && ((p = strstr(p, "<Data>")) != NULL) ) { p += strlen("<Data>"); data = p; p = strstr(p, "</Data>"); printf ("%s", base64_convert_cp(data, e_b64_mime, p - data, b64_decoded, e_b64_hex, sizeof(b64_decoded), flg_Base64_NO_FLAGS, 0)); } else if (filesize_keyfile == 32) print_hex(buffer, filesize_keyfile); else if (filesize_keyfile == 64) { for (counter = 0; counter <64; counter++) printf("%c", buffer[counter]); } else { /* precompute sha256 to speed-up cracking */ SHA256_Init(&ctx); SHA256_Update(&ctx, buffer, filesize_keyfile); SHA256_Final(hash, &ctx); print_hex(hash, 32); } MEM_FREE(buffer); } printf("\n"); bailout: MEM_FREE(masterSeed); MEM_FREE(transformSeed); MEM_FREE(initializationVectors); MEM_FREE(expectedStartBytes); fclose(fp); } #ifndef HAVE_LIBFUZZER static int usage(char *name) { fprintf(stderr, "Usage: %s [-k <keyfile>] <.kdbx database(s)>\n", name); return EXIT_FAILURE; } int main(int argc, char **argv) { int c; errno = 0; /* Parse command line */ while ((c = getopt(argc, argv, "k:")) != -1) { switch (c) { case 'k': keyfile = (char *)malloc(strlen(optarg) + 1); strcpy(keyfile, optarg); break; case '?': default: return usage(argv[0]); } } argc -= optind; if (argc == 0) return usage(argv[0]); argv += optind; while(argc--) process_database(*argv++); MEMDBG_PROGRAM_EXIT_CHECKS(stderr); return 0; } #endif #ifdef HAVE_LIBFUZZER int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { int fd; char name[] = "/tmp/libFuzzer-XXXXXX"; fd = mkstemp(name); // this approach is somehow faster than the fmemopen way if (fd < 0) { fprintf(stderr, "Problem detected while creating the input file, %s, aborting!\n", strerror(errno)); exit(-1); } write(fd, data, size); close(fd); process_database(name); remove(name); return 0; } #endif[/CODE] [CENTER] Bonne soirée, [URL='https://reality-gaming.fr/members/arkantik.789619/'][B]ArKantiK[/B][/URL][/CENTER] [/QUOTE]
Insérer les citations…
Vérification
Publier la réponse
Forums
Plateformes
PC et Serveurs
Linux
Problème d'execution script
Ce site utilise des cookies. En continuant à utiliser ce site, vous acceptez l'utilisation des cookies.
Acceptez
En savoir plus.…
Haut