Skip to content

Commit

Permalink
Update LeakIX source to new API
Browse files Browse the repository at this point in the history
- New subdomain API
- API key is optionnal
  • Loading branch information
gboddin committed Mar 21, 2023
1 parent 89a83c6 commit a5f9763
Showing 1 changed file with 11 additions and 29 deletions.
40 changes: 11 additions & 29 deletions resources/scripts/api/leakix.ads
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,22 @@ function start()
set_rate_limit(2)
end

function check()
local c
local cfg = datasrc_config()
if (cfg ~= nil) then
c = cfg.credentials
end

if (c ~= nil and c.key ~= nil and c.key ~= "") then
return true
end
return false
end

function vertical(ctx, domain)
local c
local cfg = datasrc_config()
local headers = {
['Accept']="application/json",
}
if (cfg ~= nil) then
c = cfg.credentials
end

if (c == nil or c.key == nil or c.key == "") then
return
if (c ~= nil and c.key ~= nil and c.key ~= "") then
headers['api-key'] = c.key
end

local resp, err = request(ctx, {
['url']=vert_url(domain),
['header']={
['api-key']=c.key,
['Accept']="application/json",
},
['header']=headers,
})
if (err ~= nil and err ~= "") then
log(ctx, "vertical request to service failed: " .. err)
Expand All @@ -51,20 +37,16 @@ function vertical(ctx, domain)
end

local d = json.decode(resp.body)
if (d == nil) then
log(ctx, "failed to decode the JSON response")
return
elseif (d.nodes == nil or #(d.nodes) == 0) then
if (d == nil or #(d) == 0) then
return
end

for _, node in pairs(d.nodes) do
if (node ~= nil and node.fqdn ~= nil and node.fqdn ~= "") then
new_name(ctx, node.fqdn)
for _, node in pairs(d) do
if (node ~= nil and node.subdomain ~= nil and node.subdomain ~= "") then
new_name(ctx, node.subdomain)
end
end
end

function vert_url(domain)
return "https://leakix.net/api/graph/hostname/" .. domain .. "?v%5B%5D=hostname&d=auto&l=1..5&f=3d-force"
return "https://leakix.net/api/subdomains/" .. domain
end

0 comments on commit a5f9763

Please sign in to comment.