Skip to content

Instantly share code, notes, and snippets.

@bararchy
Last active August 29, 2015 14:20
Show Gist options
  • Save bararchy/f962f4003f6eb734a443 to your computer and use it in GitHub Desktop.
Save bararchy/f962f4003f6eb734a443 to your computer and use it in GitHub Desktop.
Libinjection Ruby Wrapper
module LibInject
extend FFI::Library
ffi_lib_flags :now, :global
ffi_lib 'libinjection.so'
class Sfilter < FFI::Struct
# layout :s, :pointer,
# :slen, :size_t,
# :userdata, :pointer,
# :flags, :int,
# :pos, :size_t
end
attach_function :libinjection_sqli_init, [Sfilter, :string, :size_t, :int], :long
attach_function :libinjection_is_sqli, [Sfilter], :int
end
class FilterSqli
def self.is_sqlinjection?(data)
length = data.size
puts "alive"
return 0 if length == 0
puts "alive 2"
sfilter = FFI::Pointer.new :pointer, length
puts "Alive 3 #{sfilter}"
LibInject::libinjection_sqli_init(sfilter, data, length, 0)
puts "alive 4"
is_injection = LibInject::libinjection_is_sqli(sfilter)
rescue => e
puts e.message, e.backtrace
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment