Open bararchy opened 9 years ago
Mostly because of my lack of C knowledge this is working sometimes and segfaulting other times, if someone with some C experience can take a look it will be great.
Expected Results:
ruby test.rb 'wh' #<FFI::Pointer address=0x00000001a47080> aa 0
WTF Results:
ruby test.rb 'wh' #<FFI::Pointer address=0x00000000b04b10> aa /home/unshadow/Desktop/git-projects/Zakif/Filter/Filter_Sqli.rb:34: [BUG] Segmentation fault at 0x00000000000008 ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux] -- Control frame information ----------------------------------------------- c:0004 p:---- s:0016 e:000015 CFUNC :libinjection_is_sqli c:0003 p:0106 s:0012 e:000011 METHOD /home/unshadow/Desktop/git-projects/Zakif/Filter/Filter_Sqli.rb:34 c:0002 p:0038 s:0005 E:001d80 EVAL test.rb:4 [FINISH] c:0001 p:0000 s:0002 E:0014d0 TOP [FINISH] -- Ruby level backtrace information ---------------------------------------- test.rb:4:in `<main>' /home/unshadow/Desktop/git-projects/Zakif/Filter/Filter_Sqli.rb:34:in `is_sqlinjection?' /home/unshadow/Desktop/git-projects/Zakif/Filter/Filter_Sqli.rb:34:in `libinjection_is_sqli' -- Machine register context ------------------------------------------------ RIP: 0x00007ffaebed148a RBP: 0x00007ffe54d6e440 RSP: 0x00007ffe54d6e410 RAX: 0x0000000000000000 RBX: 0x00007ffe54d6e440 RCX: 0x0000000000000001 RDX: 0x0000000000861578 RDI: 0x0000000000000000 RSI: 0x0000000000000000 R8: 0x0000000000000002 R9: 0x00007ffaedc88509 R10: 0x00007ffe54d6e390 R11: 0x00007ffaebed1480 R12: 0x0000000000000008 R13: 0x0000000000000000 R14: 0x0000000000cf4a90 R15: 0x00007ffe54d6e560 EFL: 0x0000000000010202 -- C level backtrace information ------------------------------------------- /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(rb_vm_bugreport+0x4ea) [0x7ffaede05b0a] vm_dump.c:693 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(rb_bug_context+0xcb) [0x7ffaedc95d5b] error.c:425 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(sigsegv+0x3e) [0x7ffaedd76abe] signal.c:879 /usr/lib/libpthread.so.0 [0x7ffaeda0b740] /usr/lib/libinjection.so(libinjection_is_sqli+0xa) [0x7ffaebed148a] libinjection_sqli.c:2238 /usr/lib/libffi.so.6(ffi_call_unix64+0x4c) [0x7ffaec10f1f0] /usr/lib/libffi.so.6(ffi_call+0x2f8) [0x7ffaec10ec58] /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi_c.so(rbffi_CallFunction+0xfa) [0x7ffaec365c2a] Call.c:443 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi_c.so(custom_trampoline+0x16) [0x7ffaec3705a6] MethodHandle.c:232 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(vm_call_cfunc+0x144) [0x7ffaedded244] vm_insnhelper.c:1382 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(vm_call_method+0x11e) [0x7ffaeddfe27e] vm_insnhelper.c:1691 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(vm_exec_core+0x13fd) [0x7ffaeddf093d] insns.def:1054 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(vm_exec+0x78) [0x7ffaeddf5c58] vm.c:1400 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(rb_iseq_eval_main+0x203) [0x7ffaeddf7b93] vm.c:1670 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(ruby_exec_internal+0xbf) [0x7ffaedc9b44f] eval.c:252 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(ruby_exec_node+0x1d) [0x7ffaedc9d7fd] eval.c:317 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2(ruby_run_node+0x1e) [0x7ffaedca00be] eval.c:309 /home/unshadow/.rvm/rubies/ruby-2.2.2/bin/ruby(main+0x4b) [0x40089b] main.c:36 -- Other runtime information ----------------------------------------------- * Loaded script: test.rb * Loaded features: 0 enumerator.so 1 rational.so 2 complex.so 3 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/enc/encdb.so 4 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/enc/trans/transdb.so 5 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/unicode_normalize.rb 6 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/rbconfig.rb 7 thread.rb 8 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/thread.so 9 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/compatibility.rb 10 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/defaults.rb 11 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/deprecate.rb 12 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/errors.rb 13 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/version.rb 14 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/requirement.rb 15 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/platform.rb 16 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb 17 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/stub_specification.rb 18 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/util/stringio.rb 19 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb 20 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/exceptions.rb 21 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_gem.rb 22 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/monitor.rb 23 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb 24 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems.rb 25 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/path_support.rb 26 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb 27 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi_c.so 28 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/platform.rb 29 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/types.rb 30 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/library.rb 31 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/errno.rb 32 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/pointer.rb 33 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/memorypointer.rb 34 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/struct_layout_builder.rb 35 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/struct.rb 36 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/union.rb 37 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/managedstruct.rb 38 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/callback.rb 39 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/io.rb 40 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/autopointer.rb 41 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/variadic.rb 42 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/enum.rb 43 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi/ffi.rb 44 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi.rb 45 /home/unshadow/Desktop/git-projects/Zakif/Filter/Filter_Sqli.rb * Process memory map: 00400000-00401000 r-xp 00000000 fe:00 6428219 /home/unshadow/.rvm/rubies/ruby-2.2.2/bin/ruby 00600000-00601000 rw-p 00000000 fe:00 6428219 /home/unshadow/.rvm/rubies/ruby-2.2.2/bin/ruby 00806000-00d0e000 rw-p 00000000 00:00 0 [heap] 7ffaeae23000-7ffaeaf0b000 r--s 00000000 fe:00 13894658 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi_c.so 7ffaeaf0b000-7ffaeafa0000 r--s 00000000 08:01 5244813 /usr/lib/libinjection.so 7ffaeafa0000-7ffaebc7f000 r--s 00000000 fe:00 6428222 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2.0 7ffaebc7f000-7ffaebc95000 r-xp 00000000 08:01 5249177 /usr/lib/libgcc_s.so.1 7ffaebc95000-7ffaebe94000 ---p 00016000 08:01 5249177 /usr/lib/libgcc_s.so.1 7ffaebe94000-7ffaebe95000 rw-p 00015000 08:01 5249177 /usr/lib/libgcc_s.so.1 7ffaebe95000-7ffaebee5000 r-xp 00000000 08:01 5244813 /usr/lib/libinjection.so 7ffaebee5000-7ffaec0e5000 ---p 00050000 08:01 5244813 /usr/lib/libinjection.so 7ffaec0e5000-7ffaec109000 rw-p 00050000 08:01 5244813 /usr/lib/libinjection.so 7ffaec109000-7ffaec111000 r-xp 00000000 08:01 5282412 /usr/lib/libffi.so.6.0.4 7ffaec111000-7ffaec310000 ---p 00008000 08:01 5282412 /usr/lib/libffi.so.6.0.4 7ffaec310000-7ffaec311000 r--p 00007000 08:01 5282412 /usr/lib/libffi.so.6.0.4 7ffaec311000-7ffaec312000 rw-p 00008000 08:01 5282412 /usr/lib/libffi.so.6.0.4 7ffaec359000-7ffaec37b000 r-xp 00000000 fe:00 13894658 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi_c.so 7ffaec37b000-7ffaec57a000 ---p 00022000 fe:00 13894658 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi_c.so 7ffaec57a000-7ffaec57c000 rw-p 00021000 fe:00 13894658 /home/unshadow/.rvm/gems/ruby-2.2.2/gems/ffi-1.9.8/lib/ffi_c.so 7ffaec57c000-7ffaec57f000 r-xp 00000000 fe:00 6428560 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/thread.so 7ffaec57f000-7ffaec77f000 ---p 00003000 fe:00 6428560 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/thread.so 7ffaec77f000-7ffaec780000 rw-p 00003000 fe:00 6428560 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/thread.so 7ffaec780000-7ffaec782000 r-xp 00000000 fe:00 10618400 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/enc/trans/transdb.so 7ffaec782000-7ffaec982000 ---p 00002000 fe:00 10618400 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/enc/trans/transdb.so 7ffaec982000-7ffaec983000 rw-p 00002000 fe:00 10618400 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/enc/trans/transdb.so 7ffaec983000-7ffaec985000 r-xp 00000000 fe:00 10618390 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/enc/encdb.so 7ffaec985000-7ffaecb84000 ---p 00002000 fe:00 10618390 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/enc/encdb.so 7ffaecb84000-7ffaecb85000 rw-p 00001000 fe:00 10618390 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/x86_64-linux/enc/encdb.so 7ffaecb85000-7ffaecc86000 rw-p 00000000 00:00 0 7ffaecc86000-7ffaece1f000 r-xp 00000000 08:01 5246357 /usr/lib/libc-2.21.so 7ffaece1f000-7ffaed01f000 ---p 00199000 08:01 5246357 /usr/lib/libc-2.21.so 7ffaed01f000-7ffaed023000 r--p 00199000 08:01 5246357 /usr/lib/libc-2.21.so 7ffaed023000-7ffaed025000 rw-p 0019d000 08:01 5246357 /usr/lib/libc-2.21.so 7ffaed025000-7ffaed029000 rw-p 00000000 00:00 0 7ffaed029000-7ffaed12c000 r-xp 00000000 08:01 5246437 /usr/lib/libm-2.21.so 7ffaed12c000-7ffaed32c000 ---p 00103000 08:01 5246437 /usr/lib/libm-2.21.so 7ffaed32c000-7ffaed32d000 r--p 00103000 08:01 5246437 /usr/lib/libm-2.21.so 7ffaed32d000-7ffaed32e000 rw-p 00104000 08:01 5246437 /usr/lib/libm-2.21.so 7ffaed32e000-7ffaed336000 r-xp 00000000 08:01 5246365 /usr/lib/libcrypt-2.21.so 7ffaed336000-7ffaed535000 ---p 00008000 08:01 5246365 /usr/lib/libcrypt-2.21.so 7ffaed535000-7ffaed536000 r--p 00007000 08:01 5246365 /usr/lib/libcrypt-2.21.so 7ffaed536000-7ffaed537000 rw-p 00008000 08:01 5246365 /usr/lib/libcrypt-2.21.so 7ffaed537000-7ffaed565000 rw-p 00000000 00:00 0 7ffaed565000-7ffaed567000 r-xp 00000000 08:01 5246410 /usr/lib/libdl-2.21.so 7ffaed567000-7ffaed767000 ---p 00002000 08:01 5246410 /usr/lib/libdl-2.21.so 7ffaed767000-7ffaed768000 r--p 00002000 08:01 5246410 /usr/lib/libdl-2.21.so 7ffaed768000-7ffaed769000 rw-p 00003000 08:01 5246410 /usr/lib/libdl-2.21.so 7ffaed769000-7ffaed7f9000 r-xp 00000000 08:01 5249898 /usr/lib/libgmp.so.10.2.0 7ffaed7f9000-7ffaed9f9000 ---p 00090000 08:01 5249898 /usr/lib/libgmp.so.10.2.0 7ffaed9f9000-7ffaed9fa000 r--p 00090000 08:01 5249898 /usr/lib/libgmp.so.10.2.0 7ffaed9fa000-7ffaed9fb000 rw-p 00091000 08:01 5249898 /usr/lib/libgmp.so.10.2.0 7ffaed9fb000-7ffaeda13000 r-xp 00000000 08:01 5246393 /usr/lib/libpthread-2.21.so 7ffaeda13000-7ffaedc12000 ---p 00018000 08:01 5246393 /usr/lib/libpthread-2.21.so 7ffaedc12000-7ffaedc13000 r--p 00017000 08:01 5246393 /usr/lib/libpthread-2.21.so 7ffaedc13000-7ffaedc14000 rw-p 00018000 08:01 5246393 /usr/lib/libpthread-2.21.so 7ffaedc14000-7ffaedc18000 rw-p 00000000 00:00 0 7ffaedc18000-7ffaedee0000 r-xp 00000000 fe:00 6428222 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2.0 7ffaedee0000-7ffaee0e0000 ---p 002c8000 fe:00 6428222 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2.0 7ffaee0e0000-7ffaee0e8000 rw-p 002c8000 fe:00 6428222 /home/unshadow/.rvm/rubies/ruby-2.2.2/lib/libruby.so.2.2.0 7ffaee0e8000-7ffaee0f9000 rw-p 00000000 00:00 0 7ffaee0f9000-7ffaee11b000 r-xp 00000000 08:01 5246430 /usr/lib/ld-2.21.so 7ffaee120000-7ffaee143000 r--s 00000000 08:01 5246393 /usr/lib/libpthread-2.21.so 7ffaee143000-7ffaee2cd000 r--p 00000000 08:01 5302396 /usr/lib/locale/locale-archive 7ffaee2cd000-7ffaee2d2000 rw-p 00000000 00:00 0 7ffaee2e8000-7ffaee2e9000 rw-p 00000000 00:00 0 7ffaee2e9000-7ffaee2f2000 r--s 00000000 08:01 5282412 /usr/lib/libffi.so.6.0.4 7ffaee2f2000-7ffaee314000 r--s 00000000 fe:00 6428219 /home/unshadow/.rvm/rubies/ruby-2.2.2/bin/ruby 7ffaee314000-7ffaee315000 r-xp 00000000 00:00 0 7ffaee315000-7ffaee316000 ---p 00000000 00:00 0 7ffaee316000-7ffaee31a000 rw-p 00000000 00:00 0 [stack:18295] 7ffaee31a000-7ffaee31b000 r--p 00021000 08:01 5246430 /usr/lib/ld-2.21.so 7ffaee31b000-7ffaee31c000 rw-p 00022000 08:01 5246430 /usr/lib/ld-2.21.so 7ffaee31c000-7ffaee31d000 rw-p 00000000 00:00 0 7ffe54570000-7ffe54d70000 rw-p 00000000 00:00 0 7ffe54d9e000-7ffe54da0000 r--p 00000000 00:00 0 [vvar] 7ffe54da0000-7ffe54da2000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] [NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html Aborted (core dumped)
It seems that setting the malloc to 1024 fixed it... I have no idea why or if 1024 is too much or good amount, but it works....
Mostly because of my lack of C knowledge this is working sometimes and segfaulting other times, if someone with some C experience can take a look it will be great.
Expected Results:
WTF Results: