Class: Arachni::Options

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

Overview

Overrides the Options class adding support for direct options parsing.

Not much to look at but it streamlines RPC server option handling.

@author: Tasos “Zapotek” Laskos

<[email protected]>
<[email protected]>

@version: 0.1

Constant Summary collapse

PROFILE_EXT =

The extension of the profile files.

Returns:

'.afp'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



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

def initialize
    reset!
end

Instance Attribute Details

#arachni_verboseBool

Be verbose?

Returns:

  • (Bool)


112
113
114
# File 'lib/arachni/options.rb', line 112

def arachni_verbose
  @arachni_verbose
end

#audit_cookiesBool

Should Arachni audit cookies?

Returns:

  • (Bool)


199
200
201
# File 'lib/arachni/options.rb', line 199

def audit_cookies
  @audit_cookies
end

#audit_formsBool

Should Arachni audit forms?

Returns:

  • (Bool)


192
193
194
# File 'lib/arachni/options.rb', line 192

def audit_forms
  @audit_forms
end

#audit_headersBool

Should Arachni audit HTTP headers?

Returns:

  • (Bool)


206
207
208
# File 'lib/arachni/options.rb', line 206

def audit_headers
  @audit_headers
end

Should Arachni audit links?

Returns:

  • (Bool)


185
186
187
# File 'lib/arachni/options.rb', line 185

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:



252
253
254
# File 'lib/arachni/options.rb', line 252

def authed_by
  @authed_by
end

Location of the cookiejar

Returns:



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

def cookie_jar
  @cookie_jar
end

#cookiesHash

To be populated by the framework

Parsed cookiejar cookies

Returns:

  • (Hash)

    name=>value pairs



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

def cookies
  @cookies
end

#costFloat

Returns cost of using the Dispatcher.

Returns:

  • (Float)

    cost of using the Dispatcher



62
63
64
# File 'lib/arachni/options.rb', line 62

def cost
  @cost
end

#custom_headersObject

Returns the value of attribute custom_headers.



381
382
383
# File 'lib/arachni/options.rb', line 381

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:

  • (Hash)


50
51
52
# File 'lib/arachni/options.rb', line 50

def datastore
  @datastore
end

#debugBool

Output debugging messages?

Returns:

  • (Bool)


119
120
121
# File 'lib/arachni/options.rb', line 119

def debug
  @debug
end

#delta_timeObject

to be populated by the framework



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

def delta_time
  @delta_time
end

#depth_limitInteger

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

Returns:

  • (Integer)


141
142
143
# File 'lib/arachni/options.rb', line 141

def depth_limit
  @depth_limit
end

#dirHash

Holds absolute paths for the directory structure of the framework

Returns:

  • (Hash)


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

def dir
  @dir
end

#excludeArray

Exclude filters <br/> URL matching any of these patterns won’t be followed

Returns:



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

def exclude
  @exclude
end

#exclude_cookiesArray

Cookies to exclude from audit<br/>

Returns:



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

def exclude_cookies
  @exclude_cookies
end

#extend_pathsObject

Returns the value of attribute extend_paths.



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

def extend_paths
  @extend_paths
end

#extend_paths_filepathObject

Returns the value of attribute extend_paths_filepath.



387
388
389
# File 'lib/arachni/options.rb', line 387

def extend_paths_filepath
  @extend_paths_filepath
end

#finish_datetimeObject

to be populated by the framework



353
354
355
# File 'lib/arachni/options.rb', line 353

def finish_datetime
  @finish_datetime
end

#follow_subdomainsBool

Should the crawler follow subdomains?

Returns:

  • (Bool)


340
341
342
# File 'lib/arachni/options.rb', line 340

def follow_subdomains
  @follow_subdomains
end

#grid_modeObject

Returns the value of attribute grid_mode.



52
53
54
# File 'lib/arachni/options.rb', line 52

def grid_mode
  @grid_mode
end

#helpBool

Show help?

Returns:

  • (Bool)


98
99
100
# File 'lib/arachni/options.rb', line 98

def help
  @help
end

#http_harvest_lastBool

Harvest the HTTP responses for the whole site at the end or for each page?

Returns:

  • (Bool)


348
349
350
# File 'lib/arachni/options.rb', line 348

def http_harvest_last
  @http_harvest_last
end

#http_req_limitInteger

How many concurrent HTTP requests?

Returns:

  • (Integer)


178
179
180
# File 'lib/arachni/options.rb', line 178

def http_req_limit
  @http_req_limit
end

#includeArray

Include filters <br/> Only URLs that match any of these patterns will be followed

Returns:



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

def include
  @include
end

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

Returns:

  • (Integer)


149
150
151
# File 'lib/arachni/options.rb', line 149

def link_count_limit
  @link_count_limit
end

#load_profileArray

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

Returns:



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

def load_profile
  @load_profile
end

#lsmodArray<Regexp>

List modules, based on regexps, and exit?

Returns:



164
165
166
# File 'lib/arachni/options.rb', line 164

def lsmod
  @lsmod
end

#lsplugObject

Returns the value of attribute lsplug.



357
358
359
# File 'lib/arachni/options.rb', line 357

def lsplug
  @lsplug
end

#lsrepBool

List reports and exit?

Returns:

  • (Bool)


171
172
173
# File 'lib/arachni/options.rb', line 171

def lsrep
  @lsrep
end

#max_slavesObject

Returns the value of attribute max_slaves.



390
391
392
# File 'lib/arachni/options.rb', line 390

def max_slaves
  @max_slaves
end

#min_pages_per_instanceObject

Returns the value of attribute min_pages_per_instance.



389
390
391
# File 'lib/arachni/options.rb', line 389

def min_pages_per_instance
  @min_pages_per_instance
end

#modsArray

Array of modules to load

Returns:



213
214
215
# File 'lib/arachni/options.rb', line 213

def mods
  @mods
end

#neighbourString

Returns the URL of a neighbouring Dispatcher.

Returns:

  • (String)

    the URL of a neighbouring Dispatcher



57
58
59
# File 'lib/arachni/options.rb', line 57

def neighbour
  @neighbour
end

#nicknameString

Returns Dispatcher nickname.

Returns:

  • (String)

    Dispatcher nickname



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

def nickname
  @nickname
end

#node_ssl_certObject

Returns the value of attribute node_ssl_cert.



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

def node_ssl_cert
  @node_ssl_cert
end

#node_ssl_pkeyObject

Returns the value of attribute node_ssl_pkey.



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

def node_ssl_pkey
  @node_ssl_pkey
end

#obey_robots_txtBool

Should the crawler obery robots.txt files?

Returns:

  • (Bool)


133
134
135
# File 'lib/arachni/options.rb', line 133

def obey_robots_txt
  @obey_robots_txt
end

#only_positivesBool

Output only positive results during the audit?

Returns:

  • (Bool)


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

def only_positives
  @only_positives
end

#pipe_idString

Returns a string identifying this bandwidth pipe.

Returns:

  • (String)

    a string identifying this bandwidth pipe



67
68
69
# File 'lib/arachni/options.rb', line 67

def pipe_id
  @pipe_id
end

#pluginsObject

Returns the value of attribute plugins.



358
359
360
# File 'lib/arachni/options.rb', line 358

def plugins
  @plugins
end

#pool_sizeObject

Returns the value of attribute pool_size.



376
377
378
# File 'lib/arachni/options.rb', line 376

def pool_size
  @pool_size
end

#proxy_addrString

The address of the proxy server

Returns:



259
260
261
# File 'lib/arachni/options.rb', line 259

def proxy_addr
  @proxy_addr
end

#proxy_passString

The proxy password

Returns:



273
274
275
# File 'lib/arachni/options.rb', line 273

def proxy_pass
  @proxy_pass
end

#proxy_portString

The port to connect on the proxy server

Returns:



266
267
268
# File 'lib/arachni/options.rb', line 266

def proxy_port
  @proxy_port
end

#proxy_typeString

The proxy type

Returns:



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

def proxy_type
  @proxy_type
end

#proxy_userString

The proxy user

Returns:



280
281
282
# File 'lib/arachni/options.rb', line 280

def proxy_user
  @proxy_user
end

#redirect_limitInteger

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

Returns:

  • (Integer)


157
158
159
# File 'lib/arachni/options.rb', line 157

def redirect_limit
  @redirect_limit
end

#redundantArray

Filters for redundant links

Returns:



126
127
128
# File 'lib/arachni/options.rb', line 126

def redundant
  @redundant
end

#reploadString

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

Returns:



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

def repload
  @repload
end

#reportsArray

Array of reports to load

Returns:



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

def reports
  @reports
end

#reroute_to_logfileObject

Returns the value of attribute reroute_to_logfile.



375
376
377
# File 'lib/arachni/options.rb', line 375

def reroute_to_logfile
  @reroute_to_logfile
end

#restrict_pathsObject

Returns the value of attribute restrict_paths.



383
384
385
# File 'lib/arachni/options.rb', line 383

def restrict_paths
  @restrict_paths
end

#restrict_paths_filepathObject

Returns the value of attribute restrict_paths_filepath.



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

def restrict_paths_filepath
  @restrict_paths_filepath
end

#rpc_addressObject

Returns the value of attribute rpc_address.



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

def rpc_address
  @rpc_address
end

#rpc_instance_port_rangeObject

Returns the value of attribute rpc_instance_port_range.



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

def rpc_instance_port_range
  @rpc_instance_port_range
end

#rpc_portObject

Returns the value of attribute rpc_port.



360
361
362
# File 'lib/arachni/options.rb', line 360

def rpc_port
  @rpc_port
end

#save_profileString

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

Returns:



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

def save_profile
  @save_profile
end

#serverObject

Returns the value of attribute server.



373
374
375
# File 'lib/arachni/options.rb', line 373

def server
  @server
end

#show_profileObject

Returns the value of attribute show_profile.



244
245
246
# File 'lib/arachni/options.rb', line 244

def show_profile
  @show_profile
end

#sslObject

Returns the value of attribute ssl.



365
366
367
# File 'lib/arachni/options.rb', line 365

def ssl
  @ssl
end

#ssl_caObject

Returns the value of attribute ssl_ca.



368
369
370
# File 'lib/arachni/options.rb', line 368

def ssl_ca
  @ssl_ca
end

#ssl_certObject

Returns the value of attribute ssl_cert.



367
368
369
# File 'lib/arachni/options.rb', line 367

def ssl_cert
  @ssl_cert
end

#ssl_pkeyObject

Returns the value of attribute ssl_pkey.



366
367
368
# File 'lib/arachni/options.rb', line 366

def ssl_pkey
  @ssl_pkey
end

#start_datetimeObject

to be populated by the framework



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

def start_datetime
  @start_datetime
end

#urlString, URI

The URL to audit

Returns:



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

def url
  @url
end

#user_agentString

The HTTP user-agent to use

Returns:



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

def user_agent
  @user_agent
end

#webui_passwordObject

Returns the value of attribute webui_password.



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

def webui_password
  @webui_password
end

#webui_usernameObject

Returns the value of attribute webui_username.



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

def webui_username
  @webui_username
end

#weightFloat

Returns Dispatcher weight.

Returns:

  • (Float)

    Dispatcher weight



72
73
74
# File 'lib/arachni/options.rb', line 72

def weight
  @weight
end

Instance Method Details

#load(filename) ⇒ Object



795
796
797
798
799
800
801
802
803
804
805
806
807
# File 'lib/arachni/options.rb', line 795

def load( filename )
    opts = YAML::load( IO.read( filename ) )

    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

    return opts
end

#merge!(options) ⇒ Object

Merges self with the object in ‘options’

Parameters:



850
851
852
853
854
855
856
857
# File 'lib/arachni/options.rb', line 850

def merge!( options )
    options.to_h.each_pair {
        |k, v|

        next if ( v.is_a?( Array ) || v.is_a?( Hash ) ) && v.empty?
        send( "#{k}=", v ) if v
    }
end

#parse!Object



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
# File 'lib/arachni/options.rb', line 460

