Secondo HAR: campioni, lettori e richieste della pagina di Instagram
Il HAR del 12 novembre (senza filtro) letto con la sonda sulla macchina di Alberto, fuori dal repository: 45 forme di richieste, 142 campioni ripuliti e verificati. Da qui otto campioni nuovi (scheda e post del profilo, schede Reel e Con tag, raccolte, storie, vassoio delle storie, serie con un video), accorciati sulla copia ripulita per non aprire mai i grezzi. Lettori: postCount = media_count e la chiave nuova highlight.cover. Le schede Reel e Con tag restano anteprime, non contenuti; il blocco della pagina iniziale da' nome e foto dell'account collegato (H10). Sonda: i numeri con esponente restano numeri; la verifica non cerca dentro i valori ammessi di proposito ma sempre nelle chiavi di dati, cerca la chiave del frammento con lo stesso confronto del testo, e non conta le parole degli indirizzi finti. docs/sonda/richieste-instagram.md: quale operazione da' che cosa, le scritture che Febe non deve mai mandare, le vie per doc_id e i campi di sessione nei limiti di 6.1, cio' che manca (seguiti, seconda pagina dei post: parte A quater delle prove dal vivo). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2ffb766a95
commit
dc60e282c5
23 files changed
+5986
-28
No files matched your search
@@ -222,7 +222,7 @@ static int Verify(string[] args)
|
||||
foreach (var leak in report.Leaks)
|
||||
{
|
||||
// Where, never what: the value itself stays on this machine.
|
||||
Console.WriteLine($"Sopravvive un frammento di {leak.Length} {leak.Kind} in {leak.CleanFile}.");
|
||||
Console.WriteLine($"Sopravvive un frammento di {leak.Length} {leak.Kind} in {leak.CleanFile}, sotto «{leak.Key}».");
|
||||
}
|
||||
|
||||
Console.WriteLine(report.Passed ? "Verifica superata: nessun valore dei grezzi sopravvive fuori dall'elenco ammesso." : "Verifica NON superata.");
|
||||
|
||||
@@ -32,7 +32,8 @@ public sealed partial class SampleSanitizer
|
||||
/// File extensions an address may keep. Only known file types: the last segment of a page address may be a user
|
||||
/// name with a dot («nome.cognome»), and its «extension» would leak part of it.
|
||||
/// </summary>
|
||||
private static readonly HashSet<string> FileExtensions = new(StringComparer.Ordinal)
|
||||
/// <summary>File extensions a fake address keeps (the only part of a real address that survives).</summary>
|
||||
internal static readonly HashSet<string> FileExtensions = new(StringComparer.Ordinal)
|
||||
{
|
||||
"jpg", "jpeg", "png", "webp", "heic", "heif", "gif", "avif", "mp4", "m4v", "mov", "webm", "m4a", "mp3", "aac",
|
||||
"m3u8", "mpd", "ts", "json", "js", "css", "html", "htm", "txt", "xml", "svg", "ico", "woff", "woff2",
|
||||
@@ -216,7 +217,15 @@ public sealed partial class SampleSanitizer
|
||||
|
||||
private string FakeNumber(string raw)
|
||||
{
|
||||
var fake = Fake(raw, "n");
|
||||
// Only the digits are faked: sign, point and exponent («1.5e+21») stay as they are, or the fake is not a number.
|
||||
var faked = Fake(raw, "n");
|
||||
var fake = string.Create(raw.Length, (raw, faked), static (span, pair) =>
|
||||
{
|
||||
for (var i = 0; i < span.Length; i++)
|
||||
{
|
||||
span[i] = char.IsAsciiDigit(pair.raw[i]) ? pair.faked[i] : pair.raw[i];
|
||||
}
|
||||
});
|
||||
|
||||
// A JSON number must not start with 0 (except «0.x»): keep the first digit non-zero.
|
||||
var first = -1;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Febe.Sonda;
|
||||
@@ -7,7 +6,11 @@ namespace Febe.Sonda;
|
||||
/// <param name="CleanFile">Cleaned file (relative path) where a raw piece survives.</param>
|
||||
/// <param name="Length">Length of the surviving piece.</param>
|
||||
/// <param name="Kind">«lettere» or «cifre».</param>
|
||||
public sealed record SampleLeak(string CleanFile, int Length, string Kind);
|
||||
/// <param name="Key">
|
||||
/// The key the piece sits under in the cleaned file when it is a key of the structure (copied from the raw samples on
|
||||
/// purpose, so it tells nothing); «(chiave di dati)» when the key itself is data, «(radice)» at the top.
|
||||
/// </param>
|
||||
public sealed record SampleLeak(string CleanFile, int Length, string Kind, string Key = "(radice)");
|
||||
|
||||
/// <summary>Result of the verification of cleaned samples.</summary>
|
||||
public sealed record VerifyReport(int RawFiles, int CleanFiles, int CheckedTokens, IReadOnlyList<SampleLeak> Leaks, IReadOnlyList<string> MissingCleanFiles)
|
||||
@@ -21,6 +24,9 @@ public sealed record VerifyReport(int RawFiles, int CleanFiles, int CheckedToken
|
||||
/// </summary>
|
||||
public static class SampleVerifier
|
||||
{
|
||||
/// <summary>The key reported for a data key and for what sits under it: no allowlist rule matches it.</summary>
|
||||
private const string DataKey = "(chiave di dati)";
|
||||
|
||||
public static VerifyReport Verify(string rawFolder, string cleanFolder, SanitizerAllowlist? allowlist = null)
|
||||
{
|
||||
var raw = Path.GetFullPath(rawFolder);
|
||||
@@ -42,19 +48,27 @@ public static class SampleVerifier
|
||||
var leaks = new List<SampleLeak>();
|
||||
foreach (var file in cleanFiles)
|
||||
{
|
||||
var atoms = new StringBuilder();
|
||||
var atoms = new List<(string Text, string Key, bool Number)>();
|
||||
foreach (var text in Documents(file))
|
||||
{
|
||||
using var document = JsonDocument.Parse(text, new JsonDocumentOptions { MaxDepth = 256 });
|
||||
Atoms(document.RootElement, atoms, 0);
|
||||
Atoms(document.RootElement, atoms, "(radice)", 0);
|
||||
}
|
||||
|
||||
var haystack = atoms.ToString().ToLowerInvariant();
|
||||
// Values the allowlist keeps on purpose (a media type, a date, a size) are not searched: their own tokens are
|
||||
// allowed already, and a short token of someone else's text that happens to sit inside one («script» in
|
||||
// «text/javascript», five digits inside a ten-digit date) is a coincidence, not a leak.
|
||||
atoms.RemoveAll(a => a.Number ? tokens.Allowlist.KeepsNumber(a.Key) : tokens.Allowlist.KeepsString(a.Key, a.Text));
|
||||
|
||||
// Separated so that tokens cannot span two atoms.
|
||||
var haystack = string.Join('\u0001', atoms.Select(a => a.Text)).ToLowerInvariant();
|
||||
foreach (var token in sensitive)
|
||||
{
|
||||
if (haystack.Contains(token, StringComparison.Ordinal))
|
||||
{
|
||||
leaks.Add(new SampleLeak(Path.GetRelativePath(clean, file), token.Length, token.Any(char.IsLetter) ? "lettere" : "cifre"));
|
||||
// The same comparison as the haystack: OrdinalIgnoreCase folds some letters differently (KELVIN SIGN).
|
||||
var key = atoms.Where(a => a.Text.ToLowerInvariant().Contains(token, StringComparison.Ordinal)).Select(a => a.Key).FirstOrDefault() ?? "(radice)";
|
||||
leaks.Add(new SampleLeak(Path.GetRelativePath(clean, file), token.Length, token.Any(char.IsLetter) ? "lettere" : "cifre", key));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +85,7 @@ public static class SampleVerifier
|
||||
/// Every value and every data key of a cleaned document, separated so that tokens cannot span two of them.
|
||||
/// Ordinary keys are structure, copied from the raw samples on purpose: they are not looked at.
|
||||
/// </summary>
|
||||
private static void Atoms(JsonElement element, StringBuilder sb, int depth)
|
||||
private static void Atoms(JsonElement element, List<(string Text, string Key, bool Number)> atoms, string key, int depth)
|
||||
{
|
||||
if (depth > 256)
|
||||
{
|
||||
@@ -83,27 +97,29 @@ public static class SampleVerifier
|
||||
case JsonValueKind.Object:
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (SensitiveTokens.IsDataKey(property.Name))
|
||||
var dataKey = SensitiveTokens.IsDataKey(property.Name);
|
||||
if (dataKey)
|
||||
{
|
||||
sb.Append(property.Name).Append('\u0001');
|
||||
// Never under its parent's rule: the sanitizer fakes every data key, so none may be skipped below.
|
||||
atoms.Add((property.Name, DataKey, false));
|
||||
}
|
||||
|
||||
Atoms(property.Value, sb, depth + 1);
|
||||
Atoms(property.Value, atoms, dataKey ? DataKey : property.Name, depth + 1);
|
||||
}
|
||||
|
||||
break;
|
||||
case JsonValueKind.Array:
|
||||
foreach (var item in element.EnumerateArray())
|
||||
{
|
||||
Atoms(item, sb, depth + 1);
|
||||
Atoms(item, atoms, key, depth + 1);
|
||||
}
|
||||
|
||||
break;
|
||||
case JsonValueKind.String:
|
||||
sb.Append(element.GetString()).Append('\u0001');
|
||||
atoms.Add((element.GetString() ?? string.Empty, key, false));
|
||||
break;
|
||||
case JsonValueKind.Number:
|
||||
sb.Append(element.GetRawText()).Append('\u0001');
|
||||
atoms.Add((element.GetRawText(), key, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,12 @@ namespace Febe.Sonda;
|
||||
/// </summary>
|
||||
public sealed class SensitiveTokens
|
||||
{
|
||||
/// <summary>Words of address structure that the cleaned samples write themselves.</summary>
|
||||
private static readonly string[] AddressWords = ["http", "https", "www", "html", "json", "jpeg", "webp", "heic", "esempio"];
|
||||
/// <summary>
|
||||
/// Words of address structure that the cleaned samples write themselves: scheme, the fake hosts
|
||||
/// «https://{sito|cdn|altro}.esempio/» and the file extensions a fake address keeps.
|
||||
/// </summary>
|
||||
private static readonly string[] AddressWords =
|
||||
["http", "https", "www", "esempio", "sito", "altro", .. SampleSanitizer.FileExtensions];
|
||||
|
||||
private readonly HashSet<string> _tokens = new(StringComparer.Ordinal);
|
||||
private readonly HashSet<string> _excluded = new(StringComparer.Ordinal);
|
||||
|
||||
Reference in new issue
Block a user