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 all commits
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
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