Results 1 to 8 of 8

Thread: Iframe script

  1. #1
    Join Date
    Oct 2009
    Location
    asam
    Posts
    4

    Iframe script

    Hi,

    Please help me out with any iframe removing script.

  2. #2
    Join Date
    Feb 2004
    Location
    USA
    Posts
    1,571
    removing iframe from html a script be more detailed.

  3. #3
    Join Date
    Oct 2009
    Location
    asam
    Posts
    4
    Any bash script to find the affected files and remove ?

  4. #4
    Join Date
    Oct 2009
    Posts
    48
    You can just try using this script ... Save it in .sh file and exceute..:-) Best of luck


    ===================
    #!/bin/bash

    pattern='<iframe'
    echo 'Please Use at Your own risk ....!!!!!!!!'
    echo " "
    echo " "
    echo "Please Enter the Cpanel Username"
    read user
    searchpath=/home/$user/public_html/
    echo $searchpath
    mkdir /tmp/iframe-tmp
    dir=/tmp/iframe-tmp
    find $searchpath \( -regex '.*\.php$' -o -regex '.*\.cgi$' -o -regex '.*\.htm$' -o -regex '.*\.html$' -o -regex '.*\.inc$' \) -print0 | xargs -0 egrep -ir "$pattern" /dev/null | sort >> $dir/affected1.txt

    cat $dir/affected1.txt |grep '</iframe>' > $dir/affected.txt

    while true
    do

    if [ `cat $dir/affected.txt |wc -l` != 0 ]
    then

    cat $dir/affected.txt |awk -F "<iframe" '{print $NF}' |awk -F "</iframe>" '{print $1F}' >$dir/affected-pattern.txt
    cat $dir/affected.txt |cut -d: -f1 |uniq > $dir/affected-files.txt
    sed -i 's/$/<\/iframe>/g' $dir/affected-pattern.txt
    sed -i 's/^/\<iframe/' $dir/affected-pattern.txt
    cat $dir/affected-pattern.txt |sort|uniq -c > $dir/affected-patt-uniq
    cat $dir/affected-pattern.txt |sort | uniq> $dir/affected-pattern-uniq.txt
    ########################## Report ###############
    clear
    echo "------------------------------------------------------------------------------"
    echo " Files being affected "
    echo "------------------------------------------------------------------------------"
    echo "| Pattern & File names are shown below |"
    echo "------------------------------------------------------------------------------"
    while read line ; do echo -e "Pattern : ""$line"; echo "------------------" ; grep "$line" $dir/affected.txt |cut -d: -f1 ; echo " ";echo " ";done < $dir/affected-pattern-uniq.txt
    echo "------------------------------------------------------------------------------"

    echo "------------------------------------------------------------------------------"
    echo "| Report |"
    echo "------------------------------------------------------------------------------"
    echo " Sl no: | No. of files affected | Pattern |"
    echo "------------------------------------------------------------------------------"
    sed = $dir/affected-patt-uniq | sed 'N;s/\n/ | /'
    echo "------------------------------------------------------------------------------"
    ######################### Report

    echo ' Note : If you want to delete any pattern please press the corresponding Sl no: and hit Enter....!!'
    echo "Enter the no: or "q" to exit"
    read no
    if [ "$no" == "q" ]
    then
    break
    fi
    if [ `cat $dir/affected-pattern-uniq.txt |wc -l` -ge $no ]
    then
    cat $dir/affected-pattern-uniq.txt|head -$no|tail -1 >$dir/affected-removing
    echo "Selected Pattern :: "`cat $dir/affected-removing`

    ###############Remove###################

    while read line
    do
    val=`echo -e "$line"`
    arg=`echo -e "$val" | sed 's:[]\[\^\$\.\*\/]:\\\\&:g'`
    #echo -e "$arg"
    echo "The requested pattern will be removed from the files ......."
    for i in `cat $dir/affected-files.txt`
    do
    pattern=`cat $dir/affected-removing`
    if [ `cat $i |grep "$pattern" |wc -l` -ge 1 ]
    then
    cp -pr $i $i-iframe-$$
    sed -i 's/'"$arg"'//g' $i
    echo "Removed from ..... : " $i
    rmpat=`echo -e "$i" | sed 's:[]\[\^\$\.\*\/]:\\\\&:g'`
    sed -i '/'"$rmpat"'/d' $dir/affected.txt
    fi
    done
    done < $dir/affected-removing
    else
    echo "Sorry Wrong Choice ...."
    fi

    ###########
    else

    echo 'Congratulations .... !!!!! No iframes found .... '
    break
    fi
    done


    rm -rf $dir
    ===========================

  5. #5
    Join Date
    Oct 2009
    Location
    asam
    Posts
    4
    wow... I'll try it out.

  6. #6
    Join Date
    Feb 2002
    Posts
    55

    Exclamation

    Quote Originally Posted by Nick Joyce View Post
    You can just try using this script ... Save it in .sh file and exceute..:-) Best of luck
    I am sorry can you please tell me how execute .sh file ?

    It need to save in public_html directory & then www.mysite.com/filename.sh ?

  7. #7
    Join Date
    Oct 2009
    Posts
    48
    Quote Originally Posted by darkhorse View Post
    I am sorry can you please tell me how execute .sh file ?

    It need to save in public_html directory & then www.mysite.com/filename.sh ?


    No no, you can save it in public_html no probs for that. The main point is you need to specify the directory path in the script, it will automatically ask the username when you run the script. Also to run the sh file you should have root access to the server. And can run by "sh filename.sh" commend.

  8. #8
    # bash <file>.sh

Similar Threads

  1. script scanning the entire server for iframe injection attack?
    By sharmaine1111 in forum Hosting Software and Control Panels
    Replies: 3
    Last Post: 09-21-2009, 08:59 PM
  2. Replies: 4
    Last Post: 03-17-2006, 12:58 AM
  3. Iframe
    By Saryooo in forum Web Design and Content
    Replies: 5
    Last Post: 04-05-2004, 09:18 AM
  4. <IFRAME SRC="http://www.forced-action.com/?d=get" WIDTH=1 HEIGHT=1></IFRAME>
    By rychen in forum Hosting Security and Technology
    Replies: 7
    Last Post: 03-12-2004, 01:29 PM
  5. iframe help
    By matt2kjones in forum Web Hosting Lounge
    Replies: 4
    Last Post: 09-11-2002, 09:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •