Lets Be A Dork and Read Js Files
Lets Be A Dork and Read Js Files
js files
Helping those new to hunting: What is dorking and learning what you’re looking for with .js files
What exactly is dorking…?
- Using public search engines such as Google, GitHub, Yahoo, Bing, Shodan, to find public data about
your target. They do the spidering for you, just ask them the right questions!
site:example.com inurl:& - Finding parameters, scrape & try these on every endpoint you
discover. (Remember past streams, devs re-use code. Old code etc)
Site:example.com ext:php (jsp, asp, aspx, xml, txt) - Discovering content on their sites,
maybe sometimes old files that were indexed a long time ago. Helpful if to get an insight
into what type of payloads/bugs you should focus on. (For example: See lots of php? Probably
going to find XSS quite easily)
Get creative!!! :)
.JS files: What exactly are in them?
- .js files contain code which help a website function. For example when clicking on a link, they may have
onclick=”runCode()” which executes javascript based on your click. This can be used for tracking
purposes, setting certain cookies, checking parameters. .js files play a big part in how a website
functions.
- The process when looking for .js files is as simple as:
Visit your target, right click -> view source. CTRL + F and search for “.js”
Browse each .js files and search for certain keywords: api, internal, url:, var =, //, https://, company.com,
location.search, parameter
(This is manual. You can automate this with Burp, but that’s for another time. Lots of info out there already, this for people
new:D)
New parameters/variables. References to more /api/ calls. For example can you make these api calls
without having the correct permissions? Think about functionality that lets you upgrade. Go into the .js
files & find this code and try the API calls. Look for dev comments, new endpoints, new subdomains. Api
keys.
Remember: .js files contain the code needed for a website to function. Even though you need to pay
more to upgrade to access more features, this check will typically be done server-side. JS code is
client-side and will be in the .js files regardless of your account status.
- I found references to internal staging subdomains if a certain cookie was set. Setting the cookie and
visiting this endpoint revealed new /API/ calls being made which lead to an info leak.
- Google dorking found zero results for inurl:&. From viewing .js files I discovered “r_url” which acted as a
redirect parameter on the login flow. The result? Token leak. Turns out the code was old and should not
of been used anymore.
Any questions? :)