Created
June 8, 2021 11:37
-
-
Save MohitDabas/be70c0a30a973588bbf4269f0b917ac2 to your computer and use it in GitHub Desktop.
The following small code of python grabs all the inputs from the html page or templates in a project and gives you a clear picture to attack and fuzz.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import listdir | |
from os.path import isfile, join | |
import re | |
from os import walk | |
from bs4 import BeautifulSoup | |
def fileGetter(): | |
fileNames = [] | |
mypath='<folder_name>' | |
for (dirPath, dirNames, fileName) in walk(mypath): | |
for fn in fileName: | |
fileNames.append(dirPath+'/'+fn) | |
return fileNames | |
def grabInputTag(fileNames): | |
inputTagFiles=[] | |
for filePath in fileNames: | |
with open(filePath) as f: | |
try: | |
data=f.read() | |
match=re.findall(r'<input',data) | |
if len(match)> 0: | |
inputTagFiles.append(filePath) | |
else : | |
pass | |
except Exception as e: | |
print (e) | |
return inputTagFiles | |
def getAllInputAttributes(inputTagFileNames): | |
inputTags=[] | |
for itf in inputTagFileNames: | |
with open(itf) as f: | |
data=f.read() | |
soup = BeautifulSoup(data) | |
try: | |
form = soup.find('form') | |
for nameAttr in form.findAll('input'): | |
inputTags.append(nameAttr.get('name')) | |
for nameAttr in form.findAll('textarea'): | |
inputTags.append(nameAttr.get('name')) | |
except Exception as e: | |
#print (e) | |
pass | |
return inputTags | |
fileNames=fileGetter() | |
inputTagFileNames=grabInputTag(fileNames) | |
inputTags=list(set(getAllInputAttributes(inputTagFileNames))) | |
print (inputTags) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment