Class: Arachni::Reports::Stdout

Inherits:
Arachni::Report::Base show all
Includes:
Arachni::Report::Registrar, Arachni::UI::Output
Defined in:
reports/stdout.rb

Overview

Default report.

Outputs the vulnerabilities to stdout, used with the CLI UI.
All UIs must have a default report.

@author: Anastasios “Zapotek” Laskos

                                     <tasos.laskos@gmail.com>
                                     <zapotek@segfault.gr>

@version: $Rev: 289 $

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Arachni::Report::Registrar

included

Methods included from Arachni::UI::Output

#debug!, #debug?, #only_positives!, #only_positives?, #print_debug, #print_debug_backtrace, #print_debug_pp, #print_error, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #verbose!, #verbose?

Constructor Details

- (Stdout) initialize(audit_store, options = nil, outfile = nil)

A new instance of Stdout

Parameters:

  • (AuditStore) audit_store
  • (Hash) options (defaults to: nil)

    options passed to the report

  • (String) outfile (defaults to: nil)

    where to save the report



41
42
43
# File 'reports/stdout.rb', line 41

def initialize( audit_store, options = nil, outfile = nil )
    @audit_store = audit_store
end

Class Method Details

+ (Object) info

REQUIRED

Do not ommit any of the info.



133
134
135
136
137
138
139
140
# File 'reports/stdout.rb', line 133

def self.info
    {
        'Name'           => 'Stdout',
        'Description'    => %q{Prints the results to standard output.},
        'Author'         => 'zapotek',
        'Version'        => '$Rev: 289 $',
    }
end

Instance Method Details

- (Object) __print_generic(key, val)



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'reports/stdout.rb', line 142

def __print_generic( key, val )
    key = key.gsub( /_/, ' ' ).capitalize
    
    if( val.instance_of?( String ) )
        print_info( key + ': ' + val )
    elsif( val.instance_of?( Array ) )
        print_line( )
        print_info( key + ':' )
        val.each {
            |item|
            print_info( "\t" + item.strip )
        }
        print_line( )
    else
        print_line( )
        print_info( key + ':' )
        val.each_pair {
            |name, item|
            print_info( "\t#{name}:\t" + item.strip )
        }
        print_line( )
    end

end

- (Object) run

REQUIRED

Use it to run your report.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'reports/stdout.rb', line 50

def run( )
    
    print_line( )
    print_ok( @audit_store.vulns.size.to_s + ' vulnerabilities were detected.' )
    print_line( )
    
    @audit_store.vulns.each {
        |vuln|
        
        print_ok( vuln.name )
        print_info( '**************' )
        
        vuln.each_pair {
            |key, val|
            
            case key
            
            when 'cwe_url', 'name'
                next
                
            when 'mod_name'
                print_info( "Module name: #{val}" )
            
            when 'references'
                
                print_line( )
                key = key.gsub( /_/, ' ' ).capitalize
                print_info( "#{key}:" )

                val.each_pair {
                    |ref, url|
                    print_info( "\t#{ref}:\t\t#{url}" )
                }
                print_line( )


            when 'remedy_guidance', 'remedy_code'
                if( val.size == 0 ) then next end
                    
                print_line( )
                
                key = key.gsub( /_/, ' ' ).capitalize
                print_info( "#{key}:" )
                print_info( "-----------" )
                print_line( "#{val}" )
                print_line( )
            
            when 'cwe'
                print_info( key.upcase + ': ' + val + " <#{vuln.cwe_url}>" )
                
            when 'variations'
                print_line( )
                print_info( 'Variations' )
                
                val.each_with_index {
                    |variation, i|
                    print_info( '#' + (i+1).to_s )
                    variation.each_pair {
                        |name, item|
                        if( item.is_a?( String ) && name != 'response' )
                            print_info( "\t#{name}" + ': ' + item )
                        end
                    }
                    
                    print_line( )
                }
                
            else
                __print_generic( key, val )
            end
            
        }
        
        print_line( )
        print_line( )
    }
end