Skip to content

Instantly share code, notes, and snippets.

View gr33n7007h's full-sized avatar
🌴
On vacation

Li gr33n7007h

🌴
On vacation
View GitHub Profile
@gr33n7007h
gr33n7007h / homer
Created March 23, 2019 13:44
c0mrade
,---. ,.'-. \ ( ( ,'"""""-. `,X `. /` ` `._ ( , ,_\ | ,---.,'o `. | / o \ ) \ ,. ( .____, \| \ \____,' \ '`'\ \ _,____,' \ ,-- ,-' \ ( C ,' \ `--' .' | | | .O | __| \ ,-'_ / `L `._ _,' ' `. / `--.._ `',. _\ ` `-. /\ | `. ( ,\ \ _/ `-._ / \ |--' ( \ ' `-. `' \/\`. `. ) \ \ `. | |
@gr33n7007h
gr33n7007h / monkey
Last active March 23, 2019 13:25
c0mrade
__.__ .--. .-" "-. .--. / .. \/ .-. .-. \/ .. \ | | '| / Y \ |' | | | \ \ \ 0 | 0 / / / | \ '- ,\.-"'' ''"-./, -' / ''-' /_ ^ ^ _\ '-'' | \._ _./ | \ \ '~' / / '._ '-=-' _.' '~---~'
@gr33n7007h
gr33n7007h / segv.rb
Created February 9, 2019 15:54
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"
>> module IO::Extensions
| extend Fiddle::Importer
| dlload Fiddle::Handle::DEFAULT
| extern 'int pipe2(int pipefd[2], int flags)'
|
| def self.pipe_2 flags:
| pipefds = [0,0].pack 'i2'
| if pipe2(pipefds, flags).zero?
| pipefds.unpack('i2').map &IO.method(:for_fd)
| else
@gr33n7007h
gr33n7007h / imap.rb
Created December 23, 2018 04:37
SNI test
>> require 'net/imap'
=> true
>> Net::IMAP.new "imap.gmail.com", 993, true
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate)
from /usr/lib/ruby/2.5.0/net/protocol.rb:44:in `connect_nonblock'
>> m = <<~SNI_test
| def start_tls_session(params = {})
| unless defined?(OpenSSL::SSL)
| raise "SSL extension not installed"
| end
require 'net/http'
uri = URI.parse("https://mydomain.com/attachments")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Got this"
req_options = {
use_ssl: uri.scheme == "https",
}
@gr33n7007h
gr33n7007h / test.rb
Created December 11, 2018 23:34
argon2
require 'fiddle/import'
module Test
extend Fiddle::Importer
dlload '/usr/lib/libargon2.so.1'
typealias 'uint8_t', 'unsigned char'
typealias 'uint32_t', 'unsigned int'
Argon2_Context = struct [
@gr33n7007h
gr33n7007h / b.rb
Created November 2, 2018 13:49
binary dance ;)
loop { $><< "\e[#{rand(50)};#{rand(50)}H"; $><< "%d" % rand(2); sleep 0.1 }
@gr33n7007h
gr33n7007h / signal.rb
Last active October 15, 2018 00:46
Messing about with Signals.
require 'fiddle'
require 'fiddle/import'
module Signal::C
include Fiddle
extend Fiddle::Importer
dlload Handle::DEFAULT
SigHandler = bind 'void sig_cb(int)' do |signo|
puts %q{you can't escape me!} if signo == 2
end
@gr33n7007h
gr33n7007h / getkeycodes.rb
Created September 18, 2018 19:29
getkeycodes
#!/usr/bin/env ruby
require 'fiddle'
require 'fiddle/import'
#require 'io/console'
extend Fiddle::Importer
KDGETKEYCODE = 0x4b4c