I am trying to send a project file via Gmail and i am having trouble sending the zip file with a .exe file in it. How can i change the zip file to fileName.zip.remove?
You can use the += operator:
string filename = "fileName.zip";
filename += ".remove";
The last line is equivalent to:
filename = filename + ".remove";
A common problem when sending e-mails is that antiviruses reject .exe files, even when they are included in zip files. You can hide the exe file in zip file if you encrypt this file. This involves giving a password to the zip file. You can write down this password in the e-mail text. The antivirus is not smart enough to use it.
I would suggest actually changing the name of the exe file itself and rezipping it and sending it. But to change the name of the file itself, you should be able to right-click on it, and rename should be an option. Just type in .remove, ignore the warning about file extensions if it shows up, and send it! :)
Related
I am working on a web app project to block all the file executable from file upload.
Example: user can upload, txt, png, image and video files and not any executable scripts like, Perl, Python, exe, PHP, .so, .sh files.
If it is a PHP file, then I strstr for "<?php" tag, If this tag is present, then it is PHP file. How can we find the same for other script/executable files?
Edit: Some time hackers will upload the malicious files using .png or .jpg extn, so what is the pattern to check inside the files?
Rather than making your own checks you make use of an existing library and you block everything that does not register as a desired format.
Most such libraries guess the content type and encoding of a file by looking for certain signatures or magic byte sequences at specific positions within the file.
Other libraries may be more specialised and will for example only identify image or video formats.
https://www.php.net/manual/en/intro.fileinfo.php
https://github.com/ahupp/python-magic
https://docs.python.org/3/library/imghdr.html
The file programme is a command line tool for identification of file types.
After the first pass where you identify and accept only the desired file formats you should then make all files that are not rejected go through an antivirus scanner.
Depending on you use cases you may decide to strip the original file name extension and/or even the complete file name that was provided during the upload and assign the mime-type that was detected rather than rely on user provided properties.
I'm looking to remotely download and detect a file from a website, like this
http://examplewebsite.com/100/download
When viewing in my browser, this automatically downloads as the appropriate file type, 100.pdf, but sometimes it can be a .xls or .doc file. etc.
Looking at libraries available, like file-type, it only works if you already have the extension
Is this possible?
If you have the url, you can split by '.' and select the last element of your list.
The file-type library you linked in your question actually checks the source of the file to guess. It doesn't use the file extension at all.
My dilemma is that there is pdf file named 'P01111-AMFLIBL.pdf' , I want to append '.NOSUFFIX' after .pdf so the result will be like 'P01111-AMFLIBL.pdf.NOSUFFIX'.
I am trying to add by this line of code :
fileName = fileName + ".pdf" + ".NOSUFFIX";
It's working, but the problem is that pdf file is not directly getting opened into my system
On Windows, the extension (i.e. suffix starting at last .) determines the file type (and associated program). If you append another suffix, this appended .NOSUFFIX will become the file extension, and the original .pdf will become just a part of the file name.
Does anyone know if it is possible to get the name of files inside a rar/zip without having to unrar/unzip the file.. and if yes, is there a way to block it or make difficult..
Thanks
The file names in a zip file are visible even if the data is encrypted. If you want to hide the names, the easy solution is to zip the zip file encrypted.
Later versions of PKZip do have an option to encrypt the file names as well with –cd=encrypt. (cd means central directory.)
The -l flag to unzip(1) does just that:
-l
list archive files (short format). The names, uncompressed file sizes and modification dates and times of the specified files are printed, along with totals for all files specified.
unrar(1) has the l option:
l
List archive content.
I think odt files are ziped files.
Why odt file can not be opened by zip but can be opened by open office?
And a zip file not complete can also be unziped??
Who is familiar with zip format?
ODT files may or may not be zipped. It could also be a plain basic XML file (see http://en.wikipedia.org/wiki/OpenDocument#Specifications).
Also, there are several versions of the ZIP file format that may or may not inter-operate well, so maybe it's just your ZIP utility not being able to read the particular format your ODT file uses.
Rename the file's extension to zip. In that case, it should open with the zip unarchiver (tested with 7-Zip, PowerArchiver, Total Commander).
The problem seems to lie with the archivers' extension sniffing: PowerArchiver (albeit an old, old version) had problems opening the file when the extension was odt, but worked fine with zip.
Of course, the file extension odt will probably be associated with OpenOffice, so double-clicking the file will start OpenOffice.
You can try with 7zip for .odt, If those are zip files, supposed to able to open.
a zip file not complete, you mean broken zip files?, its depends on how its damage. even you can open it, you will not get desired results.
Finally, i found the file is doc format, but saved as odt.
This file is searched by google.
odt files are open office document text files.