Removed traces of the old prototype vmlinux stuff.
committer: mfx <mfx> 976719035 +0000
This commit is contained in:
@@ -156,37 +156,6 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
// bvmlinux/i386 (Linux kernel image)
|
|
||||||
// vmlinux/i386 (Linux kernel image)
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
class PackBvmlinuxI386 : public Packer
|
|
||||||
{
|
|
||||||
typedef Packer super;
|
|
||||||
public:
|
|
||||||
PackBvmlinuxI386(InputFile *f);
|
|
||||||
virtual int getVersion() const { return 11; }
|
|
||||||
virtual int getFormat() const { return UPX_F_BVMLINUX_i386; }
|
|
||||||
virtual const char *getName() const { return "bvmlinux/386"; }
|
|
||||||
virtual int getCompressionMethod() const;
|
|
||||||
virtual const int *getFilters() const { return NULL; }
|
|
||||||
|
|
||||||
virtual void pack(OutputFile *fo);
|
|
||||||
virtual void unpack(OutputFile *fo);
|
|
||||||
|
|
||||||
virtual bool canPack();
|
|
||||||
virtual int canUnpack();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// virtual const upx_byte *getLoader() const;
|
|
||||||
// virtual int getLoaderSize() const;
|
|
||||||
|
|
||||||
unsigned elf_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// solaris/sparc
|
// solaris/sparc
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|||||||
@@ -1,155 +0,0 @@
|
|||||||
/* p_vmlinux.cpp --
|
|
||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
|
||||||
|
|
||||||
Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer
|
|
||||||
Copyright (C) 1996-2000 Laszlo Molnar
|
|
||||||
All Rights Reserved.
|
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
|
||||||
and/or modify them under the terms of the GNU General Public License as
|
|
||||||
published by the Free Software Foundation; either version 2 of
|
|
||||||
the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; see the file COPYING.
|
|
||||||
If not, write to the Free Software Foundation, Inc.,
|
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
|
||||||
markus.oberhumer@jk.uni-linz.ac.at ml1050@cdata.tvnet.hu
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "conf.h"
|
|
||||||
|
|
||||||
#include "file.h"
|
|
||||||
#include "packer.h"
|
|
||||||
#include "p_unix.h"
|
|
||||||
#include "p_elf.h"
|
|
||||||
#include <zlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
PackBvmlinuxI386::PackBvmlinuxI386(InputFile *f) :
|
|
||||||
super(f), elf_offset(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int PackBvmlinuxI386::getCompressionMethod() const
|
|
||||||
{
|
|
||||||
return M_NRV2D_LE32;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool PackBvmlinuxI386::canPack()
|
|
||||||
{
|
|
||||||
Elf_LE32_Ehdr ehdr;
|
|
||||||
Elf_LE32_Phdr text;
|
|
||||||
Elf_LE32_Phdr data;
|
|
||||||
unsigned char *buf = ehdr.e_ident;
|
|
||||||
|
|
||||||
fi->seek(elf_offset, SEEK_SET);
|
|
||||||
fi->readx(&ehdr, sizeof(ehdr));
|
|
||||||
fi->readx(&text, sizeof(text));
|
|
||||||
fi->readx(&data, sizeof(data));
|
|
||||||
|
|
||||||
// check the ELF header
|
|
||||||
if (memcmp(buf, "\x7f\x45\x4c\x46\x01\x01\x01", 7)) // ELF 32-bit LSB
|
|
||||||
return false;
|
|
||||||
if (!memcmp(buf+8, "FreeBSD", 7)) // branded
|
|
||||||
return false;
|
|
||||||
if (ehdr.e_type != 2) // executable
|
|
||||||
return false;
|
|
||||||
if (ehdr.e_machine != 3 && ehdr.e_machine != 6) // Intel 80[34]86
|
|
||||||
return false;
|
|
||||||
if (ehdr.e_version != 1) // version
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// now check for bvmlinux
|
|
||||||
if (ehdr.e_phoff != 52 || ehdr.e_ehsize != 52 || ehdr.e_phentsize != 32)
|
|
||||||
return false;
|
|
||||||
if (ehdr.e_entry != 0x100000 || ehdr.e_phnum != 2)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// check for bvmlinux - text segment
|
|
||||||
if (text.p_type != 1 || text.p_offset != 0x1000)
|
|
||||||
return false;
|
|
||||||
if (text.p_vaddr != 0x100000 || text.p_paddr != 0x100000)
|
|
||||||
return false;
|
|
||||||
if (text.p_flags != 5)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// check for bvmlinux - data segment
|
|
||||||
if (data.p_type != 1)
|
|
||||||
return false;
|
|
||||||
if (data.p_filesz < 200000)
|
|
||||||
return false;
|
|
||||||
if (data.p_flags != 6)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// check gzip data
|
|
||||||
unsigned char magic[2];
|
|
||||||
LE32 uncompressed_size;
|
|
||||||
off_t gzip_offset = elf_offset + data.p_offset + 472;
|
|
||||||
fi->seek(gzip_offset, SEEK_SET);
|
|
||||||
fi->readx(magic, 2);
|
|
||||||
if (memcmp(magic, "\037\213", 2))
|
|
||||||
return false;
|
|
||||||
fi->seek(data.p_filesz - 2 - 4 - 472, SEEK_CUR);
|
|
||||||
fi->readx(&uncompressed_size, 4);
|
|
||||||
if (uncompressed_size < data.p_filesz || uncompressed_size > 4*1024*1024)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// uncompress kernel with zlib
|
|
||||||
fi->seek(gzip_offset, SEEK_SET);
|
|
||||||
gzFile f = gzdopen(fi->getFd(), "r");
|
|
||||||
if (f == NULL)
|
|
||||||
return false;
|
|
||||||
ibuf.alloc(uncompressed_size);
|
|
||||||
unsigned ilen = gzread(f, ibuf, uncompressed_size);
|
|
||||||
bool ok = ilen == uncompressed_size;
|
|
||||||
gzclose(f);
|
|
||||||
|
|
||||||
printf("decompressed kernel: %d -> %d\n", (int)data.p_filesz, ilen);
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
void PackBvmlinuxI386::pack(OutputFile *fo)
|
|
||||||
{
|
|
||||||
fo = fo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
//
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
int PackBvmlinuxI386::canUnpack()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PackBvmlinuxI386::unpack(OutputFile *fo)
|
|
||||||
{
|
|
||||||
fo = fo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
vi:ts=4:et
|
|
||||||
*/
|
|
||||||
|
|
||||||
+2
-1
@@ -76,11 +76,12 @@ typedef unsigned upx_uint32;
|
|||||||
#define UPX_F_TMT_ADAM 8
|
#define UPX_F_TMT_ADAM 8
|
||||||
#define UPX_F_W32_PE 9
|
#define UPX_F_W32_PE 9
|
||||||
#define UPX_F_LINUX_i386 10
|
#define UPX_F_LINUX_i386 10
|
||||||
#define UPX_F_BVMLINUX_i386 11
|
/* UNUSED */
|
||||||
#define UPX_F_LINUX_ELF_i386 12
|
#define UPX_F_LINUX_ELF_i386 12
|
||||||
#define UPX_F_LINUX_SEP_i386 13
|
#define UPX_F_LINUX_SEP_i386 13
|
||||||
#define UPX_F_LINUX_SH_i386 14
|
#define UPX_F_LINUX_SH_i386 14
|
||||||
#define UPX_F_VMLINUZ_i386 15
|
#define UPX_F_VMLINUZ_i386 15
|
||||||
|
#define UPX_F_BVMLINUX_i386 16
|
||||||
#define UPX_F_ATARI_TOS 129
|
#define UPX_F_ATARI_TOS 129
|
||||||
#define UPX_F_SOLARIS_SPARC 130
|
#define UPX_F_SOLARIS_SPARC 130
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user