Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def peek(pipe)
- pkt = RubySMB::SMB2::Packet::IoctlRequest.new
- pkt.ctl_code = RubySMB::Fscc::ControlCodes::FSCTL_PIPE_PEEK
- pkt.flags.is_fsctl = true
- pkt = pipe.set_header_fields(pkt)
- resp = pipe.tree.client.send_recv(pkt)
- rpkt = RubySMB::SMB2::Packet::IoctlResponse.read(resp)
- rpkt.output_count
- end
- def open_pipe(address, username, password)
- sock = TCPSocket.new(address, 445)
- dispatcher = RubySMB::Dispatcher::Socket.new(sock)
- client = RubySMB::Client.new(dispatcher, smb1: false, username: username, password: password)
- client.negotiate
- # puts "ServerMaxRead: #{client.max_read_size}"
- # puts "ServerMaxWrite: #{client.max_write_size}"
- client.authenticate
- client.tree_connect("\\\\#{address}\\IPC$")
- pipe = client.create_pipe('msf-pipe', nil)
- pipe.write(data: 'hello, world')
- avail = peek(pipe)
- puts "Available: #{avail}"
- end
Add Comment
Please, Sign In to add comment