Skip to content

Instantly share code, notes, and snippets.

View ch1c0t's full-sized avatar

Anatoly Chernov ch1c0t

View GitHub Profile
modules = ObjectSpace.each_object(Module).reject { |m| m.is_a? Class }
p modules.map { |m| m.to_s }
p modules.size
module Hobby
class Test
class Report
def initialize exchanges
@exchanges = exchanges
end
def ok?
@exchanges.all? &:passed?
end
module Hobby
class Test
class Report
def initialize(exchanges)
@exchanges = self
end
end
end
end
- rspec:0:./spec/http_spec.rb:8/Hobby::JSON #<Hobby::Test:0x00000002f60818> works
[0/1897]
evil:Hobby::JSON.included:/home/ch1c0t/sources/ruby/hobby-json/lib/hobby/json.rb:6:581f7
@@ -1,5 +1,5 @@
-def self.included(app)
+def self.included
app.use(Rack::ContentType, "application/json")
app.response = Response
end
-----------------------
- rspec:0:./spec/http_spec.rb:8/Hobby::JSON #<Hobby::Test:0x00000003018e40> works
evil:Hobby::JSON.included:/home/ch1c0t/sources/ruby/hobby-json/lib/hobby/json.rb:6:581f7
@@ -1,5 +1,5 @@
-def self.included(app)
+def self.included
app.use(Rack::ContentType, "application/json")
app.response = Response
end
-----------------------
Mutant configuration:
module Hobby
module Auth
def self.[] *users
Module.new do
define_singleton_method :included do |app|
users.each do |user|
app.define_singleton_method user.downcase do |route|
action = route.action
route.action = -> do
if user = (user.find_by_token request.headers['Authorization'])
TRACE_POINTS = []
TRACE = TracePoint.new :return, :c_return do |t|
TRACE_POINTS << [t.event, t.path, t.lineno, t.binding, t.defined_class, t.method_id, t.return_value]
end
def Trace
TRACE_POINTS.clear
TRACE.enable
yield
TRACE.disable
curl https://rubygems.org/api/v1/gems/method_source/reverse_dependencies.json
# http://eli.thegreenplace.net/2011/09/29/an-interesting-tree-serialization-algorithm-from-dwarf
def load array
root = Node.new array.shift.first
stack = [root]
array.each do |pair|
if pair.nil?
stack.pop
else
#define _GNU_SOURCE
#include <dlfcn.h>
#include <unistd.h>
#include <stdio.h>
typedef int (*LibcStartMainFnType)(int (*main)(int, char **, char **), int argc, char **argv,
int (*init)(void), void (*fini)(void),
void (*ldso_fini)(void), void (*stack_end));
int __libc_start_main(int (*main)(int, char **, char **), int argc, char **argv,