Trolling Twitter followers with .htaccess and PHP

Trolling Twitter followers with .htaccess and PHP

Adam

Mr. Webwide
Administrator
Local time
16:10
Joined
Sep 24, 2019
Messages
1,254
Pronouns
he/him


Thought this was pretty entertaining! David Sandberg trolls his Twitter followers by using .htaccess to spoof an image file to return a PHP script that programatically returns an image based on the visitor IP address.

Here's the code from the Tweet for anybody wanting to try anything similar:

.htaccess:
RewriteEngine on
Redirect /whatisthis.jpg /whatisthis.php
whatisthis.php:
<?php
function getIMG() {
    // Get last digit of IP address
    $numb = substr($_SERVER['REMOTE_ADDR'], -1);

    // Return a different image based on IP
    if($numb == 1 || $numb == 2) {
        header("Location: 1.jpg");
    } elseif($numb == 3 || $numb == 4) {
        header("Location: 2.jpg");
    } elseif($numb == 5 || $numb == 6) {
        header("Location: 3.jpg");
    } elseif($numb == 7 || $numb == 8) {
        header("Location: 4.jpg");
    } elseif($numb == 9 || $numb == 0) {
        header("Location: 5.jpg");
    }
}

getIMG();
?>

 
Last edited:

Gummibeer

Astroneer
Moderator
Local time
17:10
Joined
Oct 5, 2019
Messages
1,167
Pronouns
he/him

Regarding the description I thought about something more complex like geoip, User-Agent, language and similar. 😅

 

Gummibeer

Astroneer
Moderator
Local time
17:10
Joined
Oct 5, 2019
Messages
1,167
Pronouns
he/him

PS: this would only work in a good way if the proxied/cached feed image would be different. So that everyone sees a different embedded image in the feed. 😅

 
Top