pwnlib.tubes.sock — Sockets¶
-
class
pwnlib.tubes.sock.sock[source]¶ Bases:
pwnlib.tubes.tube.tubeMethods available exclusively to sockets.
-
class
pwnlib.tubes.remote.remote(host, port, fam='any', typ='tcp', ssl=False, sock=None, *args, **kwargs)[source]¶ Bases:
pwnlib.tubes.sock.sockCreates a TCP or UDP-connection to a remote host. It supports both IPv4 and IPv6.
The returned object supports all the methods from
pwnlib.tubes.sockandpwnlib.tubes.tube.Parameters: - host (str) – The host to connect to.
- port (int) – The port to connect to.
- fam – The string “any”, “ipv4” or “ipv6” or an integer to pass to
socket.getaddrinfo(). - typ – The string “tcp” or “udp” or an integer to pass to
socket.getaddrinfo(). - timeout – A positive number, None or the string “default”.
- ssl (bool) – Wrap the socket with SSL
- sock (socket) – Socket to inherit, rather than connecting
Examples
>>> r = remote('google.com', 443, ssl=True) >>> r.send('GET /\r\n\r\n') >>> r.recvn(4) 'HTTP' >>> r = remote('127.0.0.1', 1) Traceback (most recent call last): ... PwnlibException: Could not connect to 127.0.0.1 on port 1 >>> import socket >>> s = socket.socket() >>> s.connect(('google.com', 80)) >>> s.send('GET /' + '\r\n'*2) 9 >>> r = remote.fromsocket(s) >>> r.recvn(4) 'HTTP'
-
class
pwnlib.tubes.listen.listen(port=0, bindaddr='0.0.0.0', fam='any', typ='tcp', *args, **kwargs)[source]¶ Bases:
pwnlib.tubes.sock.sockCreates an TCP or UDP-socket to receive data on. It supports both IPv4 and IPv6.
The returned object supports all the methods from
pwnlib.tubes.sockandpwnlib.tubes.tube.Parameters: - port (int) – The port to connect to.
- bindaddr (str) – The address to bind to.
- fam – The string “any”, “ipv4” or “ipv6” or an integer to pass to
socket.getaddrinfo(). - typ – The string “tcp” or “udp” or an integer to pass to
socket.getaddrinfo().