简体   繁体   中英

How to use ExtFilterDefine for png files in perl as one liner?

Because of md5 hash scanning tools like wpscan , I want to prevent the script kiddies to detect as much information as possible about my wordpress site. With to following perl snippet, I m trying to add some extra characters to all requested png files. But it does not work and I don't know why. Does somebody can help me out? My goal is not to change it right inside the files - just for requested output on screen.

ExtFilterDefine pngfilter mode=output intype=image/png cmd="/usr/bin/perl -pe 'END { unless (-fq{/tmp/md5_filter.tmp}) { print qq(\/*) . time() . qq(\*/) } }'"

I use the same snippet logic for css and js files. Here it works as expected.

It does work.

$ perl -pe 'END { print qq(/*) . time() . qq(*/) }' derpkin.png >derpkin_.png

$ diff <( hexdump -C derpkin.png ) <( hexdump -C derpkin_.png )
3023,3024c3023,3025
< 0000bce0  00 00 00 00 49 45 4e 44  ae 42 60 82              |....IEND.B`.|
< 0000bcec
---
> 0000bce0  00 00 00 00 49 45 4e 44  ae 42 60 82 2f 2a 31 36  |....IEND.B`./*16|
> 0000bcf0  35 36 33 35 30 37 37 36  2a 2f                    |56350776*/|
> 0000bcfa

At least, it works in the sense that it does exactly what you wanted it to do. But does it makes sense to add arbitrary text to the end of a PNG? I'm not familiar enough withe PNG file format to answer that.

Caveat: It will not work on Windows because of CRLF ⇔ LF translation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM