pwnbox.pipe

General purpose pipe interface.

class pwnbox.pipe.BasePipe(log_to=stderr, logging=True)

Base class of pipes.

Parameters:
  • log_to – (optional) fd to write logs. Set None to disable logging.
  • logging (bool) – (optional) use log_to instead.
close()

Close pipe.

interact(stdin=stdin, stdout=stdout)

Interact pipe directly with standard IO. Graceful return is not guaranteed.

Parameters:
  • stdin – (optional) standard input fd.
  • stdout – (optional) standard output fd.
read(*args, **kwargs)

Read up to size bytes of data from pipe. Function blocks until at least a byte of data is available.

Parameters:size (int) – (optional) maximum size of data in bytes to read.
Returns:data read from pipe.
read_byte(*args, **kwargs)

Read exactly count bytes of data from pipe. Function blocks until count bytes of data is available.

Parameters:byte (int) – (optional) size of data in bytes to read.
Returns:data read from pipe.
read_line(*args, **kwargs)

Read exactly line lines of data from pipe. Function blocks until line \n appears in available data.

Parameters:line (int) – (optional) lines to read.
Returns:data read from pipe including \n.
read_some(*args, **kwargs)

Read up some data from pipe. Function blocks until at least a byte of data is available.

Returns:data read from pipe.
read_until(*args, **kwargs)

Read until until appears in pipe. Function blocks until until appears in available data.

Parameters:until (str) – string to read until.
Returns:data read from pipe ends with until.
write(*args, **kwargs)

Write buf to pipe.

Parameters:buf (str) – data to be written.
write_line(*args, **kwargs)

Write data with \n to pipe.

Parameters:data (str) – data to be written.
pwnbox.pipe.pipe(*args, **kwargs)

Alias of Pipe.

class pwnbox.pipe.Pipe(**kwargs)

An echo pipe with os.pipe().

Parameters:kwargsBasePipe options.
pwnbox.pipe.connect(*args, **kwargs)

Alias of SocketPipe.

class pwnbox.pipe.SocketPipe(addr, port, **kwargs)

A pipe with a TCP connection.

Parameters:
  • addr (str) – network address of remote server.
  • port (int) – port number of remote server.
  • kwargsBasePipe options.
pwnbox.pipe.popen(*args, **kwargs)

Alias of ProcessPipe.

class pwnbox.pipe.ProcessPipe(cmd, **kwargs)

A pipe with local process.

Parameters:
  • cmd (str) – command to execute.
  • kwargsBasePipe options.