2014-10-13 13:19:07 +02:00
|
|
|
---
|
|
|
|
magic/Magdir/elf | 2
|
|
|
|
magic/Magdir/linux | 36 +++++----
|
|
|
|
magic/Magdir/msad | 5 +
|
2016-11-30 13:51:53 +01:00
|
|
|
magic/Magdir/msdos | 6 -
|
2021-10-19 11:56:46 +02:00
|
|
|
magic/Makefile.am | 63 +++++++++-------
|
2014-10-13 13:19:07 +02:00
|
|
|
magic/Makefile.in | 60 +++++++++------
|
|
|
|
src/Makefile.am | 2
|
|
|
|
src/dcore.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2021-10-19 11:56:46 +02:00
|
|
|
8 files changed, 313 insertions(+), 68 deletions(-)
|
2014-10-13 13:19:07 +02:00
|
|
|
|
2023-01-09 15:41:18 +01:00
|
|
|
--- magic/Magdir/elf
|
2023-07-28 11:56:34 +02:00
|
|
|
+++ magic/Magdir/elf 2023-07-28 09:42:01.845813939 +0000
|
|
|
|
@@ -154,7 +154,7 @@
|
2013-01-22 17:19:33 +01:00
|
|
|
>18 leshort 47 Renesas H8/300H,
|
|
|
|
>18 leshort 48 Renesas H8S,
|
|
|
|
>18 leshort 49 Renesas H8/500,
|
|
|
|
->18 leshort 50 IA-64,
|
|
|
|
+>18 leshort 50 IA-64 (Intel 64 bit architecture),
|
|
|
|
>18 leshort 51 Stanford MIPS-X,
|
|
|
|
>18 leshort 52 Motorola Coldfire,
|
|
|
|
>18 leshort 53 Motorola M68HC12,
|
2023-01-09 15:41:18 +01:00
|
|
|
--- magic/Magdir/linux
|
2023-07-28 11:56:34 +02:00
|
|
|
+++ magic/Magdir/linux 2023-07-28 09:42:01.845813939 +0000
|
2020-07-01 09:55:09 +02:00
|
|
|
@@ -140,27 +140,31 @@
|
2011-06-14 19:53:47 +02:00
|
|
|
# All known start with: b8 c0 07 8e d8 b8 00 90 8e c0 b9 00 01 29 f6 29
|
|
|
|
# Linux kernel boot images (i386 arch) (Wolfram Kleff)
|
2019-05-27 11:37:06 +02:00
|
|
|
# URL: https://www.kernel.org/doc/Documentation/x86/boot.txt
|
2011-06-14 19:53:47 +02:00
|
|
|
-514 string HdrS Linux kernel
|
2013-01-22 17:19:33 +01:00
|
|
|
+514 string HdrS Linux
|
2013-09-30 16:29:55 +02:00
|
|
|
!:strength + 55
|
2019-05-27 11:37:06 +02:00
|
|
|
# often no extension like in linux, vmlinuz, bzimage or memdisk but sometimes
|
|
|
|
# Acronis Recovery kernel64.dat and Plop Boot Manager plpbtrom.bin
|
|
|
|
# DamnSmallLinux 1.5 damnsmll.lnx
|
|
|
|
!:ext /dat/bin/lnx
|
2011-06-14 19:53:47 +02:00
|
|
|
->510 leshort 0xAA55 x86 boot executable
|
|
|
|
->>518 leshort >0x1ff
|
|
|
|
->>>529 byte 0 zImage,
|
|
|
|
->>>529 byte 1 bzImage,
|
2013-12-02 12:33:34 +01:00
|
|
|
->>>526 lelong >0
|
|
|
|
->>>>(526.s+0x200) string >\0 version %s,
|
2011-06-14 19:53:47 +02:00
|
|
|
->>498 leshort 1 RO-rootFS,
|
|
|
|
->>498 leshort 0 RW-rootFS,
|
2021-10-19 11:56:46 +02:00
|
|
|
->>508 leshort >0 root_dev %#X,
|
|
|
|
->>502 leshort >0 swap_dev %#X,
|
2011-06-14 19:53:47 +02:00
|
|
|
->>504 leshort >0 RAMdisksize %u KB,
|
|
|
|
->>506 leshort 0xFFFF Normal VGA
|
|
|
|
->>506 leshort 0xFFFE Extended VGA
|
|
|
|
->>506 leshort 0xFFFD Prompt for Videomode
|
|
|
|
->>506 leshort >0 Video mode %d
|
|
|
|
+>510 leshort 0xAA55 \b/x86 Kernel
|
|
|
|
+>510 leshort <0xAA55 Kernel
|
|
|
|
+>510 leshort >0xAA55 Kernel
|
|
|
|
+>518 leshort 0x0105 \b, Setup Version 0x105, zImage
|
2014-06-25 11:07:53 +02:00
|
|
|
+>518 leshort >0x0105 \b, Setup Version %#x
|
2013-12-02 12:33:34 +01:00
|
|
|
+>518 leshort >0x1ff
|
2011-06-14 19:53:47 +02:00
|
|
|
+>>529 byte 0 \b, zImage
|
|
|
|
+>>529 byte 1 \b, bzImage
|
2013-12-02 12:33:34 +01:00
|
|
|
+>>526 lelong >0
|
|
|
|
+>>>(526.s+0x200) string >\0 \b, Version %s
|
2011-06-14 19:53:47 +02:00
|
|
|
+>>498 leshort 1 \b, RO-rootFS
|
|
|
|
+>>498 leshort 0 \b, RW-rootFS
|
2021-10-19 11:56:46 +02:00
|
|
|
+>>508 leshort >0 \b, root_dev %#X
|
|
|
|
+>>502 leshort >0 \b, swap_dev %#X
|
2011-06-14 19:53:47 +02:00
|
|
|
+>>504 leshort >0 \b, RAMdisksize %u KB
|
|
|
|
+>>506 leshort 0xFFFF \b, Normal VGA
|
|
|
|
+>>506 leshort 0xFFFE \b, Extended VGA
|
|
|
|
+>>506 leshort 0xFFFD \b, Prompt for Videomode
|
|
|
|
+>>506 leshort >0 \b, Video mode %d
|
|
|
|
# This also matches new kernels, which were caught above by "HdrS".
|
|
|
|
0 belong 0xb8c0078e Linux kernel
|
|
|
|
>0x1e3 string Loading version 1.3.79 or older
|
2023-01-09 15:41:18 +01:00
|
|
|
--- magic/Magdir/msad
|
2023-07-28 11:56:34 +02:00
|
|
|
+++ magic/Magdir/msad 2023-07-28 09:42:01.845813939 +0000
|
2011-06-14 19:53:47 +02:00
|
|
|
@@ -0,0 +1,5 @@
|
|
|
|
+#------------------------------------------------------------------------------
|
|
|
|
+# msad: file(1) magic for msad
|
|
|
|
+# Microsoft visual C
|
|
|
|
+# This must precede the heuristic for raw G3 data
|
|
|
|
+4 string Standard\ Jet\ DB Microsoft Access Database
|
2023-01-09 15:41:18 +01:00
|
|
|
--- magic/Magdir/msdos
|
2023-07-28 11:56:34 +02:00
|
|
|
+++ magic/Magdir/msdos 2023-07-28 09:42:01.845813939 +0000
|
|
|
|
@@ -298,9 +298,9 @@
|
2019-12-17 10:59:56 +01:00
|
|
|
>>(0x3c.l+22) leshort&0x0200 >0 (stripped to external PDB)
|
|
|
|
>>(0x3c.l+22) leshort&0x1000 >0 system file
|
|
|
|
>>(0x3c.l+24) leshort 0x010b
|
|
|
|
->>>(0x3c.l+232) lelong >0 Mono/.Net assembly
|
|
|
|
+>>>(0x3c.l+232) lelong >0 \b, Mono/.Net assembly
|
|
|
|
>>(0x3c.l+24) leshort 0x020b
|
|
|
|
->>>(0x3c.l+248) lelong >0 Mono/.Net assembly
|
|
|
|
+>>>(0x3c.l+248) lelong >0 \b, Mono/.Net assembly
|
2011-06-14 19:53:47 +02:00
|
|
|
|
|
|
|
# hooray, there's a DOS extender using the PE format, with a valid PE
|
|
|
|
# executable inside (which just prints a message and exits if run in win)
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -1026,7 +1026,7 @@
|
2022-09-13 22:12:04 +02:00
|
|
|
>1 leshort <-259
|
2016-11-30 13:51:53 +01:00
|
|
|
# that offset must be accessible
|
2022-09-13 22:12:04 +02:00
|
|
|
# add 10000h to jump at end of 64 KiB segment, add 1 for jump instruction and 2 for 16-bit offset
|
2016-11-30 13:51:53 +01:00
|
|
|
->>(1,s+65539) byte x
|
|
|
|
+>>(1.s+65539) byte x
|
2022-09-13 22:12:04 +02:00
|
|
|
# after jump next instruction for DEBUGGING!
|
|
|
|
#>>>&-1 ubelong x \b, NEXT instruction %#8.8x
|
2016-11-30 13:51:53 +01:00
|
|
|
>>>0 use msdos-com
|
2023-01-09 15:41:18 +01:00
|
|
|
--- magic/Makefile.am
|
2023-07-28 11:56:34 +02:00
|
|
|
+++ magic/Makefile.am 2023-07-28 09:42:01.849813866 +0000
|
2010-02-05 17:16:36 +01:00
|
|
|
@@ -5,7 +5,7 @@ MAGIC_FRAGMENT_BASE = Magdir
|
|
|
|
MAGIC_DIR = $(top_srcdir)/magic
|
|
|
|
MAGIC_FRAGMENT_DIR = $(MAGIC_DIR)/$(MAGIC_FRAGMENT_BASE)
|
2008-04-14 19:32:36 +02:00
|
|
|
|
|
|
|
-pkgdata_DATA = magic.mgc
|
|
|
|
+pkgdata_DATA = magic.mgc magic
|
|
|
|
|
2021-10-19 11:56:46 +02:00
|
|
|
MAGIC_FRAGMENTS = \
|
2010-02-05 17:16:36 +01:00
|
|
|
$(MAGIC_DIR)/Header \
|
2021-04-06 09:26:22 +02:00
|
|
|
@@ -24,7 +24,6 @@ $(MAGIC_FRAGMENT_DIR)/animation \
|
2013-01-22 17:19:33 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/aout \
|
2017-05-24 13:14:26 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/apache \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/apl \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/apple \
|
2016-11-24 11:45:15 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/application \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/applix \
|
2016-11-24 11:45:15 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/apt \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -106,7 +105,6 @@ $(MAGIC_FRAGMENT_DIR)/erlang \
|
2019-02-21 08:19:34 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/espressif \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/esri \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/fcs \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/filesystems \
|
2016-04-18 15:32:24 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/finger \
|
2023-01-09 15:41:18 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/firmware \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/flash \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -153,6 +151,8 @@ $(MAGIC_FRAGMENT_DIR)/isz \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/java \
|
2013-01-22 17:19:33 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/javascript \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/jpeg \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/linux \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/filesystems \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/karma \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/kde \
|
2013-01-22 17:19:33 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/keepass \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -163,7 +163,6 @@ $(MAGIC_FRAGMENT_DIR)/lammps \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/lecter \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/lex \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/lif \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/linux \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/lisp \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/llvm \
|
2021-04-06 09:26:22 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/locoscript \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -171,7 +170,6 @@ $(MAGIC_FRAGMENT_DIR)/lua \
|
2019-05-27 11:37:06 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/luks \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/m4 \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/mach \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/macintosh \
|
2019-05-27 11:37:06 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/macos \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/magic \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/mail.news \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -195,11 +193,11 @@ $(MAGIC_FRAGMENT_DIR)/misctools \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/mkid \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/mlssa \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/mmdf \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/modem \
|
2019-12-17 10:59:56 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/modulefile \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/motorola \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/mozilla \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/msdos \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/modem \
|
2011-06-14 19:53:47 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/msooxml \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/msvc \
|
2019-05-27 11:37:06 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/msx \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -263,6 +261,8 @@ $(MAGIC_FRAGMENT_DIR)/qt \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/revision \
|
2022-09-13 22:12:04 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/ringdove \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/riff \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/apple \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/macintosh \
|
2018-06-12 17:26:41 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/rpi \
|
2008-04-14 19:32:36 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/rpm \
|
2019-05-27 11:37:06 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/rpmsg \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -355,9 +355,21 @@ EXTRA_DIST = \
|
2021-10-19 11:56:46 +02:00
|
|
|
$(MAGIC_DIR)/scripts/create_filemagic_flac \
|
|
|
|
$(MAGIC_FRAGMENTS)
|
2008-04-14 19:32:36 +02:00
|
|
|
|
2021-10-19 11:56:46 +02:00
|
|
|
-
|
|
|
|
+RAW = magic
|
2008-04-14 19:32:36 +02:00
|
|
|
MAGIC = magic.mgc
|
2010-02-05 17:16:36 +01:00
|
|
|
-CLEANFILES = ${MAGIC} $(MAGIC_FRAGMENT_DIR)/Localstuff
|
2018-10-22 10:10:34 +02:00
|
|
|
+CLEANFILES = ${MAGIC} $(MAGIC_FRAGMENT_DIR)/Localstuff ${RAW}
|
2008-04-14 19:32:36 +02:00
|
|
|
+
|
2021-10-19 11:56:46 +02:00
|
|
|
+${RAW}: $(MAGIC_DIR)/Header $(MAGIC_DIR)/Localstuff $(MAGIC_FRAGMENTS)
|
2008-04-14 19:32:36 +02:00
|
|
|
+ cat /dev/null > $@
|
2021-10-19 11:56:46 +02:00
|
|
|
+ for frag in $(MAGIC_FRAGMENTS); do \
|
2010-02-05 17:16:36 +01:00
|
|
|
+ if test -f $(srcdir)/$$frag; then \
|
2021-10-19 11:56:46 +02:00
|
|
|
+ f=$(srcdir)/$$frag; \
|
2010-02-05 17:16:36 +01:00
|
|
|
+ else \
|
2021-10-19 11:56:46 +02:00
|
|
|
+ f=$$frag; \
|
2010-02-05 17:16:36 +01:00
|
|
|
+ fi; \
|
|
|
|
+ cat $$f; \
|
2008-04-14 19:32:36 +02:00
|
|
|
+ done >> $@
|
2021-10-19 11:56:46 +02:00
|
|
|
+
|
2008-04-14 19:32:36 +02:00
|
|
|
|
|
|
|
# FIXME: Build file natively as well so that it can be used to compile
|
2011-08-23 16:56:34 +02:00
|
|
|
# the target's magic file; for now we bail if the local version does not match
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -369,19 +381,22 @@ FILE_COMPILE = $(top_builddir)/src/file$
|
2009-05-06 18:38:39 +02:00
|
|
|
FILE_COMPILE_DEP = $(FILE_COMPILE)
|
2008-04-14 19:32:36 +02:00
|
|
|
endif
|
|
|
|
|
2021-10-19 11:56:46 +02:00
|
|
|
-${MAGIC}: $(MAGIC_FRAGMENTS) $(FILE_COMPILE_DEP)
|
2011-06-14 19:53:47 +02:00
|
|
|
- @rm -fr magic
|
2021-10-19 11:56:46 +02:00
|
|
|
- @mkdir magic && cp -p $(MAGIC_FRAGMENTS) magic
|
2011-08-23 16:56:34 +02:00
|
|
|
- @(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \
|
|
|
|
- echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \
|
|
|
|
- else \
|
2016-04-18 15:32:24 +02:00
|
|
|
- v=$$(${FILE_COMPILE} --version | sed -e s/file-// -e q); \
|
2011-08-23 16:56:34 +02:00
|
|
|
- if [ "$$v" != "${PACKAGE_VERSION}" ]; then \
|
|
|
|
- echo "Cannot use the installed version of file ($$v) to"; \
|
|
|
|
- echo "cross-compile file ${PACKAGE_VERSION}"; \
|
|
|
|
- echo "Please install file ${PACKAGE_VERSION} locally first"; \
|
|
|
|
- exit 1; \
|
|
|
|
- fi; \
|
|
|
|
- fi)
|
2010-02-05 17:16:36 +01:00
|
|
|
- $(FILE_COMPILE) -C -m magic
|
|
|
|
- @rm -fr magic
|
2021-10-19 11:56:46 +02:00
|
|
|
+${MAGIC}: $(MAGIC_FRAGMENTS) $(FILE_COMPILE_DEP) $(RAW)
|
2008-04-14 19:32:36 +02:00
|
|
|
+ $(FILE_COMPILE) -C -m $(RAW)
|
2011-08-23 16:56:34 +02:00
|
|
|
+
|
2021-10-19 11:56:46 +02:00
|
|
|
+#${MAGIC}: $(MAGIC_FRAGMENTS) $(FILE_COMPILE_DEP)
|
2011-08-23 16:56:34 +02:00
|
|
|
+# @rm -fr magic
|
2021-10-19 11:56:46 +02:00
|
|
|
+# @mkdir magic && cp -p $(MAGIC_FRAGMENTS) magic
|
2011-08-23 16:56:34 +02:00
|
|
|
+# @(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \
|
|
|
|
+# echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \
|
|
|
|
+# else \
|
2016-04-18 15:32:24 +02:00
|
|
|
+# v=$$(${FILE_COMPILE} --version | sed -e s/file-// -e q); \
|
2011-08-23 16:56:34 +02:00
|
|
|
+# if [ "$$v" != "${PACKAGE_VERSION}" ]; then \
|
|
|
|
+# echo "Cannot use the installed version of file ($$v) to"; \
|
|
|
|
+# echo "cross-compile file ${PACKAGE_VERSION}"; \
|
|
|
|
+# echo "Please install file ${PACKAGE_VERSION} locally first"; \
|
|
|
|
+# exit 1; \
|
|
|
|
+# fi; \
|
|
|
|
+# fi)
|
|
|
|
+# $(FILE_COMPILE) -C -m magic
|
|
|
|
+# @rm -fr magic
|
2023-01-09 15:41:18 +01:00
|
|
|
--- magic/Makefile.in
|
2023-07-28 11:56:34 +02:00
|
|
|
+++ magic/Makefile.in 2023-07-28 09:42:01.849813866 +0000
|
|
|
|
@@ -283,7 +283,7 @@ top_srcdir = @top_srcdir@
|
2012-01-16 15:23:30 +01:00
|
|
|
MAGIC_FRAGMENT_BASE = Magdir
|
|
|
|
MAGIC_DIR = $(top_srcdir)/magic
|
|
|
|
MAGIC_FRAGMENT_DIR = $(MAGIC_DIR)/$(MAGIC_FRAGMENT_BASE)
|
|
|
|
-pkgdata_DATA = magic.mgc
|
|
|
|
+pkgdata_DATA = magic.mgc magic
|
2021-10-19 11:56:46 +02:00
|
|
|
MAGIC_FRAGMENTS = \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_DIR)/Header \
|
|
|
|
$(MAGIC_DIR)/Localstuff \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -301,7 +301,6 @@ $(MAGIC_FRAGMENT_DIR)/animation \
|
2013-02-22 11:15:52 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/aout \
|
2017-05-24 13:14:26 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/apache \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/apl \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/apple \
|
2016-11-24 11:45:15 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/application \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/applix \
|
2016-11-24 11:45:15 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/apt \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -383,7 +382,6 @@ $(MAGIC_FRAGMENT_DIR)/erlang \
|
2019-02-21 08:19:34 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/espressif \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/esri \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/fcs \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/filesystems \
|
2016-04-18 15:32:24 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/finger \
|
2023-01-09 15:41:18 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/firmware \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/flash \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -430,6 +428,8 @@ $(MAGIC_FRAGMENT_DIR)/isz \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/java \
|
2013-01-22 17:19:33 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/javascript \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/jpeg \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/linux \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/filesystems \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/karma \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/kde \
|
2013-01-22 17:19:33 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/keepass \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -440,7 +440,6 @@ $(MAGIC_FRAGMENT_DIR)/lammps \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/lecter \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/lex \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/lif \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/linux \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/lisp \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/llvm \
|
2021-04-06 09:26:22 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/locoscript \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -448,7 +447,6 @@ $(MAGIC_FRAGMENT_DIR)/lua \
|
2019-05-27 11:37:06 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/luks \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/m4 \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/mach \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/macintosh \
|
2019-05-27 11:37:06 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/macos \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/magic \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/mail.news \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -472,11 +470,11 @@ $(MAGIC_FRAGMENT_DIR)/misctools \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/mkid \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/mlssa \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/mmdf \
|
|
|
|
-$(MAGIC_FRAGMENT_DIR)/modem \
|
2019-12-17 10:59:56 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/modulefile \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/motorola \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/mozilla \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/msdos \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/modem \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/msooxml \
|
|
|
|
$(MAGIC_FRAGMENT_DIR)/msvc \
|
2019-05-27 11:37:06 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/msx \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -540,6 +538,8 @@ $(MAGIC_FRAGMENT_DIR)/qt \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/revision \
|
2022-09-13 22:12:04 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/ringdove \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/riff \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/apple \
|
|
|
|
+$(MAGIC_FRAGMENT_DIR)/macintosh \
|
2018-06-12 17:26:41 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/rpi \
|
2012-01-16 15:23:30 +01:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/rpm \
|
2019-05-27 11:37:06 +02:00
|
|
|
$(MAGIC_FRAGMENT_DIR)/rpmsg \
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -632,10 +632,22 @@ EXTRA_DIST = \
|
2021-10-19 11:56:46 +02:00
|
|
|
$(MAGIC_DIR)/scripts/create_filemagic_flac \
|
|
|
|
$(MAGIC_FRAGMENTS)
|
2012-01-16 15:23:30 +01:00
|
|
|
|
|
|
|
+RAW = magic
|
|
|
|
MAGIC = magic.mgc
|
|
|
|
-CLEANFILES = ${MAGIC} $(MAGIC_FRAGMENT_DIR)/Localstuff
|
2018-10-22 10:10:34 +02:00
|
|
|
+CLEANFILES = ${MAGIC} $(MAGIC_FRAGMENT_DIR)/Localstuff ${RAW}
|
2013-09-30 16:29:55 +02:00
|
|
|
@IS_CROSS_COMPILE_FALSE@FILE_COMPILE = $(top_builddir)/src/file${EXEEXT}
|
2012-01-16 15:23:30 +01:00
|
|
|
|
2021-10-19 11:56:46 +02:00
|
|
|
+${RAW}: $(MAGIC_DIR)/Header $(MAGIC_DIR)/Localstuff $(MAGIC_FRAGMENTS)
|
2012-01-16 15:23:30 +01:00
|
|
|
+ cat /dev/null > $@
|
2021-10-19 11:56:46 +02:00
|
|
|
+ for frag in $(MAGIC_FRAGMENTS); do \
|
2012-01-16 15:23:30 +01:00
|
|
|
+ if test -f $(srcdir)/$$frag; then \
|
2021-10-19 11:56:46 +02:00
|
|
|
+ f=$(srcdir)/$$frag; \
|
2012-01-16 15:23:30 +01:00
|
|
|
+ else \
|
2021-10-19 11:56:46 +02:00
|
|
|
+ f=$$frag; \
|
2012-01-16 15:23:30 +01:00
|
|
|
+ fi; \
|
|
|
|
+ cat $$f; \
|
|
|
|
+ done >> $@
|
|
|
|
+
|
|
|
|
# FIXME: Build file natively as well so that it can be used to compile
|
|
|
|
# the target's magic file; for now we bail if the local version does not match
|
2013-09-30 16:29:55 +02:00
|
|
|
@IS_CROSS_COMPILE_TRUE@FILE_COMPILE = file${EXEEXT}
|
2023-07-28 11:56:34 +02:00
|
|
|
@@ -859,23 +871,25 @@ uninstall-am: uninstall-pkgdataDATA
|
2018-10-15 13:15:31 +02:00
|
|
|
|
|
|
|
.PRECIOUS: Makefile
|
2012-01-16 15:23:30 +01:00
|
|
|
|
2021-10-19 11:56:46 +02:00
|
|
|
+${MAGIC}: $(MAGIC_FRAGMENTS) $(FILE_COMPILE_DEP) $(RAW)
|
2014-02-18 11:22:22 +01:00
|
|
|
+ $(FILE_COMPILE) -C -m $(RAW)
|
2012-01-16 15:23:30 +01:00
|
|
|
|
2021-10-19 11:56:46 +02:00
|
|
|
-${MAGIC}: $(MAGIC_FRAGMENTS) $(FILE_COMPILE_DEP)
|
2012-01-16 15:23:30 +01:00
|
|
|
- @rm -fr magic
|
2021-10-19 11:56:46 +02:00
|
|
|
- @mkdir magic && cp -p $(MAGIC_FRAGMENTS) magic
|
2012-01-16 15:23:30 +01:00
|
|
|
- @(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \
|
|
|
|
- echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \
|
|
|
|
- else \
|
2016-04-18 15:32:24 +02:00
|
|
|
- v=$$(${FILE_COMPILE} --version | sed -e s/file-// -e q); \
|
2012-01-16 15:23:30 +01:00
|
|
|
- if [ "$$v" != "${PACKAGE_VERSION}" ]; then \
|
|
|
|
- echo "Cannot use the installed version of file ($$v) to"; \
|
|
|
|
- echo "cross-compile file ${PACKAGE_VERSION}"; \
|
|
|
|
- echo "Please install file ${PACKAGE_VERSION} locally first"; \
|
|
|
|
- exit 1; \
|
|
|
|
- fi; \
|
|
|
|
- fi)
|
|
|
|
- $(FILE_COMPILE) -C -m magic
|
|
|
|
- @rm -fr magic
|
2021-10-19 11:56:46 +02:00
|
|
|
+#${MAGIC}: $(MAGIC_FRAGMENTS) $(FILE_COMPILE_DEP)
|
2012-01-16 15:23:30 +01:00
|
|
|
+# @rm -fr magic
|
2021-10-19 11:56:46 +02:00
|
|
|
+# @mkdir magic && cp -p $(MAGIC_FRAGMENTS) magic
|
2012-01-16 15:23:30 +01:00
|
|
|
+# @(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \
|
|
|
|
+# echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \
|
|
|
|
+# else \
|
2016-04-18 15:32:24 +02:00
|
|
|
+# v=$$(${FILE_COMPILE} --version | sed -e s/file-// -e q); \
|
2012-01-16 15:23:30 +01:00
|
|
|
+# if [ "$$v" != "${PACKAGE_VERSION}" ]; then \
|
|
|
|
+# echo "Cannot use the installed version of file ($$v) to"; \
|
|
|
|
+# echo "cross-compile file ${PACKAGE_VERSION}"; \
|
|
|
|
+# echo "Please install file ${PACKAGE_VERSION} locally first"; \
|
|
|
|
+# exit 1; \
|
|
|
|
+# fi; \
|
|
|
|
+# fi)
|
|
|
|
+# $(FILE_COMPILE) -C -m magic
|
|
|
|
+# @rm -fr magic
|
|
|
|
|
|
|
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
|
|
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
2023-01-09 15:41:18 +01:00
|
|
|
--- src/Makefile.am
|
2023-07-28 11:56:34 +02:00
|
|
|
+++ src/Makefile.am 2023-07-28 09:42:01.849813866 +0000
|
2006-12-19 00:15:53 +01:00
|
|
|
@@ -1,4 +1,4 @@
|
2008-04-14 19:32:36 +02:00
|
|
|
-MAGIC = $(pkgdatadir)/magic
|
|
|
|
+MAGIC = $(sysconfdir)/magic:$(pkgdatadir)/magic
|
2006-12-19 00:15:53 +01:00
|
|
|
lib_LTLIBRARIES = libmagic.la
|
2016-08-16 14:02:27 +02:00
|
|
|
nodist_include_HEADERS = magic.h
|
2009-05-06 18:38:39 +02:00
|
|
|
|
2023-01-09 15:41:18 +01:00
|
|
|
--- src/dcore.c
|
2023-07-28 11:56:34 +02:00
|
|
|
+++ src/dcore.c 2023-07-28 09:42:01.865813574 +0000
|
2006-12-19 00:15:53 +01:00
|
|
|
@@ -0,0 +1,207 @@
|
|
|
|
+/*
|
|
|
|
+ * Show goo about ELF core files
|
|
|
|
+ * Jeremy Fitzhardinge <jeremy@zip.com.au> 1996
|
|
|
|
+ */
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <fcntl.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <string.h>
|
|
|
|
+#if defined __GLIBC__ && __GLIBC__ >= 2
|
|
|
|
+#include <elf.h>
|
|
|
|
+#include <sys/procfs.h>
|
|
|
|
+# ifndef NT_PRFPREG
|
|
|
|
+# define NT_PRFPREG 2
|
|
|
|
+# endif
|
|
|
|
+# ifndef NT_TASKSTRUCT
|
|
|
|
+# define NT_TASKSTRUCT 4
|
|
|
|
+# endif
|
|
|
|
+#else
|
|
|
|
+#include <linux/elf.h>
|
|
|
|
+#include <linux/elfcore.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+static void fperror(const char *str)
|
|
|
|
+{
|
|
|
|
+ perror(str);
|
|
|
|
+ exit(1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static size_t myread(int fd, void *buf, size_t sz)
|
|
|
|
+{
|
|
|
|
+ size_t ret;
|
|
|
|
+
|
|
|
|
+ if ((ret = read(fd, buf, sz)) != sz)
|
|
|
|
+ fperror("read failed");
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void print_prstatus(const prstatus_t *pr)
|
|
|
|
+{
|
|
|
|
+ unsigned i;
|
|
|
|
+ static const char *regs[] = { "ebx", "ecx", "edx", "esi", "edi", "ebp",
|
|
|
|
+ "eax", "ds", "es", "fs", "gs",
|
|
|
|
+ "orig_eax", "eip", "cs",
|
|
|
|
+ "efl", "uesp", "ss"};
|
|
|
|
+
|
|
|
|
+ printf(" pid=%d ppid=%d pgrp=%d sid=%d\n",
|
|
|
|
+ pr->pr_pid, pr->pr_ppid, pr->pr_pgrp, pr->pr_sid);
|
|
|
|
+ for(i = 0; i < NGREG; i++)
|
|
|
|
+ {
|
|
|
|
+ unsigned long val = pr->pr_reg[i];
|
|
|
|
+ printf(" %-2u %-5s=%08lx %lu\n", i, regs[i], val, val);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void print_prpsinfo(const prpsinfo_t *ps)
|
|
|
|
+{
|
|
|
|
+ printf(" uid=%d gid=%d\n", ps->pr_uid, ps->pr_gid);
|
|
|
|
+ printf(" comm=%s\n", ps->pr_fname);
|
|
|
|
+ printf(" psargs=%s\n", ps->pr_psargs);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
|
|
|
|
+
|
|
|
|
+static void do_note(int fd, Elf32_Phdr *phdr)
|
|
|
|
+{
|
|
|
|
+ off_t here = lseek(fd, 0, SEEK_CUR);
|
|
|
|
+ int size = phdr->p_filesz;
|
|
|
|
+ char *raw = alloca(size), *end;
|
|
|
|
+ end = raw+size;
|
|
|
|
+
|
|
|
|
+ lseek(fd, phdr->p_offset, SEEK_SET);
|
|
|
|
+ myread(fd, raw, size);
|
|
|
|
+
|
|
|
|
+ while(raw < end)
|
|
|
|
+ {
|
|
|
|
+ Elf32_Nhdr *note = (Elf32_Nhdr *)raw;
|
|
|
|
+ const char *str;
|
|
|
|
+ const char *name, *desc;
|
|
|
|
+
|
|
|
|
+ raw += sizeof(*note);
|
|
|
|
+ name = raw;
|
|
|
|
+ raw += roundup(note->n_namesz, sizeof(long));
|
|
|
|
+ desc = raw;
|
|
|
|
+ raw += roundup(note->n_descsz, sizeof(long));
|
|
|
|
+
|
|
|
|
+ printf(" name=%.*s", (int)note->n_namesz, name);
|
|
|
|
+
|
|
|
|
+ if(strncmp(name, "CORE", note->n_namesz) != 0)
|
|
|
|
+ {
|
|
|
|
+ printf("\n");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ switch(note->n_type)
|
|
|
|
+ {
|
|
|
|
+#define X(x) case x: str = #x; break;
|
|
|
|
+ X(NT_PRSTATUS);
|
|
|
|
+ X(NT_PRFPREG);
|
|
|
|
+ X(NT_PRPSINFO);
|
|
|
|
+ X(NT_TASKSTRUCT);
|
|
|
|
+#undef X
|
|
|
|
+ default:
|
|
|
|
+ str = "???";
|
|
|
|
+ }
|
|
|
|
+ printf(" n_type=%s n_descsz=%ld\n",
|
|
|
|
+ str, note->n_descsz);
|
|
|
|
+ switch(note->n_type)
|
|
|
|
+ {
|
|
|
|
+ case NT_PRSTATUS:
|
|
|
|
+ print_prstatus((prstatus_t *)desc);
|
|
|
|
+ break;
|
|
|
|
+ case NT_PRPSINFO:
|
|
|
|
+ print_prpsinfo((prpsinfo_t *)desc);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ lseek(fd, here, SEEK_SET);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int main(int argc, char *argv[])
|
|
|
|
+{
|
|
|
|
+ int fd;
|
|
|
|
+ Elf32_Ehdr elf;
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ if (argc != 2)
|
|
|
|
+ {
|
|
|
|
+ fprintf(stderr, "Usage: %s corefile\n", argv[0]);
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ((fd = open(argv[1], O_RDONLY)) == -1)
|
|
|
|
+ fperror("open of core");
|
|
|
|
+
|
|
|
|
+ myread(fd, &elf, sizeof(elf));
|
|
|
|
+
|
|
|
|
+ if (memcmp(ELFMAG, elf.e_ident, SELFMAG) != 0)
|
|
|
|
+ printf("bad magic\n");
|
|
|
|
+
|
|
|
|
+ if (elf.e_ident[EI_CLASS] != ELFCLASS32)
|
|
|
|
+ printf("wrong class\n");
|
|
|
|
+
|
|
|
|
+ if (elf.e_ident[EI_DATA] != ELFDATA2LSB)
|
|
|
|
+ printf("wrong endianess\n");
|
|
|
|
+
|
|
|
|
+ if (elf.e_ident[EI_VERSION] != EV_CURRENT)
|
|
|
|
+ printf("wrong version\n");
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ const char *str;
|
|
|
|
+ switch(elf.e_type)
|
|
|
|
+ {
|
|
|
|
+#define C(x) case ET_##x: str = #x; break;
|
|
|
|
+ C(NONE);
|
|
|
|
+ C(REL);
|
|
|
|
+ C(EXEC);
|
|
|
|
+ C(DYN);
|
|
|
|
+ C(CORE);
|
|
|
|
+#undef C
|
|
|
|
+ default: str = "???"; break;
|
|
|
|
+ }
|
|
|
|
+ printf("elf file type ET_%s\n", str);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (elf.e_machine != EM_386 && elf.e_machine != EM_486)
|
|
|
|
+ printf("not i386 or i486\n");
|
|
|
|
+
|
|
|
|
+ if (elf.e_ehsize != sizeof(elf))
|
|
|
|
+ printf("wrong header size\n");
|
|
|
|
+
|
|
|
|
+ if (elf.e_phentsize != sizeof(Elf32_Phdr))
|
|
|
|
+ printf("wrong phdr size\n");
|
|
|
|
+
|
|
|
|
+ if (lseek(fd, elf.e_phoff, SEEK_SET) != (off_t)elf.e_phoff)
|
|
|
|
+ fperror("lseek to phdr failed\n");
|
|
|
|
+
|
|
|
|
+ for(i = 0; i < elf.e_phnum; i++)
|
|
|
|
+ {
|
|
|
|
+ Elf32_Phdr phdr;
|
|
|
|
+ const char *str;
|
|
|
|
+
|
|
|
|
+ myread(fd, &phdr, sizeof(phdr));
|
|
|
|
+ switch(phdr.p_type)
|
|
|
|
+ {
|
|
|
|
+#define C(x) case PT_##x: str = #x; break;
|
|
|
|
+ C(NULL);
|
|
|
|
+ C(LOAD);
|
|
|
|
+ C(DYNAMIC);
|
|
|
|
+ C(INTERP);
|
|
|
|
+ C(NOTE);
|
|
|
|
+ C(SHLIB);
|
|
|
|
+ C(PHDR);
|
|
|
|
+#undef C
|
|
|
|
+ default:
|
|
|
|
+ str = "???"; break;
|
|
|
|
+ }
|
|
|
|
+ printf("type PT_%s off=%ld vaddr=%lx filesz=%ld flags=%lx\n",
|
|
|
|
+ str, phdr.p_offset, phdr.p_vaddr, phdr.p_filesz,
|
|
|
|
+ (unsigned long)phdr.p_flags);
|
|
|
|
+ if (phdr.p_type == PT_NOTE)
|
|
|
|
+ do_note(fd, &phdr);
|
|
|
|
+ }
|
|
|
|
+ exit(0);
|
|
|
|
+}
|
|
|
|
+
|