Guest User

Untitled

a guest
Mar 4th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. def peek(pipe)
  2. pkt = RubySMB::SMB2::Packet::IoctlRequest.new
  3. pkt.ctl_code = RubySMB::Fscc::ControlCodes::FSCTL_PIPE_PEEK
  4. pkt.flags.is_fsctl = true
  5. pkt = pipe.set_header_fields(pkt)
  6. resp = pipe.tree.client.send_recv(pkt)
  7. rpkt = RubySMB::SMB2::Packet::IoctlResponse.read(resp)
  8. rpkt.output_count
  9. end
  10.  
  11. def open_pipe(address, username, password)
  12. sock = TCPSocket.new(address, 445)
  13. dispatcher = RubySMB::Dispatcher::Socket.new(sock)
  14. client = RubySMB::Client.new(dispatcher, smb1: false, username: username, password: password)
  15. client.negotiate
  16. # puts "ServerMaxRead: #{client.max_read_size}"
  17. # puts "ServerMaxWrite: #{client.max_write_size}"
  18. client.authenticate
  19. client.tree_connect("\\\\#{address}\\IPC$")
  20. pipe = client.create_pipe('msf-pipe', nil)
  21. pipe.write(data: 'hello, world')
  22. avail = peek(pipe)
  23. puts "Available: #{avail}"
  24. end
Add Comment
Please, Sign In to add comment