forked from coderobe/VBiosFinder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* auto-fix formatting where acceptable * adjust regexps * fix issues with uppercase names * correct upx path to output file
- Loading branch information
Showing
11 changed files
with
165 additions
and
166 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require "./src/cli" | ||
require './src/cli' | ||
|
||
$0=ARGV.first | ||
$PROGRAM_NAME=$0 | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
require "terrapin" | ||
require 'terrapin' | ||
|
||
module VBiosFinder | ||
class Extract | ||
def self.p7zip file | ||
begin | ||
line = Terrapin::CommandLine.new("7z", "x :file") | ||
line.run(file: file) | ||
rescue Terrapin::ExitStatusError => e | ||
puts e.message | ||
return | ||
end | ||
def self.p7zip(file) | ||
line = Terrapin::CommandLine.new('7z', 'x :file') | ||
line.run(file: file) | ||
rescue Terrapin::ExitStatusError => e | ||
puts e.message | ||
nil | ||
end | ||
end | ||
|
||
class Test | ||
def self.p7zip file | ||
begin | ||
line = Terrapin::CommandLine.new("7z", "l :file | grep 'Type = 7z'") | ||
line.run(file: file) | ||
true | ||
rescue Terrapin::ExitStatusError => e | ||
false | ||
end | ||
def self.p7zip(file) | ||
line = Terrapin::CommandLine.new('7z', "l :file | grep 'Type = 7z'") | ||
line.run(file: file) | ||
true | ||
rescue Terrapin::ExitStatusError => e | ||
false | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
require "terrapin" | ||
require 'terrapin' | ||
|
||
module VBiosFinder | ||
class Extract | ||
def self.innosetup file | ||
begin | ||
line = Terrapin::CommandLine.new("innoextract", ":file") | ||
puts line.run(file: file) | ||
rescue Terrapin::ExitStatusError => e | ||
puts e.message | ||
return | ||
end | ||
def self.innosetup(file) | ||
line = Terrapin::CommandLine.new('innoextract', ':file') | ||
puts line.run(file: file) | ||
rescue Terrapin::ExitStatusError => e | ||
puts e.message | ||
nil | ||
end | ||
end | ||
|
||
class Test | ||
def self.innosetup file | ||
begin | ||
line = Terrapin::CommandLine.new("innoextract", "-t :file") | ||
line.run(file: file) | ||
true | ||
rescue Terrapin::ExitStatusError => e | ||
false | ||
end | ||
def self.innosetup(file) | ||
line = Terrapin::CommandLine.new('innoextract', '-t :file') | ||
line.run(file: file) | ||
true | ||
rescue Terrapin::ExitStatusError => e | ||
false | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
module VBiosFinder | ||
class Extract | ||
def self.polyglot file | ||
File.open file, "r:ASCII-8BIT" do |data| | ||
regex = /(.{4})\xAA\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51(.{1})/n | ||
def self.polyglot(file) | ||
File.open file, 'r:ASCII-8BIT' do |data| | ||
regex = /(.{4})\xAA\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51(.)/n | ||
input = data.read | ||
matches = regex.match input | ||
payload_size = matches.captures.first.unpack('V').first | ||
payload_size = matches.captures.first.unpack1('V') | ||
payload_offset = matches.offset(2).last | ||
data.seek payload_offset | ||
File.open "#{file}-polyglot", "w:ASCII-8BIT" do |outdata| | ||
File.open "#{file}-polyglot", 'w:ASCII-8BIT' do |outdata| | ||
outdata.write data.read | ||
end | ||
end | ||
end | ||
end | ||
|
||
class Test | ||
def self.polyglot file | ||
File.open file, "r:ASCII-8BIT" do |data| | ||
regex = /(.{4})\xAA\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51.{1}/n | ||
return !(regex.match(data.read).nil?) | ||
def self.polyglot(file) | ||
File.open file, 'r:ASCII-8BIT' do |data| | ||
regex = /(.{4})\xAA\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51./n | ||
return !regex.match(data.read).nil? | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
require "terrapin" | ||
require 'terrapin' | ||
|
||
module VBiosFinder | ||
class Extract | ||
def self.uefi file | ||
begin | ||
line = Terrapin::CommandLine.new("UEFIExtract", ":file all") | ||
line.run(file: file) | ||
rescue Terrapin::ExitStatusError => e | ||
# TODO: fix Test::uefi before uncommenting this | ||
puts e.message | ||
return | ||
end | ||
def self.uefi(file) | ||
line = Terrapin::CommandLine.new('uefiextract', ':file all') | ||
line.run(file: file) | ||
rescue Terrapin::ExitStatusError => e | ||
# TODO: fix Test::uefi before uncommenting this | ||
puts e.message | ||
nil | ||
end | ||
end | ||
|
||
class Test | ||
def self.uefi file | ||
begin | ||
line = Terrapin::CommandLine.new("UEFIExtract", ":file report") | ||
line.run(file: file) | ||
true | ||
rescue Terrapin::ExitStatusError => e | ||
false | ||
end | ||
def self.uefi(file) | ||
line = Terrapin::CommandLine.new('uefiextract', ':file report') | ||
line.run(file: file) | ||
true | ||
rescue Terrapin::ExitStatusError => e | ||
false | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
require "terrapin" | ||
require 'terrapin' | ||
|
||
module VBiosFinder | ||
class Extract | ||
def self.upx file | ||
begin | ||
line = Terrapin::CommandLine.new("upx", "-d :file -o :outfile") | ||
line.run(file: file, outfile: "upx-#{file}") | ||
rescue Terrapin::ExitStatusError => e | ||
puts e.message | ||
return | ||
end | ||
def self.upx(file) | ||
line = Terrapin::CommandLine.new('upx', '-d :file -o :outfile') | ||
line.run(file: file, outfile: "upx-#{File.basename(file)}") | ||
rescue Terrapin::ExitStatusError => e | ||
puts e.message | ||
nil | ||
end | ||
end | ||
|
||
class Test | ||
def self.upx file | ||
begin | ||
line = Terrapin::CommandLine.new("upx", "-t :file") | ||
line.run(file: file) | ||
true | ||
rescue Terrapin::ExitStatusError => e | ||
false | ||
end | ||
def self.upx(file) | ||
line = Terrapin::CommandLine.new('upx', '-t :file') | ||
line.run(file: file) | ||
true | ||
rescue Terrapin::ExitStatusError => e | ||
false | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
require "zlib" | ||
require 'zlib' | ||
|
||
module VBiosFinder | ||
class Extract | ||
def self.zlib file | ||
def self.zlib(file) | ||
target = "#{file}-zlib" | ||
begin | ||
File.open file, "r:ASCII-8BIT" do |data| | ||
File.open target, "w:ASCII-8BIT" do |outdata| | ||
File.open file, 'r:ASCII-8BIT' do |data| | ||
File.open target, 'w:ASCII-8BIT' do |outdata| | ||
outdata.write Zlib::Inflate.inflate(data.read) | ||
end | ||
end | ||
rescue Zlib::DataError | ||
puts "wrong guess :(".colorize(:red) | ||
puts 'wrong guess :('.colorize(:red) | ||
FileUtils.rm target | ||
end | ||
end | ||
end | ||
|
||
class Test | ||
def self.zlib file | ||
File.open file, "r:ASCII-8BIT" do |data| | ||
def self.zlib(file) | ||
File.open file, 'r:ASCII-8BIT' do |data| | ||
regex = /^\x78\x9C/n | ||
return !(regex.match(data.read).nil?) | ||
return !regex.match(data.read).nil? | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Oops, something went wrong.