Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: JsonParsingError when vt-lookup failed with invalid api key #40

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/takajopkg/vtDomainLookup.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ var vtAPIDomainChannel: Channel[VirusTotalResult] # channel for receiving parall

proc queryDomainAPI(domain:string, headers: httpheaders.HttpHeaders) {.thread.} =
let response = get("https://www.virustotal.com/api/v3/domains/" & encodeUrl(domain), headers)
let jsonResponse = parseJson(response.body)
var jsonResponse = %* {}
var singleResultTable = newTable[string, string]()
var malicious = false
singleResultTable["Domain"] = domain
singleResultTable["Link"] = "https://www.virustotal.com/gui/domain/" & domain
if response.code == 200:
jsonResponse = parseJson(response.body)
singleResultTable["Response"] = "200"
# Parse values that need epoch time to human readable time
singleResultTable["CreationDate"] = getJsonDate(jsonResponse, @["data", "attributes", "creation_date"])
Expand Down
6 changes: 3 additions & 3 deletions src/takajopkg/vtHashLookup.nim
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Todo: add more info useful for triage, trusted_verdict, signature info, sandbox results etc...
# TODO: add more info useful for triage, trusted_verdict, signature info, sandbox results etc...
# https://blog.virustotal.com/2021/08/introducing-known-distributors.html
# TODO:
# Add output not found to txt file

var vtAPIHashChannel: Channel[VirusTotalResult] # channel for receiving parallel query results

proc queryHashAPI(hash:string, headers: httpheaders.HttpHeaders) {.thread.} =
let response = get("https://www.virustotal.com/api/v3/files/" & hash, headers)
let jsonResponse = parseJson(response.body)
var jsonResponse = %* {}
var singleResultTable = newTable[string, string]()
var malicious = false
singleResultTable["Hash"] = hash
singleResultTable["Link"] = "https://www.virustotal.com/gui/file/" & hash
if response.code == 200:
jsonResponse = parseJson(response.body)
singleResultTable["Response"] = "200"

# Parse values that need epoch time to human readable time
Expand Down
3 changes: 2 additions & 1 deletion src/takajopkg/vtIpLookup.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ var vtIpAddressChannel: Channel[VirusTotalResult] # channel for receiving parall

proc queryIpAPI(ipAddress:string, headers: httpheaders.HttpHeaders) {.thread.} =
let response = get("https://www.virustotal.com/api/v3/ip_addresses/" & ipAddress, headers)
let jsonResponse = parseJson(response.body)
var jsonResponse = %* {}
var singleResultTable = newTable[string, string]()
var malicious = false
singleResultTable["IP-Address"] = ipAddress
singleResultTable["Link"] = "https://www.virustotal.com/gui/ip_addresses/" & ipAddress
if response.code == 200:
jsonResponse = parseJson(response.body)
singleResultTable["Response"] = "200"

# Parse values that need epoch time to human readable time
Expand Down