LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
LinkBack Search this Thread
Old 08-20-2010, 10:07 AM   #1
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 63
question about different checksum of binaries


Dears,

We have 4 servers running CentOS 5.5.

I realize some binaries between systems have different checksums even they have the same package.

In fact, copying the binaries from each system to another machine running a live distro (based on a DVD) and calculating the checksums, they are different. (this is just to be sure theses calculations are done in a machine not compromised)

the facts: (below, I will show only two files from distinct packages from 2 systems - but in fact, this happens with several files, from several packages, in at least 4 systems)

server A and server B both have the same output: (there is no output from the last command)
Code:
# rpm -qf --queryformat "name: %{NAME} version:%{VERSION} rel:%{RELEASE} arch: %{ARCH}\n" /usr/bin/sha1sum /usr/bin/elinks
name: coreutils version:5.97 rel:23.el5_4.1 arch: x86_64
name: elinks version:0.11.1 rel:6.el5_4.1 arch: x86_64
# ls -l /usr/bin/sha1sum /usr/bin/elinks
-rwxr-xr-x 1 root root 1089264 Oct 26  2009 /usr/bin/elinks
-rwxr-xr-x 1 root root   32472 Oct 27  2009 /usr/bin/sha1sum
# rpm -qV coreutils elinks
#
server A, sha1sum
Code:
a394074b596385600efab838e34586b9a7f7ae6a  /usr/bin/elinks
49d26e198a5660608f101c68630b4acc7674bc41  /usr/bin/sha1sum
server B, sha1sum
Code:
af456681b4493034ed159c84cf120ea82dca9bda  /usr/bin/elinks
6ecd6554e088b60c9015ccf81835347909af8bc2  /usr/bin/sha1sum
As additional information, both systems have chkrootkit and rkhunter (with a check followed by a --propupd after each system update) and none inform any problem.

I don't have a exhaustive list of different checksums in all 4 systems. But some files I randomly check are:
Code:
usr/bin/elinks
usr/bin/find
usr/sbin/lsof
usr/bin/passwd
usr/bin/killall
usr/bin/pstree
usr/bin/pstree.x11
bin/rpm
usr/bin/rpm2cpio
usr/bin/rpmdb
usr/bin/rpmquery
usr/bin/rpmsign
usr/bin/rpmverify
bin/mountpoint
sbin/init
sbin/sulogin
bin/mount
usr/sbin/vipw
usr/bin/wget
usr/bin/sha1sum
usr/bin/md5sum
Also, the machines I got the data above were off (unplugged from outlet) since Feb 15 2010 (they are spares) with the last system update in Feb 10 2010, and all 4 have SELinux enable and in enforcing mode, not directly attached to internet, not serving anything outside our restricted LAN, with firewall enabled and allowing only DNS, DHCP, SAMBA, SSH.

so, the verify rpm returns ok, the files have the same size, the packages are the same but even so, they have different checksums (also using md5). How this is possible ? What is the explanation ?
 
Old 08-20-2010, 12:17 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,550
Blog Entries: 51

Rep: Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611
Prelinking?
 
Old 08-20-2010, 01:12 PM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Original Poster
Rep: Reputation: 63
uhmm....I'm not sure how prelink will change the checksum...the results are the same after a prelink on /usr/bin/elinks /usr/bin/sha1sum

on system A:
Code:
# sha1sum /usr/bin/elinks /usr/bin/sha1sum
a394074b596385600efab838e34586b9a7f7ae6a  /usr/bin/elinks
49d26e198a5660608f101c68630b4acc7674bc41  /usr/bin/sha1sum
# prelink /usr/bin/elinks /usr/bin/sha1sum
# sha1sum /usr/bin/elinks /usr/bin/sha1sum
a394074b596385600efab838e34586b9a7f7ae6a  /usr/bin/elinks
49d26e198a5660608f101c68630b4acc7674bc41  /usr/bin/sha1sum
#
on system B:
Code:
# sha1sum /usr/bin/elinks /usr/bin/sha1sum
af456681b4493034ed159c84cf120ea82dca9bda  /usr/bin/elinks
6ecd6554e088b60c9015ccf81835347909af8bc2  /usr/bin/sha1sum
# prelink /usr/bin/elinks /usr/bin/sha1sum
# sha1sum /usr/bin/elinks /usr/bin/sha1sum
af456681b4493034ed159c84cf120ea82dca9bda  /usr/bin/elinks
6ecd6554e088b60c9015ccf81835347909af8bc2  /usr/bin/sha1sum
#
they still are different....
 
Old 08-20-2010, 01:40 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,550
Blog Entries: 51

Rep: Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611
Quote:
Originally Posted by marozsas View Post
I'm not sure how prelink will change the checksum
On both systems running 'rpm -q --dump elinks | grep `prelink -y --md5 /usr/bin/elinks | awk '{print $1}'`;' might explain it?
 
Old 08-20-2010, 01:47 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, FreeBSD
Posts: 3,925
Blog Entries: 5

Rep: Reputation: Disabled
@marozsas:

IIRC, prelink does change the cryptographic hash. (At very least it changes mtime.) On your test above, you may be comparing already "prelinked" binaries.

For this reason, prelink is disabled (/etc/sysconfig/prelink) on my systems that are running a HIDS.
 
Old 08-20-2010, 02:57 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,550
Blog Entries: 51

Rep: Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611Reputation: 2611
Quote:
Originally Posted by anomie View Post
For this reason, prelink is disabled (/etc/sysconfig/prelink) on my systems that are running a HIDS.
Ah ;-p Samhain supports prelink and so does Aide (please read whole thread for details).
 
