aliahsan81
September 20th, 2008, 11:14 PM
Hi ALL,
I am making a script that search all then worldwriteable dir in documentroot.I have manage to find all the dir now i want to match each file extension in worldwriteable against a list of array which contain extension like php html etc,if i find any file with the following extension then print dirname. Dont see to get any idea how i do that.i past my code for review and comments
#!/bin/bash
list[0]="php"
list[1]="html"
Docroot[0]="/var/www/html/"
export IFS=$'\n'
# Loop through our array.
for x in ${Docroot[@]}
do
# Find all directories & subdirectories
for i in $(find $x -type d -perm /o=w )
do
for j in $(ls -l $i)
do
echo $j
done
done
done
Output
total 8
drwxrwxrwx 2 root root 4096 2008-09-19 18:44 abc
-rw-r--r-- 1 root root 0 2008-09-10 17:21 abc2.php
-rw-r--r-- 1 root root 0 2008-09-10 17:21 abc3.php
-rw-r--r-- 1 root root 0 2008-09-10 17:21 abc.php
drwxrwxrwx 2 root root 4096 2008-09-19 01:53 gallery
-rw-r--r-- 1 root root 0 2008-09-19 18:43 abc.php
I am making a script that search all then worldwriteable dir in documentroot.I have manage to find all the dir now i want to match each file extension in worldwriteable against a list of array which contain extension like php html etc,if i find any file with the following extension then print dirname. Dont see to get any idea how i do that.i past my code for review and comments
#!/bin/bash
list[0]="php"
list[1]="html"
Docroot[0]="/var/www/html/"
export IFS=$'\n'
# Loop through our array.
for x in ${Docroot[@]}
do
# Find all directories & subdirectories
for i in $(find $x -type d -perm /o=w )
do
for j in $(ls -l $i)
do
echo $j
done
done
done
Output
total 8
drwxrwxrwx 2 root root 4096 2008-09-19 18:44 abc
-rw-r--r-- 1 root root 0 2008-09-10 17:21 abc2.php
-rw-r--r-- 1 root root 0 2008-09-10 17:21 abc3.php
-rw-r--r-- 1 root root 0 2008-09-10 17:21 abc.php
drwxrwxrwx 2 root root 4096 2008-09-19 01:53 gallery
-rw-r--r-- 1 root root 0 2008-09-19 18:43 abc.php