Ethical Hacker Tip: Query All Fields – Display Nice List

Listen to this Post

As seen in the image below, this one-liner in JavaScript (to be pasted into dev tools/inspect) on your target (once the page is loaded) will reveal all `` fields. Remember: input can be “hidden,” meaning you won’t see any input bar, but the default is to show an input bar. This method will show (all) input statements.

Paste into console:

console.table([...document.querySelectorAll('input')].map(e => ({ id: e.id, name: e.name, value: e.value })));

Once you hit enter, provided the page you have loaded currently (this should work in any browser that has dev tools), you should see what is displayed in the screenshot. Examine them closely, as this can reveal information that can be an excellent way of finding new attack surfaces and obviously hidden input fields that may be hidden for a reason.

You Should Know:

  1. Linux Command to Extract Hidden Inputs from Web Pages:

– Use `curl` and `grep` to extract hidden input fields from a webpage:

curl -s http://example.com | grep -oP '<input type="text">]<em>type="hidden"[^>]</em>>'

– This command fetches the webpage and filters out hidden input fields.

2. Windows PowerShell Command to Analyze Web Forms:

  • Use PowerShell to inspect web forms:
    Invoke-WebRequest -Uri "http://example.com" | Select-String -Pattern '<input type="text">]<em>type="hidden"[^>]</em>>'
    
  • This command retrieves the webpage content and searches for hidden input fields.

3. Python Script to Automate Input Field Extraction: