I have been using this so far
system 'strings binary-file.dmp | grep search_string'
Is there something more "Ruby like"?
Here is my quick-and-dirty strings.rb:
#! /usr/bin/ruby
ARGV.each do |filename|
File.open filename,"rb" do |f|
f.each_line do |line|
line.scan(/([\x32-\x7e]{4,})/).each {|a| puts a[0]}
end
end
end
This is not a work of art or anything - it only works in straight US-ASCII. The regex bascially means "all groups of printable US-ASCII characters of size 4 charaters or more". This is essentially what strings(1)
does.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.