pwn++  0.1.4
A (toy) Windows & Linux pwn library to play with modern C++.
pwn::Net::Tube Class Referenceabstract

Generic interface that represent a tube. Tube definition (process, remote) are OS-specific. More...

#include <Tube.hpp>

Public Member Functions

PWNAPI Result< usize > send (std::vector< u8 > const &str)
 Move data given as argument to the send buffer, tries to send. More...
 
PWNAPI Result< usize > send (std::string const &str)
 Move data given as argument to the send buffer, tries to send. More...
 
Result< std::vector< u8 > > recv (_In_ usize size=Tube::PIPE_DEFAULT_SIZE)
 Read bytes from the tube, moves the read bytes to the receive buffer. More...
 
Result< usize > sendline (_In_ std::vector< u8 > const &data)
 Send the data (as byte vector) followed by a line separator. More...
 
PWNAPI Result< usize > sendline (_In_ std::string const &str)
 Send the data (as str) followed by a line separator. More...
 
PWNAPI Result< std::vector< u8 > > recvuntil (_In_ std::vector< u8 > const &pattern)
 Read from tube until receiving the given pattern, and return that data.
 
PWNAPI Result< std::vector< u8 > > recvuntil (_In_ std::string const &pattern)
 
PWNAPI Result< std::vector< u8 > > recvline ()
 Read from tube until receiving a line separator and return it.
 
PWNAPI Result< usize > sendafter (_In_ std::string const &pattern, _In_ std::string const &data)
 function combining in one call recvuntil() + send() More...
 
PWNAPI Result< usize > sendafter (_In_ std::vector< u8 > const &pattern, _In_ std::vector< u8 > const &data)
 
PWNAPI Result< usize > sendlineafter (_In_ std::string const &pattern, _In_ std::string const &data)
 Convenience function combining in one call recvuntil() + sendline() More...
 
PWNAPI Result< usize > sendlineafter (_In_ std::vector< u8 > const &pattern, _In_ std::vector< u8 > const &data)
 
PWNAPI Result< usize > peek ()
 Peek into the tube to see if any data is available.
 
PWNAPI void interactive ()
 Basic REPL.
 

Static Public Attributes

static constexpr usize PIPE_DEFAULT_SIZE = 1024
 Default read size from the pipe.
 
static constexpr u8 LINE_SEPARATOR = '\n'
 Default line separator.
 
static constexpr std::string_view INTERACTIVE_PROMPT = "(pwn)> "
 Default prompt.
 

Protected Member Functions

virtual Result< usize > send_internal (_In_ std::vector< u8 > const &data)=0
 
virtual Result< std::vector< u8 > > recv_internal (_In_ usize size)=0
 
virtual Result< usize > peek_internal ()=0
 

Protected Attributes

std::vector< u8 > m_receive_buffer
 
std::vector< u8 > m_send_buffer
 

Detailed Description

Generic interface that represent a tube. Tube definition (process, remote) are OS-specific.

Member Function Documentation

◆ recv()

Result<std::vector<u8> > pwn::Net::Tube::recv ( _In_ usize  size = Tube::PIPE_DEFAULT_SIZE)

Read bytes from the tube, moves the read bytes to the receive buffer.

Parameters
sizeThe number of expected to be received (default: Tube::PIPE_DEFAULT_SIZE)
Returns
Result<std::vector<u8>>

◆ recvuntil()

PWNAPI Result<std::vector<u8> > pwn::Net::Tube::recvuntil ( _In_ std::string const &  pattern)
Parameters
pattern
Returns
Result<std::vector<u8>>

◆ send() [1/2]

PWNAPI Result<usize> pwn::Net::Tube::send ( std::string const &  str)

Move data given as argument to the send buffer, tries to send.

Parameters
str
Returns
A Result object with the number of bytes sent

◆ send() [2/2]

PWNAPI Result<usize> pwn::Net::Tube::send ( std::vector< u8 > const &  str)

Move data given as argument to the send buffer, tries to send.

Parameters
str
Returns
A Result object with the number of bytes sent

◆ sendafter() [1/2]

PWNAPI Result<usize> pwn::Net::Tube::sendafter ( _In_ std::string const &  pattern,
_In_ std::string const &  data 
)

function combining in one call recvuntil() + send()

Parameters
pattern
data
Returns

◆ sendafter() [2/2]

PWNAPI Result<usize> pwn::Net::Tube::sendafter ( _In_ std::vector< u8 > const &  pattern,
_In_ std::vector< u8 > const &  data 
)
Parameters
pattern
data
Returns
Result<usize>

◆ sendline() [1/2]

PWNAPI Result<usize> pwn::Net::Tube::sendline ( _In_ std::string const &  str)

Send the data (as str) followed by a line separator.

Parameters
str
Returns
Result<usize> A Result object with the number of bytes sent

◆ sendline() [2/2]

Result<usize> pwn::Net::Tube::sendline ( _In_ std::vector< u8 > const &  data)

Send the data (as byte vector) followed by a line separator.

Parameters
data
Returns
Result<usize> A Result object with the number of bytes sent

◆ sendlineafter() [1/2]

PWNAPI Result<usize> pwn::Net::Tube::sendlineafter ( _In_ std::string const &  pattern,
_In_ std::string const &  data 
)

Convenience function combining in one call recvuntil() + sendline()

Parameters
pattern
data
Returns

◆ sendlineafter() [2/2]

PWNAPI Result<usize> pwn::Net::Tube::sendlineafter ( _In_ std::vector< u8 > const &  pattern,
_In_ std::vector< u8 > const &  data 
)
Parameters
pattern
data
Returns
PWNAPI

The documentation for this class was generated from the following file: