summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-09-14 06:15:12 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-09-14 06:15:12 (GMT)
commitf2f0fc476e032ada5460f251aace7878e1cd3934 (patch)
treea76bbece61b0aa933ca8840a238eb3d67badf742 /src
parenta7137c2ae4c977c0f3aa6055387ab43bdfa5b4d4 (diff)
Include lengths in ROST JSON reports.
Diffstat (limited to 'src')
-rw-r--r--src/analysis/scan/matches/bytes.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/analysis/scan/matches/bytes.c b/src/analysis/scan/matches/bytes.c
index ccd73a1..de101c4 100644
--- a/src/analysis/scan/matches/bytes.c
+++ b/src/analysis/scan/matches/bytes.c
@@ -459,6 +459,7 @@ static void g_scan_bytes_match_output_to_json(const GScanBytesMatch *match, cons
init_vmpa(&pos, match->start, VMPA_NO_VIRTUAL);
data = g_binary_content_get_raw_access(match->content, &pos, match->len);
+ assert(data != NULL);
for (k = 0; k < match->len; k++)
{
@@ -505,6 +506,7 @@ static void g_scan_bytes_match_output_to_json(const GScanBytesMatch *match, cons
init_vmpa(&pos, match->start, VMPA_NO_VIRTUAL);
data = g_binary_content_get_raw_access(match->content, &pos, match->len);
+ assert(data != NULL);
for (k = 0; k < match->len; k++)
{
@@ -536,6 +538,50 @@ static void g_scan_bytes_match_output_to_json(const GScanBytesMatch *match, cons
}
- write(fd, "\"\n", 2);
+ write(fd, "\",\n", 3);
+
+ /* Affichage du contenu brut */
+
+ for (i = 0; i < level; i++)
+ write(fd, padding->data, padding->len);
+
+ write(fd, "\"length\": ", 10);
+
+ init_vmpa(&pos, match->start, VMPA_NO_VIRTUAL);
+
+ ret = snprintf(value, ULLONG_MAXLEN, "%llu", (unsigned long long)match->len);
+
+ if (ret > 0)
+ write(fd, value, ret);
+
+ else
+ {
+ log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
+ write(fd, "-1", 2);
+ }
+
+ write(fd, ",\n", 2);
+
+ /* Affichage du contenu brut (hexadécimal) */
+
+ for (i = 0; i < level; i++)
+ write(fd, padding->data, padding->len);
+
+ write(fd, "\"length_hex\": ", 14);
+
+ init_vmpa(&pos, match->start, VMPA_NO_VIRTUAL);
+
+ ret = snprintf(value, ULLONG_MAXLEN, "\"0x%llx\"", (unsigned long long)match->len);
+
+ if (ret > 0)
+ write(fd, value, ret);
+
+ else
+ {
+ log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
+ write(fd, "\"0xffffffffffffffff\"", 20);
+ }
+
+ write(fd, "\n", 1);
}