Skip to content

Instantly share code, notes, and snippets.

@ar1a
Created February 11, 2016 09:20
Show Gist options
  • Save ar1a/842d28c54cb1b5278f0e to your computer and use it in GitHub Desktop.
Save ar1a/842d28c54cb1b5278f0e to your computer and use it in GitHub Desktop.
--converts string to shellcode string
local useconsoleargs = false
local function converttocha(str)
if str == nil then print ("Error - no string passed!") return end
local length = #str + 1
-- will break variable name if special characters in the string (". / * etc")
local retn = "char ch" .. str .. "[" .. length .. "] = {"
--Iterate over every character
for c in str:gmatch(".") do
retn = retn .. "'" .. c .. "', "
end
retn = retn .. "0 };"
return retn
end
if useconsoleargs then
print(converttocha(...)) else
while true do
print(converttocha(io.read()))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment