LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-19-2011, 07:15 AM   #1
kingkashif
Member
 
Registered: May 2009
Posts: 94

Rep: Reputation: 16
Can we change Entries in the inode table of a file (Linux)


Hello,

Anyone, I would like to ask if it was possible to change the entries of a file's inode table ?

For example
Code:
File: `index.php'
  Size: 38        	Blocks: 8          IO Block: 4096   regular file
Device: 807h/2055d	Inode: 164744      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2011-05-19 16:32:01.939059278 +0500
Modify: 2011-05-19 17:03:54.518074785 +0500
Change: 2011-05-19 17:03:54.518074785 +0500
Now the above is the inode stat of the index.php's file.

I was wondering if I can change the entries in this inode table's entries.
For example I want to change the "Modify" entry ? I want it to reflect to day 2009-05-19 for example.

Can i do it ?
 
Old 05-19-2011, 07:17 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
If you want to do it from the command prompt or in a script that can run commands, the touch command can do that.
 
Old 05-19-2011, 07:21 AM   #3
kingkashif
Member
 
Registered: May 2009
Posts: 94

Original Poster
Rep: Reputation: 16
Thank you for your reply..

Can you please elaborate how I could change the "modify" line of an inode table of a file to reflect the date my specified date ?

How can I do it using touch ?

Thanks
 
Old 05-19-2011, 07:46 AM   #4
manyrootsofallevil
Member
 
Registered: Dec 2010
Distribution: Red Hat, Kubuntu
Posts: 130

Rep: Reputation: 14
Quote:
Originally Posted by kingkashif View Post
Thank you for your reply..

Can you please elaborate how I could change the "modify" line of an inode table of a file to reflect the date my specified date ?

How can I do it using touch ?

Thanks
You simply do
Code:
touch filename
 
Old 05-19-2011, 07:57 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by kingkashif View Post
How can I do it using touch ?
Most commands have a "man page" (man = manual). To see the touch man page run man touch.

Many commands have "info" too so it is worth trying info coreutils 'touch invocation'

The Internet often has pages explaining how to use commands; here is a Google Linux search for the words touch, command and example.
 
Old 05-19-2011, 10:09 AM   #6
kingkashif
Member
 
Registered: May 2009
Posts: 94

Original Poster
Rep: Reputation: 16
Well thanks for your replies but I guess you guys have misunderstood me, or just didn't read the question well.

I know how to use the touch commands etc, I am not a newbie.

Here is the question Again ..

When I run following command

Code:
stat index.php
as a result of above command, I get following result

Code:
File: `index.php'
  Size: 38        	Blocks: 8          IO Block: 4096   regular file
Device: 807h/2055d	Inode: 164744      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2011-05-19 16:32:01.939059278 +0500
Modify: 2011-05-19 17:03:54.518074785 +0500
Change: 2011-05-19 17:03:54.518074785 +0500

now you see there are various entries in this inode table of file index.php

I am wondering if there is a way I can hack these entries ?

for example I want to change the "Modify:" line in this table

and I want to set the date in the "Modify:" line of this table to reflect 2001-04-19
instead of it's current value 2011-05-19 ..

is it possible ?

Have you guys understood my problem now ?
 
Old 05-19-2011, 10:58 AM   #7
OlRoy
Member
 
Registered: Dec 2002
Posts: 306

Rep: Reputation: 86
I'm pretty sure they understand what you're asking, and have already answered it. Can I ask why you want to change the modified time?
 
Old 05-20-2011, 01:55 AM   #8
manyrootsofallevil
Member
 
Registered: Dec 2010
Distribution: Red Hat, Kubuntu
Posts: 130

Rep: Reputation: 14
Quote:
Originally Posted by kingkashif View Post
Well thanks for your replies but I guess you guys have misunderstood me, or just didn't read the question well.

I know how to use the touch commands etc, I am not a newbie.

Here is the question Again ..

When I run following command

Code:
stat index.php
as a result of above command, I get following result

