From 79a323cb54e2b2b1b67aa7492b25fb44036e7007 Mon Sep 17 00:00:00 2001 From: Harvie Date: Mon, 24 May 2010 22:52:36 +0200 Subject: [PATCH] Added junk found in ~harvie at harvie.cz --- c/drivespeed.c | 14 +++ c/rand.c | 23 +++++ php/DoS/test.php | 9 ++ php/DoS/udp.php | 5 ++ php/fopen-bug.php | 21 +++++ php/hfirewall/firewall.php | 170 ++++++++++++++++++++++++++++++++++++ php/hfirewall/fwscript.sh | 50 +++++++++++ php/hfirewall/hfwrules.conf | 47 ++++++++++ php/hfirewall/output.txt | 25 ++++++ php/hfirewall/tmp.txt | 46 ++++++++++ php/hfirewall/unfw.sh | 9 ++ php/http_server.php | 165 ++++++++++++++++++++++++++++++++++ php/idgen.php | 21 +++++ php/parser.php | 11 +++ php/php_demo.php | 31 +++++++ 15 files changed, 647 insertions(+) create mode 100644 c/drivespeed.c create mode 100644 c/rand.c create mode 100755 php/DoS/test.php create mode 100755 php/DoS/udp.php create mode 100755 php/fopen-bug.php create mode 100755 php/hfirewall/firewall.php create mode 100755 php/hfirewall/fwscript.sh create mode 100644 php/hfirewall/hfwrules.conf create mode 100644 php/hfirewall/output.txt create mode 100644 php/hfirewall/tmp.txt create mode 100755 php/hfirewall/unfw.sh create mode 100755 php/http_server.php create mode 100755 php/idgen.php create mode 100755 php/parser.php create mode 100755 php/php_demo.php diff --git a/c/drivespeed.c b/c/drivespeed.c new file mode 100644 index 0000000..fe247f1 --- /dev/null +++ b/c/drivespeed.c @@ -0,0 +1,14 @@ +#include +#include + +int main() { + +char drive[] = "/dev/hdc"; +int stime = time(NULL); +printf("%d\n", stime); +system("cat /dev/hdc > /dev/null"); +stime = time(NULL); +printf("%d\n", stime); +return(0); + +} diff --git a/c/rand.c b/c/rand.c new file mode 100644 index 0000000..0c06846 --- /dev/null +++ b/c/rand.c @@ -0,0 +1,23 @@ +#include +#include +#include + +int main() { + int g, r, max = 10; + char buff[80]; + while(1) { + r = rand() % max; + printf("hadej cislo (od 0 do" + "%d):", max - 1); + fgets(buff, sizeof(buff)-2, stdin); + *strpbrk(buff, "\r\n") = '\0'; + if (!*buff) + break; + g = strtol(buff, NULL, 10); + if(r == g) puts("Bravo maestro!"); + else printf("Loooooooozre! " + "bylo to %d\n", r); + + } + puts("konec!"); +} diff --git a/php/DoS/test.php b/php/DoS/test.php new file mode 100755 index 0000000..d5541f4 --- /dev/null +++ b/php/DoS/test.php @@ -0,0 +1,9 @@ +#!/usr/bin/php + diff --git a/php/DoS/udp.php b/php/DoS/udp.php new file mode 100755 index 0000000..6af1c19 --- /dev/null +++ b/php/DoS/udp.php @@ -0,0 +1,5 @@ +#!/usr/bin/php + + diff --git a/php/hfirewall/firewall.php b/php/hfirewall/firewall.php new file mode 100755 index 0000000..714bfad --- /dev/null +++ b/php/hfirewall/firewall.php @@ -0,0 +1,170 @@ +#! /usr/bin/php + /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts\n"); +} else { + fwrite($ipt, "echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts\n"); +} + +if($accept_source_route) { + echo("Accept source routed packets\n"); + fwrite($ipt, "echo 1 > /proc/sys/net/ipv4/conf/all/accept_source_route\n"); +} else { + fwrite($ipt, "echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route\n"); +} + +if($tcp_syncookies) { + echo("Enable TCP SYN cookie protection from SYN floods\n"); + fwrite($ipt, "echo 1 > /proc/sys/net/ipv4/tcp_syncookies\n"); +} else { + fwrite($ipt, "echo 0 > /proc/sys/net/ipv4/tcp_syncookies\n"); +} + +if($accept_redirects) { + echo("Accept ICMP redirect messages\n"); + fwrite($ipt, "echo 1 > /proc/sys/net/ipv4/conf/all/accept_redirects\n"); +} else { + fwrite($ipt, "echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects\n"); +} + +if($send_redirects) { + echo("Send ICMP redirect messages\n"); + fwrite($ipt, "echo 1 > /proc/sys/net/ipv4/conf/all/send_redirects\n"); +} else { + fwrite($ipt, "echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects\n"); +} + +if($rp_filter) { + echo("Enable source address spoofing protection\n"); + fwrite($ipt, "echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter\n"); +} else { + fwrite($ipt, "echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter\n"); +} + +if($log_martians) { + echo("Log packets from Martians (with impossible source addresses)\n"); + fwrite($ipt, "echo 1 > /proc/sys/net/ipv4/conf/all/log_martians\n"); +} else { + fwrite($ipt, "echo 0 > /proc/sys/net/ipv4/conf/all/log_martians\n"); +} + +fwrite($ipt, "\n"); +echo("\n"); + +///Rules IPTables////////////////////////////////////////////////////////////////// +fwrite($ipt, "#Rules IPTables:\n"); +echo("Rules IPTables:\n"); + +//Rules flush +if($flush_rules) { + echo("Flush old rules\n"); + fwrite($ipt, "$iptbin --flush\n\n"); +} + +//Rules loopback +if($loopback_allow_all == true) { + echo("Allow all traffic on loopback\n"); + fwrite($ipt, "$iptbin -A INPUT -i lo -j ACCEPT\n"); + fwrite($ipt, "$iptbin -A OUTPUT -o lo -j ACCEPT\n\n"); +} + +//Rules policies +echo("Default policies: "); +foreach($default_policies as $default_policy) { + fwrite($ipt, "$iptbin --policy $default_policy\n"); + echo("$default_policy, "); +} +fwrite($ipt, "\n"); +echo("\n"); + +//Rules outbound traffic +if($allow_outbound_traffic) { + fwrite($ipt, "$iptbin -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\n"); + fwrite($ipt, "$iptbin -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT\n\n"); +} + +//Rules open ports +echo("Open ports: "); +foreach($open_ports as $open_port) { + fwrite($ipt, "$iptbin -A INPUT -p tcp --dport $open_port -m state --state NEW -j ACCEPT\n"); + echo("$open_port, "); +} +fwrite($ipt, "\n"); +echo("\n"); + +//Drop other +if(drop_other == true) { + echo("Other traffic will be droped\n"); + fwrite($ipt, "$iptbin -A INPUT -j DROP\n"); +} + + + +//Close iptables script +fwrite($ipt, "\n\n"); +echo("\nClosing $fwscript\n"); +fclose($ipt); + +//Chmod u+x iptables script +if($chmod) { + echo("chmod u+x $fwscript\n"); + system("chmod u+x $fwscript"); +} +//Run iptables script +if($run) { + echo("Running firewall script...\n\n"); + system("./".$fwscript); +} \ No newline at end of file diff --git a/php/hfirewall/fwscript.sh b/php/hfirewall/fwscript.sh new file mode 100755 index 0000000..3725f6f --- /dev/null +++ b/php/hfirewall/fwscript.sh @@ -0,0 +1,50 @@ +#!/bin/sh +#This firewall script was generated by Harvie's php firewall (0.1 Alpha) + +#Author: Harvie 2oo7 +#Description: Sample HFW Configuration File (THX2 http://www.brandonhutchinson.com/iptables_fw.html) +###################################################################################################### + + +#Rules Others: +echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts +echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route +echo 1 > /proc/sys/net/ipv4/tcp_syncookies +echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects +echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects +echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter +echo 1 > /proc/sys/net/ipv4/conf/all/log_martians + +#Rules IPTables: +/sbin/iptables --flush + +/sbin/iptables -A INPUT -i lo -j ACCEPT +/sbin/iptables -A OUTPUT -o lo -j ACCEPT + +/sbin/iptables --policy INPUT DROP +/sbin/iptables --policy OUTPUT DROP +/sbin/iptables --policy FORWARD DROP + +/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT +/sbin/iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT + +/sbin/iptables -A INPUT -p tcp --dport 20 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 21 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 8080 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 111 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 113 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 139 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 445 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 548 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 901 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 1023 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 2049 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 5500 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 5900 -m state --state NEW -j ACCEPT +/sbin/iptables -A INPUT -p tcp --dport 5901 -m state --state NEW -j ACCEPT + +/sbin/iptables -A INPUT -j DROP + + diff --git a/php/hfirewall/hfwrules.conf b/php/hfirewall/hfwrules.conf new file mode 100644 index 0000000..bdab17d --- /dev/null +++ b/php/hfirewall/hfwrules.conf @@ -0,0 +1,47 @@ + /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts + +# Drop source routed packets +echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route + +# Enable TCP SYN cookie protection from SYN floods +echo 1 > /proc/sys/net/ipv4/tcp_syncookies + +# Don't accept ICMP redirect messages +echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects + +# Don't send ICMP redirect messages +echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects + +# Enable source address spoofing protection +echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter + +# Log packets with impossible source addresses +echo 1 > /proc/sys/net/ipv4/conf/all/log_martians + +# Flush all chains +/sbin/iptables --flush + +# Allow unlimited traffic on the loopback interface +/sbin/iptables -A INPUT -i lo -j ACCEPT +/sbin/iptables -A OUTPUT -o lo -j ACCEPT + +# Set default policies +/sbin/iptables --policy INPUT DROP +/sbin/iptables --policy OUTPUT DROP +/sbin/iptables --policy FORWARD DROP + +# Previously initiated and accepted exchanges bypass rule checking +# Allow unlimited outbound traffic +/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT +/sbin/iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT + +# Allow incoming TCP port 22 (ssh) traffic from office +/sbin/iptables -A INPUT -p tcp -s 192.168.1.100 --dport 22 -m state --state NEW -j ACCEPT + +# Drop all other traffic +/sbin/iptables -A INPUT -j DROP + +# Have these rules take effect when iptables is started +/sbin/service iptables save \ No newline at end of file diff --git a/php/hfirewall/unfw.sh b/php/hfirewall/unfw.sh new file mode 100755 index 0000000..81749c3 --- /dev/null +++ b/php/hfirewall/unfw.sh @@ -0,0 +1,9 @@ +#!/bin/sh +#HFirewall Uninstall 0.1 Alpha +#This will disable IPTables blocking + +iptables --flush +iptables --policy INPUT ACCEPT +iptables --policy OUTPUT ACCEPT +iptables --policy FORWARD ACCEPT + diff --git a/php/http_server.php b/php/http_server.php new file mode 100755 index 0000000..45f2726 --- /dev/null +++ b/php/http_server.php @@ -0,0 +1,165 @@ +#!/usr/bin/php + 1) $port = trim($argv[1]); + if($argc > 2) $interface = trim($argv[2]); +} + +///FUNCTIONS////////////////////////////////////////////////////////////////////// +function send_dir_listing($fp, $directory) { + $num = "0"; + //Header + @fwrite($fp, "\nIndex of $directory\n\n"); + @fwrite($fp, "Available volumes:
\n"); + + //Special folders + @fwrite($fp, "[/]\n"); //Server root + if(is_dir("/")) { //Unix root + @fwrite($fp, "[//]\n"); + } + + //Available volumes + $dsks = "cdefghijklmnopqrstuvwxyz"; //Show this volumes (if available) + for($i=0;$i$vol:]\n"); + } + //echo($dsks[$i].":"); + } + @fwrite($fp, "
\n\n"); + + //Directory listing + @fwrite($fp, "Directory listing of $directory :

\n\n"); + @fwrite($fp, "[DIR] Parent Directory (../)
\n"); + $files=opendir ($directory); + while (false!==($file = readdir($files))) + { + if ($file != "." && $file != "..") + { + $num++; + if(is_dir("$directory/$file")) { + fwrite($fp, "$num - [DIR] $file
\n"); + } else { + fwrite($fp, "$num - $file
\n"); + } + } + } + + //Footer + fwrite($fp, "
\nTotal: $num\n
\n"); +} + +///CODE/////////////////////////////////////////////////////////////////////////// +echo("\n\tStarting Harvie's HTTPd at:\n\ttcp://$interface:$port\n\n"); +//system("title Harvie's HTTPd at tcp://$interface:$port"); //Microsoft Windows only +set_time_limit(0); +$sss = stream_socket_server("tcp://$interface:$port"); + +while(1) { + @$sfp = stream_socket_accept($sss); + if(!$sfp) continue; + + $loop = 1; + while($sfp && !@feof($sfp) && $loop) { + $line = fgets($sfp); + //echo($line); + if(eregi("(GET|POST)", $line)) { + $line = trim($line); + //echo($line); + $line = explode(" ", $line); + + $line[1] = trim(urldecode($line[1])); + + + if($line[1] == "/") { + $line[1] = "./"; + } else { + $line[1] = substr($line[1], 1); + } + + + if(is_file($line[1])) { //200 OK FILE + fwrite($sfp, $okheader); + echo("200 ".$line[1]); + $fp = fopen($line[1], "rb"); + while( fwrite($sfp, fgets($fp)) ); + @fclose($sfp); + echo(" SENT!\n"); + } + + elseif(is_dir($line[1])) { //200 OK DIR + if(substr($line[1], strlen($line[1])-1) != "/") { //301 MOV DIR + $header = ("/".$line[1]."/"); + echo("301 ".$line[1]." -> $header\n"); + $header = str_replace("%DIR%", $header, $dirheader); + //$header = str_replace("./", "./", $dirheader); + //echo($header); + fwrite($sfp, $header); + @fclose($sfp); + break; + } + echo("200 [DIR] ".$line[1]."\n"); + send_dir_listing($sfp, $line[1]); + } + + else { //404 NOT FOUND + echo("404 ".$line[1]."\n"); + fwrite($sfp, $badheader); + fwrite($sfp, $err404); + @fclose($sfp); + } + + $loop = 0; + } + } + @fclose($sfp); +} + +?> diff --git a/php/idgen.php b/php/idgen.php new file mode 100755 index 0000000..29d1382 --- /dev/null +++ b/php/idgen.php @@ -0,0 +1,21 @@ +#!/usr/bin/php +", $line[1]); + echo($line[0]."\n"); + } +} diff --git a/php/php_demo.php b/php/php_demo.php new file mode 100755 index 0000000..2c56e54 --- /dev/null +++ b/php/php_demo.php @@ -0,0 +1,31 @@ +#!/usr/bin/php +0;$x--) echo("#"); + echo("\x0d"); +} + +$tnum = rand(0,99); +echo("Find: ".($find = md5($tnum)).":??\n"); +$i = 0; +while(1) { + $tnum = rand(0,99); + $test = md5($tnum); + echo("\x0d MD5: ".$test." ".$tocse[$i]." :$tnum "); + usleep(50000); + if($test == $find) { break; } + $i++; + if($i > 3) { $i = 0; } +} +echo("\x0d MD5: ".$test.":$tnum \n Found\x07!!!\n\n"); + +} + -- 2.30.2