Class: Arachni::Options

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/arachni/options.rb

Overview

Options storage class.

Implements the Singleton pattern and formally defines all of Arachni’s runtime options.

Author:

Defined Under Namespace

Classes: Error

Constant Summary collapse

PROFILE_EXT =

The extension of the profile files.

Returns:

'.afp'
USER_AGENT =
'Arachni/v' + Arachni::VERSION.to_s

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



540
541
542
# File 'lib/arachni/options.rb', line 540

def initialize
    reset
end

Instance Attribute Details

#arachni_verboseBool

Be verbose?

Returns:

  • (Bool)


145
146
147
# File 'lib/arachni/options.rb', line 145

def arachni_verbose
  @arachni_verbose
end

#audit_cookiesBool

Should Arachni audit cookies?

Returns:

  • (Bool)


240
241
242
# File 'lib/arachni/options.rb', line 240

def audit_cookies
  @audit_cookies
end

#audit_cookies_extensivelyObject Also known as: audit_cookies_extensively?

Returns the value of attribute audit_cookies_extensively.



242
243
244
# File 'lib/arachni/options.rb', line 242

def audit_cookies_extensively
  @audit_cookies_extensively
end

#audit_formsBool

Should Arachni audit forms?

Returns:

  • (Bool)


233
234
235
# File 'lib/arachni/options.rb', line 233

def audit_forms
  @audit_forms
end

#audit_headersBool

Should Arachni audit HTTP headers?

Returns:

  • (Bool)


250
251
252
# File 'lib/arachni/options.rb', line 250

def audit_headers
  @audit_headers
end

Should Arachni audit links?

Returns:

  • (Bool)


226
227
228
# File 'lib/arachni/options.rb', line 226

def audit_links
  @audit_links
end

#authed_byString

The person that authorized the scan<br/> It will be added to the HTTP “user-agent” and “from” headers.

Returns:



296
297
298
# File 'lib/arachni/options.rb', line 296

def authed_by
  @authed_by
end

#auto_redundantBool

Returns configure the Spider‘s auto-redundant feature.

Returns:

  • (Bool)

    configure the Spider‘s auto-redundant feature



500
501
502
# File 'lib/arachni/options.rb', line 500

def auto_redundant
  @auto_redundant
end

Location of the cookiejar

Returns:



350
351
352
# File 'lib/arachni/options.rb', line 350

def cookie_jar
  @cookie_jar
end

Returns cookies in the form of “name=value; name2=value2”.

Returns:

  • (String)

    cookies in the form of “name=value; name2=value2”



355
356
357
# File 'lib/arachni/options.rb', line 355

def cookie_string
  @cookie_string
end

#cookiesHash

To be populated by the framework

Parsed cookiejar cookies

Returns:

  • (Hash)

    name=>value pairs



343
344
345
# File 'lib/arachni/options.rb', line 343

def cookies
  @cookies
end

#costFloat

Returns cost of using the Dispatcher.

Returns:

  • (Float)

    cost of using the Dispatcher



95
96
97
# File 'lib/arachni/options.rb', line 95

def cost
  @cost
end

#custom_headersHash<String, String>

Returns custom HTTP headers to be included for every HTTP Request.

Returns:

  • (Hash<String, String>)

    custom HTTP headers to be included for every HTTP Request



472
473
474
# File 'lib/arachni/options.rb', line 472

def custom_headers
  @custom_headers
end

#datastoreHash

General purpose datastore.

Since this class is a Singleton and is passed to pretty much everything it’s a good candidate for message passing or obscure options that the user doesn’t need to know.

Returns:



77
78
79
# File 'lib/arachni/options.rb', line 77

def datastore
  @datastore
end

#debugBool

Output debugging messages?

Returns:

  • (Bool)


152
153
154
# File 'lib/arachni/options.rb', line 152

def debug
  @debug
end

#delta_timeInteger

Returns to be populated by the framework.

Returns:

  • (Integer)

    to be populated by the framework



417
418
419
# File 'lib/arachni/options.rb', line 417

def delta_time
  @delta_time
end

#depth_limitInteger

How deep to go in the site structure?<br/> If nil, depth_limit = inf

Returns:

  • (Integer)


174
175
176
# File 'lib/arachni/options.rb', line 174

def depth_limit
  @depth_limit
end

#dirHash

Holds absolute paths for the directory structure of the framework

Returns:



117
118
119
# File 'lib/arachni/options.rb', line 117

def dir
  @dir
end

#excludeArray

Exclusion filters.

URLs matching any of these patterns won’t be followed or audited.

Returns:



371
372
373
# File 'lib/arachni/options.rb', line 371

def exclude
  @exclude
end

#exclude_binariesObject

Returns the value of attribute exclude_binaries.



497
498
499
# File 'lib/arachni/options.rb', line 497

def exclude_binaries
  @exclude_binaries
end

#exclude_cookiesArray

Cookies to exclude from the audit

Returns:



385
386
387
# File 'lib/arachni/options.rb', line 385

def exclude_cookies
  @exclude_cookies
end

#exclude_pagesArray

Page bodies matching any of these patterns will be are ignored.

Returns:



378
379
380
# File 'lib/arachni/options.rb', line 378

def exclude_pages
  @exclude_pages
end

#exclude_vectorsArray

Vectors to exclude from the audit

Returns:



392
393
394
# File 'lib/arachni/options.rb', line 392

def exclude_vectors
  @exclude_vectors
end

#extend_pathsArray<String>

Returns paths to use in addition to crawling the webapp.

Returns:

  • (Array<String>)

    paths to use in addition to crawling the webapp



481
482
483
# File 'lib/arachni/options.rb', line 481

def extend_paths
  @extend_paths
end

#extend_paths_filepathString

Returns path to file containing #extend_paths.

Returns:



484
485
486
# File 'lib/arachni/options.rb', line 484

def extend_paths_filepath
  @extend_paths_filepath
end

#finish_datetimeTime

Returns to be populated by the framework.

Returns:

  • (Time)

    to be populated by the framework



414
415
416
# File 'lib/arachni/options.rb', line 414

def finish_datetime
  @finish_datetime
end

#follow_subdomainsBool

Should the crawler follow subdomains?

Returns:

  • (Bool)


408
409
410
# File 'lib/arachni/options.rb', line 408

def follow_subdomains
  @follow_subdomains
end

#fuzz_methodsObject

