Notes
  • 👀About me
  • â„šī¸Good Reads
  • 🌐Web
    • Web Pentesting Checklist
    • Insecure Deserialization
    • Blind XPath Injection
    • GraphQL
    • Reverse Shells
      • IIS
    • Content-Security-Policy
      • XSS (Static Nonce in CSP)
    • LLM (Large Language Models)
  • 📘Windows API
    • C# - P/Invoke
  • ☕Miscellaneous Topics
    • Phishing with Gophish
    • Pentest Diaries
      • SQL Queries via Grafana
      • LDAP Pass Back Attack
      • Misconfigured File Upload to RCE
  • 🧃Hack The Box
    • Intelligence
    • Seal
    • Under Construction
    • Previse
    • Return
    • Sauna
    • Nest
  • 📕TryHackMe
    • Wordpress CVE-2021-29447
    • Attacktiv
    • Fortress
    • internal
  • đŸ› ī¸Cheatsheet
    • Anti-Forensic Techniques
    • JSON - jq
    • Docker
    • Hidden Secrets
    • Database Exploitation
      • PostgreSQL
        • Blind SQLi script
      • SQL Server
    • C Sharp
    • Reversing
      • Windows
    • SSH
    • Python
      • Miscellaneous Scripts
        • Credential Bruteforcing a CLI service
    • Privilege Escalation
      • Windows
    • socat
    • OSINT
      • Shodan
    • Installation
Powered by GitBook
On this page

Was this helpful?

  1. Cheatsheet

JSON - jq

# Displaying nested keys:

This is highly useful when dealing when large JSON structure which can contain multiple nested keys. For instance, if you wanted to know what set of JSON keys lead to a value of 'XYZ', the below command would provide the keys in the format A.B.C=XYZ Note: You may encounter integers 0,1,2,etc. This basically indicates the presence of multiple values for the key i.e. Arrays "[]".

jq -r 'paths(scalars | true) as $p  | [ ( [ $p[] | tostring ] | join(".") ), ( getpath($p) | tojson )] | join(": ")'  > json.paths
Sample Output
glossary.title: "example glossary"
glossary.GlossDiv.title: "S"
glossary.GlossDiv.GlossList.GlossEntry.ID: "SGML"
glossary.GlossDiv.GlossList.GlossEntry.SortAs: "SGML"
glossary.GlossDiv.GlossList.GlossEntry.GlossTerm: "Standard Generalized Markup Language"
glossary.GlossDiv.GlossList.GlossEntry.Acronym: "SGML"
glossary.GlossDiv.GlossList.GlossEntry.Abbrev: "ISO 8879:1986"
glossary.GlossDiv.GlossList.GlossEntry.GlossDef.para: "A meta-markup language, used to create markup languages such as DocBook."
glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso.0: "GML"
glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso.1: "XML"
glossary.GlossDiv.GlossList.GlossEntry.GlossSee: "markup"
PreviousAnti-Forensic TechniquesNextDocker

Last updated 1 year ago

Was this helpful?

đŸ› ī¸