mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-27 19:04:15 +01:00
Merge pull request #160 from calebstewart/issue-159-valueerror-on-loopback
[FIXES 159] Correctly handle IPv6 Sockets
This commit is contained in:
commit
1d7d35e3cd
@ -11,6 +11,7 @@ and simply didn't have the time to go back and retroactively create one.
|
||||
|
||||
### Fixed
|
||||
- Possible exception due to _pre-registering_ of `session` with `manager`
|
||||
- Fixed handling of `socket.getpeername` when `Socket` channel uses IPv6 ([#159](https://github.com/calebstewart/pwncat/issues/159)).
|
||||
### Added
|
||||
- Added alternatives to `bash` to be used during _shell upgrade_ for a _better shell_
|
||||
- Added a warning message when a `KeyboardInterrupt` is caught
|
||||
|
@ -50,7 +50,11 @@ class Socket(Channel):
|
||||
|
||||
if client is not None:
|
||||
# Report host and port number to base channel
|
||||
host, port = client.getpeername()
|
||||
host, port, *_ = client.getpeername()
|
||||
|
||||
# Localhost is sometimes a IPv4 and sometimes IPv6 socket, just normalize the name
|
||||
if host == "::1" or host == "127.0.0.1":
|
||||
host = "localhost"
|
||||
|
||||
if "host" not in kwargs:
|
||||
kwargs["host"] = host
|
||||
@ -78,6 +82,10 @@ class Socket(Channel):
|
||||
self.client = client
|
||||
self.address = client.getpeername()
|
||||
|
||||
# Localhost is sometimes a IPv4 and sometimes IPv6 socket, just normalize the name
|
||||
if self.address[0] == "::1" or self.address[0] == "127.0.0.1":
|
||||
self.address = ("localhost", *self.address[1:])
|
||||
|
||||
self.client.setblocking(False)
|
||||
fcntl.fcntl(self.client, fcntl.F_SETFL, os.O_NONBLOCK)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user