Skip to content

Instantly share code, notes, and snippets.

@knugie
knugie / macOS.md
Created September 30, 2021 07:43
Open ssh tunnel macOS

image

@knugie
knugie / keyboard_controller.rb
Last active March 10, 2022 07:57 — forked from efi/keyboard_controller.rb
Send system keyboard events in JRuby via java.awt.Robot
class KeyboardController
def initialize
@robot = java.awt.Robot.new
end
def type *args
[args].flatten.map(&:to_s).map{|s|s.split(/\s+/)}.flatten.map(&:upcase).each do |n|
press, name = (n[0]=="-") ? [false,n[1..-1]] : [true,n]
press ? @robot.key_press(@code) : @robot.key_release(@code) if @code = java.awt.event.KeyEvent.const_get("VK_#{name}")
end
self
@knugie
knugie / decrypt.rb
Last active March 26, 2022 07:56 — forked from equivalent/gist:b492f6779e99ee9defb2
WIP: Ruby AES Encryption using AES-256-CBC
require 'openssl'
# We use the AES 256 bit cipher-block chaining symetric encryption.
# AES 256 is virtually impenetrable using brute-force methods.
# However, CBC introduces a data integrity vulnerability (stream cipher attacks).
# We should use HMAC or GCM to mitigate the issue.
alg = 'aes-256-cbc'
cipher = OpenSSL::Cipher::Cipher.new(alg)
cipher.decrypt
@knugie
knugie / decrypt.rb
Created March 26, 2022 07:56
WIP: Ruby AES Encryption using AES-256-GCM
require 'openssl'
################
# Public Input #
################
hex_message = 'a9a08f273d9e96d567ccc3db8f6a6634c895973a260e2b7cb36c1dde457293102163900cc12ffe4ec51aa02db70a0979b510911fa99d50aeadd67f7ff0c37a8ab82e5e45cb4b7d713e8365b1f0e67e188e2807fa31f674f25318de6de122517a06cfa018e0edf308eeaa87530720ecdcac42'
auth_data = 'something'
################
# Secret Input #
@knugie
knugie / pdf2jpg.sh
Created April 9, 2022 05:49
Split PDF into JPEGs
gs -dNOPAUSE -sDEVICE=jpeg -r300 -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -sOutputFile="document-%02d.jpg" "document.pdf" -dBATCH