1

Is it possible to read/execute files/programs using the LBA addressing rather than the file system location?

For example can I execute /bin/sh using the LBA sector locations of it obtained using hdparm? If yes, then how?

I am trying to do this on Linux Mint (version 4.14.13+).

  • 1
    Sure, but do you have a good reason for bypassing the VFS? – Ignacio Vazquez-Abrams Jul 10 '18 at 18:01
  • Yes I do, its for a project I am working for – systolicDrake Jul 10 '18 at 18:18
  • Your biggest issue is you can't guarantee all of the sector of any file are contiguous. Files get fragmented, so if you just start reading the sectors in sequential you may get lucky or their could be other data there. Given storage units are usually only a couple kb even sh is around 250 storage units. – cybernard Jul 11 '18 at 11:55
1

Is it possible to read/execute files/programs using the LBA addressing rather than the file system location

You can read and store data into a second file (based in RAM if you use a tmpfs) one LBA at a time, turn on the execute bits, and execute what you stored.

dd is not far from hdparm and will be a bit easier to work with, and you are practically doing the same thing if you use dd on raw block devices like /dev/sda, etc.

For example can I execute /bin/sh using the LBA sector locations of it obtained using hdparm?

  • You would have to do the same thing the underlying filesystem does. For ext2/3/4, that means parse partition tables, find the superblock, search through inode tables, etc.

  • This is not typically trivial. You have to know exactly what the filesystem does and how it works. There's the source code for Ext2/3/4 that you could study, or any number of texts on the subject. For NTFS there's lots of similar info, both provided by Microsoft and discovered through reverse engineering as well.

  • If you are looking for an "easy-to-hack" filesystem, try FAT (not FAT32). It's very old and as a result very well documented.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.