Advertisement
Guest User

Untitled

a guest
Jun 21st, 2011
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.84 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include "site_data.hpp"
  5. #include "Literals.hpp"
  6.  
  7.  
  8.  
  9. /*  Constructor to assign / set all the necessary site data  */
  10.  
  11. site_data::site_data(int type, int t, string hash) {
  12.    
  13.     switch(type) {
  14.    
  15.          case(1): // MD5
  16.            
  17.               size = (t != 0) ? (NUM_MD5_SITES - (NUM_MD5_SITES - t)) : NUM_MD5_SITES;
  18.              
  19.               post_data = new string[size];
  20.               offset = new int[size];
  21.               end_extractor = new string[size];
  22.               is_found = new string[size];
  23.               sites = new string[size];
  24.            
  25.               for(int x = 0; x < size; x++)
  26.               {
  27.                      post_data[x] = md5_post_data[x][0] + hash + md5_post_data[x][1];
  28.                      offset[x] = md5_offset[x];
  29.                      sites[x] = md5_sites[x];
  30.                      is_found[x] = md5_is_found[x];
  31.                      end_extractor[x] = md5_end_extractor[x];
  32.               }
  33.              
  34.               break;
  35.            
  36.          case(2):  // SHA1
  37.            
  38.               size = (t != 0) ? (NUM_SHA1_SITES - (NUM_SHA1_SITES - t)) : NUM_SHA1_SITES;
  39.            
  40.               post_data = new string[size];
  41.               offset = new int[size];
  42.               end_extractor = new string[size];
  43.               is_found = new string[size];
  44.               sites = new string[size];
  45.              
  46.               for(int x = 0; x < size; x++)
  47.               {
  48.                    post_data[x] = md5_post_data[x][0] + hash + md5_post_data[x][1];
  49.                    offset[x] = sha1_offset[x];
  50.                    sites[x] = sha1_sites[x];
  51.                    is_found[x] = sha1_is_found[x];
  52.                    end_extractor[x] = sha1_end_extractor[x];
  53.               }
  54.              
  55.               break;
  56.              
  57.     }
  58.    
  59. }
  60.  
  61.  
  62.  
  63. /*  What the hell, why not...  */
  64.  
  65. void site_data::randomize() {
  66.    
  67.     srand(time(NULL));
  68.    
  69.     for(int x = 0; x < size; x++)
  70.     {
  71.          int r_index = x + (rand() % (size - x));
  72.          
  73.          string temp = sites[x];
  74.          sites[x] = sites[r_index];
  75.          sites[r_index] = temp;
  76.          
  77.          temp = post_data[x];
  78.          post_data[x] = post_data[r_index];
  79.          post_data[r_index] = temp;
  80.          
  81.          temp = is_found[x];
  82.          is_found[x] = is_found[r_index];
  83.          is_found[r_index] = temp;
  84.          
  85.          temp = end_extractor[x];
  86.          end_extractor[x] = end_extractor[r_index];
  87.          end_extractor[r_index] = temp;
  88.          
  89.          int i_temp = offset[x];
  90.          offset[x] = offset[r_index];
  91.          offset[r_index] = i_temp;
  92.     }
  93.    
  94. }
  95.  
  96.  
  97.  
  98. /*  Default destructor to clean up  */
  99.  
  100. site_data::~site_data() {
  101.    
  102.     delete [] offset;
  103.     delete [] sites;
  104.     delete [] post_data;
  105.     delete [] is_found;
  106.     delete [] end_extractor;
  107.    
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement