메모리 영역이 액세스되지 않도록 보호하고 더 이상 필요하지 않은 경우 데이터가 지워지도록하여 해커 또는 프로세스 디버거로부터 민감한 데이터를 보호합니다.

암호화 키, 암호 및 기타 기밀 데이터와 같은 민감한 정보를 무단 액세스로부터 보호하는 것이 중요합니다. 적절한 메모리 보호가 없으면 메모리에 일시적으로 저장된 민감한 데이터조차도 메모리 덤프 나 프로세스 주입과 같은 공격에 취약 할 수 있습니다. 이 장치는 메모리를 잠그고 보호하여 민감한 데이터가 더 이상 필요하지 않을 때는 차폐 및 안전하게 지워지도록 도와줍니다.
ProtectedMemory 장치를 Delphi 프로젝트로 다운로드하십시오.ProtectMemory , UnProtectMemory 및 ReleaseProtectedMemory 절차를 사용하여 메모리를 보호하십시오.ReleaseAllProtectedMemory 호출하여 사용 후 메모리를 릴리스하고 지우는지 확인하십시오.TProtectedStream 클래스가 추가되었습니다TMemoryStream 에서 상속되는 새로운 TProtectedStream 클래스가 추가되었습니다.VirtualAlloc 사용하고 메모리를 보호하고 보호하지 않도록 VirtualProtect 사용합니다.IsProtected 속성을 사용하면 보호 (액세스 없음)와 보호되지 않은 상태 (읽기/쓰기)를 전환 할 수 있습니다. uses
ProtectedMemory;
var
Data: array [ 0 .. 255 ] of Byte;
DataPtr: Pointer;
begin
Data[ 0 ] := 99 ;
Data[ 1 ] := 11 ;
Data[ 2 ] := 22 ;
Data[ 3 ] := 33 ;
Data[ 4 ] := 44 ;
Data[ 5 ] := 55 ;
DataPtr := @Data[ 0 ];
// Protect the memory (prevents access to the memory region)
ProtectMemory(DataPtr, SizeOf(Data));
// Accessing the protected memory here will return zeros.
// Unprotect the memory before accessing it
UnProtectMemory(DataPtr);
// Optionally release the memory and clear its content
ReleaseProtectedMemory(DataPtr);
end ; uses
ProtectedMemory;
var
SensitiveStr: string;
NonSensitiveStr: string;
DataPtr: Pointer;
begin
SensitiveStr := ' Sensitive Data ' ;
NonSensitiveStr := ' Not Sensitive Data ' ;
// Get a pointer to SensitiveStr's memory
DataPtr := Pointer(SensitiveStr);
// Protect the memory region containing SensitiveStr
Writeln( ' Protecting memory... ' );
ProtectMemory(DataPtr, Length(SensitiveStr) * SizeOf(Char));
// Accessing SensitiveStr here will return zeros or show undefined behavior
Writeln( ' SensitiveStr after protection: ' , SensitiveStr);
// You can still access NonSensitiveStr, which is unaffected
NonSensitiveStr := ' Updated Non-Sensitive Data ' ;
Writeln( ' NonSensitiveStr: ' , NonSensitiveStr);
// UnProtect Memory it's reutrn it's orginal data
Writeln( ' Releasing memory... ' );
UnProtectMemory(DataPtr);
// SensitiveStr is now restored
Writeln( ' Restored SensitiveStr: ' , SensitiveStr);
end ; uses
ProtectedStream;
var
Stream: TProtectedStream;
Data: AnsiString;
Buffer: array [ 0 .. 255 ] of Byte;
begin
Data := ' Sensitive Data ' ;
Stream := TProtectedStream.Create;
try
Stream.Write(PAnsiChar(Data)^, Length(Data));
Data := ' ' ;
Stream.IsProtected := True; // Protect the memory
// Unprotect to read
Stream.IsProtected := False;
Stream.Read(Buffer, 10 );
finally
Stream.Free;
end ;
end ; ProtectMemory(var DataPtr: Pointer; Size: NativeUInt) : 지정된 메모리 영역을 PAGE_NOACCESS 로 설정하여 페이징을 방지하기 위해 그것을 잠그면 보호합니다. 데이터는 새로운 보호 메모리 블록에 복사되며 원래 포인터 가이 보호 블록을 가리키도록 업데이트됩니다.
UnProtectMemory(DataPtr: Pointer) : 메모리 보호를 PAGE_READWRITE 로 복원하고 보호 된 메모리 블록 목록에서 영역을 제거합니다.
ReleaseProtectedMemory(DataPtr: Pointer) : 메모리 액세스를 복원하고 메모리를 안전하게 제로화하여 내용을 지우고 보호 된 목록에서 제거합니다.
ReleaseAllProtectedMemory() : 모든 보호 된 메모리 영역을 릴리스하고 지 웁니다.
Shadi Ajam
예! 우리는 당신의 지원을 사랑합니다! 주세요. 다른 사람들과 공유하십시오.
소셜 미디어 공유 :