user3044500 user3044500 - 1 month ago 10
Javascript Question

Is it possible to retrieve a Javascript file from a server?

In Python, I can retrieve Javascript from an HTML document using the following code.

import urllib2, jsbeautifier
from bs4 import BeautifulSoup

f = urllib2.urlopen("http://www.google.com.ph/")

soup = BeautifulSoup(f, "lxml")
script_raw = str(soup.script)

script_pretty = jsbeautifier.beautify(script_raw)
print(script_pretty)


But how about if the script comes from a Javascript file on the server, like:

<script src="some/directory/example.js" type="text/javascript">


Is it possible to retrieve "example.js"? If so, how?

Context: I'm examining the Javascript of phishing web pages.

Answer
<script src="some/directory/example.js" type="text/javascript">

the code above will get some/directory/example.js from server you just make folders and file structure follow the pattern above