duanni5726 2013-10-10 22:10
浏览 371

使用PHP连接的base64_decode的正则表达式(正则表达式)匹配

So i've been trying to build a regex for the past couple hours and i'm starting to go crazy in thinking if this is even possible or worth wild.

I have a script that scans PHP files checking MD5 sum for known malicious files, and certain strings. Most recently i've come across files where instead of using base64_decode in the PHP file, they are using variables and concatenating it so the scanner doesn't pick it up.

As an example here's the latest one I found:

$a='bas'.'e6'.'4_d'.'ecode';eval($a

So because the scanner searches for base64_decode this file wasn't picked up as they are using PHP to concatenate base64_decode in a variable, and then call the variable.

Forgive me because i've just started with regex, but is it even possible to search for something like this using regex? I mean, I understand and was able to get a regex that would match that exact one, but what about if they used this instead:

$a='b'.'ase'.'64_d'.'ecode';eval($a

It wouldn't be picked up because the regex was looking for ' then b then a, etc etc.

I've already added

(eval)\(\$[a-z]

To send me an email as a notice to check the file, i'll have to let it run for a couple days and see how many false positives show up, but my main concern is with the base64_decode

If someone could please shed some light on this for me and maybe point me in the right direction, I would greatly appreciate it.

Thanks!!

  • 写回答

1条回答

  • duanli0453 2013-10-10 22:15
    关注

    You can use this regexp:

    b\W*a\W*s\W*e\W*6\W4\W*_\W*d\W*e\W*c\W*o\W*d\W*e
    

    It searches for base64_decode with any non-alphanumeric characters interspersed.

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)