def parse!

    # 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 ],
        [ '--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 ],
        [ '--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 ],
        [ '--user-agent',        '-b', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--exclude',           '-e', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--include',           '-i', GetoptLong::REQUIRED_ARGUMENT ],
        [ '--exclude-cookie',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--http-req-limit',          GetoptLong::REQUIRED_ARGUMENT ],
        [ '--follow-subdomains', '-f', GetoptLong::NO_ARGUMENT ],
        [ '--http-harvest-last', '-s', GetoptLong::NO_ARGUMENT ],
        [ '--debug',             '-w', GetoptLong::NO_ARGUMENT ],
        [ '--server',                  GetoptLong::REQUIRED_ARGUMENT ],
        [ '--plugin',                  GetoptLong::OPTIONAL_ARGUMENT ],
        [ '--lsplug',                  GetoptLong::OPTIONAL_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 ],
        [ '--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 ]
    )

    opts.quiet = true

    begin
        opts.each {
            |opt, arg|

            case opt

                when '--help'
                    @help = true

                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'
                    @redundant << {
                        'regexp'  => Regexp.new( arg.to_s.split( /:/ )[0] ),
                        'count'   => Integer( arg.to_s.split( /:/ )[1] ),
                    }

                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 '--http-req-limit'
                  @http_req_limit = 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'
                    @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_addr, @proxy_port =
                        arg.to_s.split( /:/ )

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

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

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

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

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

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

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

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

                when '--http-harvest-last'
                    @http_harvest_last = true

                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 '--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 '--username'
                    @webui_username = arg.to_s

                when '--password'
                    @webui_password = arg.to_s

            end
        }
    rescue Exception => e
        puts e.inspect
        exit
    end

    self.url = ARGV.shift
end

#paths_from_file(file) ⇒ Object



969
970
971
972
973
974
975
976
# File 'lib/arachni/options.rb', line 969

def paths_from_file( file )
    IO.read( file ).lines.map {
        |path|
        path.gsub!( "\n", '' )
        path.gsub!( "\r", '' )
        path
    }
end

#reset!Object



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/arachni/options.rb', line 397

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']    = @dir['root'] + 'logs/'
    @dir['data']    = @dir['root'] + 'data/'
    @dir['modules'] = @dir['root'] + 'modules/'
    @dir['reports'] = @dir['root'] + 'reports/'
    @dir['plugins'] = @dir['root'] + 'plugins/'
    @dir['path_extractors']    = @dir['root'] + 'path_extractors/'
    @dir['lib']     = @dir['root'] + 'lib/arachni/'
    @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

    @datastore  = {}
    @redundant  = []

    @obey_robots_txt = false

    @depth_limit      = -1
    @link_count_limit = -1
    @redirect_limit   = 20

    @lsmod      = []
    @lsrep      = []

    @http_req_limit = 20

    @mods = []

    @reports    = {}

    @exclude    = []
    @exclude_cookies    = []

    @include    = []

    @lsplug     = []
    @plugins    = {}

    @rpc_instance_port_range = [1025, 65535]

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

    @min_pages_per_instance = 30
    @max_slaves = 10
end

#root_pathObject



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

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:



757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
# File 'lib/arachni/options.rb', line 757

def save( file )

    dir           = @dir.clone
    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 = nil
    @save_profile = nil
    @authed_by    = nil
    @restrict_paths = nil
    @extend_paths   = nil


    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

    return f.path
end

#set(hash) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/arachni/rpc/server/options.rb', line 25

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

#to_arg(key) ⇒ Object



874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
# File 'lib/arachni/options.rb', line 874

def to_arg( key )

    do_not_parse = [
        '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 == ['stdout']

    key = 'exclude_cookie' if key == 'exclude_cookies'
    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 {
                |rule|
                arg += " --#{key}=#{rule['regexp'].source}:#{rule['count']}"
            }
            return arg

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

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

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

        when 'proxy-port'
            return

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


    end

    if( var.is_a?( TrueClass ) )
        arg = "--#{key}"
    end

    if( var.is_a?( String ) || var.is_a?( Fixnum ) )
        arg = "--#{key}=#{var.to_s}"
    end

    if( var.is_a?( Array ) )

        var.each {
            |i|

            i = i.source if i.is_a?( Regexp )

            arg += " --#{key}=#{i}"
        }

    end

    return arg
end

#to_argsObject



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

def to_args

    cli_args = ''

    self.to_h.keys.each {
        |key|

        arg = self.to_arg( key )

        cli_args += " #{arg.to_s}" if arg
    }

    return cli_args += " #{self.url}"
end

#to_hHash

Converts the Options object to hash

Returns:

  • (Hash)


836
837
838
839
840
841
842
843
# File 'lib/arachni/options.rb', line 836

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