Use different Mime-Type in FTP - ftp

When uploading a file to an FTP server it always defines the mime type as the file extension that the name is. Is there any way to change the mime type that the file is being uploaded as?
EX: If I am uploading Hi.php to the URL /Hi.bz2 it doesn't run the .php script at all and just reads it as plain text

FTP has no idea of a MIME-Type.
But the HTTP server, which serves the file later needs some way to determine the type of the file and the usual way for static files is to look at the files extension. It it the same way most system determine the type of the file when they need to know the responsable application.

Related

Mime types for custom file type in Jmeter

I am trying to upload a custom file type with our own file extension through Jmeter file upload. My custom filetype, with a custom extension, is actually a zip archive containing various xml and other files.
I am not sure about the mime type that i should use for custom file. However i tried with application/zip and application/sfp(extension of my file). Getting a Response code: 415 in Jmeter
Record the action using jmeter recorder. It will create the upload request for you and will set the MIME type. Use that MIME type to check if it works.

How to decode and inspect an HTTP payload when it is a zip

So I'm pretty new at all this. I am trying to reverse engineer a web application.
When I submit a form, it sends a POST with a request payload that looks something similar to this:
encoding=UTF8&zip=1&size=136240&html=DwQgIg_a_whole_lot_more_gibberish_not_worth_posting
Anyways, from inspecting the captured traffic from Chrome developer tools, I noticed it is encoded and sent as a zipped up html?
How would I go about reversing this to see what the content is actually being sent to the server?
What you want to do is this:
1) Get the name of the zip file
2) Get the path of the zip file (likely the root directory or the current path the form is at)
3) Generate the URL (http://site_name.com/path/to/folder/zip_file.zip)
4) Download it using a too such as wget (typing the URL into the browser may work too)
I used this technique to download all the files that get downloaded to the OTA updates on iOS devices (used burp suit to intercept the zip file name where the server was on my computer which my iDevice was connected to).
Please note: the name of the zip file you have given does not end in .zip. this may mean it doesn't have a extension; you may have to add .zip to the file manually; or it may have another ending such as .tar, .tar.gz etc.

How to create (on Windows) a file with a extension different that mime type ?

I have a problem.
In my PHP code, I want to check if the file uploaded have its extension similar of its mime type :
for image.png:
if this extension (.png) is associated to the png mime type( image/png )
upload is authorised.
if this extension (.png) is not associated to the png mime type, (ex : text/html)
upload is not authorised.
I know we can change the type mime of the file on HTTP Request (on the file's header) . But, for my tests I need to create a file with a mime type different from its extension.
Do you know I want create this file? ("image.png" with "application/octet-stream" mime type).
On windows, when I change the file's extension, this change also the mime type...
I found a page for create a file with "Appcmd.exe" on Windows, but this software don't exist on my computer...

How to edit remote file with ruby?

I have a remote file on my server, It's writable. I know how to read and edit local files, but I have a problem with remote files. For example: www.mysite.com/myfile.txt
There is no standard way of using HTTP to edit a file, so you will have to:
Write a PHP script that accepts HTTP requests with data in them and writes the data to the file. You will probably want some form of security and you will probably need to mark the file as writable by all (chmod a+wfilename). You will probably want it to be a POST request so the file length is not limited by the max length of a URI.
Make a little HTML form to test the script.
Write a ruby script that sends that HTTP request. The built-in Net::HTTP library will probably work for you.

Detecting file type

What is the best way to find the file mime type of remote file in ruby on rails application (eg. I have a file located in s3 and want to check its file type, I don't think checking extension of file is a good idea).
To be specific, I want to find whether the given media is video or audio.
There's a library called ruby-filemagic that can check the content of the file and return the mime type. However, it required to access and read the file and it can be an issue if you need to fetch the content of the file from a remote source.
Please note that in the specific Amazon S3 case, you can also store the mime type of the file to Amazon S£ as object metadata when you upload the file itself. I strongly recommend you to do this, so that you can easily retrieve the metadata and search for the given attribute, instead of guessing it from the file.

Resources