![]() |
|
ssdeep hash ile çalışan var mı - Baskı Önizleme +- Delphi Can (https://www.delphican.com) +-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3) +--- Forum: Genel Programlama (https://www.delphican.com/forumdisplay.php?fid=6) +--- Konu Başlığı: ssdeep hash ile çalışan var mı (/showthread.php?tid=4655) |
ssdeep hash ile çalışan var mı - berk06 - 28-03-2020 Merhaba, ssdeep(https://github.com/ssdeep-project/ssdeep) hash kütüphanesini deneyimleyen var mı? fuzzy.dll ile işlem yapmaya çalışıyorum fakat c den çevirme konusunda baya zorlandım. Delphi ile ilgili kaynağı sıfır durumda sanırım google üzerinden hiç bir ip ucu bulamadım. bu hariç Cvp: ssdeep hash ile çalışan var mı - ismailkocacan - 29-03-2020 (28-03-2020, Saat: 00:20)berk06 Adlı Kullanıcıdan Alıntı: fuzzy.dll ile işlem yapmaya çalışıyorum fakat c den çevirme konusunda baya zorlandım. Aşağıdaki kaynakları inceleyebilirsiniz.
ssdeep hash ile çalışan var mı - engerex - 30-03-2020 Merhaba, function GetDosOutput(CommandLine: string; Work: string = 'C:\'): AnsiString;
var
SA: TSecurityAttributes;
SI: TStartupInfo;
PI: TProcessInformation;
StdOutPipeRead, StdOutPipeWrite: THandle;
WasOK: Boolean;
Buffer: array[0..255] of ansiChar;
BytesRead: Cardinal;
WorkDir: String;
Handle: Boolean;
begin
Result := '';
with SA do begin
nLength := SizeOf(SA);
bInheritHandle := True;
lpSecurityDescriptor := nil;
end;
CreatePipe(StdOutPipeRead, StdOutPipeWrite, @SA, 0);
try
with SI do
begin
FillChar(SI, SizeOf(SI), 0);
cb := SizeOf(SI);
dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't redirect stdin
hStdOutput := StdOutPipeWrite;
hStdError := StdOutPipeWrite;
end;
WorkDir := Work;
Handle := CreateProcess(nil, PChar('cmd.exe /C ' + CommandLine),
nil, nil, True, 0, nil,
PChar(WorkDir), SI, PI);
CloseHandle(StdOutPipeWrite);
if Handle then
try
repeat
WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
if BytesRead > 0 then
begin
Buffer[BytesRead] := #0;
Result := Result + Buffer;
end;
until not WasOK or (BytesRead = 0);
WaitForSingleObject(PI.hProcess, INFINITE);
finally
CloseHandle(PI.hThread);
CloseHandle(PI.hProcess);
end;
finally
CloseHandle(StdOutPipeRead);
end;
end;
function SSDEEP(Fname : string): string;
var
s1 : AnsiString;
i1, i2 : Integer;
begin
Result := GetDosOutput('C:\Win32\Debug\ssdeep.exe '+Fname);
i1 := Pos(#10,Result);
i2 := Pos(',',Result,43);
Result := MidStr(Result,i1+1,i2-i1-1);
end;
ssdeep.exe için : https://yadi.sk/d/DlccwfDqjk8bXA Cvp: ssdeep hash ile çalışan var mı - berk06 - 30-03-2020 (29-03-2020, Saat: 17:41)ismailkocacan Adlı Kullanıcıdan Alıntı:Değerli kaynaklar için teşekkür ederim, ayrıca araştırırken https://github.com/WouterVanNifterick/C-To-Delphi böyle bir programa rastladım. En azından karmaşık gelen yerlerde biraz rahatlattı beni. Fakat işin içinden çıkamayacağımı anladım. dll i python ile kullanabilmişler, delphi içerisinde py çalıştıran bir kütüphane görmüştüm belki onun üzerinden çeviriye gidebilirim. Bu karantina günlerinde python öğrenmek için güzel bir fırsat olabilir(28-03-2020, Saat: 00:20)berk06 Adlı Kullanıcıdan Alıntı: fuzzy.dll ile işlem yapmaya çalışıyorum fakat c den çevirme konusunda baya zorlandım. ![]() (30-03-2020, Saat: 00:01)engerex Adlı Kullanıcıdan Alıntı: Merhaba, Çok teşekkür ederim, dll dışında ki tek yolu direkt göstermiş oldunuz. Cvp: ssdeep hash ile çalışan var mı - berk06 - 01-04-2020 İki ssdeep çıktısını kıyaslamak için; const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; function LevenshteinDistance(const s, t: string): integer;inline; var d : array of array of integer; n, m, i, j : integer; begin n := length(s); m := length(t); if n = 0 then Exit(m); if m = 0 then Exit(n); SetLength(d, n + 1, m + 1); for i := 0 to n do d[i, 0] := i; for j := 0 to m do d[0, j] := j; for i := 1 to n do for j := 1 to m do d[i, j] := Min(Min(d[i-1, j]+1, d[i,j-1]+1), d[i-1,j-1]+Integer(s[i] <> t[j])); Result := d[n, m]; end; function matchScore(s1,s2:String):Extended; var e,r :Extended; begin e := LevenshteinDistance(s1,s2); r := 1 - e / Max(s1.Length,s2.Length); Result := r * 100; end; function similarity(d1,d2:String):Extended; var b1,b2 :integer; begin b1 := b64.IndexOf(d1.Chars[0]); b2 := b64.IndexOf(d2.Chars[0]); if (b1 > b2) then Result := similarity(d2,d1); if ((Abs(b1-b2)) > 1) then Result := 0 else if (b1 = b2) then Result := matchScore(d1.Split([':'])[1],d2.Split([':'])[1]) else Result := matchScore(d1.Split([':'])[2],d2.Split([':'])[1]); end; Buradan kodları çevirdim > https://github.com/cloudtracer/ssdeep.js/blob/master/ssdeep.js LevenshteinDistance kaynağı> https://stackoverflow.com/questions/10580241/how-can-i-compute-a-difference-between-two-strings/10593797#10593797 ssdeep hash ile çalışan var mı - berk06 - 15-06-2024 unit dSSDEEP; interface uses SysUtils, Windows; const FUZZY_FLAG_ELIMSEQ = $1; FUZZY_FLAG_NOTRUNC = $2; SPAMSUM_LENGTH = 64; FUZZY_MAX_RESULT = 2 * SPAMSUM_LENGTH + 20; type PFuzzyState = ^TFuzzyState; TFuzzyState = record // Define the internal state fields here end; function FuzzyNew: PFuzzyState; stdcall; external 'fuzzy.dll' name 'fuzzy_new'; function FuzzyClone(const state: PFuzzyState): PFuzzyState; stdcall; external 'fuzzy.dll' name 'fuzzy_clone'; function FuzzySetTotalInputLength(state: PFuzzyState; totalFixedLength: UInt64): Integer; stdcall; external 'fuzzy.dll' name 'fuzzy_set_total_input_length'; function FuzzyUpdate(state: PFuzzyState; const buffer: PByte; bufferSize: NativeUInt): Integer; stdcall; external 'fuzzy.dll' name 'fuzzy_update'; function FuzzyDigest(const state: PFuzzyState; result: PAnsiChar; flags: UInt32): Integer; stdcall; external 'fuzzy.dll' name 'fuzzy_digest'; procedure FuzzyFree(state: PFuzzyState); stdcall; external 'fuzzy.dll' name 'fuzzy_free'; function FuzzyHashBuf(const buf: PByte; bufLen: UInt32; result: PAnsiChar): Integer; stdcall; external 'fuzzy.dll' name 'fuzzy_hash_buf'; function FuzzyHashFile(handle: THandle; result: PAnsiChar): Integer; stdcall; external 'fuzzy.dll' name 'fuzzy_hash_file'; function FuzzyHashStream(handle: THandle; result: PAnsiChar): Integer; stdcall; external 'fuzzy.dll' name 'fuzzy_hash_stream'; function FuzzyHashFilename(const filename: PAnsiChar; result: PAnsiChar): Integer; stdcall; external 'fuzzy.dll' name 'fuzzy_hash_filename'; function FuzzyCompare(const sig1, sig2: PAnsiChar): Integer; stdcall; external 'fuzzy.dll' name 'fuzzy_compare'; implementation end. |