Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "site_data.hpp"
- #include "Literals.hpp"
- /* Constructor to assign / set all the necessary site data */
- site_data::site_data(int type, int t, string hash) {
- switch(type) {
- case(1): // MD5
- size = (t != 0) ? (NUM_MD5_SITES - (NUM_MD5_SITES - t)) : NUM_MD5_SITES;
- post_data = new string[size];
- offset = new int[size];
- end_extractor = new string[size];
- is_found = new string[size];
- sites = new string[size];
- for(int x = 0; x < size; x++)
- {
- post_data[x] = md5_post_data[x][0] + hash + md5_post_data[x][1];
- offset[x] = md5_offset[x];
- sites[x] = md5_sites[x];
- is_found[x] = md5_is_found[x];
- end_extractor[x] = md5_end_extractor[x];
- }
- break;
- case(2): // SHA1
- size = (t != 0) ? (NUM_SHA1_SITES - (NUM_SHA1_SITES - t)) : NUM_SHA1_SITES;
- post_data = new string[size];
- offset = new int[size];
- end_extractor = new string[size];
- is_found = new string[size];
- sites = new string[size];
- for(int x = 0; x < size; x++)
- {
- post_data[x] = md5_post_data[x][0] + hash + md5_post_data[x][1];
- offset[x] = sha1_offset[x];
- sites[x] = sha1_sites[x];
- is_found[x] = sha1_is_found[x];
- end_extractor[x] = sha1_end_extractor[x];
- }
- break;
- }
- }
- /* What the hell, why not... */
- void site_data::randomize() {
- srand(time(NULL));
- for(int x = 0; x < size; x++)
- {
- int r_index = x + (rand() % (size - x));
- string temp = sites[x];
- sites[x] = sites[r_index];
- sites[r_index] = temp;
- temp = post_data[x];
- post_data[x] = post_data[r_index];
- post_data[r_index] = temp;
- temp = is_found[x];
- is_found[x] = is_found[r_index];
- is_found[r_index] = temp;
- temp = end_extractor[x];
- end_extractor[x] = end_extractor[r_index];
- end_extractor[r_index] = temp;
- int i_temp = offset[x];
- offset[x] = offset[r_index];
- offset[r_index] = i_temp;
- }
- }
- /* Default destructor to clean up */
- site_data::~site_data() {
- delete [] offset;
- delete [] sites;
- delete [] post_data;
- delete [] is_found;
- delete [] end_extractor;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement