Skip to content

Instantly share code, notes, and snippets.

View KINGSABRI's full-sized avatar
♠️

KING SABRI KINGSABRI

♠️
View GitHub Profile
@KINGSABRI
KINGSABRI / ex-ssh-pty.rb
Created August 28, 2012 16:04
ex. SSH with real PTY
require 'net/ssh'
host = "the.host"
user = "joe"
su_user = "bob"
password = "password"
commands = ["cd /", "pwd", "ls -l", "exit"]
finished = ("%08x" * 8) % Array.new(8) { rand(0xFFFFFFFF) }
@jstorimer
jstorimer / port_scanner.rb
Created August 30, 2012 03:40
Simple, parallel port scanner in Ruby built with connect_nonblock and IO.select.
require 'socket'
# Set up the parameters.
PORT_RANGE = 1..512
HOST = 'archive.org'
TIME_TO_WAIT = 5 # seconds
# Create a socket for each port and initiate the nonblocking
# connect.
sockets = PORT_RANGE.map do |port|
@acook
acook / keypress.rb
Created December 2, 2012 18:42
Read keypresses from user in terminal, including arrow keys using pure Ruby. This has since been folded into a much more robust gem called Remedy. https://rubygems.org/gems/remedy & https://github.com/acook/remedy
require 'io/console'
# Reads keypresses from the user including 2 and 3 escape character sequences.
def read_char
STDIN.echo = false
STDIN.raw!
input = STDIN.getc.chr
if input == "\e" then
input << STDIN.read_nonblock(3) rescue nil
@shinaisan
shinaisan / test.rb
Created December 17, 2012 14:58
A PE header reading sample using BinData Ruby gem.
require 'bindata'
require 'pp'
class ImageDosHeader < BinData::Record
endian :little
uint16 :e_magic, :check_value => 0x5A4D # MZ
uint16 :e_cblp
uint16 :e_cp
uint16 :e_crlc
uint16 :e_cparhdr
@spalladino
spalladino / san.msupn.rb
Last active March 20, 2018 13:38
Extracting Subject Alternative Name Other Name (1.3.6.1.4.1.311.20.2.3) from Microsoft authorization client certificates
cert = OpenSSL::X509::Certificate.new(certificate_string)
subject_alt_name = cert.extensions.find {|e| e.oid == "subjectAltName"}
# Parse the subject alternate name certificate extension as ASN1, first value should be the key
asn_san = OpenSSL::ASN1.decode(subject_alt_name)
raise "Expected ASN1 Subject Alternate Name extension key to be subjectAltName but was #{asn_san.value[0].value}" if asn_san.value[0].value != 'subjectAltName'
# And the second value should be a nested ASN1 sequence
asn_san_sequence = OpenSSL::ASN1.decode(asn_san.value[1].value)
@rxaviers
rxaviers / gist:7360908
Last active June 2, 2024 16:48
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@mubix
mubix / hacked_windowtext.rb
Created December 20, 2013 05:03
Sets all of the windows titles for the current user to "Hacked"
windows = client.extapi.window.enumerate
windows.each do |winder|
if winder[:title] != 'Default IME'
result = client.railgun.user32.SetWindowTextA(winder[:handle],"Hacked")
end
end
@sonots
sonots / gist:8923003
Last active February 14, 2017 11:35
how to use net/http in muliti threads
require 'net/http'
require 'uri'
host = "localhost"
port = 5125
path = "/api/hoge/hoge/hoge"
body = URI.encode_www_form({'number'=>0, 'mode'=>'gauge'})
# 1)
@client = Net::HTTP.new(host, port)
# @client.set_debug_output(STDOUT)
@mubix
mubix / brutelist.rb
Created February 20, 2014 04:54
Just charset brute force script
#!/usr/bin/env ruby
#
## Brute code stolen form: https://gist.github.com/petehamilton/4755855
#
def result?(sub)
puts sub
1 == 2
@mubix
mubix / brutedns.rb
Created February 20, 2014 04:55
Iteratively brutes dns hostnames
#!/usr/bin/env ruby
#
## Brute code stolen form: https://gist.github.com/petehamilton/4755855
#
@domain = 'contoso.com'
def result?(sub)
results = %x(dig +noall #{sub}.#{@domain} +answer)