This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "fisk" | |
require "aarch64" | |
require "jit_buffer" | |
require "fiddle" | |
x86 = Fisk.new | |
x86.put_label(:foo) | |
x86.mov(x86.rax, x86.imm(42)) | |
x86.ret | |
x86.jmp(x86.label(:foo)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Smart Health Card decoder | |
# This decodes the SHC url thing that is stored in smart health card QR codes | |
str = DATA.readline | |
require "base64" | |
require "zlib" | |
require "json" | |
require "pp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fiddle, passing a pointer to an int. This gets the current process command | |
module Hacks | |
include Fiddle | |
func = "_NSGetExecutablePath" | |
path_ptr = Fiddle::Handle::DEFAULT[func] | |
path = Function.new path_ptr, [TYPE_VOIDP, TYPE_INTPTR_T], TYPE_INT, name: func | |
define_singleton_method(func, &path.to_proc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "fisk" | |
require "fisk/helpers" | |
require "fiddle/import" | |
module Ruby | |
extend Fiddle::Importer | |
dlload | |
typealias "VALUE", "uintptr_t" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Have you ever wanted lldb to break in a certain place, but you weren't | |
# sure where to set the breakpoint? Look no further than this script! | |
# | |
# This script creates a chunk of executable code that uses the int3 x86 | |
# instruction. This instruction is defined for use by debuggers, and you can | |
# read more about it here: https://en.wikipedia.org/wiki/INT_%28x86_instruction%29#INT3 | |
# | |
# When that instruction is executed, the debugger will halt and you can do | |
# what you need! | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "objspace" | |
require "json" | |
def go x | |
count = GC.stat(:major_gc_count) | |
loop do | |
info = JSON.parse(ObjectSpace.dump(x)) | |
break if info["flags"]["old"] | |
GC.start | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'pp' | |
files = {'vm.inc' => [], 'insns.def' => []} | |
current_insn = nil | |
current_filename = 'vm.inc' | |
lineno_offset = 0 | |
IO.foreach('vm.inc') do |line| | |
case line | |
when /^INSN_ENTRY\((\w+)\)/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Not Great PNG class. This is a very simple example of writing a PNG. It | |
# only supports colors from the color palette stored in `@palette`. This is | |
# meant to be example code, but I am using it in a program for visualizing | |
# heap dumps from Ruby. | |
# | |
# This is free and unencumbered software released into the public domain. | |
# | |
# Anyone is free to copy, modify, publish, use, compile, sell, or | |
# distribute this software, either in source code form or as a compiled | |
# binary, for any purpose, commercial or non-commercial, and by any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[aaron@tc-lan-adapter ~]$ cat x.rb | |
require "rbconfig" | |
# Change the compiler to "aarons-compiler" | |
RbConfig::CONFIG["CC"] = "aarons-compiler" | |
[aaron@tc-lan-adapter ~]$ RUBYOPT='-I/Users/aaron -rx' gem install sqlite3 | |
Building native extensions. This could take a while... | |
ERROR: Error installing sqlite3: | |
ERROR: Failed to build gem native extension. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.