Skip to content

Cumulative PR #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# frozen_string_literal: true

source "https://rubygems.org"
source 'https://rubygems.org'

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem "terrapin"
gem 'rubocop', group: 'development'
gem 'terrapin'

gem 'thor', '~> 1.2.1'

# Added at 2017-12-24 10:16:46 +0100 by coderobe:
gem "thor", "~> 0.20.0"
gem 'pry', '~> 0.14.1'

# Added at 2017-12-24 12:04:47 +0100 by coderobe:
gem "pry", "~> 0.11.3"
gem 'posix-spawn', '~> 0.3.13'

# Added at 2017-12-24 12:27:01 +0100 by coderobe:
gem "posix-spawn", "~> 0.3.13"

# Added at 2017-12-24 12:50:49 +0100 by coderobe:
gem "colorize", "~> 0.8.1"
gem 'colorize', '~> 0.8.1'
43 changes: 33 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
climate_control (0.2.0)
coderay (1.1.2)
coderay (1.1.3)
colorize (0.8.1)
method_source (0.9.0)
posix-spawn (0.3.13)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
json (2.6.2)
method_source (1.0.0)
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
posix-spawn (0.3.15)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rainbow (3.1.1)
regexp_parser (2.6.0)
rexml (3.2.5)
rubocop (1.37.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.23.0)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
thor (0.20.0)
thor (1.2.1)
unicode-display_width (2.3.0)

PLATFORMS
ruby

DEPENDENCIES
colorize (~> 0.8.1)
posix-spawn (~> 0.3.13)
pry (~> 0.11.3)
pry (~> 0.14.1)
rubocop
terrapin
thor (~> 0.20.0)
thor (~> 1.2.1)

BUNDLED WITH
1.17.3
2.3.24
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Some dependencies might not offer a package for your linux distribution **(like
- Extracted VBIOS roms will be placed in `./output`

## Compatibility (non-exhaustive)
- Acer Aspire E1-571G (and models with the same BIOS)
- [ASUS N580GD](https://github.com/coderobe/VBiosFinder/issues/15)
- Lenovo y50-70
- [Lenovo S5 2nd Gen (20JAA009HH)](https://github.com/coderobe/VBiosFinder/issues/1)
Expand Down
2 changes: 1 addition & 1 deletion _init.rb
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
Expand Down
32 changes: 17 additions & 15 deletions src/cli.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
require "thor"
require "fileutils"
require "logger"
require "colorize"
require "./src/methods"
require "./src/utils"

#Terrapin::CommandLine.logger = Logger.new(STDOUT)
require 'thor'
require 'fileutils'
require 'logger'
require 'colorize'
require './src/methods'
require './src/utils'

# Terrapin::CommandLine.logger = Logger.new(STDOUT)
module VBiosFinder
@@wd

class CLI < Thor
desc 'extract <bios update file>'.colorize(:blue), 'attempts to extract an embedded vbios from a bios update'
def extract file=nil

def extract(file = nil)
wd = "#{Dir.pwd}/tmp-vbiosfinder"
if file.nil?
puts "no file specified".colorize(:red)
puts 'no file specified'.colorize(:red)
return
end
if File.directory? wd
Expand All @@ -23,17 +24,18 @@ def extract file=nil
end
FileUtils.mkdir_p wd
Kernel.at_exit do
puts "Cleaning up garbage".colorize(:blue)
puts 'Cleaning up garbage'.colorize(:blue)
FileUtils.remove_entry_secure wd
end
@@wd = wd
Dir.chdir wd
puts "output will be stored in '#{wd}'".colorize(":blue")
Utils::installed?("ruby") # "bugfix"
Utils::get_new_files # "bugfix" #2
puts "output will be stored in '#{wd}'".colorize(':blue')
Utils.installed?('ruby') # "bugfix"
Utils.get_new_files # "bugfix" #2
FileUtils.cp(file, wd)
puts 'copying BIOS file to the work directory'.colorize(':blue')
puts
Main::run Utils::get_new_files.first
Main.run Utils.get_new_files.first
end
end
end
33 changes: 15 additions & 18 deletions src/extract-7z.rb
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
33 changes: 15 additions & 18 deletions src/extract-innosetup.rb
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
21 changes: 11 additions & 10 deletions src/extract-polyglot.rb
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
35 changes: 16 additions & 19 deletions src/extract-uefi.rb
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
33 changes: 15 additions & 18 deletions src/extract-upx.rb
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
Loading