1 members found this post helpful.
Old 08-20-2010, 03:02 PM   #7
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, FreeBSD
Posts: 3,925
Blog Entries: 5

Rep: Reputation: Disabled
Hmm, thanks for the patch. Can't promise that I'll apply it, but it is good to be aware of.
 
Old 08-20-2010, 04:03 PM   #8
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Original Poster
Rep: Reputation: 63
hi anomie, hi unspawn,

@unspawn: so, what I understood is you want to check if the md5sum returned by rpm is the same ms5 returned by prelink, right ?

here a simple script I used on both systems to return the info you asked:
Code:
#!/bin/bash
echo prelink -y --md5 /usr/bin/elinks
prelink -y --md5 /usr/bin/elinks
echo prelink -y --md5 /usr/bin/md5sum
prelink -y --md5 /usr/bin/md5sum
echo rpm -q --dump elinks pipe grep /usr/bin/elinks
rpm -q --dump elinks | grep /usr/bin/elinks
echo rpm -q --dump coreutils pipe grep /usr/bin/md5sum
rpm -q --dump coreutils | grep /usr/bin/md5sum
echo /usr/bin/md5sum /usr/bin/md5sum /usr/bin/elinks
/usr/bin/md5sum /usr/bin/md5sum /usr/bin/elinks
on server A:
Code:
prelink -y --md5 /usr/bin/elinks
65a265294f2f403dd4624835d20bacc9  /usr/bin/elinks
prelink -y --md5 /usr/bin/md5sum
c1f12e1919f578d75892e0ad9c841851  /usr/bin/md5sum
rpm -q --dump elinks pipe grep /usr/bin/elinks
/usr/bin/elinks 1064856 1256603845 65a265294f2f403dd4624835d20bacc9 0100755 root root 0 0 0 X
rpm -q --dump coreutils pipe grep /usr/bin/md5sum
/usr/bin/md5sum 26152 1256609348 c1f12e1919f578d75892e0ad9c841851 0100755 root root 0 0 0 X
/usr/bin/md5sum /usr/bin/md5sum /usr/bin/elinks
b4b220fcd68c43d13c2196499befa168  /usr/bin/md5sum
5c97ff530716f766115efee5918b2324  /usr/bin/elinks
server B:
Code:
prelink -y --md5 /usr/bin/elinks
65a265294f2f403dd4624835d20bacc9  /usr/bin/elinks
prelink -y --md5 /usr/bin/md5sum
c1f12e1919f578d75892e0ad9c841851  /usr/bin/md5sum
rpm -q --dump elinks pipe grep /usr/bin/elinks
/usr/bin/elinks 1064856 1256603845 65a265294f2f403dd4624835d20bacc9 0100755 root root 0 0 0 X
rpm -q --dump coreutils pipe grep /usr/bin/md5sum
/usr/bin/md5sum 26152 1256609348 c1f12e1919f578d75892e0ad9c841851 0100755 root root 0 0 0 X
/usr/bin/md5sum /usr/bin/md5sum /usr/bin/elinks
04a4b2e49ab156a66870573414e7f7b2  /usr/bin/md5sum
ed417d0a6cc3dd752ab0763627baf34a  /usr/bin/elinks
so, the md5 returned by rpm and by prelink ARE THE SAME in both systems ! uff...a relief indeed !
What remains strange is the md5 (sha1) returned by /usr/bin/md5sum (or /usr/bin/sha1sum) be different in each system (I've prelinked /usr/bin/md5sum and /usr/bin/sha1sum and /usr/bin/elinks just in case)

@anonie: this is new for me, thanks to make it clear. Let me understand: If I update a library in this system but not re-link a binary which depends on that library, the binary will return different hashs before and after prelink on the binary, that is right ?

anyway, why md5sum or sha1sum are returning different hashs in each system ? (of course, at this point we can assume the system is not compromised - at least the 2 systems were off for a long time - they were turned on for this investigation a few hours ago and unplugged from the network, just in case)
 
Old 08-23-2010, 12:38 PM   #9
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, FreeBSD
Posts: 3,925
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by marozsas
this is new for me, thanks to make it clear. Let me understand: If I update a library in this system but not re-link a binary which depends on that library, the binary will return different hashs before and after prelink on the binary, that is right ?
Dunno if I can definitely speak to that exact scenario. I recommend that you test and check the results.

I can demonstrate this much (Fedora 13 system, BTW):

Code:
# openssl dgst -sha1 /bin/more
SHA1(/bin/more)= b7cc7f4108c81b3dc5b65e2b839e60cadb636d60

# prelink -v /bin
Laying out 52 libraries in virtual address space 00101000-50000000
...
Prelinking /bin/more
...

# openssl dgst -sha1 /bin/more
SHA1(/bin/more)= e709c416366f67f09238a21f1038bdb459d87f33
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checksum 4 Slackware download - what type of checksum is this. Earnest Lux Linux - Newbie 1 02-02-2008 08:02 PM
question about installing binaries correctly jimjamjahaa Linux - Software 4 05-11-2006 02:09 AM
Can't fix this checksum error ! Binary File ! My VERY FIRST Question ! help pls !!!! Zaher Programming 1 03-20-2006 09:35 PM
Slack 8.1 iso checksum question Pres Linux - Newbie 5 10-09-2002 08:03 AM


All times are GMT -5. The time now is 03:11 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration