I know that when requesting a webpage, there is different ways of requesting it. Get, Post, PUT, Patch, Delete and a few more. But I wonder how I could send like a text file including multiple lines to a php web server, and get that server to catch the message and save it? I managed to do this with 1 line, and looked like this:
GET /SECRET-MESSAGE HTTP/1.1" 404 2306
But it only made me request a directory that doesn't exists and multiple lines would be problematic which makes this method really stupid.
I got inspired by this video, where he shows the rubber ducky sending some kind of custom request to a php webserver. (No, I'm not gonna steal passwords) I'm not totally sure what type of request it does, or how it sends the data to the server. The server then catches it by doing the following code:
file_put_contents($file, file_get_contents("php://input"));
But I simply doesn't get it to work. When I look up the file, it says 0 bytes and doesn't include anything.
The code I'm using so far is this
$file = "log/" . date("m.d.y") . "/[" . $_SERVER['REMOTE_ADDR'] . "] " . date("H:i:s") . ".lll";
$content = file_get_contents("php://input");
file_put_contents($file, $content);
There is nothing wrong with permissions because I've tested with some other text and I've set all permission allowed to everyone: "0777" Reason I want to do this, is to make a kind of a text saving cloud where I can send my notes to my server. If I remember something I want to write down, I could just send it to the server, and look it up later.
Is it anything I'm doing wrong here or not noticing? Please help.
php://input
reads from the request body of a POST request