Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pwntools-like socket library #59

Closed
10 of 13 tasks
kpcyrd opened this issue Jul 9, 2018 · 0 comments
Closed
10 of 13 tasks

pwntools-like socket library #59

kpcyrd opened this issue Jul 9, 2018 · 0 comments

Comments

@kpcyrd
Copy link
Owner

kpcyrd commented Jul 9, 2018

It should be possible to naively implement arbitrary (text) protocols using badtouch, using functions similar to the socket functions provided by pwntools.

This allows more creative solutions for #58, eg by talking to an smtpd.

  • sock_connect(host, port, {fam='ipv4', timeout=3, ssl=true, ssl_verify=false, newline="\r\n"}), create a connection
  • sock_send(sock, data), send data
  • sock_recv(sock), receive up to 4096 bytes
  • sock_sendline(sock, line), send a line, automatically adds a newline
  • sock_recvline(sock), receive a line, strips newline
  • sock_recvall(sock), receive until EOF
  • sock_recvline_contains(sock, needle), receive lines until one contains at least one needle, then return that line (supports string and list of strings)
  • sock_recvline_regex(sock, regex), receive lines until one matches the regex, then return that line
  • sock_recvn(sock, n), receive exactly n bytes
  • sock_recvuntil(sock, delim), receive until a sequence of bytes is found, then return all data including the sequence (supports string and list of strings)
  • sock_sendafter(sock, delim, data), shorthand for sock_recvuntil(sock, delim) and sock_send(sock, data)
  • sock_unrecv(sock, data), put data back into the buffered reader
  • sock_newline(sock, "\r\n"), update the newline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant