Skip to content

Commit b2d56fa

Browse files
committed
Merge branch 'beta' into dev
2 parents 24d217c + a0ddbf5 commit b2d56fa

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ The table below shows which release corresponds to each branch, and what date th
145145
[2435]: https://github.com/Gallopsled/pwntools/pull/2435
146146
[2437]: https://github.com/Gallopsled/pwntools/pull/2437
147147

148+
## 4.13.2
149+
150+
- [#2497][2497] Fix remote.fromsocket() to handle AF_INET6 socket
151+
152+
[2497]: https://github.com/Gallopsled/pwntools/pull/2497
153+
148154
## 4.13.1 (`stable`)
149155

150156
- [#2445][2445] Fix parsing the PLT on Windows

pwnlib/gdb.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def debug_assembly(asm, gdbscript=None, vma=None, api=False):
195195
196196
>>> assembly = shellcraft.echo("Hello world!\n")
197197
>>> io = gdb.debug_assembly(assembly)
198-
>>> io.recvline(timeout=1)
198+
>>> io.recvline()
199199
b'Hello world!\n'
200200
"""
201201
tmp_elf = make_elf_from_assembly(asm, vma=vma, extract=False)
@@ -230,7 +230,7 @@ def debug_shellcode(data, gdbscript=None, vma=None, api=False):
230230
>>> assembly = shellcraft.echo("Hello world!\n")
231231
>>> shellcode = asm(assembly)
232232
>>> io = gdb.debug_shellcode(shellcode)
233-
>>> io.recvline(timeout=1)
233+
>>> io.recvline()
234234
b'Hello world!\n'
235235
"""
236236
if isinstance(data, six.text_type):
@@ -490,12 +490,12 @@ def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, por
490490
Send a command to Bash
491491
492492
>>> io.sendline(b"echo hello")
493-
>>> io.recvline(timeout=30)
493+
>>> io.recvline()
494494
b'hello\n'
495495
496496
Interact with the process
497497
498-
>>> io.interactive(timeout=1) # doctest: +SKIP
498+
>>> io.interactive() # doctest: +SKIP
499499
>>> io.close()
500500
501501
Create a new process, and stop it at '_start'
@@ -514,7 +514,7 @@ def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, por
514514
Send a command to Bash
515515
516516
>>> io.sendline(b"echo hello")
517-
>>> io.recvline(timeout=10)
517+
>>> io.recvline()
518518
b'hello\n'
519519
520520
Interact with the process
@@ -526,19 +526,19 @@ def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, por
526526
527527
>>> io = gdb.debug(args=[b'\xde\xad\xbe\xef'], gdbscript='continue', exe="/bin/sh")
528528
>>> io.sendline(b"echo $0")
529-
>>> io.recvline(timeout=10)
529+
>>> io.recvline()
530530
b'\xde\xad\xbe\xef\n'
531531
>>> io.close()
532532
533533
Demonstrate that LD_PRELOAD is respected
534534
535535
>>> io = process(["grep", "libc.so.6", "/proc/self/maps"])
536-
>>> real_libc_path = io.recvline(timeout=1).split()[-1]
536+
>>> real_libc_path = io.recvline().split()[-1]
537537
>>> io.close()
538538
>>> import shutil
539539
>>> local_path = shutil.copy(real_libc_path, "./local-libc.so") # make a copy of libc to demonstrate that it is loaded
540540
>>> io = gdb.debug(["grep", "local-libc.so", "/proc/self/maps"], gdbscript="continue", env={"LD_PRELOAD": "./local-libc.so"})
541-
>>> io.recvline(timeout=1).split()[-1] # doctest: +ELLIPSIS
541+
>>> io.recvline().split()[-1] # doctest: +ELLIPSIS
542542
b'.../local-libc.so'
543543
>>> io.close()
544544
>>> os.remove("./local-libc.so") # cleanup
@@ -572,15 +572,15 @@ def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, por
572572
573573
>>> io = gdb.debug(args=[b'\xde\xad\xbe\xef'], gdbscript='continue', exe="/bin/sh", ssh=shell)
574574
>>> io.sendline(b"echo $0")
575-
>>> io.recvline(timeout=10)
575+
>>> io.recvline()
576576
b'$ \xde\xad\xbe\xef\n'
577577
>>> io.close()
578578
579579
Using an empty args[0] on a remote process
580580
581581
>>> io = gdb.debug(args=[], gdbscript='continue', exe="/bin/sh", ssh=shell)
582582
>>> io.sendline(b"echo $0")
583-
>>> io.recvline(timeout=10)
583+
>>> io.recvline()
584584
b'$ \n'
585585
>>> io.close()
586586
@@ -620,12 +620,12 @@ def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, por
620620
Resume the program
621621
622622
>>> io.gdb.continue_nowait()
623-
>>> io.recvline(timeout=1)
623+
>>> io.recvline()
624624
b'foo\n'
625625
>>> io.close()
626626
627627
>>> ssh_io.gdb.continue_nowait()
628-
>>> ssh_io.recvline(timeout=1)
628+
>>> ssh_io.recvline()
629629
b'foo\n'
630630
>>> ssh_io.close()
631631
>>> shell.close()
@@ -980,7 +980,7 @@ def attach(target, gdbscript = '', exe = None, gdb_args = None, ssh = None, sysr
980980
... detach
981981
... quit
982982
... ''')
983-
>>> io.recvline(timeout=10)
983+
>>> io.recvline()
984984
b'Hello from process debugger!\n'
985985
>>> io.sendline(b'echo Hello from bash && exit')
986986
>>> io.recvall()
@@ -1007,7 +1007,7 @@ def attach(target, gdbscript = '', exe = None, gdb_args = None, ssh = None, sysr
10071007
10081008
Observe the forced line
10091009
1010-
>>> io.recvline(timeout=1)
1010+
>>> io.recvline()
10111011
b'Hello from process debugger!\n'
10121012
10131013
Interact with the program in a regular way
@@ -1031,7 +1031,7 @@ def attach(target, gdbscript = '', exe = None, gdb_args = None, ssh = None, sysr
10311031
... detach
10321032
... quit
10331033
... ''')
1034-
>>> io.recvline(timeout=10)
1034+
>>> io.recvline()
10351035
b'Hello from remote debugger!\n'
10361036
>>> io.sendline(b'echo Hello from bash && exit')
10371037
>>> io.recvall()
@@ -1074,7 +1074,7 @@ def attach(target, gdbscript = '', exe = None, gdb_args = None, ssh = None, sysr
10741074
>>> io.recvline(timeout=5) # doctest: +SKIP
10751075
b'Hello from ssh debugger!\n'
10761076
>>> io.sendline(b'This will be echoed back')
1077-
>>> io.recvline(timeout=1)
1077+
>>> io.recvline()
10781078
b'This will be echoed back\n'
10791079
>>> io.close()
10801080
"""

pwnlib/tubes/remote.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ class remote(sock):
5353
>>> r = remote.fromsocket(s)
5454
>>> r.recvn(4)
5555
b'HTTP'
56+
>>> s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) #doctest: +SKIP
57+
>>> s.connect(('2606:4700:4700::1111', 80)) #doctest: +SKIP
58+
>>> s.send(b'GET ' + b'\r\n'*2) #doctest: +SKIP
59+
8
60+
>>> r = remote.fromsocket(s) #doctest: +SKIP
61+
>>> r.recvn(4) #doctest: +SKIP
62+
b'HTTP'
5663
"""
5764

5865
def __init__(self, host, port,
@@ -141,7 +148,7 @@ def fromsocket(cls, socket):
141148
Instance of pwnlib.tubes.remote.remote.
142149
"""
143150
s = socket
144-
host, port = s.getpeername()
151+
host, port = s.getpeername()[:2]
145152
return remote(host, port, fam=s.family, typ=s.type, sock=s)
146153

147154
class tcp(remote):

0 commit comments

Comments
 (0)