I'm running into a strange error... After I call a thrift method, all file IO I try to do fails with errors like:
log writing failed. undefined method `write_struct_begin'
This occurs if I try to do logger.info etc., or even if I just open a file directly, and try to write to it.
Totally stumped!
The problem was that the Thrift interface I was consuming defined a type called "File". As soon as I pulled in the generated Ruby code for this file it rewrote the built-in File class. It would be nice if ruby's thrift generator namespaced things better!
Related
I have a simple ruby script which prints a exception message when something goes wrong.
i am unable to find where the logs are stored to check this.
any help on this would be really great.
Thanks.
There are no log files. When errors occur, the Ruby standard library will write its messages to the standard error stream. You can redirect this to a file if you'd like.
Of course, you can do whatever you want in your own code. It's absolutely possible to open a file and log messages to it. There are many logging libraries that provide this functionality.
I've been trying to get credentials hashes on a windows meterpreter session, but each time i run "run post/windows/gather/hashdump" i get the following error:
Post failed: NoMethodError undefined method unpack' for nil:NilClass
Call stack:
/usr/share/metasploit-framework/modules/post/windows/gather/hashdump.rb:42:inrun'
the unpack() method is used through all of the hashdump.rb script but as the meterpeter session tells it's not defined.
I've never used ruby before, so i don't know whether it's a predefined method or should i define it, nor how to do it.
Any help is appreciated.
Thanks.
It looks like hashdump is failing to retrieve the boot key from the system registry. My best guess is that you're trying to run hashdump without system privileges.
With insufficient access, the script returns nil instead of the boot key, then tries to unpack nil which causes a fairly unhelpful NoMethodError.
Try running getsystem before you run hashdump.
I'm trying out DOMPDF and include this file as instructed: dompdf_config.inc.php. But when I go to the page, I get a fatal error, as in the title. It appears the file with classes isn't be loaded or something is going on. Any suggestions?
Since you're using 0.6.x (based on the presence of the dompdf_config.inc.php file) the correct method is $dompdf->load_html(); [wiki].
When loading a page, I am getting the following error:
Uncaught TypeError: no implicit conversion of NilClass into Hash
I am using the volt framework for ruby. My routes file inside of the component is as follows:
client '/summary_reporting/daily_reports/new', component: 'summary_reporting', controller: 'daily_reports', action: 'new'
My controller and view are correctly made and declared and the component was generated using:
bundle exec volt generate component summary_reporting
Can anyone offer some insight?
I think I just fixed an issue that was similar to this. Are you loading the url with a #fragment ? If thats not it, any chance you can post the code somewhere so I can try it and figure out what the issue is?
Thanks
I figured it out, just needed to include the new component in the main dependencies file.
I want to grab the contents of a webpage like this:
open("http://www.ruby-lang.org/")
However, sometimes, that page doesn't exist:
open("http://www.ruby-lang.org/blabla.html")
The open command throws an exception. I know I can catch that exception, but it seems inappropriate in my case. I know there will regularly be bad URLs because visitors and users type in URLs to retrieve.
I don't like the idea of using exceptions for this regular situation. Is there a way that I can know the page was not found without an exception being thrown?
You're using a simplified method to read a file (open-uri), so you're getting a simplified result for errors. It's just not a robust way of doing things beyond simple success/fail.
Check out using Net::HTTP (specifically the request method) or Mechanize or many other available APIs for such tasks.