Skip to content

Instantly share code, notes, and snippets.

@MohitDabas
Created June 8, 2021 11:37
Show Gist options
  • Save MohitDabas/be70c0a30a973588bbf4269f0b917ac2 to your computer and use it in GitHub Desktop.
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.
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