Finding Hidden Parameters in JavaScript Files for Ethical Hacking

Listen to this Post

In the world of ethical hacking and penetration testing, discovering hidden parameters in JavaScript files can be a goldmine for identifying potential vulnerabilities. This article will guide you through the process of uncovering these hidden parameters using a combination of tools and commands. We will also provide practical, verified code snippets and steps to help you implement this technique effectively.

You Should Know:

1. Tools and Commands Used:

  • assetfinder: A tool to find domains and subdomains.
  • gau (Get All URLs): A tool to fetch known URLs from AlienVault’s Open Threat Exchange, Wayback Machine, and Common Crawl.
  • curl: A command-line tool to transfer data from or to a server.
  • egrep: A pattern searching tool.
  • sed: A stream editor for filtering and transforming text.

2. Step-by-Step Process:

  • Use `assetfinder` to discover domains and subdomains.
  • Pipe the output to `gau` to fetch URLs.
  • Filter out unnecessary file types like `.css` and `.svg` using egrep.
  • Loop through each URL and use `curl` to fetch the content.
  • Extract hidden parameters using `grep` and sed.

3. Practical Code Example:

assetfinder <em>.com | gau | egrep -v '(.css|.svg)' | while read url; do 
vars=$(curl -s $url | grep -Eo "var [a-zA-Z0-9]+" | sed -e 's,'var','"$url"?',g' -e 's/ //g' | grep -v '.js' | sed 's/.</em>/&=xss/g'); 
echo -e "\e[1;33m$url\n\e[1;32m$vars"
done

4. Explanation of the Code:

  • assetfinder *.com: Discovers domains and subdomains.
  • gau: Fetches known URLs.
  • egrep -v '(.css|.svg)': Filters out CSS and SVG files.
  • while read url; do ... done: Loops through each URL.
  • curl -s $url: Fetches the content of the URL silently.
  • grep -Eo "var [a-zA-Z0-9]+": Extracts JavaScript variables.
  • sed -e 's,'var','"$url"?',g' -e 's/ //g': Transforms the variables into URL parameters.
  • echo -e "\e[1;33m$url\n\e[1;32m$vars": Prints the URL and discovered parameters in colored output.

5. Additional Linux Commands for Cybersecurity:

  • nmap: Network exploration tool and security scanner.
    nmap -sV -p 1-65535 target.com
    
  • nikto: Web server scanner.
    nikto -h target.com
    
  • sqlmap: Automatic SQL injection tool.
    sqlmap -u "http://target.com/page?id=1" --dbs
    
  • metasploit: Penetration testing framework.
    msfconsole
    

6. Windows Commands for IT and Cybersecurity:

  • netstat: Displays network connections.
    netstat -an
    
  • ipconfig: Displays network configuration.
    ipconfig /all
    
  • tasklist: Displays running processes.
    tasklist
    
  • netsh: Configures network settings.
    netsh advfirewall set allprofiles state on
    

What Undercode Say:

Discovering hidden parameters in JavaScript files is a crucial step in identifying potential vulnerabilities in web applications. By using tools like assetfinder, gau, and curl, you can automate the process of finding these parameters and enhance your penetration testing capabilities. Always ensure you have proper authorization before performing any security testing on a target system.

Expected Output:

The output of the provided script will display URLs along with any hidden parameters found in JavaScript files. The parameters will be appended with `=xss` to simulate a potential XSS vulnerability. This output can then be used for further analysis and exploitation in a controlled and ethical manner.

Course URLs:

  1. Ethical Hacking Course
  2. Penetration Testing Course
  3. Advanced Cybersecurity Course

References:

Reported By: Zlatanh Find – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image