Skip to content

Instantly share code, notes, and snippets.

View picatz's full-sized avatar
Graph Theory

Kent Gruber picatz

Graph Theory
View GitHub Profile
@picatz
picatz / streaming_unix_password_cracking_api_basic_post_params_to_config.rb
Created April 16, 2017 18:13
Violent Ruby: Streaming REST API Unix Password Cracker using Params
post '/crack_passwords' do
content_type :json
config = {
file: params['file'][:tempfile],
dictionary: params['dictionary'][:tempfile]
}
upc = ViolentRuby::UnixPasswordCracker.new(config) # not really doing anything
end
@picatz
picatz / streaming_unix_password_cracking_api_basic_stream.rb
Created April 16, 2017 18:16
Violent Ruby: Streaming REST API Unix Password Cracker Basic Stream
post '/crack_passwords' do
content_type :json
config = {
file: params['file'][:tempfile],
dictionary: params['dictionary'][:tempfile]
}
stream do |out|
ViolentRuby::UnixPasswordCracker.new(config).crack do |result|
out << result.to_json
end
@picatz
picatz / thread_poold_port_scanner_1.rb
Created July 8, 2017 23:21
Starting a Thread Pool'd Port Scanner
require 'socket'
require 'thread'
@picatz
picatz / thread_poold_port_scanner_2.rb
Created July 8, 2017 23:35
Thread Pool'd Port Scanner End of Operation Class
require 'socket'
require 'thread'
# Class to signal end of operation for job queue.
class EndOfOp ; end
@picatz
picatz / thread_poold_port_scanner_3.rb
Created July 8, 2017 23:42
Thread Pool'd Port Scanner Base Class
# previous code...
class PortScanner
def initialize(host:, ports: (1..1024))
@host = host
@ports = ports
@semaphore = Mutex.new
end
@picatz
picatz / thread_poold_port_scanner_4.rb
Created July 8, 2017 23:52
Thread Pool'd connect_to method
# previous code...
class PortScanner
# previous code ...
def connect_to(port, ip = @host)
# Create proccess to be ran later.
p = Proc.new do
# Create socket.
@picatz
picatz / thread_poold_port_scanner_5.rb
Created July 8, 2017 23:58
Thread Pool'd threaded_scan Method
# previous code...
class PortScanner
# previous code ...
def threaded_scan(threads: 10)
pool = Queue.new
# Spool up jobs in a queue with its own thread.
Thread.new do
@picatz
picatz / thread_poold_port_scanner_5.rb
Created July 9, 2017 00:03
Thread Pool'd Using Scanner
# previous code...
ps = PortScanner.new host: "target_ip_or_web.com"
ps.threaded_scan threads: 5
@picatz
picatz / port_scanner_crystal.cr
Last active July 9, 2017 20:03
Crystal Port Scanner
require "socket"
host = "target_ip"
ports = (1..1024).to_a
channel = Channel(Nil).new
semaphore = Mutex.new
spawn do
60.times do
@picatz
picatz / example.cr
Last active July 30, 2017 15:06
ARGV Error
ARGV << "example"
i = ARGV.index("example")
i # is 0
result = i + 1
# expect result to be 1