Returns the value of attribute fuzz_methods.



495
496
497
# File 'lib/arachni/options.rb', line 495

def fuzz_methods
  @fuzz_methods
end

#grid_modenil, Symbol

Returns Grid mode to use, available modes are:

  • ‘nil` – No grid.

  • ‘:balance` – Default load balancing across available Dispatchers.

  • ‘:aggregate` – Default load balancing with line aggregation.

    Will only request Instances from Grid members with different
    {#pipe_id Pipe-IDs}.
    

Returns:

  • (nil, Symbol)

    Grid mode to use, available modes are:

    • ‘nil` – No grid.

    • ‘:balance` – Default load balancing across available Dispatchers.

    • ‘:aggregate` – Default load balancing with line aggregation.

      Will only request Instances from Grid members with different
      {#pipe_id Pipe-IDs}.
      


525
526
527
# File 'lib/arachni/options.rb', line 525

def grid_mode
  @grid_mode
end

#helpBool

Show help?

Returns:

  • (Bool)


131
132
133
# File 'lib/arachni/options.rb', line 131

def help
  @help
end

#http_passwordInteger

Returns HTTP auth password.

Returns:

  • (Integer)

    HTTP auth password.



512
513
514
# File 'lib/arachni/options.rb', line 512

def http_password
  @http_password
end

#http_queue_sizeInteger

Maximum amount of requests to keep in the queue.

Bigger size means better scheduling and bette performance, smaller means less RAM consumption.

Returns:

  • (Integer)


219
220
221
# File 'lib/arachni/options.rb', line 219

def http_queue_size
  @http_queue_size
end

#http_req_limitInteger

How many concurrent HTTP requests?

Returns:

  • (Integer)


211
212
213
# File 'lib/arachni/options.rb', line 211

def http_req_limit
  @http_req_limit
end

#http_timeoutInteger

Returns HTTP request timeout in milliseconds.

Returns:

  • (Integer)

    HTTP request timeout in milliseconds



506
507
508
# File 'lib/arachni/options.rb', line 506

def http_timeout
  @http_timeout
end

#http_usernameInteger

Returns HTTP auth username.

Returns:

  • (Integer)

    HTTP auth username.



509
510
511
# File 'lib/arachni/options.rb', line 509

def http_username
  @http_username
end

#https_onlyBool

Returns Only follow HTTPS links.

Returns:

  • (Bool)

    Only follow HTTPS links.



515
516
517
# File 'lib/arachni/options.rb', line 515

def https_only
  @https_only
end

#includeArray

Inclusion filters.

Only URLs that match any of these patterns will be followed.

Returns:



401
402
403
# File 'lib/arachni/options.rb', line 401

def include
  @include
end

How many links to follow? If -1, link_count_limit = inf

Returns:

  • (Integer)


182
183
184
# File 'lib/arachni/options.rb', line 182

def link_count_limit
  @link_count_limit
end

#load_profileArray

Location of Arachni Framework Profile (.afp) files to load

Returns:



285
286
287
# File 'lib/arachni/options.rb', line 285

def load_profile
  @load_profile
end

#login_check_patternObject

Returns the value of attribute login_check_pattern.



503
504
505
# File 'lib/arachni/options.rb', line 503

def 
  @login_check_pattern
end

#login_check_urlObject

Returns the value of attribute login_check_url.



502
503
504
# File 'lib/arachni/options.rb', line 502

def 
  @login_check_url
end

#lsmodArray<Regexp>

List modules, based on regexps, and exit?

Returns:



197
198
199
# File 'lib/arachni/options.rb', line 197

def lsmod
  @lsmod
end

#lsplatObject

Returns the value of attribute lsplat.



535
536
537
# File 'lib/arachni/options.rb', line 535

def lsplat
  @lsplat
end

#lsplugArray<Regexp>

Returns regexps to use to select which plugins to list.

Returns:

  • (Array<Regexp>)

    regexps to use to select which plugins to list



420
421
422
# File 'lib/arachni/options.rb', line 420

def lsplug
  @lsplug
end

#lsrepBool

List reports and exit?

Returns:

  • (Bool)


204
205
206
# File 'lib/arachni/options.rb', line 204

def lsrep
  @lsrep
end

#max_retriesInteger

Returns maximum retries for failed RPC calls.

Returns:

  • (Integer)

    maximum retries for failed RPC calls



80
81
82
# File 'lib/arachni/options.rb', line 80

def max_retries
  @max_retries
end

#max_slavesInteger

Returns maximum amount of slave Instances to use.

Returns:

  • (Integer)

    maximum amount of slave Instances to use



490
491
492
# File 'lib/arachni/options.rb', line 490

def max_slaves
  @max_slaves
end

#min_pages_per_instanceInteger

Returns minimum pages per RPC Instance when in High Performance Mode.

Returns:

  • (Integer)

    minimum pages per RPC Instance when in High Performance Mode



487
488
489
# File 'lib/arachni/options.rb', line 487

def min_pages_per_instance
  @min_pages_per_instance
end

#modsArray Also known as: modules

Array of modules to load

Returns:



257
258
259
# File 'lib/arachni/options.rb', line 257

def mods
  @mods
end

#neighbourString

Returns the URL of a neighbouring Dispatcher.

Returns:

  • (String)

    the URL of a neighbouring Dispatcher



85
86
87
# File 'lib/arachni/options.rb', line 85

def neighbour
  @neighbour
end

#nicknameString

Returns Dispatcher nickname.

Returns:

  • (String)

    Dispatcher nickname



110
111
112
# File 'lib/arachni/options.rb', line 110

def nickname
  @nickname
end

#no_fingerprintingBool

Returns Disable platform fingeprinting.

Returns:

  • (Bool)

    Disable platform fingeprinting.



528
529
530
# File 'lib/arachni/options.rb', line 528

def no_fingerprinting
  @no_fingerprinting
end

#node_ping_intervalFloat

Returns how soon to check for neighbour node status.

Returns:

  • (Float)

    how soon to check for neighbour node status



90
91
92
# File 'lib/arachni/options.rb', line 90

def node_ping_interval
  @node_ping_interval
end

#node_ssl_certString

Returns path to a client PEM certificate key for the grid nodes.

Returns:

  • (String)

    path to a client PEM certificate key for the grid nodes



458
459
460
# File 'lib/arachni/options.rb', line 458

def node_ssl_cert
  @node_ssl_cert
end

#node_ssl_pkeyString

Returns path to a client PEM private key for the grid nodes.

Returns:

  • (String)

    path to a client PEM private key for the grid nodes



455
456
457
# File 'lib/arachni/options.rb', line 455

def node_ssl_pkey
  @node_ssl_pkey
end

#obey_robots_txtBool

Should the crawler obery robots.txt files?

Returns:

  • (Bool)


166
167
168
# File 'lib/arachni/options.rb', line 166

def obey_robots_txt
  @obey_robots_txt
end

#only_positivesBool

Output only positive results during the audit?

Returns:

  • (Bool)


138
139
140
# File 'lib/arachni/options.rb', line 138

def only_positives
  @only_positives
end

#pipe_idString

Returns a string identifying this bandwidth pipe.

Returns:

  • (String)

    a string identifying this bandwidth pipe



100
101
102
# File 'lib/arachni/options.rb', line 100

def pipe_id
  @pipe_id
end

#platformsArray<Symbol>

Returns User supplied platforms to use instead of (or in addition to – depending on the option) fingerprinting.

Returns:

  • (Array<Symbol>)

    User supplied platforms to use instead of (or in addition to – depending on the option) fingerprinting.



533
534
535
# File 'lib/arachni/options.rb', line 533

def platforms
  @platforms
end

#pluginsArray<String>

Returns plugins to load, by name.

Returns:



423
424
425
# File 'lib/arachni/options.rb', line 423

def plugins
  @plugins
end

#pool_sizeInteger

Returns amount of Instances to keep in the pool.

Returns:

  • (Integer)

    amount of Instances to keep in the pool



468
469
470
# File 'lib/arachni/options.rb', line 468

def pool_size
  @pool_size
end

#proxyString

Returns Proxy URL (‘host:port`).

Returns:

  • (String)

    Proxy URL (‘host:port`)



334
335
336
# File 'lib/arachni/options.rb', line 334

def proxy
  @proxy
end

#proxy_hostString

The address of the proxy server

Returns:



303
304
305
# File 'lib/arachni/options.rb', line 303

def proxy_host
  @proxy_host
end

#proxy_passwordString

The proxy password

Returns:



317
318
319
# File 'lib/arachni/options.rb', line 317

def proxy_password
  @proxy_password
end

#proxy_portString

The port to connect on the proxy server

Returns:



310
311
312
# File 'lib/arachni/options.rb', line 310

def proxy_port
  @proxy_port
end

#proxy_typeString

The proxy type

Returns:



331
332
333
# File 'lib/arachni/options.rb', line 331

def proxy_type
  @proxy_type
end

#proxy_usernameString

The proxy user

Returns:



324
325
326
# File 'lib/arachni/options.rb', line 324

def proxy_username
  @proxy_username
end

#redirect_limitInteger

How many redirects to follow? If -1, redirect_limit = inf

Returns:

  • (Integer)


190
191
192
# File 'lib/arachni/options.rb', line 190

def redirect_limit
  @redirect_limit
end

#redundantHash[Regexp, Integer]

Filters for redundant links in the form of (pattern => counter).

Returns:

  • (Hash[Regexp, Integer])


159
160
161
# File 'lib/arachni/options.rb', line 159

def redundant
  @redundant
end

#reploadString

Location of an Arachni Framework Report (.afr) file to load

Returns:



271
272
273
# File 'lib/arachni/options.rb', line 271

def repload
  @repload
end

#reportsArray

Array of reports to load

Returns:



264
265
266
# File 'lib/arachni/options.rb', line 264

def reports
  @reports
end

#reroute_to_logfileBool

Returns ‘true` if the output of the RPC instances should be redirected to a file, `false` otherwise.

Returns:

  • (Bool)

    ‘true` if the output of the RPC instances should be redirected to a file, `false` otherwise



465
466
467
# File 'lib/arachni/options.rb', line 465

def reroute_to_logfile
  @reroute_to_logfile
end

#restrict_pathsArray<String>

Returns paths to use instead of crawling the webapp.

Returns:

  • (Array<String>)

    paths to use instead of crawling the webapp



475
476
477
# File 'lib/arachni/options.rb', line 475

def restrict_paths
  @restrict_paths
end

#restrict_paths_filepathString

Returns path to file containing #restrict_paths.

Returns:



478
479
480
# File 'lib/arachni/options.rb', line 478

def restrict_paths_filepath
  @restrict_paths_filepath
end

#rpc_addressString

Returns Hostname or IP address for the RPC server to bind to.

Returns:

  • (String)

    Hostname or IP address for the RPC server to bind to.



432
433
434
# File 'lib/arachni/options.rb', line 432

def rpc_address
  @rpc_address
end

#rpc_external_addressString

Returns External (hostname or IP) address for the RPC server to bind to.

Returns:

  • (String)

    External (hostname or IP) address for the RPC server to bind to.



435
436
437
# File 'lib/arachni/options.rb', line 435

def rpc_external_address
  @rpc_external_address
end

#rpc_instance_port_rangeArray<Integer>

Returns Range of ports to use when spawning instances, first element should be the lowest port number, last the max port number.

Returns:

  • (Array<Integer>)

    Range of ports to use when spawning instances, first element should be the lowest port number, last the max port number.



440
441
442
# File 'lib/arachni/options.rb', line 440

def rpc_instance_port_range
  @rpc_instance_port_range
end

#rpc_portInteger

Returns port for the RPC server to listen to.

Returns:

  • (Integer)

    port for the RPC server to listen to.



429
430
431
# File 'lib/arachni/options.rb', line 429

def rpc_port
  @rpc_port
end

#rpc_socketString

Returns Path to the UNIX socket to use.

Returns:

  • (String)

    Path to the UNIX socket to use.



426
427
428
# File 'lib/arachni/options.rb', line 426

def rpc_socket
  @rpc_socket
end

#save_profileString

Where to save the Arachni Framework Profile (.afp) file

Returns:



278
279
280
# File 'lib/arachni/options.rb', line 278

def save_profile
  @save_profile
end

#serverString

Returns URL of an RPC dispatcher (used by the CLI RPC client interface).

Returns:

  • (String)

    URL of an RPC dispatcher (used by the CLI RPC client interface)



461
462
463
# File 'lib/arachni/options.rb', line 461

def server
  @server
end

#show_profileObject

Returns the value of attribute show_profile.



288
289
290
# File 'lib/arachni/options.rb', line 288

def show_profile
  @show_profile
end

#spawnsInteger

Returns amount of child Instances to spawn.

Returns:

  • (Integer)

    amount of child Instances to spawn



493
494
495
# File 'lib/arachni/options.rb', line 493

def spawns
  @spawns
end

#sslBool

Returns ‘true` if SSL should be enabled, `false` otherwise.

Returns:

  • (Bool)

    ‘true` if SSL should be enabled, `false` otherwise.



443
444
445
# File 'lib/arachni/options.rb', line 443

def ssl
  @ssl
end

#ssl_caString

Returns path to a PEM CA file.

Returns:

  • (String)

    path to a PEM CA file



452
453
454
# File 'lib/arachni/options.rb', line 452

def ssl_ca
  @ssl_ca
end

#ssl_certString

Returns path to a PEM certificate.

Returns:

  • (String)

    path to a PEM certificate



449
450
451
# File 'lib/arachni/options.rb', line 449

def ssl_cert
  @ssl_cert
end

#ssl_pkeyString

Returns path to a PEM private key.

Returns:

  • (String)

    path to a PEM private key



446
447
448
# File 'lib/arachni/options.rb', line 446

def ssl_pkey
  @ssl_pkey
end

#start_datetimeTime

Returns to be populated by the framework.

Returns:

  • (Time)

    to be populated by the framework



411
412
413
# File 'lib/arachni/options.rb', line 411

def start_datetime
  @start_datetime
end

#urlString

The URL to audit

Returns:



124
125
126
# File 'lib/arachni/options.rb', line 124

def url
  @url
end

#user_agentString

The HTTP user-agent to use

Returns:



362
363
364
# File 'lib/arachni/options.rb', line 362

def user_agent
  @user_agent
end

#versionBool

Returns Display version info and quit?.

Returns:

  • (Bool)

    Display version info and quit?



538
539
540
# File 'lib/arachni/options.rb', line 538

def version
  @version
end

#weightFloat

Returns Dispatcher weight.

Returns:

  • (Float)

    Dispatcher weight



105
106
107
# File 'lib/arachni/options.rb', line 105

def weight
  @weight
end

Class Method Details

.method_missing(sym, *args, &block) ⇒ Object



1566
1567
1568
1569
1570
1571
1572
# File 'lib/arachni/options.rb', line 1566

def self.method_missing( sym, *args, &block )
    if instance.respond_to?( sym )
        instance.send( sym, *args, &block )
    elsif
        super( sym, *args, &block )
    end
end

.respond_to?(m) ⇒ Boolean

Returns:

  • (Boolean)


1574
1575
1576
# File 'lib/arachni/options.rb', line 1574

def self.respond_to?( m )
    super( m ) || instance.respond_to?( m )
end

Instance Method Details

#==(other) ⇒ Bool

Compares 2 Arachni::Options objects.

Parameters:

Returns:

  • (Bool)

    ‘true` if `self == other` `false` otherwise



1458
1459
1460
# File 'lib/arachni/options.rb', line 1458

def ==( other )
    to_hash == other.to_hash
end

#audit(*element_types) ⇒ Object Also known as: audit=

Enables auditing of element types.

Parameters:

  • element_types (String, Symbol, Array)
    Allowed: links, forms, cookies, headers


820
821
822
823
824
825
826
827
828
829
830
831
832
# File 'lib/arachni/options.rb', line 820

def audit( *element_types )
    element_types.flatten.compact.each do |type|
        begin
            self.send( "audit_#{type}=", true )
        rescue
            begin
                self.send( "audit_#{type}s=", true )
            rescue
            end
        end
    end
    true
end

#audit?(*element_types) ⇒ Bool

Get audit settings for the given element types.

Parameters:

  • element_types (String, Symbol, Array)
    Allowed: links, forms, cookies, headers

Returns:

  • (Bool)


862
863
864
865
866
867
868
869
870
871
872
873
# File 'lib/arachni/options.rb', line 862

def audit?( *element_types )
    !element_types.flatten.compact.map do |type|
        !!begin
            self.send( "audit_#{type}" )
        rescue
            begin
                self.send( "audit_#{type}s" )
            rescue
            end
        end
    end.uniq.include?( false )
end

#auto_redundant?Boolean

Returns:

  • (Boolean)


755
756
757
# File 'lib/arachni/options.rb', line 755

def auto_redundant?
    !!@auto_redundant
end

#crawlObject



767
768
769
# File 'lib/arachni/options.rb', line 767

def crawl
    self.link_count_limit = nil
end

#crawl?Boolean

Returns:

  • (Boolean)


771
772
773
# File 'lib/arachni/options.rb', line 771

def crawl?
    !link_count_limit || link_count_limit != 0
end

#do_not_crawlObject



763
764
765
# File 'lib/arachni/options.rb', line 763

def do_not_crawl
    self.link_count_limit = 0
end

#do_not_fingerprintObject

Disables platform fingerprinting.



679
680
681
# File 'lib/arachni/options.rb', line 679

def do_not_fingerprint
    self.no_fingerprinting = true
end

#dont_audit(*element_types) ⇒ Object

Disables auditing of element types.

Parameters:

  • element_types (String, Symbol, Array)
    Allowed: links, forms, cookies, headers


840
841
842
843
844
845
846
847
848
849
850
851
852
# File 'lib/arachni/options.rb', line 840

def dont_audit( *element_types )
    element_types.flatten.compact.each do |type|
        begin
            self.send( "audit_#{type}=", false )
        rescue
            begin
                self.send( "audit_#{type}s=", false )
            rescue
            end
        end
    end
    true
end

#exclude_binaries?Boolean

Returns:

  • (Boolean)


751
752
753
# File 'lib/arachni/options.rb', line 751

def exclude_binaries?
    self.exclude_binaries
end

#exclude_page?(body) ⇒ Bool

Checks if the given string matches one of the configured #exclude_pages patterns.

Parameters:

Returns:

  • (Bool)

    ‘true` if `body` matches an #exclude_pages pattern, `false` otherwise.

See Also:



746
747
748
749
# File 'lib/arachni/options.rb', line 746

def exclude_page?( body )
    Options.exclude_pages.each { |i| return true if body.to_s =~ i }
    false
end

#fingerprintObject

Enables platform fingerprinting.



684
685
686
# File 'lib/arachni/options.rb', line 684

def fingerprint
    self.no_fingerprinting = false
end

#fingerprint?Bool

Returns ‘true` if platform fingerprinting is enabled, `false` otherwise.

Returns:

  • (Bool)

    ‘true` if platform fingerprinting is enabled, `false` otherwise.



690
691
692
# File 'lib/arachni/options.rb', line 690

def fingerprint?
    !@no_fingerprinting
end

#fuzz_methods?Boolean

Returns:

  • (Boolean)


759
760
761
# File 'lib/arachni/options.rb', line 759

def fuzz_methods?
    self.fuzz_methods
end

#grid=(bool) ⇒ Object

Parameters:

  • bool (Bool)

    ‘true` to use the Grid, `false` otherwise. Serves as a shorthand to setting #grid_mode to `:balance`.



639
640
641
# File 'lib/arachni/options.rb', line 639

def grid=( bool )
    @grid_mode = bool ? :balance : nil
end

#grid?Bool

Returns ‘true` if the Grid should be used, `false` otherwise.

Returns:

  • (Bool)

    ‘true` if the Grid should be used, `false` otherwise.



632
633
634
# File 'lib/arachni/options.rb', line 632

def grid?
    !!@grid_mode
end

#grid_aggregate?Bool

Returns ‘true` if the grid mode is in line-aggregation mode, `false` otherwise.

Returns:

  • (Bool)

    ‘true` if the grid mode is in line-aggregation mode, `false` otherwise.



668
669
670
# File 'lib/arachni/options.rb', line 668

def grid_aggregate?
    @grid_mode == :aggregate
end

#grid_balance?Bool

Returns ‘true` if the grid mode is in load-balancing mode, `false` otherwise.

Returns:

  • (Bool)

    ‘true` if the grid mode is in load-balancing mode, `false` otherwise.



674
675
676
# File 'lib/arachni/options.rb', line 674

def grid_balance?
    @grid_mode == :balance
end

#https_only?Boolean

Returns:

  • (Boolean)


698
699
700
# File 'lib/arachni/options.rb', line 698

def https_only?
    !!@https_only
end

Returns:

  • (Boolean)


775
776
777
# File 'lib/arachni/options.rb', line 775

def link_count_limit_reached?( count )
    link_count_limit && link_count_limit.to_i > 0 && count >= link_count_limit
end

#load(filepath) ⇒ Arachni::Options

Loads a file created by #save.

Parameters:

  • filepath (String)

    path to the file created by #save

Returns:



1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
# File 'lib/arachni/options.rb', line 1422

def load( filepath )
    opts = YAML::load( IO.read( filepath ) )
    opts = self.deep_clone.merge!( opts ) if opts.is_a? Hash

    if opts.restrict_paths_filepath
        opts.restrict_paths = paths_from_file( opts.restrict_paths_filepath )
    end

    if opts.extend_paths_filepath
        opts.extend_paths   = paths_from_file( opts.extend_paths_filepath )
    end

    opts
end

#merge!(options) ⇒ Arachni::Options

Merges ‘self` with the object in `options` skipping `nils` and empty `Array`s or `Hash`es.

Parameters:

Returns:



1470
1471
1472
1473
1474
1475
1476
1477
# File 'lib/arachni/options.rb', line 1470

def merge!( options )
    options.to_hash.each_pair do |k, v|
        next if !v
        next if ( v.is_a?( Array ) || v.is_a?( Hash ) ) && v.empty?
        send( "#{k.to_s}=", v ) rescue NoMethodError
    end
    self
end

#no_protocol_for_urlObject



1332
1333
1334
# File 'lib/arachni/options.rb', line 1332

def no_protocol_for_url
    @no_protocol_for_url = true
end

#no_protocol_for_url?Boolean

Returns:

  • (Boolean)


1336
1337
1338
# File 'lib/arachni/options.rb', line 1336

def no_protocol_for_url?
    !!@no_protocol_for_url
end

#parse(require_url = true) ⇒ Object



949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
# File 'lib/arachni/options.rb', line 949

def parse( require_url = true )
    # Construct getops struct
    opts = GetoptLong.new(
        [ '--help',              '-h', GetoptLong::NO_ARGUMENT ],
        [ '--verbosity',         '-v', GetoptLong::NO_ARGUMENT ],
        [ '--only-positives',    '-k', GetoptLong::NO_ARGUMENT ],
        [ '--lsmod',                   GetoptLong::OPTIONAL_ARGUMENT ],
        [ '--lsrep',                   GetoptLong::OPTIONAL_ARGUMENT ],
        [ '--lsplat',                  GetoptLong::NO_ARGUMENT ],
        [ '--audit-links',       '-g', GetoptLong::NO_ARGUMENT ],
        [ '--audit-forms',       '-p', GetoptLong::NO_ARGUMENT ],
        [ '--audit-cookies',     '-c', GetoptLong::NO_ARGUMENT ],
        [ '--audit-cookie-jar',        GetoptLong::NO_ARGUMENT ],
        [ '--audit-headers',           GetoptLong::NO_ARGUMENT ],
        [ '--spider-first',            GetoptLong::NO_ARGUMENT ],
        [ '--obey-robots-txt',   '-o', GetoptLong::NO_ARGUMENT ],
        [ '--redundant',               GetoptLong::REQUIRED_ARGUMENT ],
        [ '--depth',             '-d', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--redirect-limit',    '-q', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--link-count',        '-u', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--mods',              '-m', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--modules',                 GetoptLong::REQUIRED_ARGUMENT ],
        [ '--report',                  GetoptLong::REQUIRED_ARGUMENT ],
        [ '--repload',                 GetoptLong::REQUIRED_ARGUMENT ],
        [ '--authed-by',               GetoptLong::REQUIRED_ARGUMENT ],
        [ '--load-profile',            GetoptLong::REQUIRED_ARGUMENT ],
        [ '--save-profile',            GetoptLong::REQUIRED_ARGUMENT ],
        [ '--show-profile',            GetoptLong::NO_ARGUMENT ],
        [ '--proxy',             '-z', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--proxy-auth',        '-x', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--proxy-type',        '-y', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--cookie-jar',        '-j', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--cookie-string'          , GetoptLong::REQUIRED_ARGUMENT ],
        [ '--user-agent',        '-b', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--exclude',           '-e', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--exclude-page',            GetoptLong::REQUIRED_ARGUMENT ],
        [ '--exclude-cookie',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--exclude-vector',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--include',           '-i', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--http-req-limit',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--http-queue-size',         GetoptLong::REQUIRED_ARGUMENT ],
        [ '--http-timeout',            GetoptLong::REQUIRED_ARGUMENT ],
        [ '--follow-subdomains', '-f', GetoptLong::NO_ARGUMENT ],
        [ '--debug',             '-w', GetoptLong::NO_ARGUMENT ],
        [ '--server',                  GetoptLong::REQUIRED_ARGUMENT ],
        [ '--plugin',                  GetoptLong::OPTIONAL_ARGUMENT ],
        [ '--lsplug',                  GetoptLong::OPTIONAL_ARGUMENT ],
        [ '--serialized-opts',         GetoptLong::REQUIRED_ARGUMENT ],
        [ '--ssl',                     GetoptLong::NO_ARGUMENT ],
        [ '--ssl-pkey',                GetoptLong::REQUIRED_ARGUMENT ],
        [ '--ssl-cert',                GetoptLong::REQUIRED_ARGUMENT ],
        [ '--node-ssl-pkey',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--node-ssl-cert',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--ssl-ca',                 GetoptLong::REQUIRED_ARGUMENT ],
        [ '--address',                GetoptLong::REQUIRED_ARGUMENT ],
        [ '--external-address',       GetoptLong::REQUIRED_ARGUMENT ],
        [ '--reroute-to-logfile',     GetoptLong::NO_ARGUMENT ],
        [ '--pool-size',              GetoptLong::REQUIRED_ARGUMENT ],
        [ '--neighbour',              GetoptLong::REQUIRED_ARGUMENT ],
        [ '--weight',                 GetoptLong::REQUIRED_ARGUMENT ],
        [ '--cost',                   GetoptLong::REQUIRED_ARGUMENT ],
        [ '--pipe-id',                GetoptLong::REQUIRED_ARGUMENT ],
        [ '--nickname',               GetoptLong::REQUIRED_ARGUMENT ],
        [ '--username',               GetoptLong::REQUIRED_ARGUMENT ],
        [ '--password',               GetoptLong::REQUIRED_ARGUMENT ],
        [ '--port',                   GetoptLong::REQUIRED_ARGUMENT ],
        [ '--host',                   GetoptLong::REQUIRED_ARGUMENT ],
        [ '--custom-header',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--restrict-paths',         GetoptLong::REQUIRED_ARGUMENT ],
        [ '--extend-paths',           GetoptLong::REQUIRED_ARGUMENT ],
        [ '--port-range',             GetoptLong::REQUIRED_ARGUMENT ],
        [ '--http-harvest-last',      GetoptLong::NO_ARGUMENT ],
        [ '--fuzz-methods',           GetoptLong::NO_ARGUMENT ],
        [ '--audit-cookies-extensively',      GetoptLong::NO_ARGUMENT ],
        [ '--exclude-binaries',       GetoptLong::NO_ARGUMENT ],
        [ '--auto-redundant',         GetoptLong::OPTIONAL_ARGUMENT ],
        [ '--login-check-url',        GetoptLong::REQUIRED_ARGUMENT ],
        [ '--login-check-pattern',    GetoptLong::REQUIRED_ARGUMENT ],
        [ '--spawns',                 GetoptLong::REQUIRED_ARGUMENT ],
        [ '--grid',                   GetoptLong::NO_ARGUMENT ],
        [ '--grid-mode',              GetoptLong::REQUIRED_ARGUMENT ],
        [ '--http-username',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--http-password',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--https-only',             GetoptLong::NO_ARGUMENT ],
        [ '--no-fingerprinting',      GetoptLong::NO_ARGUMENT ],
        [ '--platforms',              GetoptLong::REQUIRED_ARGUMENT ],
        [ '--version',                GetoptLong::NO_ARGUMENT ]
    )

    opts.quiet = true

    begin
        opts.each do |opt, arg|

            case opt

                when '--help'
                    @help = true

                when '--version'
                    @version = true

                when '--no-fingerprinting'
                    @no_fingerprinting = true

                when '--platforms'
                    @platforms = arg.to_s.split( ',' )

                when '--serialized-opts'
                    merge!( unserialize( arg ) )

                when '--only-positives'
                    @only_positives = true

                when '--verbosity'
                    @arachni_verbose = true

                when '--debug'
                    @debug = true

                when '--plugin'
                    plugin, opt_str = arg.split( ':', 2 )

                    opts = {}
                    if opt_str
                        opt_arr = opt_str.split( ',' )
                        opt_arr.each {
                            |c_opt|
                            name, val = c_opt.split( '=', 2 )
                            opts[name] = val
                        }
                    end

                    @plugins[plugin] = opts

                when '--redundant'
                    regexp, counter = arg.to_s.split( ':', 2 )
                    @redundant[ Regexp.new( regexp ) ] = Integer( counter )

                when '--port-range'
                    first, last = arg.to_s.split( '-' )
                    @rpc_instance_port_range = [ Integer( first ), Integer( last ) ]

                when '--custom-header'
                    header, val = arg.to_s.split( /=/, 2 )
                    @custom_headers[header] = val

                when '--restrict-paths'
                    @restrict_paths |= paths_from_file( arg )
                    @restrict_paths_filepath = arg

                when '--extend-paths'
                    @extend_paths |= paths_from_file( arg )
                    @extend_paths_filepath = arg

                when '--obey_robots_txt'
                    @obey_robots_txt = true

                when '--depth'
                    @depth_limit = arg.to_i

                when '--link-count'
                    @link_count_limit = arg.to_i

                when '--redirect-limit'
                    @redirect_limit = arg.to_i

                when '--lsmod'
                    @lsmod << Regexp.new( arg.to_s )

                when '--lsplug'
                    @lsplug << Regexp.new( arg.to_s )

                when '--lsrep'
                    @lsrep << Regexp.new( arg.to_s )

                when '--lsplat'
                    @lsplat = true

                when '--http-req-limit'
                    @http_req_limit = arg.to_i

                when '--http-queue-size'
                    @http_queue_size = arg.to_i

                when '--http-timeout'
                    @http_timeout = arg.to_i

                when '--audit-links'
                    @audit_links = true

                when '--audit-forms'
                    @audit_forms = true

                when '--audit-cookies'
                    @audit_cookies = true

                when '--audit-cookie-jar'
                    @audit_cookie_jar = true

                when '--audit-headers'
                    @audit_headers = true

                when '--mods', '--modules'
                    @mods = arg.to_s.split( ',' )

                when '--report'
                    report, opt_str = arg.split( ':' )

                    opts = {}
                    if opt_str
                        opt_arr = opt_str.split( ',' )
                        opt_arr.each {
                            |c_opt|
                            name, val = c_opt.split( '=' )
                            opts[name] = val
                        }
                    end

                    @reports[report] = opts

                when '--repload'
                    @repload = arg

                when '--save-profile'
                    @save_profile = arg

                when '--load-profile'
                    @load_profile << arg

                when '--show-profile'
                    @show_profile = true

                when '--authed-by'
                    @authed_by = arg

                when '--proxy'
                    @proxy_host, @proxy_port =
                        arg.to_s.split( /:/ )

                    @proxy_port = @proxy_port.to_i

                when '--proxy-auth'
                    @proxy_username, @proxy_password =
                        arg.to_s.split( /:/ )

                when '--proxy-type'
                    @proxy_type = arg.to_s

                when '--cookie-jar'
                    @cookie_jar = arg.to_s

                when '--cookie-string'
                    @cookie_string = arg.to_s

                when '--user-agent'
                    @user_agent = arg.to_s

                when '--exclude'
                    @exclude << Regexp.new( arg )

                when '--exclude-page'
                    @exclude_pages << Regexp.new( arg )

                when '--exclude-cookie'
                    @exclude_cookies << arg

                when '--exclude-vector'
                    @exclude_vectors << arg

                when '--include'
                    @include << Regexp.new( arg )

                when '--follow-subdomains'
                    @follow_subdomains = true

                when '--http-harvest-last'
                    puts 'The http-harvest-last option has been removed.'
                    puts 'Please adjust your command-line arguments and try again.'
                    exit

                when '--ssl'
                    @ssl = true

                when '--ssl-pkey'
                    @ssl_pkey = arg.to_s

                when '--ssl-cert'
                    @ssl_cert = arg.to_s

                when '--ssl-ca'
                    @ssl_ca = arg.to_s

                when '--server'
                    @server = arg.to_s

                when '--reroute-to-logfile'
                    @reroute_to_logfile = true

                when '--port'
                    @rpc_port = arg.to_i

                when '--address'
                    @rpc_address = arg.to_s

                when '--external-address'
                    @rpc_external_address = arg.to_s

                when '--pool-size'
                    @pool_size = arg.to_i

                when '--neighbour'
                    @neighbour = arg.to_s

                when '--cost'
                    @cost = arg.to_s

                when '--weight'
                    @weight = arg.to_s

                when '--pipe-id'
                    @pipe_id = arg.to_s

                when '--nickname'
                    @nickname = arg.to_s

                when '--host'
                    @server = arg.to_s

                when '--fuzz-methods'
                    @fuzz_methods = true

                when '--audit-cookies-extensively'
                    @audit_cookies_extensively = true

                when '--exclude-binaries'
                    @exclude_binaries = true

                when '--auto-redundant'
                    @auto_redundant = arg.empty? ? 10 : arg.to_i

                when '--login-check-url'
                    @login_check_url = arg

                when '--login-check-pattern'
                    @login_check_pattern = arg

                when '--spawns'
                    @spawns = arg.to_i

                when '--grid'
                    self.grid = true

                when '--grid-mode'
                    self.grid_mode = arg

                when '--https-only'
                    @https_only = true

                when '--http-username'
                    @http_username = arg

                when '--http-password'
                    @http_password = arg
            end
        end

        if (!@login_check_url && @login_check_pattern) ||
            (@login_check_url && !@login_check_pattern)
            fail Error, "Both '--login-check-url' and " +
                "'--login-check-pattern' options are required."
        end

    rescue => e
        puts BANNER
        puts
        puts e
        exit
    end

    self.url = ARGV.shift if require_url
end

#paths_from_file(file) ⇒ Object



1562
1563
1564
# File 'lib/arachni/options.rb', line 1562

def paths_from_file( file )
    IO.read( file ).lines.map { |p| p.strip }
end

#redundant?(url, &block) ⇒ Bool

Checks is the provided URL matches a redundant filter and decreases its counter if so.

If a filter’s counter has reached 0 the method returns true.

Parameters:

  • url (String)
  • block (Block)

    to be called for each match and be passed the count, regexp and url

Returns:

  • (Bool)

    true if the url is redundant, false otherwise

See Also:



724
725
726
727
728
729
730
731
732
733
734
# File 'lib/arachni/options.rb', line 724

def redundant?( url, &block )
    redundant.each do |regexp, count|
        next if !(url =~ regexp)
        return true if count == 0

        block.call( count, regexp, url ) if block_given?

        redundant[regexp] -= 1
    end
    false
end

#resetObject



544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
# File 'lib/arachni/options.rb', line 544

def reset
    # nil everything out
    self.instance_variables.each { |var| instance_variable_set( var.to_s, nil ) }

    @dir            = {}
    @dir['root']    = root_path
    @dir['gfx']     = @dir['root'] + 'gfx/'
    @dir['conf']    = @dir['root'] + 'conf/'

    @dir['logs']    = ENV['ARACHNI_FRAMEWORK_LOGDIR'] ?
        "#{ENV['ARACHNI_FRAMEWORK_LOGDIR']}/" : @dir['root'] + 'logs/'

    @dir['data']    = @dir['root'] + 'data/'
    @dir['modules'] = @dir['root'] + 'modules/'
    @dir['reports'] = @dir['root'] + 'reports/'
    @dir['plugins'] = @dir['root'] + 'plugins/'
    @dir['rpcd_handlers']   = @dir['root'] + 'rpcd_handlers/'
    @dir['path_extractors'] = @dir['root'] + 'path_extractors/'
    @dir['fingerprinters']  = @dir['root'] + 'fingerprinters/'

    @dir['lib']     = @dir['root'] + 'lib/arachni/'
    @dir['support'] = @dir['lib'] + 'support/'
    @dir['mixins']  = @dir['lib'] + 'mixins/'
    @dir['arachni'] = @dir['lib'][0...-1]

    # we must add default values for everything because that can serve
    # both as a default configuration and as an inexpensive way to declare
    # their data types for later verification

    @user_agent   = USER_AGENT
    @http_timeout = 50000

    @datastore  = {}
    @redundant  = {}

    @grid_mode = nil

    @https_only        = false
    @obey_robots_txt   = false
    @fuzz_methods      = false
    @audit_cookies_extensively = false
    @exclude_binaries  = false
    @auto_redundant    = nil

    @depth_limit      = nil
    @link_count_limit = nil
    @redirect_limit   = 20

    @lsmod  = []
    @lsrep  = []

    @http_req_limit  = 20
    @http_queue_size = 500
    @http_username   = nil
    @http_password   = nil

    @mods = []

    @reports    = {}

    @exclude    = []
    @exclude_pages   = []
    @exclude_cookies = []
    @exclude_vectors = []

    @include    = []

    @lsplug     = []
    @plugins    = {}

    @rpc_instance_port_range = [1025, 65535]

    @load_profile       = []
    @restrict_paths     = []
    @extend_paths       = []
    @custom_headers     = {}

    @min_pages_per_instance = 30
    @max_slaves = 10

    @no_fingerprinting = false
    @platforms = []

    @spawns = 0
    self
end

#root_pathString

Returns root path of the framework.

Returns:

  • (String)

    root path of the framework



1341
1342
1343
# File 'lib/arachni/options.rb', line 1341

def root_path
    File.dirname( File.dirname( File.dirname( File.expand_path( File.expand_path(  __FILE__  ) ) ) ) ) + '/'
end

#save(file) ⇒ Object

Saves ‘self’ to ‘file`

Parameters:



1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
# File 'lib/arachni/options.rb', line 1372

def save( file )

    dir = @dir.clone

    load_profile    = []
    save_profile    = nil
    authed_by       = nil
    restrict_paths  = []
    extend_paths    = []

    load_profile   = @load_profile.clone    if @load_profile
    save_profile   = @save_profile.clone    if @save_profile
    authed_by      = @authed_by.clone       if @authed_by
    restrict_paths = @restrict_paths.clone  if @restrict_paths
    extend_paths   = @extend_paths.clone    if @extend_paths

    @dir            = nil
    @load_profile   = []
    @save_profile   = nil
    @authed_by      = nil
    @restrict_paths = []
    @extend_paths   = []

    begin
        f = File.open( file, 'w' )
        YAML.dump( self, f )
    rescue
        return
    ensure
        f.close

        @dir          = dir
        @load_profile = load_profile
        @save_profile = save_profile
        @authed_by    = authed_by

        @restrict_paths = restrict_paths
        @extend_paths   = extend_paths
    end

    f.path
end

#serializeString

Returns Single-line, Base64 encoded serialized version of self.

Returns:

  • (String)

    Single-line, Base64 encoded serialized version of self.

See Also:



1350
1351
1352
# File 'lib/arachni/options.rb', line 1350

def serialize
    Base64.encode64( to_yaml ).split( "\n" ).join
end

#set(options) ⇒ TrueClass

Configures options via a Hash object

Parameters:

  • options (Hash)

    options to set

Returns:

  • (TrueClass)


882
883
884
885
886
887
888
889
890
891
892
# File 'lib/arachni/options.rb', line 882

def set( options )
    options.each do |k, v|
        begin
            send( "#{k.to_s}=", v )
        rescue => e
            #ap e
            #ap e.backtrace
        end
    end
    true
end

#show_version?Boolean

Returns:

  • (Boolean)


694
695
696
# File 'lib/arachni/options.rb', line 694

def show_version?
    !!@version
end

#to_arg(key) ⇒ Object



1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
# File 'lib/arachni/options.rb', line 1483

def to_arg( key )

    do_not_parse = %w(show_profile url dir)

    var = self.instance_variable_get( "@#{key}" )

    return if !var
    return if ( var.is_a?( Array ) || var.is_a?( Hash ) ) && var.empty?
    return if do_not_parse.include?( key )
    return if key == 'include' && var == [/.*/]
    return if key == 'reports' && var.keys == %w(stdout)

    key = 'exclude_cookie' if key == 'exclude_cookies'
    key = 'exclude_vector' if key == 'exclude_vectors'
    key = 'report'         if key == 'reports'

    key = key.gsub( '_', '-' )

    arg = ''

    case key

        when 'mods'
            var = var.join( ',' )

        when 'restrict-paths'
            var = @restrict_paths_filepath

        when 'extend-paths'
            var = @extend_paths_filepath

        when 'rpc-instance-port-range'
            var = var.join( '-' )

        when 'arachni-verbose'
            key = 'verbosity'

        when 'redundant'
            var.each do |rule|
                arg += " --#{key}=#{rule['regexp'].source}:#{rule['count']}"
            end
            return arg

        when 'plugins','report'
            arg = ''
            var.each do |opt, val|
                arg += " --#{key.chomp( 's' )}=#{opt}"
                arg += ':' if !val.empty?

                val.each {
                    |k, v|
                    arg += "#{k}=#{v},"
                }

                arg.chomp!( ',' )
            end
            return arg

        when 'proxy-port'
            return

        when 'proxy-addr'
            return "--proxy=#{self.proxy_host}:#{self.proxy_port}"
    end

    if var.is_a?( TrueClass )
        arg = "--#{key}"
    elsif var.is_a?( String ) || var.is_a?( Fixnum )
        arg = "--#{key}=#{var.to_s}"
    elsif var.is_a?( Array )
        var.each do |i|
            i = i.source if i.is_a?( Regexp )
            arg += " --#{key}=#{i}"
        end
    end

    arg
end

#to_argsObject



1479
1480
1481
# File 'lib/arachni/options.rb', line 1479

def to_args
    ' ' + to_hash.map { |key, val| to_arg( key ) if val }.compact.join( ' ' ) + " #{self.url}"
end

#to_hHash Also known as: to_hash

Converts the Options object to hash

Returns:



1442
1443
1444
1445
1446
1447
1448
# File 'lib/arachni/options.rb', line 1442

def to_h
    hash = {}
    self.instance_variables.each do |var|
        hash[normalize_name( var )] = self.instance_variable_get( var )
    end
    hash
end

#unserialize(str) ⇒ Arachni::Options

Unserializes what is returned by #serialize.

Parameters:

Returns:

See Also:



1363
1364
1365
# File 'lib/arachni/options.rb', line 1363

def unserialize( str )
    YAML.load( Base64.decode64( str ) )
end