Class: Arachni::Options
- 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.
'.afp'
Instance Attribute Summary collapse
-
#arachni_verbose ⇒ Bool
Be verbose?.
-
#audit_cookies ⇒ Bool
Should Arachni audit cookies?.
-
#audit_forms ⇒ Bool
Should Arachni audit forms?.
-
#audit_headers ⇒ Bool
Should Arachni audit HTTP headers?.
-
#audit_links ⇒ Bool
Should Arachni audit links?.
-
#authed_by ⇒ String
The person that authorized the scan<br/> It will be added to the HTTP “user-agent” and “from” headers.
-
#cookie_jar ⇒ String
Location of the cookiejar.
-
#cookies ⇒ Hash
To be populated by the framework.
-
#cost ⇒ Float
Cost of using the Dispatcher.
-
#custom_headers ⇒ Object
Returns the value of attribute custom_headers.
-
#datastore ⇒ Hash
General purpose datastore.
-
#debug ⇒ Bool
Output debugging messages?.
-
#delta_time ⇒ Object
to be populated by the framework.
-
#depth_limit ⇒ Integer
How deep to go in the site structure?<br/> If nil, depth_limit = inf.
-
#dir ⇒ Hash
Holds absolute paths for the directory structure of the framework.
-
#exclude ⇒ Array
Exclude filters <br/> URL matching any of these patterns won’t be followed.
-
#exclude_cookies ⇒ Array
Cookies to exclude from audit<br/>.
-
#extend_paths ⇒ Object
Returns the value of attribute extend_paths.
-
#extend_paths_filepath ⇒ Object
Returns the value of attribute extend_paths_filepath.
-
#finish_datetime ⇒ Object
to be populated by the framework.
-
#follow_subdomains ⇒ Bool
Should the crawler follow subdomains?.
-
#grid_mode ⇒ Object
Returns the value of attribute grid_mode.
-
#help ⇒ Bool
Show help?.
-
#http_harvest_last ⇒ Bool
Harvest the HTTP responses for the whole site at the end or for each page?.
-
#http_req_limit ⇒ Integer
How many concurrent HTTP requests?.
-
#include ⇒ Array
Include filters <br/> Only URLs that match any of these patterns will be followed.
-
#link_count_limit ⇒ Integer
How many links to follow? If -1, link_count_limit = inf.
-
#load_profile ⇒ Array
Location of Arachni Framework Profile (.afp) files to load.
-
#lsmod ⇒ Array<Regexp>
List modules, based on regexps, and exit?.
-
#lsplug ⇒ Object
Returns the value of attribute lsplug.
-
#lsrep ⇒ Bool
List reports and exit?.
-
#max_slaves ⇒ Object
Returns the value of attribute max_slaves.
-
#min_pages_per_instance ⇒ Object
Returns the value of attribute min_pages_per_instance.
-
#mods ⇒ Array
Array of modules to load.
-
#neighbour ⇒ String
The URL of a neighbouring Dispatcher.
-
#nickname ⇒ String
Dispatcher nickname.
-
#node_ssl_cert ⇒ Object
Returns the value of attribute node_ssl_cert.
-
#node_ssl_pkey ⇒ Object
Returns the value of attribute node_ssl_pkey.
-
#obey_robots_txt ⇒ Bool
Should the crawler obery robots.txt files?.
-
#only_positives ⇒ Bool
Output only positive results during the audit?.
-
#pipe_id ⇒ String
A string identifying this bandwidth pipe.
-
#plugins ⇒ Object
Returns the value of attribute plugins.
-
#pool_size ⇒ Object
Returns the value of attribute pool_size.
-
#proxy_addr ⇒ String
The address of the proxy server.
-
#proxy_pass ⇒ String
The proxy password.
-
#proxy_port ⇒ String
The port to connect on the proxy server.
-
#proxy_type ⇒ String
The proxy type.
-
#proxy_user ⇒ String
The proxy user.
-
#redirect_limit ⇒ Integer
How many redirects to follow? If -1, redirect_limit = inf.
-
#redundant ⇒ Array
Filters for redundant links.
-
#repload ⇒ String
Location of an Arachni Framework Report (.afr) file to load.
-
#reports ⇒ Array
Array of reports to load.
-
#reroute_to_logfile ⇒ Object
Returns the value of attribute reroute_to_logfile.
-
#restrict_paths ⇒ Object
Returns the value of attribute restrict_paths.
-
#restrict_paths_filepath ⇒ Object
Returns the value of attribute restrict_paths_filepath.
-
#rpc_address ⇒ Object
Returns the value of attribute rpc_address.
-
#rpc_instance_port_range ⇒ Object
Returns the value of attribute rpc_instance_port_range.
-
#rpc_port ⇒ Object
Returns the value of attribute rpc_port.
-
#save_profile ⇒ String
Where to save the Arachni Framework Profile (.afp) file.
-
#server ⇒ Object
Returns the value of attribute server.
-
#show_profile ⇒ Object
Returns the value of attribute show_profile.
-
#ssl ⇒ Object
Returns the value of attribute ssl.
-
#ssl_ca ⇒ Object
Returns the value of attribute ssl_ca.
-
#ssl_cert ⇒ Object
Returns the value of attribute ssl_cert.
-
#ssl_pkey ⇒ Object
Returns the value of attribute ssl_pkey.
-
#start_datetime ⇒ Object
to be populated by the framework.
-
#url ⇒ String, URI
The URL to audit.
-
#user_agent ⇒ String
The HTTP user-agent to use.
-
#webui_password ⇒ Object
Returns the value of attribute webui_password.
-
#webui_username ⇒ Object
Returns the value of attribute webui_username.
-
#weight ⇒ Float
Dispatcher weight.
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #load(filename) ⇒ Object
-
#merge!(options) ⇒ Object
Merges self with the object in ‘options’.
- #parse! ⇒ Object
- #paths_from_file(file) ⇒ Object
- #reset! ⇒ Object
- #root_path ⇒ Object
-
#save(file) ⇒ Object
Saves ‘self’ to file.
- #set(hash) ⇒ Object
- #to_arg(key) ⇒ Object
- #to_args ⇒ Object
-
#to_h ⇒ Hash
Converts the Options object to hash.
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
393 394 395 |
# File 'lib/arachni/options.rb', line 393 def initialize reset! end |
Instance Attribute Details
#arachni_verbose ⇒ Bool
Be verbose?
112 113 114 |
# File 'lib/arachni/options.rb', line 112 def arachni_verbose @arachni_verbose end |
#audit_cookies ⇒ Bool
Should Arachni audit cookies?
199 200 201 |
# File 'lib/arachni/options.rb', line 199 def @audit_cookies end |
#audit_forms ⇒ Bool
Should Arachni audit forms?
192 193 194 |
# File 'lib/arachni/options.rb', line 192 def audit_forms @audit_forms end |
#audit_headers ⇒ Bool
Should Arachni audit HTTP headers?
206 207 208 |
# File 'lib/arachni/options.rb', line 206 def audit_headers @audit_headers end |
#audit_links ⇒ Bool
Should Arachni audit links?
185 186 187 |
# File 'lib/arachni/options.rb', line 185 def audit_links @audit_links end |
#authed_by ⇒ String
The person that authorized the scan<br/> It will be added to the HTTP “user-agent” and “from” headers.
252 253 254 |
# File 'lib/arachni/options.rb', line 252 def authed_by @authed_by end |
#cookie_jar ⇒ String
Location of the cookiejar
303 304 305 |
# File 'lib/arachni/options.rb', line 303 def @cookie_jar end |
#cookies ⇒ Hash
To be populated by the framework
Parsed cookiejar cookies
296 297 298 |
# File 'lib/arachni/options.rb', line 296 def @cookies end |
#cost ⇒ Float
Returns cost of using the Dispatcher.
62 63 64 |
# File 'lib/arachni/options.rb', line 62 def cost @cost end |
#custom_headers ⇒ Object
Returns the value of attribute custom_headers.
381 382 383 |
# File 'lib/arachni/options.rb', line 381 def custom_headers @custom_headers end |
#datastore ⇒ Hash
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.
50 51 52 |
# File 'lib/arachni/options.rb', line 50 def datastore @datastore end |
#debug ⇒ Bool
Output debugging messages?
119 120 121 |
# File 'lib/arachni/options.rb', line 119 def debug @debug end |
#delta_time ⇒ Object
to be populated by the framework
355 356 357 |
# File 'lib/arachni/options.rb', line 355 def delta_time @delta_time end |
#depth_limit ⇒ Integer
How deep to go in the site structure?<br/> If nil, depth_limit = inf
141 142 143 |
# File 'lib/arachni/options.rb', line 141 def depth_limit @depth_limit end |
#dir ⇒ Hash
Holds absolute paths for the directory structure of the framework
84 85 86 |
# File 'lib/arachni/options.rb', line 84 def dir @dir end |
#exclude ⇒ Array
Exclude filters <br/> URL matching any of these patterns won’t be followed
318 319 320 |
# File 'lib/arachni/options.rb', line 318 def exclude @exclude end |
#exclude_cookies ⇒ Array
Cookies to exclude from audit<br/>
325 326 327 |
# File 'lib/arachni/options.rb', line 325 def @exclude_cookies end |
#extend_paths ⇒ Object
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_filepath ⇒ Object
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_datetime ⇒ Object
to be populated by the framework
353 354 355 |
# File 'lib/arachni/options.rb', line 353 def finish_datetime @finish_datetime end |
#follow_subdomains ⇒ Bool
Should the crawler follow subdomains?
340 341 342 |
# File 'lib/arachni/options.rb', line 340 def follow_subdomains @follow_subdomains end |
#grid_mode ⇒ Object
Returns the value of attribute grid_mode.
52 53 54 |
# File 'lib/arachni/options.rb', line 52 def grid_mode @grid_mode end |
#help ⇒ Bool
Show help?
98 99 100 |
# File 'lib/arachni/options.rb', line 98 def help @help end |
#http_harvest_last ⇒ Bool
Harvest the HTTP responses for the whole site at the end or for each page?
348 349 350 |
# File 'lib/arachni/options.rb', line 348 def http_harvest_last @http_harvest_last end |
#http_req_limit ⇒ Integer
How many concurrent HTTP requests?
178 179 180 |
# File 'lib/arachni/options.rb', line 178 def http_req_limit @http_req_limit end |
#include ⇒ Array
Include filters <br/> Only URLs that match any of these patterns will be followed
333 334 335 |
# File 'lib/arachni/options.rb', line 333 def include @include end |
#link_count_limit ⇒ Integer
How many links to follow? If -1, link_count_limit = inf
149 150 151 |
# File 'lib/arachni/options.rb', line 149 def link_count_limit @link_count_limit end |
#load_profile ⇒ Array
Location of Arachni Framework Profile (.afp) files to load
241 242 243 |
# File 'lib/arachni/options.rb', line 241 def load_profile @load_profile end |
#lsmod ⇒ Array<Regexp>
List modules, based on regexps, and exit?
164 165 166 |
# File 'lib/arachni/options.rb', line 164 def lsmod @lsmod end |
#lsplug ⇒ Object
Returns the value of attribute lsplug.
357 358 359 |
# File 'lib/arachni/options.rb', line 357 def lsplug @lsplug end |
#lsrep ⇒ Bool
List reports and exit?
171 172 173 |
# File 'lib/arachni/options.rb', line 171 def lsrep @lsrep end |
#max_slaves ⇒ Object
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_instance ⇒ Object
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 |
#mods ⇒ Array
Array of modules to load
213 214 215 |
# File 'lib/arachni/options.rb', line 213 def mods @mods end |
#neighbour ⇒ String
Returns the URL of a neighbouring Dispatcher.
57 58 59 |
# File 'lib/arachni/options.rb', line 57 def neighbour @neighbour end |
#nickname ⇒ String
Returns Dispatcher nickname.
77 78 79 |
# File 'lib/arachni/options.rb', line 77 def nickname @nickname end |
#node_ssl_cert ⇒ Object
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_pkey ⇒ Object
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_txt ⇒ Bool
Should the crawler obery robots.txt files?
133 134 135 |
# File 'lib/arachni/options.rb', line 133 def obey_robots_txt @obey_robots_txt end |
#only_positives ⇒ Bool
Output only positive results during the audit?
105 106 107 |
# File 'lib/arachni/options.rb', line 105 def only_positives @only_positives end |
#pipe_id ⇒ String
Returns a string identifying this bandwidth pipe.
67 68 69 |
# File 'lib/arachni/options.rb', line 67 def pipe_id @pipe_id end |
#plugins ⇒ Object
Returns the value of attribute plugins.
358 359 360 |
# File 'lib/arachni/options.rb', line 358 def plugins @plugins end |
#pool_size ⇒ Object
Returns the value of attribute pool_size.
376 377 378 |
# File 'lib/arachni/options.rb', line 376 def pool_size @pool_size end |
#proxy_addr ⇒ String
The address of the proxy server
259 260 261 |
# File 'lib/arachni/options.rb', line 259 def proxy_addr @proxy_addr end |
#proxy_pass ⇒ String
The proxy password
273 274 275 |
# File 'lib/arachni/options.rb', line 273 def proxy_pass @proxy_pass end |
#proxy_port ⇒ String
The port to connect on the proxy server
266 267 268 |
# File 'lib/arachni/options.rb', line 266 def proxy_port @proxy_port end |
#proxy_type ⇒ String
The proxy type
287 288 289 |
# File 'lib/arachni/options.rb', line 287 def proxy_type @proxy_type end |
#proxy_user ⇒ String
The proxy user
280 281 282 |
# File 'lib/arachni/options.rb', line 280 def proxy_user @proxy_user end |
#redirect_limit ⇒ Integer
How many redirects to follow? If -1, redirect_limit = inf
157 158 159 |
# File 'lib/arachni/options.rb', line 157 def redirect_limit @redirect_limit end |
#redundant ⇒ Array
Filters for redundant links
126 127 128 |
# File 'lib/arachni/options.rb', line 126 def redundant @redundant end |
#repload ⇒ String
Location of an Arachni Framework Report (.afr) file to load
227 228 229 |
# File 'lib/arachni/options.rb', line 227 def repload @repload end |
#reports ⇒ Array
Array of reports to load
220 221 222 |
# File 'lib/arachni/options.rb', line 220 def reports @reports end |
#reroute_to_logfile ⇒ Object
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_paths ⇒ Object
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_filepath ⇒ Object
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_address ⇒ Object
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_range ⇒ Object
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_port ⇒ Object
Returns the value of attribute rpc_port.
360 361 362 |
# File 'lib/arachni/options.rb', line 360 def rpc_port @rpc_port end |
#save_profile ⇒ String
Where to save the Arachni Framework Profile (.afp) file
234 235 236 |
# File 'lib/arachni/options.rb', line 234 def save_profile @save_profile end |
#server ⇒ Object
Returns the value of attribute server.
373 374 375 |
# File 'lib/arachni/options.rb', line 373 def server @server end |
#show_profile ⇒ Object
Returns the value of attribute show_profile.
244 245 246 |
# File 'lib/arachni/options.rb', line 244 def show_profile @show_profile end |
#ssl ⇒ Object
Returns the value of attribute ssl.
365 366 367 |
# File 'lib/arachni/options.rb', line 365 def ssl @ssl end |
#ssl_ca ⇒ Object
Returns the value of attribute ssl_ca.
368 369 370 |
# File 'lib/arachni/options.rb', line 368 def ssl_ca @ssl_ca end |
#ssl_cert ⇒ Object
Returns the value of attribute ssl_cert.
367 368 369 |
# File 'lib/arachni/options.rb', line 367 def ssl_cert @ssl_cert end |
#ssl_pkey ⇒ Object
Returns the value of attribute ssl_pkey.
366 367 368 |
# File 'lib/arachni/options.rb', line 366 def ssl_pkey @ssl_pkey end |
#start_datetime ⇒ Object
to be populated by the framework
351 352 353 |
# File 'lib/arachni/options.rb', line 351 def start_datetime @start_datetime end |
#url ⇒ String, URI
The URL to audit
91 92 93 |
# File 'lib/arachni/options.rb', line 91 def url @url end |
#user_agent ⇒ String
The HTTP user-agent to use
310 311 312 |
# File 'lib/arachni/options.rb', line 310 def user_agent @user_agent end |
#webui_password ⇒ Object
Returns the value of attribute webui_password.
379 380 381 |
# File 'lib/arachni/options.rb', line 379 def webui_password @webui_password end |
#webui_username ⇒ Object
Returns the value of attribute webui_username.
378 379 380 |
# File 'lib/arachni/options.rb', line 378 def webui_username @webui_username end |
#weight ⇒ Float
Returns 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’
850 851 852 853 854 855 856 857 |
# File 'lib/arachni/options.rb', line 850 def merge!( ) .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_path ⇒ Object
748 749 750 |
# File 'lib/arachni/options.rb', line 748 def root_path File.dirname( File.dirname( File.dirname( File.( File.( __FILE__ ) ) ) ) ) + '/' end |
#save(file) ⇒ Object
Saves ‘self’ to file
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_args ⇒ Object
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_h ⇒ Hash
Converts the Options object to 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 |