lug-bg: C/C++ + binary executable file
(/++) binary executable? file(1). `man file` , binary executable magic number . ... A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers). http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
Re: lug-bg: C/C++ + binary executable file
, 2004-09-30 12:33, Aleksander Valchev : (/++) binary executable? file(1). `man file` , binary executable magic number . ... , magic (man 5 magic), /usr/share/misc/magic, , file . source file , . ELF executable, , googleELF executable format. signature.asc Description: This is a digitally signed message part
Re: lug-bg: C/C++ + binary executable file
On Thu, Sep 30, 2004 at 12:53:24PM +0300, Vasil Kolev wrote: , 2004-09-30 12:33, Aleksander Valchev : (/++) binary executable? file(1). `man file` , binary executable magic number . ... , magic (man 5 magic), /usr/share/misc/magic,, file . source file, . ELF executable, , googleELF executable format. , ELF0x7F, 'E', 'L', 'F'. magic- file(1), file(1), magic, ELF, , :) , -- Peter Pentchev [EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] PGP key:http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 What would this sentence be like if pi were 3? pgp1xQU0ZFx7z.pgp Description: PGP signature
Re: lug-bg: C/C++ + binary executable file
12:33:23pm +0300 30 2004, Aleksander Valchev : (/++) binary executable? file(1). `man file` , binary executable magic number . ... , ELF[1]. , [2]. :) [1] http://www.caldera.com/developers/gabi [2] http://www.caldera.com/developers/gabi/latest/ch4.eheader.html#elfid , -- Linux is for those who hate Windows. FreeBSD is for those who love UNIX. #include stdio.h #include unistd.h #include fcntl.h #include elf.h int check_elf(int fd) { Elf_Ehdr ehdr; int ret; ret = read(fd, ehdr, sizeof(Elf_Ehdr)); if(ret == -1 || ret sizeof(Elf_Ehdr)) return -1; if(ehdr.e_ident[EI_MAG0] != ELFMAG0 || ehdr.e_ident[EI_MAG1] != ELFMAG1 || ehdr.e_ident[EI_MAG2] != ELFMAG2 || ehdr.e_ident[EI_MAG3] != ELFMAG3) return -1; return 0; } int main(int argc, char **argv) { char *files[] = { /bin/ls, /etc/motd }; int fd; fd = open(files[0], O_RDONLY); if(fd == -1) return 1; if(check_elf(fd) == -1) printf(%s: not an ELF executable\n, files[0]); else printf(%s: an ELF executable\n, files[0]); close(fd); fd = open(files[1], O_RDONLY); if(fd == -1) return 1; if(check_elf(fd) == -1) printf(%s: not an ELF executable\n, files[1]); else printf(%s: an ELF executable\n, files[1]); close(fd); return 0; }