Skip to content

Instantly share code, notes, and snippets.

View bararchy's full-sized avatar

Bar Hofesh bararchy

View GitHub Profile
@bararchy
bararchy / experimntal
Last active August 29, 2015 14:03
Testing
Process.spawn do
Dir.mktmpdir do |temp_dir|
driver = Driver.new(temp_dir)
%x(sudo mv backup* #{temp_dir})
print "\nDone, the backup archive has been created at #{temp_dir}/backup#{Time.now.strftime('%Y%m%d-%H%M')}.tar.gz"
server = Ftpd::FtpServer.new(driver)
get_ip
server.interface = @localip
server.start
puts "\nFTP server listening on port #{server.bound_port}, Press enter to close the FTP server\n"
@bararchy
bararchy / Safe-T1
Created July 20, 2014 19:13
Ruby code for Safe-T 1
#!/usr/bin/ruby
require 'savon'
user = ""
pass = ""
server = ""
msg = "######################################################################\n"\
@cookies = []
@cookies << ["1234", Time.now, "this will be deleted"]
sleep 1
@cookies << ["1234", Time.now + 1, "this also should be deleted"]
sleep 1
@cookies << ["1234", Time.now + 60, "this wont be deleted"]
sleep 5
puts "This is the whole array: ", @cookies
@bararchy
bararchy / ugly :(
Created November 17, 2014 09:45
CRIME check
def check_s_client
server = "Generel Settings: "
renegotiation = "Insecure Renegotiation".colorize(:red)
crime = "SSL Compression Enabled <= CRIME - CVE-2012-4929".colorize(:red)
results = %x(echo "q" | openssl s_client -host #{@server} -port #{@port} 2> /dev/null)
if results =~ /Secure Renegotiation IS supported/i
renegotiation = "Secured Renegotiation".colorize(:green)
end
if results =~ /Compression: NONE/
crime = "SSL Compression is disabled".colorize(:green)
require 'ffi'
require 'socket'
module SSL_Client
extend FFI::Library
ffi_lib 'ssl'
attach_function :SSL_library_init, [], :int
attach_function :SSL_load_error_strings, [], :long
attach_function :SSLv3_client_method, [], :long
@bararchy
bararchy / fiddle.rb
Last active August 29, 2015 14:09 — forked from ik5/fiddle.rb
require 'fiddle'
require 'socket'
libssl = Fiddle.dlopen('/usr/lib/libssl.so')
ssl_init = Fiddle::Function.new(libssl['SSL_library_init'],[],Fiddle::TYPE_INT)
ssl_load_error = Fiddle::Function.new(libssl['SSL_load_error_strings'],[],Fiddle::TYPE_INT)
ssl_client_method = Fiddle::Function.new(libssl['SSLv3_client_method'],[],Fiddle::TYPE_LONG)
ssl_ctx = Fiddle::Function.new(libssl['SSL_CTX_new'],[Fiddle::TYPE_LONG],Fiddle::TYPE_LONG)
ssl_ctx_reneg = Fiddle::Function.new(libssl['SSL_CTX_sess_connect_renegotiate'],[Fiddle::TYPE_LONG],Fiddle::TYPE_LONG)
@bararchy
bararchy / initiate
Created November 21, 2014 08:58
SSHScoket
require 'fiddle'
require 'socket'
libssh = Fiddle.dlopen('/usr/lib/libssh.so')
# sshbind = ssh_bind_new();
# session = ssh_new();
ssh_bind = Fiddle::Function.new(libssh['ssh_bind_new'],[],Fiddle::TYPE_LONG)
ssh_session = Fiddle::Function.new(libssh['ssh_new'],[],Fiddle::TYPE_LONG)
ssh_bind_listen = Fiddle::Function.new(libssh['ssh_bind_listen'],[Fiddle::TYPE_LONG],Fiddle::TYPE_INT)
ssh_bind_accept = Fiddle::Function.new(libssh['ssh_bind_accept'],[Fiddle::TYPE_LONG, Fiddle::TYPE_LONG],Fiddle::TYPE_CHAR)
@bararchy
bararchy / gist:611823f691dbf765c80c
Created November 22, 2014 10:07
SSH Socket Try 1
require 'fiddle'
require 'socket'
libssh = Fiddle.dlopen('/usr/lib/libssh.so')
ssh_bind = Fiddle::Function.new(libssh['ssh_bind_new'],[],Fiddle::TYPE_LONG_LONG)
ssh_session = Fiddle::Function.new(libssh['ssh_new'],[],Fiddle::TYPE_LONG_LONG)
ssh_bind_listen = Fiddle::Function.new(libssh['ssh_bind_listen'],[Fiddle::TYPE_LONG_LONG],Fiddle::TYPE_INT)
ssh_bind_accept = Fiddle::Function.new(libssh['ssh_bind_accept'],[Fiddle::TYPE_LONG_LONG,Fiddle::TYPE_LONG_LONG],Fiddle::TYPE_CHAR)
ssh_get_error = Fiddle::Function.new(libssh['ssh_get_error'],[Fiddle::TYPE_LONG],Fiddle::TYPE_CHAR)
@bararchy
bararchy / sshsock.rb
Last active August 29, 2015 14:10
SSHScoket v2
require 'rubygems'
require 'ffi'
module SSHSocket
extend FFI::Library
ffi_lib_flags :now, :global
ffi_lib 'libssh'
attach_function :ssh_init, [], :int
attach_function :ssh_bind_new, [], :pointer
@bararchy
bararchy / Error.sh
Created November 25, 2014 10:30
sigfault
ruby sshsocket.rb
No Error: 0
No Error: 0
No Error: 0
No Error: 0
No Error: 0
should return 'SSH_OK':
sshsocket.rb:65: [BUG] Segmentation fault at 0x000000ffffffc0
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]