Skip to content

Commit

Permalink
Merge pull request #40 from Yamato-Security/fix-vt-lookup-error
Browse files Browse the repository at this point in the history
fix: `JsonParsingError` when `vt-lookup` failed with invalid api key
  • Loading branch information
YamatoSecurity authored Sep 18, 2023
2 parents 56a7eaf + c312d90 commit 1334a87
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-Japanese.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
**バグ修正*:**

- Hayabusa 2.8.0以上の結果で`timeline-suspicious-processes`を実行した際のクラッシュを修正した。 (#35) (@fukusuket)
- 無効なAPIキーが指定された場合に、VirusTotalの検索でJSONパースエラーが発生する問題を修正した。(@fukusuket)

## 2.0.0 [2022/08/03] - [SANS DFIR Summit 2023 Release](https://www.sans.org/cyber-security-training-events/digital-forensics-summit-2023/)

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
**Bug Fixes*:**

- `timeline-suspicious-processes` would crash when Hayabusa results from version 2.8.0+ was used. (#35) (@fukusuket)
- Fixed a JSON parsing error in VirusTotal lookups when an invalid API key was specified. (@fukusuket)

## 2.0.0 [2022/08/03] - [SANS DFIR Summit 2023 Release](https://www.sans.org/cyber-security-training-events/digital-forensics-summit-2023/)

Expand Down
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

0 comments on commit 1334a87

Please sign in to comment.