This is a very special tutorial as I haven't seen it anywhere else. I suppose it will be leeched, copied, pasted and everything else, but such is life and this is my contribution.
How does a PHP RAT work?
We have a form which posts data like this:
And we have one form to let the user type in their command:
http://prntscr.com/36wx7
One to say we got it:
http://prntscr.com/36wxc
One text file to store the command, and one file to delete the contents of the text file. So let's go.
You should have a thread, however in this tutorial for simplicity's sake, I'll use a timer.
The timer checks the text file constantly for the command, which is why when we get a new command we go to delete.php to get rid of what we've already read and to conserve bandwidth. Now you may be going "ZOMG ALL THE TIME, THAT'LL KILL MY BANDWIDTH." But you're wrong. The truth is, if we use commands like s:Hello World, which would stand for say hello world. It would still be only 13 bytes at the time it has a command, never mind it not having a command. (0 Bytes.)
So if you do the math, that's if you wish to be astronomical and say 13 bytes a second, which is 780 bytes in a minute, which is 46800 bytes in an hour, that's still only 45.70313 kb an hour, which isn't even a meg! Work it out for yourself if you wish here.
So now that we know how it works, we can begin making it, I'll break the rest into two parts, the client and the server.
Our client just posts a command, you can do this with Commands.php which would look like:
So we would also need go.php to take the command and do something with it.
go.php:
The top part is just to be fancy and say we got the command, and you can go back now and send another. The second part writes the command to commands.txt, which you would need a blank text file for. So you could use a web browser or web request, or whatever to get the command across and that's the client finished.
The server is pretty easy too, once we get the command, we split it and we check what it wants, and then we go to delete.php to make the text file blank again.
delete.php:
So we're just making commands.txt blank again. However before we can navigate to delete.php and make it blank, we must first read the command, which will happen like so:
Now if you've ever read Live Message Of The Day by Violent, you'd know that we can download a text file in VB.Net, like so:
So that would be on a timer event or thread, constantly checking. So if it isn't blank we need to do something, right?
So once we've got it, we split it, and if the command is say m meaning Msgbox() we show what we received after : in the Msgbox. The reason I used m as opposed to Msgbox in the commands is, it would make the file much larger, ie 7 bytes to 32 or something.
And then we just navigate to delete.php to make the text file blank again.
The code for delete.php is:
I hope you enjoyed my tutorial, and any questions feel free to ask. ^.^
How does a PHP RAT work?
We have a form which posts data like this:
Code
go.php?command=CommandHereAnd we have one form to let the user type in their command:
http://prntscr.com/36wx7
One to say we got it:
http://prntscr.com/36wxc
One text file to store the command, and one file to delete the contents of the text file. So let's go.
What our program does.
You should have a thread, however in this tutorial for simplicity's sake, I'll use a timer.
The timer checks the text file constantly for the command, which is why when we get a new command we go to delete.php to get rid of what we've already read and to conserve bandwidth. Now you may be going "ZOMG ALL THE TIME, THAT'LL KILL MY BANDWIDTH." But you're wrong. The truth is, if we use commands like s:Hello World, which would stand for say hello world. It would still be only 13 bytes at the time it has a command, never mind it not having a command. (0 Bytes.)
So if you do the math, that's if you wish to be astronomical and say 13 bytes a second, which is 780 bytes in a minute, which is 46800 bytes in an hour, that's still only 45.70313 kb an hour, which isn't even a meg! Work it out for yourself if you wish here.
So now that we know how it works, we can begin making it, I'll break the rest into two parts, the client and the server.
The client
Our client just posts a command, you can do this with Commands.php which would look like:
Code
<form action="go.php" method="get">
Command: <input type="text" name="command" />
<input type="submit" />
</form>So we would also need go.php to take the command and do something with it.
go.php:
Code
The command <?php echo $_GET["command"]; ?> has been sent.
</br>
</br>
<A HREF="javascript:history.go(-1)">You may now want to go back.</A>
<?php
$myFile = "commands.txt";
$fh = fopen($myFile, 'w') or die("File Open Failed.");
fwrite($fh, $_GET["command"]);
fclose($fh);
?>The top part is just to be fancy and say we got the command, and you can go back now and send another. The second part writes the command to commands.txt, which you would need a blank text file for. So you could use a web browser or web request, or whatever to get the command across and that's the client finished.
The server.
The server is pretty easy too, once we get the command, we split it and we check what it wants, and then we go to delete.php to make the text file blank again.
delete.php:
Code
<?php
$file = 'commands.txt';
$fp = fopen($file , 'w');
fclose($fp);
?>So we're just making commands.txt blank again. However before we can navigate to delete.php and make it blank, we must first read the command, which will happen like so:
Now if you've ever read Live Message Of The Day by Violent, you'd know that we can download a text file in VB.Net, like so:
Code
Dim W As New WebClient
Dim DownloadedFile As String = W.DownloadString("Site.com/commands.txt")So that would be on a timer event or thread, constantly checking. So if it isn't blank we need to do something, right?
So once we've got it, we split it, and if the command is say m meaning Msgbox() we show what we received after : in the Msgbox. The reason I used m as opposed to Msgbox in the commands is, it would make the file much larger, ie 7 bytes to 32 or something.
Code
Dim W As New WebClient
Dim DownloadedFile As String = W.DownloadString("Site.com/commands.txt")
Dim Command As String = DownloadedFile.Split(":")(0)
Dim AfterCommand As String = DownloadedFile.Split(":")(1)
'MessageBox.Show("Command: " & sCommand & vbNewLine & "Variable: " & sVariable)
Select Case Command.ToLower
Case Is = "m"
MsgBox(AfterCommand)
Case Is = "o"
'Open CD Tray
Case Is = "c"
'Close CD Tray
End SelectAnd then we just navigate to delete.php to make the text file blank again.
The code for delete.php is:
Code
<?php
$file = 'commands.txt';
$fp = fopen($file , 'w');
fclose($fp);
?>I hope you enjoyed my tutorial, and any questions feel free to ask. ^.^