Code:
File: `index.php'
  Size: 38        	Blocks: 8          IO Block: 4096   regular file
Device: 807h/2055d	Inode: 164744      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2011-05-19 16:32:01.939059278 +0500
Modify: 2011-05-19 17:03:54.518074785 +0500
Change: 2011-05-19 17:03:54.518074785 +0500

now you see there are various entries in this inode table of file index.php

I am wondering if there is a way I can hack these entries ?

for example I want to change the "Modify:" line in this table

and I want to set the date in the "Modify:" line of this table to reflect 2001-04-19
instead of it's current value 2011-05-19 ..

is it possible ?

Have you guys understood my problem now ?
This should modify the Modify entry only

Code:
touch -m --date='2001-04-19' index.php
 
Old 05-20-2011, 02:08 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by kingkashif View Post
for example I want to change the "Modify:" line in this table

and I want to set the date in the "Modify:" line of this table to reflect 2001-04-19
instead of it's current value 2011-05-19 ..

is it possible ?
Yes -- it is possible. The easiest way is to use the touch command. Why do you not want to do it that way? Do you want to write a program to do what the touch command does? Do you want to find the location of the data on HDD and change it directly?
 
Old 05-21-2011, 02:34 PM   #10
kingkashif
Member
 
Registered: May 2009
Posts: 94

Original Poster
Rep: Reputation: 16
thanks for your help guys. It's great to finally know it.

I would like to know whether I could know this file's location directly on HDD?

Can I open that file from there and change it instead ?

Thanks
 
Old 05-22-2011, 12:26 AM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by kingkashif View Post
I would like to know whether I could know this file's location directly on HDD?

Can I open that file from there and change it instead ?

Thanks
It is technically possible but difficult to locate and modify an inode on HDD. The specifics depend on the file system type.

Why do you want to do so when the touch command can do exactly what you want and a lot more easily?

Please be aware of LQ's rule "Posts containing information about cracking, piracy, warez, fraud or any topic that could be damaging to either LinuxQuestions.org or any third party will be immediately removed". You are unlikely to get much help here unless you convince us you are not breaking that rule.
 
1 members found this post helpful.
Old 05-24-2011, 03:09 AM   #12
kingkashif
Member
 
Registered: May 2009
Posts: 94

Original Poster
Rep: Reputation: 16
Well actually I am not breaking any rules..

I was just wondering, if all the entries in the inode table of a file
are editable by the owner of that file ? Or there are any entries that
can only be modified by the kernel only.

Thats all.
 
Old 05-24-2011, 08:59 AM   #13
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
The straighforward way to alter file system data is by system calls to the kernel (which may be generated by commands such as rm, ln, touch etc., via a shell's redirection operators such as >, via a GUI or from a program using system call libraries such as compiled C) which then alters the file system data via file system drivers. In this case the file and directory permissions control which users can change the data.

Alternatively you can write directly to the HDD via its block device files such as /dev/sda, /dev/sda2 etc. using something like the dd command. This requires a knowledge of the file system structure to determine the position of the data (including inode) to be changed. A mistake can corrupt the file system. If it is done while the file system is mounted the usual issues of multi-write access causing data skew arise. The HDD's block device files are writeable only by root so only root can do this.
 
1 members found this post helpful.
Old 05-25-2011, 03:58 AM   #14
kingkashif
Member
 
Registered: May 2009
Posts: 94

Original Poster
Rep: Reputation: 16
Okay thank you catkin for your generous time.

This post stands resolved now.

Thanks everyone else, who shared their views here.
 
  


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
To Increase routing Table Entries in a Linux box. adassss Linux - Networking 7 10-18-2014 01:55 AM
where is inode table in ext3 _Linux_Learner Linux - Newbie 4 03-16-2010 03:23 PM
missing inode table mottl3y Linux - Hardware 8 06-14-2008 09:01 AM
In Linux, How to read and modify Kernel IP routing table entries from a c program sakthivelbatusai Linux - Networking 1 03-29-2007 06:36 AM
viewing the Inode table 0perat0r Linux - Newbie 1 07-20-2004 02:20 PM

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

All times are GMT -5. The time now is 05:15 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