Class: Watobo::Gui::AddProxyDialog

Inherits:
FXDialogBox
  • Object
show all
Includes:
Responder
Defined in:
lib/watobo/gui/proxy_dialog.rb

Constant Summary

Constants included from Constants

Constants::AC_GROUP_APACHE, Constants::AC_GROUP_DOMINO, Constants::AC_GROUP_ENUMERATION, Constants::AC_GROUP_FILE_INCLUSION, Constants::AC_GROUP_FLASH, Constants::AC_GROUP_GENERIC, Constants::AC_GROUP_JBOSS, Constants::AC_GROUP_JOOMLA, Constants::AC_GROUP_SAP, Constants::AC_GROUP_SQL, Constants::AC_GROUP_TYPO3, Constants::AC_GROUP_XSS, Constants::AUTH_TYPE_BASIC, Constants::AUTH_TYPE_DIGEST, Constants::AUTH_TYPE_NONE, Constants::AUTH_TYPE_NTLM, Constants::CHAT_SOURCE_AUTO_SCAN, Constants::CHAT_SOURCE_FUZZER, Constants::CHAT_SOURCE_INTERCEPT, Constants::CHAT_SOURCE_MANUAL, Constants::CHAT_SOURCE_MANUAL_SCAN, Constants::CHAT_SOURCE_PROXY, Constants::CHAT_SOURCE_UNDEF, Constants::DEFAULT_PORT_HTTP, Constants::DEFAULT_PORT_HTTPS, Constants::FINDING_TYPE_HINT, Constants::FINDING_TYPE_INFO, Constants::FINDING_TYPE_UNDEFINED, Constants::FINDING_TYPE_VULN, Constants::FIRST_TIME_FILE, Constants::GUI_REGULAR_FONT_SIZE, Constants::GUI_SMALL_FONT_SIZE, Constants::ICON_PATH, Constants::LOG_DEBUG, Constants::LOG_INFO, Constants::SCAN_CANCELED, Constants::SCAN_FINISHED, Constants::SCAN_PAUSED, Constants::SCAN_STARTED, Constants::TE_CHUNKED, Constants::TE_COMPRESS, Constants::TE_DEFLATE, Constants::TE_GZIP, Constants::TE_IDENTITY, Constants::TE_NONE, Constants::VULN_RATING_CRITICAL, Constants::VULN_RATING_HIGH, Constants::VULN_RATING_INFO, Constants::VULN_RATING_LOW, Constants::VULN_RATING_MEDIUM, Constants::VULN_RATING_UNDEFINED

Instance Method Summary collapse

Constructor Details

#initialize(owner, proxy = nil) ⇒ AddProxyDialog

Returns a new instance of AddProxyDialog.


104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/watobo/gui/proxy_dialog.rb', line 104

def initialize(owner, proxy=nil)

  super(owner, "Proxy Settings", :opts => DECOR_TITLE|DECOR_BORDER)

  FXMAPFUNC(SEL_COMMAND, ID_ACCEPT, :onAccept)

  @proxy_name_dt = FXDataTarget.new('')
  @proxy_port_dt = FXDataTarget.new('')
  @proxy_dt = FXDataTarget.new('')
  @username_dt = FXDataTarget.new('')
  @password_dt = FXDataTarget.new('')
  @password_rt_dt = FXDataTarget.new('')
  @workstation_dt = FXDataTarget.new('')
  @domain_dt = FXDataTarget.new('')
  @auth_type_dt = FXDataTarget.new(AUTH_TYPE_NTLM)

  unless proxy.nil?
    begin
      @proxy_name_dt.value = proxy[:name]
      @proxy_port_dt.value = proxy[:port]
      @proxy_dt.value = proxy[:host]

      @username_dt.value = proxy[:username] if proxy.has_key? :username
      @password_dt.value = proxy[:password] if proxy.has_key? :password
      @password_rt_dt.value = proxy[:password] if proxy.has_key? :password
      @workstation_dt.value = proxy[:workstation] if proxy.has_key? :workstation
      @domain_dt.value = proxy[:domain] if proxy.has_key? :domain
      @auth_type_dt.value = proxy[:auth_type] if proxy.has_key? :auth_type
    rescue => bang
      puts bang
    end

  end

 # @password_policy = Hash.new
 # @password_policy.update password_policy
  main = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)

  matrix = FXMatrix.new(main, 2, :opts => MATRIX_BY_COLUMNS|LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_GROOVE)

  FXLabel.new(matrix, "Name:", nil, :opts => LAYOUT_TOP|JUSTIFY_RIGHT)
  proxy_name = FXTextField.new(matrix, 25,
  :target => @proxy_name_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)

  proxy_name.handle(self, FXSEL(SEL_UPDATE, 0), nil)

  FXLabel.new(matrix, "Hostname/IP:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)

  hostname = FXTextField.new(matrix, 25,
  :target => @proxy_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)
  hostname.handle(self, FXSEL(SEL_UPDATE, 0), nil)

  FXLabel.new(matrix, "Port:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  port = FXTextField.new(matrix, 25,
  :target => @proxy_port_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)

  port.handle(self, FXSEL(SEL_UPDATE, 0), nil)

  FXLabel.new(matrix, "Auth-Type:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  @auth_types_cb = FXComboBox.new(matrix, 5, nil, 0,
  COMBOBOX_STATIC|FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
  #@filterCombo.width =200
  auth_types = ['None', 'NTLM']
  @auth_types_cb.numVisible = auth_types.length
  @auth_types_cb.numColumns = 25
  @auth_types_cb.editable = false
  auth_types.each do |at|
    @auth_types_cb.appendItem(at, nil)
  end
  @auth_types_cb.setCurrentItem(0)

  unless proxy.nil?
    if proxy.has_key?(:auth_type)
      case proxy[:auth_type]
      when AUTH_TYPE_NTLM
        @auth_types_cb.setCurrentItem(1)
      end
    end
  end

  @auth_types_cb.connect(SEL_COMMAND){
    updateCredFrame()
  }

  @credentials_frame = FXMatrix.new(main, 2, :opts => MATRIX_BY_COLUMNS|LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_GROOVE)
  FXLabel.new(@credentials_frame, "Username:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  username = FXTextField.new(@credentials_frame, 25,
  :target => @username_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)
  username.handle(self, FXSEL(SEL_UPDATE, 0), nil)

  FXLabel.new(@credentials_frame, "Password:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  password = FXTextField.new(@credentials_frame, 25,
  :target => @password_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT|TEXTFIELD_PASSWD)
  password.handle(self, FXSEL(SEL_UPDATE, 0), nil)

  FXLabel.new(@credentials_frame, "Password(retype):", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  password = FXTextField.new(@credentials_frame, 25,
  :target => @password_rt_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT|TEXTFIELD_PASSWD)
  password.handle(self, FXSEL(SEL_UPDATE, 0), nil)

  FXLabel.new(@credentials_frame, "Workstation:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  workstation = FXTextField.new(@credentials_frame, 25,
  :target => @workstation_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)
  workstation.handle(self, FXSEL(SEL_UPDATE, 0), nil)

  FXLabel.new(@credentials_frame, "Domain:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  domain = FXTextField.new(@credentials_frame, 25,
  :target => @domain_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)
  domain.handle(self, FXSEL(SEL_UPDATE, 0), nil)

#  frame = FXVerticalFrame.new(main, :opts => LAYOUT_FILL_X)
#  @save_pws_cbt = FXCheckButton.new(frame, "save passwords")
#  @save_pws_cbt.checkState = false
#  @save_pws_cbt.checkState = true if password_policy[:save_passwords] == true
#  note_label = FXLabel.new(frame, "This setting affects all passwords!!!")

  buttons = FXHorizontalFrame.new(main, :opts => LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,
  :padLeft => 40, :padRight => 40, :padTop => 20, :padBottom => 20)

  accept = FXButton.new(buttons, "&Accept", nil, self, ID_ACCEPT,
  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
  accept.enable
  # Cancel
  FXButton.new(buttons, "&Cancel", nil, self, ID_CANCEL,
  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)

  updateCredFrame()
end

Instance Method Details

#getProxySettingsObject


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/watobo/gui/proxy_dialog.rb', line 29

def getProxySettings
  s = {
    :name =>  @proxy_name_dt.value,
    :port => @proxy_port_dt.value,
    :host => @proxy_dt.value

  }

  c = {
    :username => @username_dt.value,
    :password => @password_dt.value,
    :workstation => @workstation_dt.value,
    :domain => @domain_dt.value,
    :auth_type => @auth_type
  }

  puts "* auth_type"
  puts c[:auth_type]
  if @auth_types_cb.currentItem > 0 and c[:username] != "" and c[:password] != ""
  s.update c
  end

  return s

end

#onAccept(sender, sel, event) ⇒ Object


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
# File 'lib/watobo/gui/proxy_dialog.rb', line 60

def onAccept(sender, sel, event)
  if @proxy_dt.value != "" then
    begin
      proxy_ip = IPSocket.getaddress(@proxy_dt.value)
    rescue
      FXMessageBox.information(self, MBOX_OK, "Wrong Host", "Could not resolve hostname #{@proxy_dt.value}")
    return 0
    end
  else
    FXMessageBox.information(self, MBOX_OK, "No Proxy", "You need to set the proxy host")
  return 0
  end

  unless @proxy_port_dt.value =~ /^\d{1,5}$/ then
    FXMessageBox.information(self, MBOX_OK, "Wrong Format", "Port format is wrong (e.g. 8080")
  return 0
  end

  if @auth_type != AUTH_TYPE_NONE

    unless @password_dt.value == @password_rt_dt.value then
      FXMessageBox.information(self, MBOX_OK, "Password Missmatch", "Passwords don't match!")
    return 0
    end

    unless @password_dt.value != ''
      FXMessageBox.information(self, MBOX_OK, "No Password!", "You need a password!")
    return 0
    end
  end

  if @proxy_name_dt.value == ""
    FXMessageBox.information(self, MBOX_OK, "Proxy Name Missing", "You need to set a name for the new proxy (e.g. myproxy)")
  return 0
  end

#  @password_policy[:save_passwords] = @save_pws_cbt.checked?
#  puts @password_policy.to_yaml
  getApp().stopModal(self, 1)
  self.hide()
  return 1

end

#savePasswords?Boolean

Returns:

  • (Boolean)

55
56
57
58
# File 'lib/watobo/gui/proxy_dialog.rb', line 55

def savePasswords?()
 return false
 # @save_pws_cbt.checked?
end