Skip to content

fix: bug when sending payload/data type of bytes instead of strings - #8

Open
HyggeHalcyon wants to merge 2 commits into
Byzero512:masterfrom
HyggeHalcyon:master
Open

fix: bug when sending payload/data type of bytes instead of strings#8
HyggeHalcyon wants to merge 2 commits into
Byzero512:masterfrom
HyggeHalcyon:master

Conversation

@HyggeHalcyon

Copy link
Copy Markdown

example case where the bug can be replicated

from winpwn import *
from os.path import normpath
import pwn

exe = normpath('./challenge.exe')
io = process(exe)
payload = pwn.p64(0x010101)
io.send(payload)

First occurred error in win.py

Traceback (most recent call last):
  File "D:\REDACTED\test.py", line 8, in <module>
    io.send(payload)
  File "C:\Python311\Lib\site-packages\winpwn\winpwn.py", line 33, in send
    rs=self.write(buf)
       ^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\winpwn\winpwn.py", line 199, in write
    return self.Process.write(buf)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\winpwn\win.py", line 234, in write
    return self.pipe.write(buf)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\winpwn\win.py", line 157, in write
    buf=Latin1_encode(buf)
        ^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\winpwn\misc.py", line 84, in Latin1_encode
    return bytes(string,"Latin1")
           ^^^^^^^^^^^^^^^^^^^^^^
TypeError: encoding without a string argument

Second occurred error in misc.py

Traceback (most recent call last):
  File "D:\REDACTED\test.py", line 8, in <module>
    io.send(payload)
  File "C:\Python311\Lib\site-packages\winpwn\winpwn.py", line 34, in send
    showbuf(buf)
  File "C:\Python311\Lib\site-packages\winpwn\misc.py", line 140, in showbuf
    if buf.endswith(context.newline):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: endswith first arg must be bytes or a tuple of bytes, not str

Third occurred error in cases when communicating through remote socket as follows

from winpwn import *
from os.path import normpath
import pwn

io = remote('127.0.0.1', 9001)
payload = pwn.p64(0x010101)
io.send(payload)

and it would generate the following error

Traceback (most recent call last):
  File "D:\REDACTED\test.py", line 9, in <module>
    io.send(payload)
  File "C:\Python311\Lib\site-packages\winpwn\winpwn.py", line 33, in send
    rs=self.write(buf)
       ^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\winpwn\winpwn.py", line 157, in write
    return self.sock.send(Latin1_encode(buf))
                          ^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\winpwn\misc.py", line 84, in Latin1_encode
    return bytes(string,"Latin1")
           ^^^^^^^^^^^^^^^^^^^^^^
TypeError: encoding without a string argument

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

Successfully merging this pull request may close these issues.

1 participant