Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h
Created February 9, 2019 15:54
Show Gist options
  • Save gr33n7007h/a152a88b3ed78b8d42cfc10f4adfc103 to your computer and use it in GitHub Desktop.
Save gr33n7007h/a152a88b3ed78b8d42cfc10f4adfc103 to your computer and use it in GitHub Desktop.
segfault.
>> handler = Handle.new '/usr/local/lib/libmonocypher.so'
=> #<Fiddle::Handle:0x0000556323b489b8>
>> sign_public_key = Function.new(handler.sym('crypto_sign_public_key'), [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOID)
=> #<Fiddle::Function:0x0000556323b723a8 @abi=2, @args=[1, 1], @ptr=140618144978256, @return_type=0>
>> sign = Function.new(handler.sym('crypto_sign'), [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_SIZE_T], TYPE_VOID)
=> #<Fiddle::Function:0x0000556323ba1b30 @abi=2, @args=[1, 1, 1, 1, -5], @ptr=140618144981584, @return_type=0>
>> check = Function.new(handler.sym('crypto_check'), [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_SIZE_T], TYPE_INT)
=> #<Fiddle::Function:0x0000556323bdf7f0 @abi=2, @args=[1, 1, 1, -5], @ptr=140618144985856, @return_type=4>
>> sk = Random.bytes 32
=> "\xA9\x8A\xEEi\x85\x90\xAF\xEEq\xDAm\x7FX\x12\x96YMa\x80\xC2V\x8Ee\xB4\xF5\xA4\xCBA\x9F!\x8E\x81"
>> pk = [''].pack('a32')
=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
>> sign_public_key.(pk, sk)
=> nil
>> pk
=> "E\xF0JX3\xEB=\x0Egb\xD0\x96kw:\xF43\x06\x961E\xEF\xE2hD?}VG\xF0\x19Z"
>> sig = "foo"
=> "foo"
>> msg = "hello world!"
=> "hello world!"
>>
>> sign.(sig, sk, pk, msg, msg.bytesize)
=> nil
>> "returns 0 for legitimate messages and -1 for forgeries";
>>
>> check.(sig, pk, msg, msg.size)
=> 0
>> wipe = Function.new(handler.sym('crypto_wipe'), [TYPE_VOIDP, TYPE_SIZE_T], TYPE_VOID)
=> #<Fiddle::Function:0x0000556323475230 @abi=2, @args=[1, -5], @ptr=140618144958208, @return_type=0>
>>
>> wipe.(sk, sk.bytesize)
=> nil
>> sk
=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
>>
>> %(/home/gr33n7007h/.gem/ruby/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:190: [BUG] Segmentation fault at 0x0000000000000000
| ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]
| )
=> "/home/gr33n7007h/.gem/ruby/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:190: [BUG] Segmentation fault at 0x0000000000000000\nruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]\n"
>> ??????????? aaarh!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment