patch 2f5946769fbd42615e0c7961d096fbdae3375146
Author: Raffaello Pelagalli <r@redstack.net>
Date: Sat Apr 10 19:56:28 CEST 2010
tagged 0.0.3
depend patch 79b0407af15880ca1811cd8b7bc83c896367e871
* v0.0.3
depend patch e94e6cfcc6556cdde0df539ee436291fd0b025d7
* Correction of readme errors
depend patch c7578fd196dfa016f42e8c4c9c34a6982dc54266
* TAG 0.0.2
patch 79b0407af15880ca1811cd8b7bc83c896367e871
Author: Raffaello Pelagalli <r@redstack.net>
Date: Sat Apr 10 19:56:14 CEST 2010
* v0.0.3
hunk ./Rakefile 10
- s.version = "0.0.2"
+ s.version = "0.0.3"
patch e94e6cfcc6556cdde0df539ee436291fd0b025d7
Author: Raffaello Pelagalli <r@redstack.net>
Date: Sat Apr 10 19:55:28 CEST 2010
* Correction of readme errors
hunk ./README.txt 17
- hash1 = Ssdeep.hash_buffer("This string contains the data of first file :)")
+ hash1 = Ssdeep.fuzzy_hash_buf("This string contains the data of first file :)")
hunk ./README.txt 19
- hash2 = Ssdeep.hash_filename("/path/to/file")
+ hash2 = Ssdeep.fuzzy_hash_filename("/path/to/file")
patch c7578fd196dfa016f42e8c4c9c34a6982dc54266
Author: Raffaello Pelagalli <r@redstack.net>
Date: Sat Apr 10 19:29:01 CEST 2010
tagged 0.0.2
depend patch c843d89323642d1ce40e50b18968c437e09905ba
* First import
patch c843d89323642d1ce40e50b18968c437e09905ba
Author: Raffaello Pelagalli <r@redstack.net>
Date: Sat Apr 10 19:28:19 CEST 2010
* First import
addfile ./History.txt
hunk ./History.txt 1
+=== 0.0.1 / 2010-04-10
+
+* First Version
+
addfile ./Manifest.txt
hunk ./Manifest.txt 1
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+lib/
+ext/ssdeep/ruby-ssdeep.c
+ext/ssdeep/extconf.rb
addfile ./README.txt
hunk ./README.txt 1
+= ssdeep
+
+* ssdeep ruby bindings (http://redstack.net/ruby-ssdeep)
+
+== DESCRIPTION:
+
+This are simple binding for the ssdeep C library (http://ssdeep.sourceforge.net/)
+
+== FEATURES/PROBLEMS:
+
+* Bindings fo hash_filename(), hash_buffer() and fuzzy_compare() APIs
+
+== SYNOPSIS:
+
+ require 'ssdeep'
+ # Fuzzy hash a buffer's content
+ hash1 = Ssdeep.hash_buffer("This string contains the data of first file :)")
+ # Fuzzy hash the content of the file '/path/to/file'
+ hash2 = Ssdeep.hash_filename("/path/to/file")
+ # Compare the 2 hashes, a value between 0 (no match) and 100 (full match) is returned
+ Ssdeep.fuzzy_compare(hash1, hash2)
+
+== REQUIREMENTS:
+
+* ssdeep library and headers
+
+== INSTALL:
+
+* sudo gem install ssdeep
+
+== DEVELOPERS:
+
+After checking out the source, run:
+
+ $ rake compile
+
+This task will compile the extension
+
+== LICENSE:
+
+(The GPL License)
+
+Copyright (c) 2010 Raffaello Pelagalli
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+ [_$_]
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+
addfile ./Rakefile
hunk ./Rakefile 1
+# -*- ruby -*-
+
+require 'rubygems'
+require 'rake/extensiontask'
+
+spec = Gem::Specification.new do |s|
+ s.author = "Raffaello Pelagalli"
+ s.email = "r _at_ redstack _dot_ net"
+ s.name = "ssdeep"
+ s.version = "0.0.2"
+ s.homepage = "http://redstack.net/ruby-ssdeep"
+ s.summary = "SSDEEP bindings for Ruby"
+ s.description = <<-EOF
+ssdeep is a program for computing context triggered piecewise hashes (CTPH). Also called fuzzy hashes, CTPH can match inputs that have homologies. Such inputs have sequences of identical bytes in the same order, although bytes in between these sequences may be different in both content and length.
+EOF
+ s.platform = Gem::Platform::RUBY
+ s.extensions = FileList["ext/**/extconf.rb"]
+ s.files = FileList['lib/', 'bin/*', '[A-Z]*', 'test/**/*', 'ext/**/*'].to_a
+end
+
+# add your default gem packing task
+Rake::GemPackageTask.new(spec) do |pkg|
+end
+
+
+Rake::ExtensionTask.new('ssdeep', spec)
+
+# vim: syntax=ruby
adddir ./ext
adddir ./ext/ssdeep
addfile ./ext/ssdeep/extconf.rb
hunk ./ext/ssdeep/extconf.rb 1
+require 'mkmf'
+
+dir_config("ssdeep")
+
+if not have_header("fuzzy.h") or not have_library("fuzzy", "fuzzy_compare")
+ fail <<-EOM
+ Can't find ssdeep library or headers.
+
+ Try passing --with-ssdeep-dir or --with-sdeep-lib and --with-ssdeep-include
+ options to extconf.
+ EOM
+end
+
+create_makefile("ssdeep")
addfile ./ext/ssdeep/ruby-ssdeep.c
hunk ./ext/ssdeep/ruby-ssdeep.c 1
+#include "ruby.h"
+#include <stdint.h>
+#include "fuzzy.h"
+
+static VALUE ssdeep_compare(VALUE module, VALUE h1, VALUE h2)
+{
+ int n;
+
+ Check_Type(h1, T_STRING);
+ Check_Type(h2, T_STRING);
+
+ n = fuzzy_compare(RSTRING(h1)->ptr, RSTRING(h2)->ptr);
+ if (n == -1)
+ rb_raise(rb_eRuntimeError, "Error while comparing hashes");
+ return (INT2FIX(n));
+}
+
+static VALUE ssdeep_hash_buf(VALUE module, VALUE buf)
+{
+ char hash[FUZZY_MAX_RESULT];
+ [_$_]
+ Check_Type(buf, T_STRING);
+ [_$_]
+ if (fuzzy_hash_buf(RSTRING(buf)->ptr, RSTRING(buf)->len, hash))
+ rb_raise(rb_eRuntimeError, "Error while fuzzy hashing");
+
+ return rb_str_new2(hash);
+}
+
+static VALUE ssdeep_hash_filename(VALUE module, VALUE path)
+{
+ char hash[FUZZY_MAX_RESULT];
+ [_$_]
+ Check_Type(path, T_STRING);
+ [_$_]
+ if (fuzzy_hash_filename(RSTRING(path)->ptr, hash))
+ rb_raise(rb_eRuntimeError, "Error while fuzzy hashing");;
+
+ return rb_str_new2(hash);
+}
+
+void Init_ssdeep()
+{
+ VALUE mSsdeep;
+ mSsdeep = rb_define_module("Ssdeep");
+ rb_define_module_function(mSsdeep, "fuzzy_compare", ssdeep_compare, 2);
+ rb_define_module_function(mSsdeep, "fuzzy_hash_buf", ssdeep_hash_buf, 1);
+ rb_define_module_function(mSsdeep, "fuzzy_hash_filename", ssdeep_hash_filename, 1);
+}
adddir ./lib