ruby 中不断增长的二进制负载
我是 ruby 新手,正在寻找一种创建随机二进制数据“有效负载”的方法。
def payload_grow(payload_stack)
payload = payload_stack
valid_chars = ("a".."f").to_a + ("0".."9").to_a
length = valid_chars.size
hex_code = ""
hex_code << valid_chars[rand(length-1)]
hex_code
payload = payload + '0x' + hex_code + hex_code
payload
end
我遇到的问题是我希望有效负载是文字而不是字符串或整数。
I am new to ruby and looking for a way to create a "payload" of random binary data.
def payload_grow(payload_stack)
payload = payload_stack
valid_chars = ("a".."f").to_a + ("0".."9").to_a
length = valid_chars.size
hex_code = ""
hex_code << valid_chars[rand(length-1)]
hex_code
payload = payload + '0x' + hex_code + hex_code
payload
end
The problem I am running into is I want the payload to be a literal and not a string or int.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建随机字节数组非常简单:
可以轻松地将其压缩为字节字符串,然后可以使用 Array#pack 将其写入文件或其他任何内容:
或者您可以创建一个数组随机十六进制字符串,使用
String#%
:我不确定这里的“文字”是什么意思,您能进一步解释一下吗?
Creating a random array of bytes is pretty easy :
This can easily be compressed into a byte string, which can then be written to a file, or whatever, using
Array#pack
:Or you could create an array of random hexadecimal strings, using
String#%
:I'm not sure what you mean by a 'literal' here, could you explain further?
我在 BinData 中找到了我要找的东西
I found what i was looking for in BinData