[File] [E] How to detect go mac executables with magic.h?

Christos Zoulas christos at zoulas.com
Wed May 26 01:17:55 UTC 2021


fIle-5.11 was released sometime in 2011... I think that if you use something more recent it will work a lot better.

christos

> On May 25, 2021, at 6:25 PM, Matthew Czarnek <matthew.czarnek at verizonmedia.com> wrote:
> 
> Hi Christos,
> 
> 
> 
> I'm using version 5.11-37.el7 of file, the latest version.
> 
> For the mac executable on Linux:
> 
> 
> "file magic8" correctly shows:
> 
> magic8: Mach-O 64-bit executable
> 
> 
> But "file -i magic8", which I believe uses the magic.h header shows:
> 
> magic8: application/octet-stream; charset=binary
> 
> Thanks,
> Matt
> 
> 
> 
> 
> On Tue, May 25, 2021 at 6:21 PM Christos Zoulas <christos at zoulas.com <mailto:christos at zoulas.com>> wrote:
> 
> I don't know, it can be a number of things. What does the file(1) program say about it? What version of file(1) do you have installed on linux?
> 
> 
> 
> christos
> 
> 
> 
>> On May 25, 2021, at 5:52 PM, Matthew Czarnek <matthew.czarnek at verizonmedia.com <mailto:matthew.czarnek at verizonmedia.com>> wrote:
>> 
>> 
>> Hello,
>> 
>> 
>> 
>> I've been using this go library to detect file types to block our users from uploading exes:
>> https://github.com/rakyll/magicmime <https://github.com/rakyll/magicmime>
>> 
>> 
>> On a mac it is capable of using the magic.h header to detect the file type of a go program compiled for mac as mime type "application/x-mach-binary", on Linux however, it is not able to detect those executables, only executables compiled for Linux. I'm guessing this is a matter of not having this file type registered in the magic database/file containing all the magic numbers?
>> 
>> This is the beginning of the file:
>> 
>> Ïúíþ^G^@^@^A^C^@^@^@^B^@^@^@^Q^@^@^@p^M^@^@<85>^@^@^@^@^@^@^@^Y^@^@^@H^@^@^@__PAGEZERO
>> 
>> 
>> Is it possible to add this/fix this for my own version or the next release?
>> 
>> 
>> 
>> -Matt
>> 
>> 
>> 
>> --
>> File mailing list
>> File at astron.com <mailto:File at astron.com>
>> https://mailman.astron.com/mailman/listinfo/file <https://mailman.astron.com/mailman/listinfo/file>
>> <sanitizer.log>
>> 
> 
> 
> 
> 
> 
> <sanitizer.log>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.astron.com/pipermail/file/attachments/20210525/0d9617b7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <https://mailman.astron.com/pipermail/file/attachments/20210525/0d9617b7/attachment.asc>


More information about the File mailing list