r/programming • • 6d ago

Ruby2Shell

https://verialabs.com/ruby2shell/
184 Upvotes

44 comments sorted by

View all comments

Show parent comment

11

u/coriandor 5d ago

It's not one byte. It's one byte per ß. The writeup says the buffer is allocated as len + 20, so you need 21 ßs to overflow 1 byte. Make that "ß*100<payload>", and you've pushed your payload 80 bytes past the buffer.

2

u/fakehalo 5d ago

Its confusing, because looking at the code snippet itself it appears like the while(to<to_len) check iterating through each character would still only allow this the be a single byte overflowing the very last iteration.. since the *to++ is happening/incrementing 2 times each loop to keep the check (except for the very last one)