Skip to content

Instantly share code, notes, and snippets.

@Cvar1984
Created May 21, 2025 07:15
Show Gist options
  • Save Cvar1984/67f16655a0fcd48e524b99ffebad50d1 to your computer and use it in GitHub Desktop.
Save Cvar1984/67f16655a0fcd48e524b99ffebad50d1 to your computer and use it in GitHub Desktop.
Parse only subdomain result from amass and make it hosts file
local filename = arg[1]
if not filename then
print("Usage: lua parse.lua file:domain.com")
os.exit(1)
end
local hostname = filename
local file = io.open(filename, "r")
if not file then
print("Failed to open file:", filename)
os.exit(1)
end
local data = file:read("*a")
file:close()
local results = {}
for domain, record_type in data:gmatch("([%w%.%-]+%.[a-zA-Z]+) %(FQDN%)%s*%-%-%>%s*([%w_]+)%s*%-%-%>") do
-- Check if domain ends with the base domain
if domain:match("%." .. hostname .. "$") or domain == hostname then
results[domain] = record_type
end
end
for domain, record_type in pairs(results) do
-- print(string.format("%s => %s", domain, record_type))
print(string.format("0.0.0.0 %s", domain))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment