EgtLock 1.6g8 :
- aggiunta gestione chiavi hardware OxySec - spostati Base64 e Crc32 in General.
This commit is contained in:
+37
-71
@@ -13,19 +13,28 @@
|
||||
|
||||
//------------------ Include -------------------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "MachineId.h"
|
||||
#include "Obfuscate.h"
|
||||
#include "RegForMachineId.h"
|
||||
#include "/EgtDev/Include/SELkMachineId.h"
|
||||
#include "/EgtDev/Include/EgtBase64.h"
|
||||
#include "/EgtDev/Include/EgtCrc32.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
#include "MachineId.h"
|
||||
#include "RegForMachineId.h"
|
||||
#include "Obfuscate.h"
|
||||
#include "/EgtDev/Include/SELkBase64.h"
|
||||
#include "/EgtDev/Include/SELkCrc32.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
// ----------------- Funzioni locali -------------------------------------------------
|
||||
static bool GetSN123FromRegistry( std::string& sSN1, std::string& sSN2, std::string& sSN3) ;
|
||||
static bool GetSN123FromMachine( std::string& sSN1, std::string& sSN2, std::string& sSN3) ;
|
||||
static void AdjustSN( const std::string& sSou, const char* szFill, std::string& sDest) ;
|
||||
static DWORD GetPhysicalDriveSN( UINT nDriveNumber, std::string& sSerialNumber) ;
|
||||
static DWORD GetDiskVolumeSN( const wchar_t* wszDisk, std::string& sSerialNumber) ;
|
||||
static DWORD GetPseudoRandomSN( std::string& sSerialNumber) ;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
bool
|
||||
CalcMachineId( bool bForceNew)
|
||||
@@ -49,7 +58,7 @@ CalcMachineId( bool bForceNew)
|
||||
string sMachineId = sSN1 + "-" + sSN2 + "-" + sSN3 ;
|
||||
|
||||
// salvo il MachineId nel registry
|
||||
if ( ! MixMachineId( sMachineId))
|
||||
if ( ! MixLockId( sMachineId))
|
||||
return false ;
|
||||
AddCrc32ToString( sMachineId) ;
|
||||
string sB64 ;
|
||||
@@ -70,8 +79,8 @@ GetMachineId( string& sMachineId)
|
||||
string sMacSN1, sMacSN2, sMacSN3 ;
|
||||
GetSN123FromMachine( sMacSN1, sMacSN2, sMacSN3) ;
|
||||
|
||||
// verifico che i primi due seriali coincidano, il terzo di macchina non conta
|
||||
if ( sRegSN1 != sMacSN1 || sRegSN2 != sMacSN2)
|
||||
// verifico che i primi due seriali coincidano e il terzo di registro esista (quello di macchina non conta)
|
||||
if ( sRegSN1 != sMacSN1 || sRegSN2 != sMacSN2 || sRegSN3.empty())
|
||||
return false ;
|
||||
|
||||
// costruisco l'Id di macchina dai seriali
|
||||
@@ -84,70 +93,19 @@ GetMachineId( string& sMachineId)
|
||||
bool
|
||||
GetMachineId2( string& sMachineId)
|
||||
{
|
||||
// recupero id in chiaro
|
||||
string sAux ;
|
||||
if ( ! GetMachineId( sAux))
|
||||
return false ;
|
||||
// eseguo Mix + CRC32 + Base64
|
||||
if ( ! MixMachineId( sAux))
|
||||
// Eseguo Mix + CRC32 + Base64.
|
||||
// Equivale a ConvertLockIdToLockId2 ma non lo uso per evitare link a sw chiave.
|
||||
if ( ! MixLockId( sAux))
|
||||
return false ;
|
||||
AddCrc32ToString( sAux) ;
|
||||
return B64Encode( sAux, sMachineId) ;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
bool
|
||||
GetMachineId3( string& sMachineId)
|
||||
{
|
||||
// recupero id in chiaro
|
||||
string sAux ;
|
||||
if ( ! GetMachineId( sAux))
|
||||
return false ;
|
||||
// eseguo Mix + Scramble + CRC32 + Base64
|
||||
if ( ! MixMachineId( sAux))
|
||||
return false ;
|
||||
if ( ! ScrambleMachineId( sAux))
|
||||
return false ;
|
||||
AddCrc32ToString( sAux) ;
|
||||
return B64Encode( sAux, sMachineId) ;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
bool
|
||||
ConvertMachineId2ToMachineId( const string& sMachId2, string& sMachId)
|
||||
{
|
||||
// eseguo decodifica da Base64
|
||||
if ( ! B64Decode( sMachId2, sMachId))
|
||||
return false ;
|
||||
// eseguo test e rimozione CRC32
|
||||
if ( ! TestCrc32AndRemoveFromString( sMachId))
|
||||
return false ;
|
||||
// eseguo demixing
|
||||
if ( ! MixMachineId( sMachId))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
bool
|
||||
ConvertMachineId2ToScramKey( const string& sMachId2, string& sScramKey)
|
||||
{
|
||||
// eseguo decodifica da Base64
|
||||
if ( ! B64Decode( sMachId2, sScramKey))
|
||||
return false ;
|
||||
// eseguo test e rimozione CRC32
|
||||
if ( ! TestCrc32AndRemoveFromString( sScramKey))
|
||||
return false ;
|
||||
// eseguo scramble
|
||||
if ( ! ScrambleMachineId( sScramKey))
|
||||
return false ;
|
||||
// aggiungo CRC32
|
||||
AddCrc32ToString( sScramKey) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
bool
|
||||
static bool
|
||||
GetSN123FromRegistry( string& sSN1, string& sSN2, string& sSN3)
|
||||
{
|
||||
// leggo MachineId da Registry
|
||||
@@ -155,8 +113,16 @@ GetSN123FromRegistry( string& sSN1, string& sSN2, string& sSN3)
|
||||
if ( ! LoadMachineIdFromReg( sRegOffMachId))
|
||||
return false ;
|
||||
// converto da forma offuscata (2) in forma chiara
|
||||
// Equivale a ConvertLockId2ToLockId ma non lo uso per evitare link a sw chiave.
|
||||
string sRegMachId ;
|
||||
if ( ! ConvertMachineId2ToMachineId( sRegOffMachId, sRegMachId))
|
||||
// eseguo decodifica da Base64
|
||||
if ( ! B64Decode( sRegOffMachId, sRegMachId))
|
||||
return false ;
|
||||
// eseguo test e rimozione CRC32
|
||||
if ( ! TestCrc32AndRemoveFromString( sRegMachId))
|
||||
return false ;
|
||||
// eseguo demixing
|
||||
if ( ! MixLockId( sRegMachId))
|
||||
return false ;
|
||||
// divisione in seriali
|
||||
sSN1 = sRegMachId.substr( 0, 6) ;
|
||||
@@ -167,7 +133,7 @@ GetSN123FromRegistry( string& sSN1, string& sSN2, string& sSN3)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
bool
|
||||
static bool
|
||||
GetSN123FromMachine( string& sSN1, string& sSN2, string& sSN3)
|
||||
{
|
||||
// recupero SN fisico del primo disco
|
||||
@@ -198,7 +164,7 @@ GetSN123FromMachine( string& sSN1, string& sSN2, string& sSN3)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
void
|
||||
static void
|
||||
AdjustSN( const string& sSou, const char* szFill, string& sDest)
|
||||
{
|
||||
static const int LEN_REF = 6 ;
|
||||
@@ -212,7 +178,7 @@ AdjustSN( const string& sSou, const char* szFill, string& sDest)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
DWORD
|
||||
static DWORD
|
||||
GetPhysicalDriveSN( UINT nDriveNumber, string& sSerialNumber)
|
||||
{
|
||||
DWORD dwRet = NO_ERROR ;
|
||||
@@ -282,7 +248,7 @@ GetPhysicalDriveSN( UINT nDriveNumber, string& sSerialNumber)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD
|
||||
static DWORD
|
||||
GetDiskVolumeSN( const wchar_t* wszDisk, string& sSerialNumber)
|
||||
{
|
||||
DWORD dwRet = NO_ERROR ;
|
||||
@@ -303,7 +269,7 @@ GetDiskVolumeSN( const wchar_t* wszDisk, string& sSerialNumber)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD
|
||||
static DWORD
|
||||
GetPseudoRandomSN( string& sSerialNumber)
|
||||
{
|
||||
sSerialNumber.clear() ;
|
||||
|
||||
Reference in New Issue
Block a user