Access sectors of HDD in C++
Hi,
I am trying to create an app that would access the MBR of the HDD. I know that this is located in the first sector of the HDD but I don't know how to access it. Is there a way to access the HDD in C++ or C with which I could access sectors and it's contents not files? Eg: MFT is in the MBR on NTFS parts and I would love to read this file. (^_^) |
Are you trying to do this under *NIX or Windows? If NIX, you can fopen the device just like any other file. e.g,
Code:
fopen("/dev/hda1","r"); |
Windows... I want to access the SAM file from a limited account and read it's contents. I need an executable that accesses the HDD as it is and uses the MFT to determine where exactly it is. After that just read it out. No hacking or such but I want to see if it was possible to do it.
From linux I would just mount it and copy the SAM file or modify it's rights or attributes and problem would be solved, however there are cases when you can't just boot up a linux. |
Quote:
just kidding, I havent done any C++ coding for quite some time, So sorry but I can't help you there :scratch: and if you are hacking then you can use ntpasswordrecovery to overwrite the same file, and ntpassword recovery also allows you to copy the sam file before overwriting it. But you can copy it nontheless, is this the kind of function you want? or would you rather impliment it in your own code? :p |
Quote:
// basic file operations #include <iostream> #include <fstream> using namespace std; int main () { ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file.\n"; myfile.close(); return 0; } Is that what you want? I remembered Myfile simply because I used it to write to log files late last year at school :D Ducky. |
Ahm... Not exactly. With this you are using the kernel and the NTFS partition to access the files. If you do not have the permissions to do so, you are screwed. Therefore this is not really a functioning solution.
Maybe, what I will do is to grab a runnable linux distro, run it under windows and just hack the file. I have no intention to write a virus for Windows. This would be only for recovery purposes for my Mom. She always forgets her passwd. (^_^) |
The Windows kernel won't allow you to directly access the hard drive (i.e., bypass the filesystem layer). It's intended as a security mechanism to prevent exactly what you are trying to do. :)
|
Quote:
|
Quote:
I didn't know that the kernel can prevent me from doing anything. How is it working? Is there a feature like this under linux too? Most likely but I don't know about it. Dani |
Doesn't the following say it all?
Quote:
Do I have to believe you? There are easy ways of doing this google is your friend, yet 99.999999999999999% of the time its used to gain illegal access to an account. :) |
Under linux, you can read devices directly, but only as a trusted user. A normal account would not allow you to read it from the disk under Linux.
|
Nope... I knew that the file is encrypted but it can be decrypted too. :) There must be some kind of method to do so.
Dmail... You don't nee to believe me. However I am always supposing of other ppl - at least for the first time - that they are saying the truth. In this case I was sarcastic and you were right that you didn't believe me. Why don't we close the off? |
Quote:
Quote:
Quote:
|
Doh... As you feel. I didn't expect to get an answer for such question anyway. Or at least I hoped so. I hoped that ppl would say that hey, are you trying to write something that could affect MS Windows users badly? I am sorry, but my moral is too high to help to you.
Inconsistency might have occurred as I didn't really want to let the people know that I want to trick out the system and gain access to information to which I am not supposed to. No matter if it is the SAM file or just the My Documents. The is what police is building on when they are questioning the accused many times and they are looking for inconsistency. But also I must let you guys all know (either you believe me or not) that I had no intention to harm other people. I am writing such application just to see if I am capable or not. I am just trying to figure out ways that are not that simple, ways that could save my butt some day at work or ways that my boss will be impressed with. I am just learning. |
Learning is good. We do encourage learning. Unfortunately, too many people claim to be 'learning' with malicious intent... it's hard for us to find the line, so we have to limit it entirely.
|
All times are GMT -5. The time now is 03:19 AM. |