LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-04-2018, 05:19 PM   #16
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043

Code:
jlinkels@donald-pc:~/$ tac
Hello World
This is the last line
CTRL-D
This is the last line
Hello World
jlinkels@donald-pc:~/$
jlinkels
 
Old 05-04-2018, 05:19 PM   #17
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hydrurga View Post
Your previous post talked about "writing to stdin". What does that mean, if I can ask?

If you run tac with no arguments, it takes its input from stdin.
no it does not first of all it does not output to screen meaning it does not write to stdout unlike cat but i also know it does not write to stdin for the following reason,
i am interested in pentesting and so i practice my hacking a small quirk of shells that are created out of exploited binary's is that they do not provide you with a way to input into them because of that a popular trick has developed where you execute your exploit and then call cat and then pipe it into the program you pass arguments to cat which passes them to stdin and then returns the programs output to stdout that looks something like this
Code:
(python exploit.py ; cat) | /whatever/vuln
however that trick does not work with
Code:
(python exploit.py ; tac) | /whatever/vuln
at first i thought it might just not write to stdout since it did not seem to do that normally either but i tried to create a directory out of the shell and it did not appear leading me to conclude it does not write to stdin or stdout sorry if this was a bit convoluted

Last edited by zaper; 05-04-2018 at 05:33 PM.
 
Old 05-04-2018, 05:29 PM   #18
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
man tac (excerpt):

Code:
DESCRIPTION
       Write each FILE to standard output, last line first.

       With no FILE, or when FILE is -, read standard input.
You should look at tac's source code to find out why it doesn't work the way you want it to for your hack.

The hack aside, please provide two commands, cat and tac-based, that anyone can run in their terminal and which illustrate your point as to the difference between the two.
 
Old 05-04-2018, 05:31 PM   #19
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213
Quote:
Originally Posted by zaper View Post
Code:
(python exploit.py ; cat) | /whatever/vuln
however that trick does not work with tac
In order to reverse the lines, tac must first read all its input and see EOF. I'm not sure what you expect your example to do. With that semicolon in the command line, neither cat nor tac is processing the output from "python exploit.py" -- it's reading from the terminal. Perhaps that's what you intended, but you have to type a ctrl-D to get any output from tac.

Last edited by rknichols; 05-04-2018 at 05:34 PM.
 
Old 05-04-2018, 05:35 PM   #20
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hydrurga View Post
man tac (excerpt):

Code:
DESCRIPTION
       Write each FILE to standard output, last line first.

       With no FILE, or when FILE is -, read standard input.
You should look at tac's source code to find out why it doesn't work the way you want it to for your hack.

The hack aside, please provide two commands, cat and tac-based, that anyone can run in their terminal and which illustrate your point as to the difference between the two.
thanks for the feedback i added the second example

Last edited by zaper; 05-05-2018 at 04:46 AM.
 
Old 05-05-2018, 04:47 AM   #21
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
thanks for the explanation you are right it works with ^D
 
Old 05-05-2018, 04:50 AM   #22
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
In order to reverse the lines, tac must first read all its input and see EOF. I'm not sure what you expect your example to do. With that semicolon in the command line, neither cat nor tac is processing the output from "python exploit.py" -- it's reading from the terminal. Perhaps that's what you intended, but you have to type a ctrl-D to get any output from tac.
yes that's what i meant just reading input from the script is not the point the point is to create a way to interact with the program by piping cat into it as to ^D i did not realise that you are correct

Last edited by zaper; 05-05-2018 at 04:51 AM.
 
Old 05-05-2018, 10:01 AM   #23
dave@burn-it.co.uk
Member
 
Registered: Sep 2011
Distribution: Puppy
Posts: 601

Rep: Reputation: 172Reputation: 172
If I wanted to look at a file containing command history to find out what caused a crash, I would not be pleased if I had to wade through hours of old commands before I found the culprit, especially at 3 O'clock in the morning.
 
