Navigation X

[C++] RatLog Processor - Filter Hits From Parsed Logs - Open Source

  • USE "RATE LEAK" TO HELP THE STAFF DELETING THREADS WITH NOT WORKING LINKS
 248 Luke

[C++] RatLog Processor - Filter Hits From Parsed Logs - Open Source

by Luke Ghost -
Let's say you've got a list of parsed RatLogs that come in the following forms, it will parse like this.

Content locked
This content has been locked. Please login or register in order to unlock it.
---> MTS:12345678
MTS:12345678:
http://127.0.0.1/webcmcc/index_content.html ---> MTS:12345678
Content locked
This content has been locked. Please login or register in order to unlock it.
MTS:12345678: ---> MTS:12345678


Code:
Code:
// RatlogParser.cpp : This file contains the 'main' function. Program execution begins and ends there.

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <regex>
#include
#include <chrono>

void Search(std::string path, std::string target)
{

std::vector<std::string> contents;
std::ifstream file(path);
std::string currLine;

while (std::getline(file, currLine)) {
contents.push_back(currLine);
}

for (int i = 0; i < contents.size(); i++)
{
std::string checkLine = contents[i];
std::string checkLineUp = checkLine;
std::string checkLineLow = checkLine;
std::transform(checkLineUp.begin(), checkLineUp.end(), checkLineUp.begin(), ::toupper);
std::transform(checkLineLow.begin(), checkLineLow.end(), checkLineLow.begin(), ::toupper);

if (checkLine.find(target) != std::string::npos || checkLineLow.find(target) != std::string::npos || checkLineUp.find(target) != std::string::npos)
{

bool hasHttp = checkLine.find("https");

if (count(checkLine.begin(), checkLine.end(), ':') > 1)
{

if (hasHttp == 0)
{

if (checkLine.find(" ") == std::string::npos)
{
try
{
int num = checkLine.find(':');
std::string extra = checkLine.substr(num + 1);
num = extra.find(':');
std::cout << extra.substr(num + 1) << std::endl;
}
catch (std::exception e)
{
continue;
}
}
int count = 0;
std::size_t pos = checkLine.find(" ");
while (pos != std::string::npos) {
count++;
pos = checkLine.find(" ", pos + 1);
if (count == 1)
{
std::cout << checkLine.substr(pos + 1, checkLine.find(" ", pos + 1) - pos - 1) << std::endl;
}
}
}
else
{
int count = 0;
std::size_t pos = checkLine.find(":h");
while (pos != std::string::npos) {
count++;
pos = checkLine.find(":h", pos + 1);
if (count == 1)
{
std::cout << checkLine.substr(pos + 1, checkLine.find(" ", pos + 1) - pos - 1) << std::endl;
}
}
}
}
}
}
}

int main(int argc, char* argv[])
{
if (argc != 2) {
std::cout << "No file has been found!" << std::endl;
return 0;
}

std::string fileLoc = std::string(argv[1]);
std::string searchTerm;
std::cout << "File Location: " + fileLoc << std::endl;
std::cout << "Searchterm: ";
std::cin >> searchTerm;

Search(fileLoc, searchTerm);

std::cout << "\nFinished" << std::endl;
auto tp = std::chrono::system_clock::now() + std::chrono::seconds(6000);
std::this_thread::sleep_until(tp);
}

Download compiled version:
Content locked
This content has been locked. Please login or register in order to unlock it.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.



Top Bottom