#include <iostream>
#include <vector>
#include <fstream>
int find_pattern( const std::vector<char>& data, std::string pattern )
{
static auto pattern_to_bytes = [ ]( const char* pattern )
{
std::vector<int8_t> bytes{};
auto start = const_cast< char* >( pattern );
auto end = const_cast< char* >( pattern ) + strlen( pattern );
for ( auto current = start; current < end; ++current )
{
if ( *current == '?' )
{
++current;
if ( *current == '?' )
++current;
bytes.push_back( -1 );
}
else
bytes.push_back( strtoul( current, ¤t, 16 ) );
}
return bytes;
};
auto pattern_bytes = pattern_to_bytes( pattern.data( ) );
auto data_size = data.size( );
auto data_ = data.data( );
auto pattern_size = pattern_bytes.size( );
for ( int i{ 0 }; i < data_size - pattern_size; ++i )
{
bool found = true;
for ( int j{ 0 }; j < pattern_size; ++j )
{
if ( data_[ i + j ] != pattern_bytes[ j ] )
{
found = false;
break;
}
}
if ( found )
return i;
}
return -1;
}
int main( )
{
std::string file_path = ""; // путь к файлу тут
std::ifstream stream( file_path, std::ios::binary );
if ( !stream.is_open( ) )
return 0;
stream.seekg( 0, std::ios::end );
auto file_size = stream.tellg( );
stream.seekg( 0, std::ios::beg );
std::vector<char> file_data( file_size );
stream.read( file_data.data( ), file_size );
stream.close( );
int pos_in_file = find_pattern( file_data, "FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02" );
std::string login( &file_data[ pos_in_file - 48 ] );
std::string pass( &file_data[ pos_in_file - 16 ] );
std::cout << "Login : " << login << " Pass : " << pass << std::endl;
return 0;
}