LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 05-25-2009, 09:11 AM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Rep: Reputation: 70
Nuking the Boot Sector


HI all,

It transpires from another thread that there's more to the space before the the start of the first partition than just the MBR. In order to be sure of wiping out any viruses lurking in the pre-first partition space it turns out one would have to wipe not just the first 512 bytes, but the first 62 sectors:

Code:
sudo dd if=/dev/zero of=/dev/sda bs=31744 count=1
One could then still boot the system from a rescue CD. I just thought I'd run this idea past the panel to see if there's any problem with it I haven't envisaged?
 
Old 05-26-2009, 06:25 PM   #2
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Arch/Manjaro, might try Slackware again
Posts: 1,851
Blog Entries: 14

Rep: Reputation: 284Reputation: 284Reputation: 284
I think there's hiding room elsewhere too. Why not nuke the whole disk:

sudo dd if=/dev/random of=/dev/sda

if I have the syntax right...
 
Old 05-26-2009, 06:49 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
*harmless;
He said he still wanted to boot from a rescue CD, so wiping the whole disk is not the right answer.

*Clueless;
63 sectors, not 62-----#0 is the MBR, 1st partition typically starts on #63 (Doesn't everyone count from zero?...)
So:
sudo dd if=/dev/zero of=/dev/sda bs=32256 count=1
OR
sudo dd if=/dev/zero of=/dev/sda bs=512 count=63

GRUB typically puts stage 1.5 and stage 2 after the MBR, so your boot method has to be compatible with all that being gone.

Why not wipe the area and then just re-install GRUB???

Quote:
I think there's hiding room elsewhere too
There's 63 empty sectors at the start of an extended, and all logical, partitions. Otherwise, where is there more hiding space?
 
Old 05-26-2009, 06:58 PM   #4
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Arch/Manjaro, might try Slackware again
Posts: 1,851
Blog Entries: 14

Rep: Reputation: 284Reputation: 284Reputation: 284
Whoops, so he did, my mistake. Isn't there also some space at the end of the disk where metadata for software RAID sits?
 
Old 05-26-2009, 10:35 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by mostlyharmless View Post
Whoops, so he did, my mistake. Isn't there also some space at the end of the disk where metadata for software RAID sits?
I suppose so, but keep in mind that a RAID setup creates a "virtual device" which looks to the OS like a single physical drive. At that point, what is actually written to the physical drives is not relevant to the typical user.
 
Old 05-27-2009, 05:21 AM   #6
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by pixellany View Post
*harmless;
He said he still wanted to boot from a rescue CD, so wiping the whole disk is not the right answer.
That's the understatement of the decade!
I do like his sig, though. :-)

Quote:
63 sectors, not 62-----#0 is the MBR, 1st partition typically starts on #63 (Doesn't everyone count from zero?...)
So:
sudo dd if=/dev/zero of=/dev/sda bs=32256 count=1
OR
sudo dd if=/dev/zero of=/dev/sda bs=512 count=63
These aren't equivalent, are they? The first command nukes the first 63 sectors once; the second over-writes the MBR 63 times, n'est pas?
 
Old 05-27-2009, 05:41 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Quote:
Originally Posted by Completely Clueless View Post
That's the understatement of the decade!
I do like his sig, though. :-)

Code:
63 sectors, not 62-----#0 is the MBR, 1st partition typically starts on #63 (Doesn't everyone count from zero?...)
So:
sudo dd if=/dev/zero of=/dev/sda bs=32256 count=1
OR
sudo dd if=/dev/zero of=/dev/sda bs=512 count=63
These aren't equivalent, are they? The first command nukes the first 63 sectors once; the second over-writes the MBR 63 times, n'est pas?
The first command writes 32256 bytes in one large chunk. The second command writes 32256 bytes in 512 byte chunks (63 of them).

EDIT:
Quote:
Originally Posted by mostlyharmless View Post
I think there's hiding room elsewhere too. Why not nuke the whole disk:

sudo dd if=/dev/random of=/dev/sda

if I have the syntax right...
That command would never finish, you would have to use '/dev/urandom', but I don't see why not just use /dev/zero ... unless you wanted to cover up the data, but then you'd still have to do it more than once.

Last edited by H_TeXMeX_H; 05-27-2009 at 05:43 AM.
 
Old 05-27-2009, 07:16 AM   #8
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by H_TeXMeX_H View Post
The first command writes 32256 bytes in one large chunk. The second command writes 32256 bytes in 512 byte chunks (63 of them).
Sigh... Oh well, I obviously need to look into "dd" a bit more.

So in that case, say one wanted to over-write the MBR 35 times with random data (the so-called Guttmann Method for secure wiping) what would the command be?
 
Old 05-27-2009, 07:33 AM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by Completely Clueless View Post
Sigh... Oh well, I obviously need to look into "dd" a bit more.

So in that case, say one wanted to over-write the MBR 35 times with random data (the so-called Guttmann Method for secure wiping) what would the command be?
dd inside a loop?
 
Old 05-27-2009, 07:36 AM   #10
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by pixellany View Post
dd inside a loop?
Well clearly, yes. But ISTR there is a concise way of doing it just by appending an option to 'dd'. Dashed if I can remember what it is, though. :-/
 
Old 05-27-2009, 07:47 AM   #11
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
No, there's no such option AFAIK, but why 35 times ? Whatever virus might have been there is gone after the first wipe. Multiple wipes are only done to make sure forensic tools used by agencies cannot recover any data even with the most sophisticated of technology.
 
Old 05-27-2009, 07:56 AM   #12
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Wink

Quote:
Originally Posted by H_TeXMeX_H View Post
No, there's no such option AFAIK, but why 35 times ? Whatever virus might have been there is gone after the first wipe. Multiple wipes are only done to make sure forensic tools used by agencies cannot recover any data even with the most sophisticated of technology.
It was only by way of an example, TM. Replace 35X with whatever factor >1 you please. I'm just curious as to what the syntax of the command would look like. However, if you say no such option for multiple overwrites exists with 'dd' then unless someone else knows better, I'm quite happy to accept your assertion. ;-)
 
Old 05-27-2009, 08:08 AM   #13
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
unless someone else knows better, I'm quite happy to accept your assertion.
man dd

dd is not very complicated, and I don't think you will find any ambiguity in the answer to your question.
 
Old 05-27-2009, 08:20 AM   #14
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Angry

Quote:
Originally Posted by pixellany View Post
man dd

dd is not very complicated, and I don't think you will find any ambiguity in the answer to your question.
dd may or may not be complicated, but the man pages for it (and for so many other commands) are an atrocity against the English language. Whoever writes such gibberish should be strung up.

BTW, you're up awfully early aren't you?

Last edited by Completely Clueless; 05-27-2009 at 08:22 AM.
 
Old 05-27-2009, 08:48 AM   #15
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
If you think you can write a better man page then do it and submit it, I'm sure they'll be happy to get a newer, better man page.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
hdd nuking question ddzc Linux - Hardware 3 03-10-2007 03:18 PM
cannot find boot sector for dual boot darinbolson Linux - General 21 02-05-2006 03:42 PM
Boot Sector on dual boot PC. Remove Mandrake and replace with FreeBSD Phin666 *BSD 1 10-30-2004 05:02 PM
Kernel nuking instructions..... CaptainInsane Red Hat 2 12-09-2003 07:18 AM
No boot sector found, error at boot areeves88 Linux - General 3 01-18-2003 08:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 01:43 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration