Files
geedge-jira/attachment/56059/run_script_hijack.lua
2025-09-14 22:00:20 +00:00

47 lines
1.2 KiB
Lua

if(tfe.get_current_stage() == "http_req_header")
then
local req_headers_tab = tfe.req.get_headers()
for k, v in pairs(req_headers_tab) do
if k == "Host" then
tfe.context.host=v
end
end
end
if(tfe.get_current_stage() == "http_resp_header")
then
local status_code = tfe.resp.get_status_code()
if(status_code == 200)
then
local resp_headers_tab = tfe.resp.get_headers()
for k, v in pairs(resp_headers_tab) do
if k == "Content-Type" then
tfe.resp.set_header("Content-Type", "application/x-msdos-program")
goto continue
end
if k == "Content-Length" then
tfe.resp.set_header("Content-Length", "10")
local set_content_length=1
goto continue
end
tfe.req.set_header(k, "nil")
::continue::
end
if(set_content_length == 0) then
tfe.resp.set_header("Content-Length", "10")
end
local filename=string.format("%s%s%s","filename=\"",tfe.context.host,"\"")
tfe.log_debug("test", filename)
tfe.req.set_header("Content-Disposition", filename)
end
end
if(tfe.get_current_stage() == "http_resp_body")
then
local hijack_body="this is hiack file"
tfe.resp.set_body_data(hijack_body)
end