ssdeep 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ === 0.0.1 / 2010-04-10
2
+
3
+ * First Version
4
+
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/
6
+ ext/ssdeep/ruby-ssdeep.c
7
+ ext/ssdeep/extconf.rb
@@ -0,0 +1,59 @@
1
+ = ssdeep
2
+
3
+ * ssdeep ruby bindings (http://redstack.net/ruby-ssdeep)
4
+
5
+ == DESCRIPTION:
6
+
7
+ This are simple binding for the ssdeep C library (http://ssdeep.sourceforge.net/)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Bindings fo hash_filename(), hash_buffer() and fuzzy_compare() APIs
12
+
13
+ == SYNOPSIS:
14
+
15
+ require 'ssdeep'
16
+ # Fuzzy hash a buffer's content
17
+ hash1 = Ssdeep.fuzzy_hash_buf("This string contains the data of first file :)")
18
+ # Fuzzy hash the content of the file '/path/to/file'
19
+ hash2 = Ssdeep.fuzzy_hash_filename("/path/to/file")
20
+ # Compare the 2 hashes, a value between 0 (no match) and 100 (full match) is returned
21
+ Ssdeep.fuzzy_compare(hash1, hash2)
22
+
23
+ == REQUIREMENTS:
24
+
25
+ * ssdeep library and headers
26
+
27
+ == INSTALL:
28
+
29
+ * sudo gem install ssdeep
30
+
31
+ == DEVELOPERS:
32
+
33
+ After checking out the source, run:
34
+
35
+ $ rake compile
36
+
37
+ This task will compile the extension
38
+
39
+ == LICENSE:
40
+
41
+ (The GPL License)
42
+
43
+ Copyright (c) 2010 Raffaello Pelagalli
44
+
45
+ This program is free software; you can redistribute it and/or
46
+ modify it under the terms of the GNU General Public License
47
+ as published by the Free Software Foundation; either version 2
48
+ of the License, or (at your option) any later version.
49
+
50
+ This program is distributed in the hope that it will be useful,
51
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
52
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53
+ GNU General Public License for more details.
54
+
55
+ You should have received a copy of the GNU General Public License
56
+ along with this program; if not, write to the Free Software
57
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
58
+ 02111-1307, USA.
59
+
@@ -0,0 +1,28 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'rake/extensiontask'
5
+
6
+ spec = Gem::Specification.new do |s|
7
+ s.author = "Raffaello Pelagalli"
8
+ s.email = "r _at_ redstack _dot_ net"
9
+ s.name = "ssdeep"
10
+ s.version = "0.0.3"
11
+ s.homepage = "http://redstack.net/ruby-ssdeep"
12
+ s.summary = "SSDEEP bindings for Ruby"
13
+ s.description = <<-EOF
14
+ 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.
15
+ EOF
16
+ s.platform = Gem::Platform::RUBY
17
+ s.extensions = FileList["ext/**/extconf.rb"]
18
+ s.files = FileList['lib/', 'bin/*', '[A-Z]*', 'test/**/*', 'ext/**/*'].to_a
19
+ end
20
+
21
+ # add your default gem packing task
22
+ Rake::GemPackageTask.new(spec) do |pkg|
23
+ end
24
+
25
+
26
+ Rake::ExtensionTask.new('ssdeep', spec)
27
+
28
+ # vim: syntax=ruby
@@ -0,0 +1,14 @@
1
+ require 'mkmf'
2
+
3
+ dir_config("ssdeep")
4
+
5
+ if not have_header("fuzzy.h") or not have_library("fuzzy", "fuzzy_compare")
6
+ fail <<-EOM
7
+ Can't find ssdeep library or headers.
8
+
9
+ Try passing --with-ssdeep-dir or --with-sdeep-lib and --with-ssdeep-include
10
+ options to extconf.
11
+ EOM
12
+ end
13
+
14
+ create_makefile("ssdeep")
@@ -0,0 +1,49 @@
1
+ #include "ruby.h"
2
+ #include <stdint.h>
3
+ #include "fuzzy.h"
4
+
5
+ static VALUE ssdeep_compare(VALUE module, VALUE h1, VALUE h2)
6
+ {
7
+ int n;
8
+
9
+ Check_Type(h1, T_STRING);
10
+ Check_Type(h2, T_STRING);
11
+
12
+ n = fuzzy_compare(RSTRING(h1)->ptr, RSTRING(h2)->ptr);
13
+ if (n == -1)
14
+ rb_raise(rb_eRuntimeError, "Error while comparing hashes");
15
+ return (INT2FIX(n));
16
+ }
17
+
18
+ static VALUE ssdeep_hash_buf(VALUE module, VALUE buf)
19
+ {
20
+ char hash[FUZZY_MAX_RESULT];
21
+
22
+ Check_Type(buf, T_STRING);
23
+
24
+ if (fuzzy_hash_buf(RSTRING(buf)->ptr, RSTRING(buf)->len, hash))
25
+ rb_raise(rb_eRuntimeError, "Error while fuzzy hashing");
26
+
27
+ return rb_str_new2(hash);
28
+ }
29
+
30
+ static VALUE ssdeep_hash_filename(VALUE module, VALUE path)
31
+ {
32
+ char hash[FUZZY_MAX_RESULT];
33
+
34
+ Check_Type(path, T_STRING);
35
+
36
+ if (fuzzy_hash_filename(RSTRING(path)->ptr, hash))
37
+ rb_raise(rb_eRuntimeError, "Error while fuzzy hashing");;
38
+
39
+ return rb_str_new2(hash);
40
+ }
41
+
42
+ void Init_ssdeep()
43
+ {
44
+ VALUE mSsdeep;
45
+ mSsdeep = rb_define_module("Ssdeep");
46
+ rb_define_module_function(mSsdeep, "fuzzy_compare", ssdeep_compare, 2);
47
+ rb_define_module_function(mSsdeep, "fuzzy_hash_buf", ssdeep_hash_buf, 1);
48
+ rb_define_module_function(mSsdeep, "fuzzy_hash_filename", ssdeep_hash_filename, 1);
49
+ }
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ssdeep
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 3
9
+ version: 0.0.3
10
+ platform: ruby
11
+ authors:
12
+ - Raffaello Pelagalli
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-10 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: |
22
+ 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.
23
+
24
+ email: r _at_ redstack _dot_ net
25
+ executables: []
26
+
27
+ extensions:
28
+ - ext/ssdeep/extconf.rb
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - README.txt
33
+ - Rakefile
34
+ - History.txt
35
+ - Manifest.txt
36
+ - ext/ssdeep/ruby-ssdeep.c
37
+ - ext/ssdeep/extconf.rb
38
+ has_rdoc: true
39
+ homepage: http://redstack.net/ruby-ssdeep
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.6
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: SSDEEP bindings for Ruby
68
+ test_files: []
69
+