“Bad” file extensions that should be avoided on a

2019-04-29 06:49发布

Im re-writing a file hosting site, and I want to have the ability to host every single file type (instead of just having a whilelist of allowed extensions).

Im running nginx and linux. Site is built in php. I'd disable th upload of .php files.... but other than that.... is there anything else I should watch out for?

3条回答
小情绪 Triste *
2楼-- · 2019-04-29 07:05

The best way here is a combination of:

  1. Disable execution in your upload dir.
  2. Rename all files that you suspect: PHP, SH, BIN, etc or store all files compressed in ZIP/TAR files.
  3. Use an antivirus (Dr. Web, ClamAV, etc) on the server and scan files regularly.
查看更多
该账号已被封号
3楼-- · 2019-04-29 07:15

Here's a list of the extensions we tend to block on our php file upload system.

1st you would be best to save the files in a none accessible folder that way no one can run any files uploaded and second do a force download of every file, that way it can't be opened either.

Extension list : bat exe cmd sh php pl cgi 386 dll com torrent js app jar pif vb vbscript wsf asp cer csr jsp drv sys ade adp bas chm cpl crt csh fxp hlp hta inf ins isp jse htaccess htpasswd ksh lnk mdb mde mdt mdw msc msi msp mst ops pcd prg reg scr sct shb shs url vbe vbs wsc wsf wsh

Also here is a Javascript regular expression of the above:

/(\.|\/)(bat|exe|cmd|sh|php([0-9])?|pl|cgi|386|dll|com|torrent|js|app|jar|pif|vb|vbscript|wsf|asp|cer|csr|jsp|drv|sys|ade|adp|bas|chm|cpl|crt|csh|fxp|hlp|hta|inf|ins|isp|jse|htaccess|htpasswd|ksh|lnk|mdb|mde|mdt|mdw|msc|msi|msp|mst|ops|pcd|prg|reg|scr|sct|shb|shs|url|vbe|vbs|wsc|wsf|wsh)$/i
查看更多
狗以群分
4楼-- · 2019-04-29 07:24

A cleaner maneer to solve the problem would be to setup a subhost (something like files.somewhere.com) or a directory, and disable execution via a .htacess (Users will be able to upload php script, but the server will send it instead of executing it).

查看更多
登录 后发表回答