LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (http://www.linuxquestions.org/questions/linux-security-4/)
-   -   safest command-line (not GUI) program to view apache logs? (http://www.linuxquestions.org/questions/linux-security-4/safest-command-line-not-gui-program-to-view-apache-logs-772879/)

bcw 12-02-2009 02:38 AM

safest command-line (not GUI) program to view apache logs?
 
The Apache 2.2 docs say

Quote:

[...] log files may contain information supplied directly by the client, without escaping. Therefore, it is possible for malicious clients to insert control-characters in the log files, so care must be taken in dealing with raw logs.
However, from Googling around, there seem to be no command-line (non-GUI) programs specifically for viewing possibly-malicious apache logs. Or am I wrong? Until now, I have been using less. Is that ok from a security standpoint?

business_kid 12-02-2009 03:35 AM

yes

18Googol2 12-02-2009 04:21 AM

'tail -f' seems to be better.

zhjim 12-02-2009 04:50 AM

tail -f will only show you the last 10 lines and all new lines coming in. But what if the information you are looking for is above the 10 lines?

(And don't be a smarass and answer with tail -n 20 -f :D)

Web31337 12-02-2009 05:36 AM

UNsafe:
Code:

php -r "include('/var/log/httpd/access.log');"
i guess all standard CLI tools would be OK.

Code:

tail -n 500 | less
is for viewing 500 last lines in a console with ability to scroll up and down.

unixfool 12-02-2009 07:00 AM

Quote:

Originally Posted by zhjim (Post 3776851)
tail -f will only show you the last 10 lines and all new lines coming in. But what if the information you are looking for is above the 10 lines?

(And don't be a smarass and answer with tail -n 20 -f :D)

The man pages are your friend.

I use tail as such:

tail -f -n 100 /var/log/httpd/access_log

Quote:

-f The -f option causes tail to not stop when end of file is reached, but rather to wait for additional data to be appended to the input. The -f option is ignored if the standard input is a pipe, but not if it is a FIFO.
Quote:

-n number The location is number lines.
Quote:

The default starting location is "-n 10", or the last 10 lines of the input.

bcw 12-03-2009 11:35 PM

thanks + a couple questions
 
thanks for the help, everyone.

Quote:

Originally Posted by Web31337 (Post 3776906)
UNsafe:
Code:

php -r "include('/var/log/httpd/access.log');"
i guess all standard CLI tools would be OK.

yeah, i can see how that could be a problem. so basically, don't feed the logs into any executable context, right?

i was actually worried more about someone using shell control characters to trick the shell itself into executing another (arbitrary) command. but now that i think about it, unredirected output from programs the shell executes are just sent to the shell's own stdout/stderr, and have no chance to influence the shell's commands (stdin). isn't that right?


All times are GMT -5. The time now is 01:08 AM.