Created
November 22, 2014 10:07
-
-
Save bararchy/611823f691dbf765c80c to your computer and use it in GitHub Desktop.
SSH Socket Try 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
sshbind = ssh_bind.call | |
puts "sshbind pointer: #{sshbind}" | |
sshsession = ssh_session.call | |
puts "sshsession pointer: #{sshsession}" | |
result = ssh_bind_listen.call(sshbind) | |
if result.to_i < 0 | |
puts "Error: #{ssh_get_error.call(sshbind)}" | |
else | |
puts "ssh_bind_listen should return 0: #{result}" | |
end | |
sshaccept = ssh_bind_accept.call(sshbind, sshsession) | |
puts "sshaccept should return 'SSH_OK': #{sshaccept}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment