Class: Relyze::Symbols::StaticLibraryPackage
- Inherits:
-
Object
- Object
- Relyze::Symbols::StaticLibraryPackage
- Defined in:
- C:/Program Files/Relyze/lib/relyze/core/symbols.rb
Defined Under Namespace
Modules: TSortPackageArray
Instance Attribute Summary collapse
-
#arch ⇒ Object
readonly
- Symbol
-
This packages architecture, :x86, x64, :arm or :arm64.
-
#children ⇒ Object
readonly
- Array<Relyze::Symbols::StaticLibraryPackage>
-
An array of child packages belonging to this package.
-
#count ⇒ Object
readonly
- Integer
-
The total number of signatures in this package not including any signatures in the child packages, unless this package contains shared child packages, in which case those shared signatures will be included in this count value.
-
#enabled ⇒ Object
- true,false
-
Set to false in order to permanently disable this package, preventing it from being automatically used during static library analysis.
-
#mode ⇒ Object
readonly
- Symbol
-
This packages mode, :user or :kernel.
-
#name ⇒ Object
readonly
- String
-
This packages name.
-
#origin ⇒ Object
readonly
- Symbol
-
The origin of this packages symbols data base, :application, :user or :memory.
-
#platform ⇒ Object
readonly
- Symbol
-
This packages platform, :windows.
-
#type ⇒ Object
readonly
- Symbol
-
This packages type, either :shared, :general or :automatic.
-
#version ⇒ Object
readonly
- String
-
The version of Relyze that generated this package.
Class Method Summary collapse
-
.create(package_options, origin = :user, parallel = true) ⇒ Relyze::Symbols::StaticLibraryPackage?
Static method to create a new package of static library signatures from a series of input files.
-
.create_packages(packages, origin = :user, parallel = true, plugin = nil) ⇒ true, false
Static helper method to create a series of packages.
Instance Method Summary collapse
-
#applicable?(target) ⇒ true, false
Test if this package is applicable to a given model or package.
-
#apply(model, functions = nil) ⇒ Number
Apply the static library signatures from this package and any child packages to a model.
-
#delete! ⇒ true, false
Permanently delete this package and all its corresponding signatures from the symbols database where it is stored.
-
#enabled? ⇒ Boolean
Test if this package is enabled or not.
-
#initialize ⇒ StaticLibraryPackage
constructor
A new instance of StaticLibraryPackage.
-
#query(model, functions = nil) ⇒ Number
Query the similarity of this package against a model.
-
#to_s ⇒ String
Get a simple description of this package.
Constructor Details
#initialize ⇒ StaticLibraryPackage
Returns a new instance of StaticLibraryPackage
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 91 def initialize @name = '' @version = '0.0.0' @origin = nil @type = nil @platform = nil @mode = nil @arch = nil @children = [] @enabled = true @count = 0 end |
Instance Attribute Details
#arch ⇒ Object (readonly)
- Symbol
-
This packages architecture, :x86, x64, :arm or :arm64.
80 81 82 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 80 def arch @arch end |
#children ⇒ Object (readonly)
- Array<Relyze::Symbols::StaticLibraryPackage>
-
An array of child packages belonging to this package.
83 84 85 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 83 def children @children end |
#count ⇒ Object (readonly)
- Integer
-
The total number of signatures in this package not including any signatures in the child packages, unless this package contains shared child packages, in which case those shared signatures will be included in this count value.
89 90 91 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 89 def count @count end |
#enabled ⇒ Object
- true,false
-
Set to false in order to permanently disable this package, preventing it from being automatically used during static library analysis.
86 87 88 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 86 def enabled @enabled end |
#mode ⇒ Object (readonly)
- Symbol
-
This packages mode, :user or :kernel.
77 78 79 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 77 def mode @mode end |
#name ⇒ Object (readonly)
- String
-
This packages name.
62 63 64 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 62 def name @name end |
#origin ⇒ Object (readonly)
- Symbol
-
The origin of this packages symbols data base, :application, :user or :memory. By default the :application origin is “%ALLUSERSPROFILE%Relyzesymbols.db” and the :user origin is “%USERPROFILE%DocumentsRelyzeSymbolssymbols.db”. The :memory origin is an in memory database that will not persist past an application restart.
68 69 70 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 68 def origin @origin end |
#platform ⇒ Object (readonly)
- Symbol
-
This packages platform, :windows.
74 75 76 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 74 def platform @platform end |
#type ⇒ Object (readonly)
- Symbol
-
This packages type, either :shared, :general or :automatic. :shared packages are used to share signatures between several other packages. A package that has a shared child package will apply those signatures in an opaque manner as if the shared signatures belonged to the parent package. :general packages are typically child packages, often having multiple parents, which are applied if the parent package is successfully applied. All :automatic packages are grouped into a set of packages, queried and the most applicable package is then applied during static library analysis.
71 72 73 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 71 def type @type end |
#version ⇒ Object (readonly)
- String
-
The version of Relyze that generated this package.
65 66 67 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 65 def version @version end |
Class Method Details
.create(package_options, origin = :user, parallel = true) ⇒ Relyze::Symbols::StaticLibraryPackage?
Static method to create a new package of static library signatures from a series of input files.
138 139 140 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 138 def self.create( , origin=:user, parallel=true ) return nil end |
.create_packages(packages, origin = :user, parallel = true, plugin = nil) ⇒ true, false
Static helper method to create a series of packages.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 180 def self.create_packages( packages, origin=:user, parallel=true, plugin=nil ) # Reorder the packages based on their dependencies, as we must create child packages before the parent packages. begin packages.extend( Relyze::Symbols::StaticLibraryPackage::TSortPackageArray.init ) packages = packages.tsort() rescue plugin.print_error( "[-] Failed to sort the package dependencies. #{$!}" ) if plugin return false end # If :path and :extensions keys are set, gather the files located at this path. packages.each do | | [:files] = [] if [:files].nil? [:children] = [] if [:children].nil? if( not [:paths].nil? and not [:extensions].nil? ) [:subdirs] = false if [:subdirs].nil? [:paths].each do | path | [:extensions].each do | extension | ::Dir.glob( "#{path}#{[:subdirs] ? '**/' : ''}*.#{extension}" ).each do | file | [:files] << file end end end end [:files].each do | file | if( not ::File.exists?( file ) ) plugin.print_error( "[-] File '#{file}' does not exist for package '#{[:name]}'." ) if plugin return false end end # Only fail if package_options has no files *and* no children, we can have packages with no files but # which has shared children with another package_options. if( [:files].empty? and [:children].empty? ) plugin.print_error( "[!] package '#{[:name]}' has no files and no children." ) if plugin return false end end packages.each do | | package_object = Relyze::Symbols::StaticLibraryPackage.create( , origin, parallel ) if( package_object.nil? ) plugin.print_error( "[!] Failed to create package '#{[:name]}'." ) if plugin return false end plugin.( "[+] Created package '%s' with %d signatures." % [ package_object.name, package_object.count ] ) if plugin end return true end |
Instance Method Details
#applicable?(target) ⇒ true, false
Test if this package is applicable to a given model or package. An applicable package will have a matching platform, mode and architecture to the target.
250 251 252 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 250 def applicable?( target ) return false end |
#apply(model, functions = nil) ⇒ Number
Apply the static library signatures from this package and any child packages to a model.
304 305 306 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 304 def apply( model, functions=nil ) return 0 end |
#delete! ⇒ true, false
Permanently delete this package and all its corresponding signatures from the symbols database where it is stored. Packages whose @origin is :application may not be deleted.
311 312 313 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 311 def delete! return false end |
#enabled? ⇒ Boolean
Test if this package is enabled or not. Disabled packages are not automatically used during static library analysis.
- true,false
257 258 259 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 257 def enabled? return @enabled end |
#query(model, functions = nil) ⇒ Number
Query the similarity of this package against a model.
274 275 276 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 274 def query( model, functions=nil ) return 0.0 end |
#to_s ⇒ String
Get a simple description of this package.
242 243 244 |
# File 'C:/Program Files/Relyze/lib/relyze/core/symbols.rb', line 242 def to_s return "Package '%s' (%s, %s, %s, %s)" % [ self.name, self.platform, self.mode, self.arch, self.type ] end |