nsonaniya2010 / SubDomainizer

A tool to find subdomains and interesting things hidden inside, external Javascript files of page, folder, and Github.
MIT License
1.71k stars 233 forks source link

JS Scan #8

Closed jaikishantulswani closed 5 years ago

jaikishantulswani commented 5 years ago

Hello @nsonaniya2010 , Can you please enhance SubDomainizer by adding one more switch to scan already downloaded js files from a folder.

jaikishantulswani commented 5 years ago

Hello @nsonaniya2010 waiting for this enhancement.

nsonaniya2010 commented 5 years ago

Not yet. Will update it by next month.

nsonaniya2010 commented 5 years ago

Hi @jaikishantulswani , I have added a feature to scan files inside folder. just put root folder in which it contains files with -f argument and it will scan all the files recursively in each folder.

jaikishantulswani commented 5 years ago

@nsonaniya2010 Thank you :+1:

nsonaniya2010 commented 5 years ago

@jaikishantulswani Please check it. And let me know if there is any error or something you view.

jaikishantulswani commented 5 years ago

Hello @nsonaniya2010 , It is not fetching the api_key related words like if a js file is having API_KEY:"&api_key=hereIam:@abc123" then it returns nothing, please correct me If I am doing anything wrong.

nsonaniya2010 commented 5 years ago

This is due to the fact that & and = is not added in the list of capturing group of regular expression.

You can add characters like '& or =' etc. as per your requirement on line 233 of SubDomainizer.py file along with @ and # etc.

Let me know if it fixes the problem.

jaikishantulswani commented 5 years ago

:100: Thank you ! it works but why I am getting this in some cases:

Getting data from folder recursively... Traceback (most recent call last): File "SubDomainizer.py", line 419, in <module> folderDataList = getRecursiveFolderData(folderName) File "SubDomainizer.py", line 99, in getRecursiveFolderData folderDataList.append(file.read()) File "/usr/lib/python3.7/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

nsonaniya2010 commented 5 years ago

@jaikishantulswani, this is due to problem in decoding content. Some content is not properly escaped, lets say Ë is character, it should be in Unicode as it is not considered as string in python. What you can do is you can add try and exception for line 99 to ignore reading of that file only.

like this: Line : 99

try:
    folderDataList.append(file.read())
except UnicodeDecodeError:
    pass

It will help you in getting contents of other files, and ignoring files which do not have proper ASCII characters.

I will come up with some other solution on next update so that it won't throw exception or error.

Let me know if it solves your problem.

jaikishantulswani commented 5 years ago

@nsonaniya2010 Thank you, meanwhile it also return no results when a js file contain like:

password= "ABC@123", password: "AbC@321@", password: "abc", password= "ABC",

nsonaniya2010 commented 5 years ago

Hi @jaikishantulswani,

On line '433' of code: If have added a minimum threshold value to 3.5 ( shannon entropy) Your given string:

  1. ABC@123 have entropy : 2.807354922057604
  2. AbC@321@ have : 2.75 and other strings will have less than them. you can change 3.5 on line 433 to 2.5 to get those results. Although this will increase the false positives.
jaikishantulswani commented 5 years ago

OK, Thank you so much for giving your time :+1:

jaikishantulswani commented 5 years ago

Hello @nsonaniya2010 , one last thing as I am getting 'Indentation Error` after changing the code in line 99 like:

def getRecursiveFolderData(rootfolder): folderDataList = list() for filename in glob.iglob(rootfolder + '/', recursive=True): if os.path.isfile(filename): with open(filename, 'r') as file: try: folderDataList.append(file.read()) except UnicodeDecodeError: pass return folderDataList

Error

File "subtest.py", line 101 except UnicodeDecodeError: ^ IndentationError: unexpected unindent

nsonaniya2010 commented 5 years ago

Code needs to be intended in python.

jaikishantulswani commented 5 years ago

@nsonaniya2010 , Yes I did the same like the screenshot attached, but still getting this. Screenshot from 2019-03-17 18-36-17

nsonaniya2010 commented 5 years ago

That is an intendation error pls check properly.