Initial commit.

This commit is contained in:
Johannes Findeisen 2024-02-07 09:27:22 +01:00
commit 317e1b4e10
13 changed files with 260 additions and 0 deletions

13
auth/auth.php Normal file
View file

@ -0,0 +1,13 @@
---
permalink: /cgi/auth/
---
<?php
session_start();
session_set_cookie_params({{ site.lifetime }});
date_default_timezone_set("{{ site.timezone }}");
header('Content-Type: text/plain');
echo('OK');

13
bash/bash.sh Executable file
View file

@ -0,0 +1,13 @@
---
permalink: /cgi/bash/index.sh
---
echo "Hello from bash!"
echo
echo 'date'
date
echo
echo 'for i in $(seq 1 10); do echo $i; done'
for i in $(seq 1 10); do echo $i; done

27
challenge/challenge.php Normal file
View file

@ -0,0 +1,27 @@
---
permalink: /cgi/challenge/
---
<?php
session_start();
session_set_cookie_params(3600);
date_default_timezone_set("{{ site.timezone }}");
if(isset($_SESSION["one"])) {
unset($_SESSION["one"]);
}
if(isset($_SESSION["two"])) {
unset($_SESSION["two"]);
}
$_SESSION["one"] = rand(0, 9);
$_SESSION["two"] = rand(0, 9);
#$_SESSION["sum"] = $_SESSION["one"] + $_SESSION["two"];
$challenge = $_SESSION["one"] . " + " . $_SESSION["two"];
header('Content-Type: text/plain');
echo($challenge);
?>

18
ifconfig/ifconfig.php Normal file
View file

@ -0,0 +1,18 @@
---
permalink: /cgi/ifconfig/
---
<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
//ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
//ip pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
header('Content-Type: text/plain');
echo($ip);
?>

47
mail/mail.php Normal file
View file

@ -0,0 +1,47 @@
---
permalink: /cgi/mail/
---
<?php
session_start();
session_set_cookie_params(3600);
date_default_timezone_set("{{ site.timezone }}");
$error = "";
$sum = $_SESSION["one"] + $_SESSION["two"];
if ($_POST["sum"] != $sum) { $error = "{{ site.challenge_error }}"; }
if ($_POST["sum"] == $sum) {
$mailTo = "{{ site.email }}";
$mailAddress = "noreply@{{ site.url_short }}";
if($_POST["email"]) {
$mailAddress = $_POST["email"];
}
$mailHeaders = "From: " . $_POST["name"] . " <" . $mailAddress . ">" . "\r\n" .
"Date: " . date(DATE_RFC822);
$mailSubject = "[{{ site.url_short }}]: No subject!";
if($_POST["subject"]) {
$mailSubject = "[{{ site.url_short }}]: " . $_POST["subject"];
}
$mailBody = $_POST["message"] . "\n\n" . "Website: " . $_POST["website"] . "\nUser Agent: " . $_SERVER['HTTP_USER_AGENT'];
if (!@mail($mailTo, $mailSubject, $mailBody, $mailHeaders)) { $error = "Failed to send mail!"; }
unset($_SESSION["one"]);
unset($_SESSION["two"]);
}
header('Content-Type: text/plain');
if ($error=="") {
echo("{{ site.mail_thank_you }}");
} else {
//echo($error . " (". $_POST["sum"] . "/" . $sum . ")");
echo($error);
}
?>

19
perl/perl.pl Executable file
View file

@ -0,0 +1,19 @@
---
permalink: /cgi/perl/index.pl
---
use warnings;
use strict;
use POSIX qw(strftime);
my $date = strftime "%m/%d/%Y", localtime;
print "Hello from Perl!\n\n";
print $date;
print "\n\n";
print('my @i = (1..10); for(@i) { print("$_", "\n"); }');
print("\n");
my @i = (1..10); for(@i) { print("$_", "\n"); }

21
php/php.php Normal file
View file

@ -0,0 +1,21 @@
---
permalink: /cgi/php/index.php
---
<?php
header('Content-Type: text/plain');
echo('Hello from PHP!');
echo("\n\n");
echo('date("l jS \of F Y h:i:s A");');
echo("\n");
echo date("l jS \of F Y h:i:s A");
echo("\n\n");
echo('for ($x = 0; $x <= 10; $x++) { echo "$x\n"; }');
echo("\n");
for ($x = 1; $x <= 10; $x++) { echo "$x\n"; }
?>

16
python/python.py Executable file
View file

@ -0,0 +1,16 @@
---
permalink: /cgi/python/index.py
---
from datetime import datetime
from pprint import pprint
print("Hello from Python!")
print("")
print('print(datetime.today().strftime("%Y-%m-%d"))')
print(datetime.today().strftime('%Y-%m-%d'))
print("")
print("for i in range(1, 11): print(i);")
for i in range(1, 11): print(i);

13
ruby/ruby.rb Executable file
View file

@ -0,0 +1,13 @@
---
permalink: /cgi/ruby/index.rb
---
puts('Hello from Ruby!')
puts
puts('puts(Time.now.strftime("%d/%m/%Y %H:%M"))')
puts(Time.now.strftime("%d/%m/%Y %H:%M"))
puts
puts("(1..10).each { |n| puts n }")
(1..10).each { |n| puts n }

19
timestamp/timestamp.php Normal file
View file

@ -0,0 +1,19 @@
---
permalink: /cgi/timestamp/
---
<?php
session_start();
session_set_cookie_params(3600);
date_default_timezone_set("{{ site.timezone }}");
$timestamp = date('Y.m.d-h:i:s', time());
$milliseconds = floor(microtime(true) * 1000);
#echo($timestamp . "_" . time() . "_" . $milliseconds);
header('Content-Type: text/plain');
echo($timestamp . '.' . microtime(true));
?>

14
uname/uname.php Normal file
View file

@ -0,0 +1,14 @@
---
permalink: /cgi/uname/
---
<?php
$uname = shell_exec('uname -mrs');
$pos = strpos($uname, '-', 0);
$res = substr($uname, 0, $pos);
header('Content-Type: text/plain');
echo($res);
?>

11
uptime/uptime.php Normal file
View file

@ -0,0 +1,11 @@
---
permalink: /cgi/uptime/
---
<?php
$uptime = shell_exec('uptime');
$version = shell_exec('uptime -V');
header('Content-Type: text/plain');
echo('Server ' . substr($version, 0, -1) . ': ' . $uptime);
?>

29
whois/whois.php Normal file
View file

@ -0,0 +1,29 @@
---
permalink: /cgi/whois/
_note: https://www.w3docs.com/snippets/php/how-to-get-the-client-ip-address-in-php.html
---
<?php
if (!empty($_GET["host"]) and empty($_POST["host"])) {
$host = $_GET["host"];
} elseif (!empty($_POST["host"]) and empty($_GET["host"])) {
$host = $_POST["host"];
} else {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
//ip from share internet
$host = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
//ip pass from proxy
$host = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$host = $_SERVER['REMOTE_ADDR'];
}
}
$cmd = 'whois ' . $host;
$whois = shell_exec($cmd);
header('Content-Type: text/plain');
echo($whois);
?>