Old 05-05-2018, 10:04 AM   #24
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dave@burn-it.co.uk View Post
If I wanted to look at a file containing command history to find out what caused a crash, I would not be pleased if I had to wade through hours of old commands before I found the culprit, especially at 3 O'clock in the morning.
why not just jump to the end of the file ?
 
Old 05-05-2018, 10:36 AM   #25
dave@burn-it.co.uk
Member
 
Registered: Sep 2011
Distribution: Puppy
Posts: 601

Rep: Reputation: 172Reputation: 172
Oh yes? wait for megabytes of unnecessary data to be transmitted over the web!!
I would guess you have never had to do support from home!! Even on call out it is nice to have some clue as to what you are going to work for at that time of the morning.
 
Old 05-05-2018, 10:50 AM   #26
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Quote:
Originally Posted by zaper View Post
fair enough any idea what running it with no argv does ?
From stdin, it doesnt know where is the last line to read from since stdin can be typed keyboard input for example.

Cat on the contrary can read first line from stdin as soon as there is content in it

[edit]
wow didn't see the second page and realize I am wrong, sorry

Last edited by keefaz; 05-05-2018 at 10:57 AM.
 
Old 05-05-2018, 11:17 AM   #27
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,899

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
was not mentioned, tac has additional features: https://www.sanfoundry.com/tac-comma...xamples-linux/
 
Old 05-05-2018, 12:38 PM   #28
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dave@burn-it.co.uk View Post
Oh yes? wait for megabytes of unnecessary data to be transmitted over the web!!
I would guess you have never had to do support from home!! Even on call out it is nice to have some clue as to what you are going to work for at that time of the morning.
how slow is your internet connection ? i mean granted i have never read huge files of remote networks but its ssh for crying out loud
 
Old 05-05-2018, 01:15 PM   #29
dave@burn-it.co.uk
Member
 
Registered: Sep 2011
Distribution: Puppy
Posts: 601

Rep: Reputation: 172Reputation: 172
In real terms??
About 1 megabyte per second if I am extremely lucky.

No I do not live in the middle of nowhere; I just happen to be able to see two exchanges from my front door, but the nearest cabinet is just under a mile away and is overloaded since a new estate is being built without a new cabinet.
I did think about fibre, but I would have to pay for ftp to be installed since ftc would go to the same cabinet and not improve matters much above 1.7 megabyte per second.

I just happen to live in a street that was having the drains replaced when BT installed FTP in this area so it wasn't installed. I did look into buying a strip of land from the house behind mine that fronts onto a street that does have FTP, but they wanted a stupid price and would not grant access rights for fibre.
 
Old 05-05-2018, 01:18 PM   #30
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dave@burn-it.co.uk View Post
In real terms??
About 1 megabyte per second if I am extremely lucky.

No I do not live in the middle of nowhere; I just happen to be able to see two exchanges from my front door, but the nearest cabinet is just under a mile away and is overloaded since a new estate is being built without a new cabinet.
I did think about fibre, but I would have to pay for ftp to be installed since ftc would go to the same cabinet and not improve matters much above 1.7 megabyte per second.

I just happen to live in a street that was having the drains replaced when BT installed FTP in this area so it wasn't installed. I did look into buying a strip of land from the house behind mine that fronts onto a street that does have FTP, but they wanted a stupid price and would not grant access rights for fibre.
oh ok in that case i totally see the appeal
 
  


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
operation of "tac" in sed dina3e Programming 7 08-24-2008 08:45 PM
Why my wireless card "atheros" run only as an acces point in "Master" mode. jardiamj Linux - Wireless Networking 3 11-11-2007 12:12 AM
kdenlive: on export, there's a tac tac tac in the sound output eantoranz Linux - Software 5 10-20-2007 11:20 AM
"Refer To" option to point questioners to existing discussion/material sboddy LQ Suggestions & Feedback 6 12-01-2005 02:14 AM
searching "TIC TAC TOE" bash script LV-chronos Linux - Newbie 5 05-29-2005 02:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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