LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 11-27-2009, 10:34 AM   #1
Oxagast
Member
 
Registered: Aug 2003
Location: Mocksville, NC, USA
Distribution: Gentoo, Slackware.
Posts: 410

Rep: Reputation: 30
1;2c after using cat or more on binary files


I noticed that if you use the hex 05 in a file and cat or more the file you can get bash to say 1;2c.

Code:
oxagast@likon ~/code $ cat fmore
^[[?1;2coxagast@likon ~/code $ 1;2c
bash: 1: command not found
bash: 2c: command not found
oxagast@likon ~/code $ hexdump fmore
0000000 0005                                   
0000001
oxagast@likon ~/code $
I was just interested in why it does this and if it's a security bug, considering most people, when using more, will press the return key until the files over, so you could craft a file that looks normal and wait until they get to the end and if an executable file 1 or 2c is in the path (or if you could possibly change what those values are) it would execute them once it drops back to bash. The fmore file does not have to be set to executable or anything.

Thanks,
oxagast
 
Old 11-28-2009, 02:54 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
It's in the way non-printing or control characters and escape sequences are interpreted. Abusing that can still fool some applications or log parsers so using precautions something like 'noexec less -dRUX /path/logfilename' or 'cat -v /path/filename|col -x' or using 'strings -an1|less' to read things make sense if you think you're onto something. Dropping files in (the '.' portion of the) $PATH is an ancient trick to make people execute things. Abusing it AFAIK hinges on having the required access rights to drop files in path items (meaning that if root does that you've got problems of a different magnitude) and sane path settings (e.g. the root account shouldn't have or need '.' in its path and certainly not as the first item or risk asking for trouble).
 
Old 11-28-2009, 09:48 AM   #3
Oxagast
Member
 
Registered: Aug 2003
Location: Mocksville, NC, USA
Distribution: Gentoo, Slackware.
Posts: 410

Original Poster
Rep: Reputation: 30
Thank you, that was helpful and interesting.
 
  


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
cat on binary: garbles stdout chars, wastes terminal jhwilliams Linux - Software 3 07-17-2007 03:55 PM
Using cat for ISO files jmsvbit Linux - Newbie 2 01-04-2007 04:35 PM
Cat with Binary File? Xaque208 Linux - General 1 12-06-2004 07:59 PM
bash: /bin/cat: cannot execute binary file inTUXicated Linux - General 9 08-06-2003 07:56 AM
cat - joining files u02gtt Linux - Newbie 6 04-22-2002 08:49 AM

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

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