Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 01-20-2003, 08:53 AM   #16 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by sde
oh geesh .. why do i even post. illya was asking what type of output that command could produce.

of course there is no output if the file exists. if it did not exist, you would probably get output of some kind at least in the terminal. that is what i was referring too.
OK, I just tried removing

/lll/lll/lll/lll/this/is/sucky

which obviously doesn't exist and still got nothing... I am thinking of just making rm setuid root and forget about it
  Reply With Quote
Old 01-20-2003, 11:26 AM   #17 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
shell_exec() has me scratchin my head .. i can't make it output either. i'll be testing some more today.
sde is offline   Reply With Quote
Old 01-20-2003, 11:55 AM   #18 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by sde
shell_exec() has me scratchin my head .. i can't make it output either. i'll be testing some more today.
I also tried doing cp /bin/rm /bin/rs just maybe because PHP team didn't think having rm was very safe but still it fscks up! I have no idea on this one. And sde I think what you have to do for shell_exec() is

$output=shell_exec("echo 'ALL YOUR BASE ARE BELONG TO US!!!!'");
echo $output;

May be wrong though...
  Reply With Quote
Old 01-20-2003, 12:05 PM   #19 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
i've tested both of these to make sure that shell_exec() will actually work.

this is putting the command in the arguments
PHP Code:
<?
$output 
shell_exec('touch new_file.txt');
echo 
$output;
?>
and this would do the same thing except putting an executable filename in the arguments
PHP Code:
<?
$output 
shell_exec('script.sh');
echo 
$output;
?>
both of these will create 'new_file.txt' ( assuming script.sh just contains the same command as my first example. )

the problem is when you use any command that generates output. i tested it with 'echo' commands and also 'rm' commands that should not detect a file and give error output.

this bugs the heck out of me.
sde is offline   Reply With Quote
Old 01-20-2003, 12:42 PM   #20 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by sde
the problem is when you use any command that generates output. i tested it with 'echo' commands and also 'rm' commands that should not detect a file and give error output.

this bugs the heck out of me.
I believe I saw somewhere on php.net about this,

/me STFW

check out /www/log/error_log

it should report the errors.
  Reply With Quote
Old 01-20-2003, 01:06 PM   #21 (permalink)
anon
Guest
 
Posts: n/a
SUCCESS!

after doing chmod 777 /www/htdocs and alot of cat /www/logs/error_log I executed:

<?php
system("mkdir BLAHWORK;ls;rm -rf BLAHWORK;echo '<br />';ls");
?>

and it worked! I was getting alot of "cannot unlink" errors....

just for fun I did:

Code:
#include<stdio.h>

void main(void) {
setuid(0);
setgid(0);
system("rm -rf /home/vlad/lll");
}
Then su'ed, compiled it, and named it as /bin/lll

when I executed lll it worked


*for those who do not know C, playing around with that may be hazardous to your health*



EDIT: Also if you want the output of a command AND the output redirected to a file RTFM on the command "tee".
  Reply With Quote
Old 01-20-2003, 03:17 PM   #22 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
i think you have ADD =)

exec, and shell_exec always worked for me .. it was the output to php i thought we were working on.

i got some answers, but i'm still at work so i'll post them later tonight.
sde is offline   Reply With Quote
Old 01-20-2003, 03:24 PM   #23 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
Quote:
Originally posted by sde
oh geesh .. why do i even post. illya was asking what type of output that command could produce.

of course there is no output if the file exists. if it did not exist, you would probably get output of some kind at least in the terminal. that is what i was referring too.
because your a spammer! :p

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-20-2003, 03:26 PM   #24 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
Quote:
Originally posted by Vlad902
SUCCESS!

after doing chmod 777 /www/htdocs and alot of cat /www/logs/error_log I executed:

<?php
system("mkdir BLAHWORK;ls;rm -rf BLAHWORK;echo '<br />';ls");
?>

and it worked! I was getting alot of "cannot unlink" errors....

just for fun I did:

Code:
#include<stdio.h>

void main(void) {
setuid(0);
setgid(0);
system("rm -rf /home/vlad/lll");
}
Then su'ed, compiled it, and named it as /bin/lll

when I executed lll it worked


*for those who do not know C, playing around with that may be hazardous to your health*



EDIT: Also if you want the output of a command AND the output redirected to a file RTFM on the command "tee".
how so?

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-20-2003, 03:35 PM   #25 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by sde
i think you have ADD =)
ADD stands for At... Uh, what are we talking about again? =)
exec, and shell_exec always worked for me .. it was the output to php i thought we were working on.
Yeah we were, but now that I know how to output stuff (system) and where to find errors /www/logs/error_log I think we are done

i got some answers, but i'm still at work so i'll post them later tonight.
Answers to what? How to get error output as well?
  Reply With Quote
Old 01-20-2003, 03:47 PM   #26 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
the whole idea i'm chasing here is getting the output to show up on the web page you are accessing.

for example, i got passthru() to work.
PHP Code:
<?
// prints /etc/passwd file
passthru("cat /etc/passwd");

print 
"<br><br>";

// this will print errors also
passthru("cat /etc/shadow 2>&1");
?>
now i want to get shell_exec() to work so i can actually get the output into a variable rather than just printing it out.
sde is offline   Reply With Quote
Old 01-20-2003, 03:53 PM   #27 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
Quote:
Originally posted by sde
the whole idea i'm chasing here is getting the output to show up on the web page you are accessing.

for example, i got passthru() to work.
PHP Code:
<?
// prints /etc/passwd file
passthru("cat /etc/passwd");

print 
"<br><br>";

// this will print errors also
passthru("cat /etc/shadow 2>&1");
?>
now i want to get shell_exec() to work so i can actually get the output into a variable rather than just printing it out.
I like, I like

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-20-2003, 04:05 PM   #28 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by sde
now i want to get shell_exec() to work so i can actually get the output into a variable rather than just printing it out.
That made no sense at all because doesn't it have to go in a variable?

ie.

$blah=shell_exec("cat /etc/shadow|mutt v902@users.sourceforge. net");
echo $blah;

?
  Reply With Quote
Old 01-20-2003, 04:37 PM   #29 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
nope...


why is it users.sourceforge. net?

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-20-2003, 05:03 PM   #30 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
what good is output if i can only print it ? i can't do anything with it but display the output.

if i can get it into a variable, i can program with it .. calculate, database, compare, etc. make sense now?
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 04:38 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting