Class: Rex::Proto::SMB::SimpleClient
- Inherits:
-
Object
- Object
- Rex::Proto::SMB::SimpleClient
- Defined in:
- lib/rex/proto/smb/simpleclient.rb
Defined Under Namespace
Classes: OpenFile, OpenPipe, UnitTest
Constant Summary collapse
- CONST =
Some short-hand class aliases
Rex::Proto::SMB::Constants
- CRYPT =
Rex::Proto::SMB::Crypt
- UTILS =
Rex::Proto::SMB::Utils
- XCEPT =
Rex::Proto::SMB::Exceptions
- EVADE =
Rex::Proto::SMB::Evasions
Instance Attribute Summary collapse
-
#client ⇒ Object
Private accessors.
-
#direct ⇒ Object
Private accessors.
-
#last_error ⇒ Object
Public accessors.
-
#last_share ⇒ Object
Private accessors.
-
#shares ⇒ Object
Private accessors.
-
#socket ⇒ Object
Private accessors.
Instance Method Summary collapse
- #connect(share) ⇒ Object
- #create_pipe(path, perm = 'c') ⇒ Object
- #delete(*args) ⇒ Object
- #disconnect(share) ⇒ Object
-
#initialize(socket, direct = false) ⇒ SimpleClient
constructor
Pass the socket object and a boolean indicating whether the socket is netbios or cifs.
- #login(name = '', user = '', pass = '', domain = '', verify_signature = false, usentlmv2 = false, usentlm2_session = true, send_lm = true, use_lanman_key = false, send_ntlm = true, native_os = 'Windows 2000 2195', native_lm = 'Windows 2000 5.0', spnopt = {}) ⇒ Object
- #login_split_next_ntlm1(user, domain, hash_lm, hash_nt) ⇒ Object
- #login_split_start_ntlm1(name = '') ⇒ Object
- #open(path, perm, chunk_size = 48000) ⇒ Object
- #trans_pipe(fid, data, no_response = nil) ⇒ Object
Constructor Details
#initialize(socket, direct = false) ⇒ SimpleClient
Pass the socket object and a boolean indicating whether the socket is netbios or cifs
175 176 177 178 179 180 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 175 def initialize(socket, direct = false) self.socket = socket self.direct = direct self.client = Rex::Proto::SMB::Client.new(socket) self.shares = { } end |
Instance Attribute Details
#client ⇒ Object
Private accessors
172 173 174 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 172 def client @client end |
#direct ⇒ Object
Private accessors
172 173 174 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 172 def direct @direct end |
#last_error ⇒ Object
Public accessors
169 170 171 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 169 def last_error @last_error end |
#last_share ⇒ Object
Private accessors
172 173 174 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 172 def last_share @last_share end |
#shares ⇒ Object
Private accessors
172 173 174 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 172 def shares @shares end |
#socket ⇒ Object
Private accessors
172 173 174 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 172 def socket @socket end |
Instance Method Details
#connect(share) ⇒ Object
264 265 266 267 268 269 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 264 def connect(share) ok = self.client.tree_connect(share) tree_id = ok['Payload']['SMB'].v['TreeID'] self.shares[share] = tree_id self.last_share = share end |
#create_pipe(path, perm = 'c') ⇒ Object
292 293 294 295 296 297 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 292 def create_pipe(path, perm = 'c') disposition = UTILS.create_mode_to_disposition(perm) ok = self.client.create_pipe(path, disposition) file_id = ok['Payload'].v['FileID'] fh = OpenPipe.new(self.client, path, self.client.last_tree_id, file_id) end |
#delete(*args) ⇒ Object
288 289 290 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 288 def delete(*args) self.client.delete(*args) end |
#disconnect(share) ⇒ Object
271 272 273 274 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 271 def disconnect(share) ok = self.client.tree_disconnect(self.shares[share]) self.shares.delete(share) end |
#login(name = '', user = '', pass = '', domain = '', verify_signature = false, usentlmv2 = false, usentlm2_session = true, send_lm = true, use_lanman_key = false, send_ntlm = true, native_os = 'Windows 2000 2195', native_lm = 'Windows 2000 5.0', spnopt = {}) ⇒ Object
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 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 182 def login( name = '', user = '', pass = '', domain = '', verify_signature = false, usentlmv2 = false, usentlm2_session = true, send_lm = true, use_lanman_key = false, send_ntlm = true, native_os = 'Windows 2000 2195', native_lm = 'Windows 2000 5.0', spnopt = {}) begin if (self.direct != true) self.client.session_request(name) end self.client.native_os = native_os self.client.native_lm = native_lm self.client.verify_signature = verify_signature self.client.use_ntlmv2 = usentlmv2 self.client.usentlm2_session = usentlm2_session self.client.send_lm = send_lm self.client.use_lanman_key = use_lanman_key self.client.send_ntlm = send_ntlm self.client.negotiate self.client.spnopt = spnopt ok = self.client.session_setup(user, pass, domain) rescue ::Interrupt raise $! rescue ::Exception => e n = XCEPT::LoginError.new n.source = e if(e.respond_to?('error_code')) n.error_code = e.error_code n.error_reason = e.get_error(e.error_code) end raise n end return true end |
#login_split_next_ntlm1(user, domain, hash_lm, hash_nt) ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 246 def login_split_next_ntlm1(user, domain, hash_lm, hash_nt) begin ok = self.client.session_setup_no_ntlmssp_prehash(user, domain, hash_lm, hash_nt) rescue ::Interrupt raise $! rescue ::Exception => e n = XCEPT::LoginError.new n.source = e if(e.respond_to?('error_code')) n.error_code = e.error_code n.error_reason = e.get_error(e.error_code) end raise n end return true end |
#login_split_start_ntlm1(name = '') ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 220 def login_split_start_ntlm1(name = '') begin if (self.direct != true) self.client.session_request(name) end # Disable extended security self.client.negotiate(false) rescue ::Interrupt raise $! rescue ::Exception => e n = XCEPT::LoginError.new n.source = e if(e.respond_to?('error_code')) n.error_code = e.error_code n.error_reason = e.get_error(e.error_code) end raise n end return true end |
#open(path, perm, chunk_size = 48000) ⇒ Object
277 278 279 280 281 282 283 284 285 286 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 277 def open(path, perm, chunk_size = 48000) mode = UTILS.open_mode_to_mode(perm) access = UTILS.open_mode_to_access(perm) ok = self.client.open(path, mode, access) file_id = ok['Payload'].v['FileID'] fh = OpenFile.new(self.client, path, self.client.last_tree_id, file_id) fh.chunk_size = chunk_size fh end |
#trans_pipe(fid, data, no_response = nil) ⇒ Object
299 300 301 |
# File 'lib/rex/proto/smb/simpleclient.rb', line 299 def trans_pipe(fid, data, no_response = nil) client.trans_named_pipe(fid, data, no_response) end |