calvary1980
New Member
- Joined
- Dec 26, 2007
- Messages
- 1,801 (0.30/day)
- Location
- Toronto, CA
Processor | Intel Core 2 Quad Q6600 Kentsfield L724A629 @ 3.8Ghz 423x9 1.47v |
---|---|
Motherboard | Abit IP-35 Pro Beta 16.B04 (vDroop) |
Cooling | 6x Scythe S-Flex SFF21F, EK Multi Option 2 Port, dB-1 Compact, Swiftech MCR80, Swiftech Apogee GT |
Memory | 2x1 OCZ Flex XLC PC-9200 @ 5-5-5-18 1220 2.3v |
Video Card(s) | Inno3D Geforce 8800GTS 320 |
Storage | Western Digital Raptor X 150 |
Display(s) | Samsung Syncmaster 226BW 22" |
Case | Cooler Master RC-690 |
Audio Device(s) | Creative SoundBlaster X-Fi Xtreme Gamer 7.1 |
Power Supply | Thermaltake ToughPower 1000 |
C++: Parsesnip Source
being a security enthusiast I usually find my self writing little tools like this on the fly I wrote this a couple years ago and planned on releasing it but never did, since the programming section is pretty quiet these days I see no harm.
- Christine
being a security enthusiast I usually find my self writing little tools like this on the fly I wrote this a couple years ago and planned on releasing it but never did, since the programming section is pretty quiet these days I see no harm.
Code:
// parsesnip
// version 1.0
// author Christine "calvary" C.
// this tool is used to parse common combinations from selected
// input file to output file with the option of a histogram
// available format http://*:*@* to *:*
// coming soon support for Zima and Crime formats
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <vector>
#define DUP_THRESHOLD 20
using namespace std;
void print_vector(vector<string> & vec);
int main(int argc, char * argv[]){
string input_fn;
string output_fn;
string make_hist;
int threshold;
cout<<"enter the path of the input file: ";
cin>>input_fn;
cout<<"enter the path of the output file: ";
cin>>output_fn;
cout<<"how many instances constitues a common combination (num > 1) : ";
cin>>threshold;
cout<<"would you like to make a histogram (y/n): ";
cin>>make_hist;
cout<<endl;
vector<string> vl_vec;
vector<string>::iterator new_end;
string line;
string::iterator line_iter;
string base;
ifstream in(input_fn.c_str());
if(!in.good()){
cout<<"error: "<<input_fn<<" could not be opened \n";
cin>>input_fn;
exit(1);
}
while (!in.eof()){
in>>line;
line_iter = line.begin();
line_iter += 7;
while(*(++line_iter) != '/');
line_iter++;
base.erase(base.begin(),base.end());
base.resize(line_iter - line.begin() + 1);
copy(line.begin(), line_iter,base.begin());
vl_vec.push_back(base);
}
sort(vl_vec.begin(),vl_vec.end());
new_end = unique(vl_vec.begin(),vl_vec.end());
vl_vec.erase(new_end + 1,vl_vec.end());
vector<string> combo_vec;
for(vector<string>::iterator cur = vl_vec.begin();
cur < new_end;
cur++){
line_iter = cur->begin();
line_iter += 7;
while(*(++line_iter) != '@');
base.erase(base.begin(),base.end());
base.resize(line_iter - cur->begin() - 6);
copy(cur->begin()+7,line_iter,base.begin());
combo_vec.push_back(base);
};
ofstream out(output_fn.c_str());
int dups;
string cur_combo;
for(vector<string>::iterator cur2 = combo_vec.begin();
cur2 < combo_vec.end();
cur2++){
dups = 0;
cur_combo = *cur2;
while(cur_combo == *cur2 && cur2 < combo_vec.end() - 1){
cur2++;
dups++;
};
if(toupper(make_hist[0]) == 'Y'){
out.width(25);
}
if(dups >= threshold){
out<<cur_combo<<" ";
if(toupper(make_hist[0]) == 'Y'){
cout<<" ";
for(int i=0; i<dups; i++)
out<<"|";
}
out<<endl;
}
}
return 0;
}
void print_vector(vector<string> & vec){ // debug
for(vector<string>::iterator cur = vec.begin();
cur < vec.end();
cur++){
cout<<*cur<<endl;
}
}// end print_vector
- Christine
Last edited: