-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Labels
bugUnexpected problem or unintended behaviorUnexpected problem or unintended behavior
Description
Configuration
- impacket version: 0.14.0.dev (from
impacket-master.zip) , also reproducible on 0.13.0 - Python version: 3.11.2
- Target OS: Linux x86_64
Debug Output With Command String
Command:
python -c "import sys; sys.path.insert(0,'./'); from impacket.ImpactPacket import LinuxSLL; sll=LinuxSLL(); print('Calling set_arphdr(1)...'); sll.set_arphdr(1)"Output:
Calling set_arphdr(1)...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/.../impacket/ImpactPacket.py", line 716, in set_arphdr
self.set_word(2, type)
File "/.../impacket/ImpactPacket.py", line 103, in set_word
ary = array.array("B", struct.pack(order + 'H', value))
struct.error: required argument is not an integer
Command:
python -c "import sys; sys.path.insert(0,'./'); from impacket.ImpactPacket import LinuxSLL; sll=LinuxSLL(); print('Calling set_addr(b\"ABCDEFGH\")...'); sll.set_addr(b'ABCDEFGH')"Output:
Calling set_addr(b"ABCDEFGH")...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/.../impacket/ImpactPacket.py", line 734, in set_addr
self.get_bytes()[6:14] = addr
TypeError: can only assign array (not "bytes") to array slice
PCAP
N/A
Additional context
Bug A: LinuxSLL.set_arphdr(self, value) uses the builtin type symbol instead of the value parameter:
self.set_word(2, type)This always fails because type is a function, not an integer.
Bug B: LinuxSLL.set_addr(self, addr) attempts to assign bytes into an array('B') slice:
self.get_bytes()[6:14] = addrThis raises TypeError because the RHS must be an array('B', ...) (or another array of compatible type).
Suggested fix:
def set_arphdr(self, value):
self.set_word(2, value)
def set_addr(self, addr):
import array
if len(addr) < 8:
addr += b'\0' * (8 - len(addr))
self.get_bytes()[6:14] = array.array('B', addr)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugUnexpected problem or unintended behaviorUnexpected problem or unintended behavior