Re: rlogin revealed
Article: 8353 of alt.hackers From: and1000@thor.cam.ac.uk (Austin Donnelly) Newsgroups: alt.hackers Subject: Re: rlogin revealed Date: 27 Jul 1995 21:11:20 GMT Organization: University of Cambridge, England Lines: 232 Approved: Austin Donnelly <and1000@cam.ac.uk> Message-ID: 3v8vdo$c93@lyra.csx.cam.ac.uk Reply-To: and1000@cam.ac.uk NNTP-Posting-Host: hammer.thor.cam.ac.uk Status: RO
[NB: This article is both posted & Cc'ed] In article <3v5ffa$c1o@umbc9.umbc.edu>, Jonas Schlein <schlein@umbc.edu> wrote: [Description of busy-waiting script] No no no no no! Busy-waiting is *evil*! :) (Unfortunately, in this case, you don't have any choice thanks to your sysadmin). >Just remember to use nohup so it will work after you log off! Optionally >you may put sleep() calls in your loop if you only expect your page to >be accessed say no more than once a minute... The sleep() call are *not* optional - they are *required* - even if it's no more than "sleep 5" to wait around 5 seconds. If you a sleep for even a small time, it's enough to keep the load on the machine down (and thus not be noticed by the Powers That Be :) >"Avoid computer viruses -- practice safe hex!" :> I posted, so here's my: ObHack: I have a friend working in Germany at the moment, unfortunately he's on a slow modem link, so can't do large ftp's. The solution was to write an ftp by mail server - a quick 3 hour hack (I already had a skeleton ftp engine). My .forward puts all my mail through a script to do random cunning stuff (sorting linux mailing list traffic into multiple inboxes) - but most importantly it will fork off the ftpproxy driver script if it decided the mail was an ftp request. The ftpproxy parses the mail, and builds a reply message. It runs the ftp engine, and puts the output from it into the reply message. It then uses a little C program to decide if it should stick the data through uuencode. Lastly it sends a log message to me, and the reply with data to the user. The ftp engine parses the ftp URL, and talks to the ftp server directly, noting any errors, and generally being paranoid :) If anyone want the source (2 perl files and a bit of C), mail me. I'll add the ftpproxy perl script to the end of this post for the curious.... Austin ---------- begin ftpproxy -------------------- #!/usr/bin/perl # expects control file (original mail message) filename as argv[0] $VERSION="0.2alpha"; $SENDMAIL="/usr/lib/sendmail"; $UUENCODE="/usr/bin/uuencode"; $SESLOG="/tmp/ftpproxy.log.$$"; $DATA="/tmp/ftpproxy.data.$$"; # the data for the user $FTPENGINE="/home/and1000/lib/ftp.engine"; $ISTEXT="/home/and1000/bin/istext"; $from=""; $subject=""; $timeout=""; $CONTROL=$ARGV[0]; open(LOG, ">$SESLOG") || &maildie("Couldn't write $SESLOG: $!"); $now=`date`; chop($now); if (!open(CTRL, $CONTROL)) { print LOG "Couldn't open control file $CONTROL: $!\n"; &bailout(); } while(<CTRL>) { /^From (\S+)/io && ($from eq "") && ($from=$1); /^Subject:\s+get:\s+(\S+)/io && ($subject eq "") && ($subject=$1); /^\s*timeout\s*=\s*(\d+)/io && ($timeout=$1); } close(CTRL); print LOG "Subject: Results of $subject\n\n"; print LOG "ftpproxy version $VERSION started $now\n\n"; if ($from eq "" || $subject eq "") { print LOG "Missing a 'Subject:' or 'From' line:\n"; print LOG "Subject=\"$subject\",\nfrom=\"$from\"\n"; &bailout(); } print LOG "Request is from \'$from\':\nURL <$subject>\n"; print LOG "Default timeout of 30secs overridden to ${timeout}secs\n" unless ($timeout eq ""); $qsubj=$subject; $qsubj =~ s/;/\\;/o; # quote ';' in the URL if (!open(RES, "$FTPENGINE $qsubj $DATA $from $timeout|")) { print LOG "\nCouldn't start ftp engine: $!\n"; &bailout(); } $now=`date`; chop($now); print LOG "\nStarted ftp engine at $now\n"; print LOG "---------------------------------------------------\n"; while(<RES>) { print LOG; } close(RES); print LOG "---------------------------------------------------\n"; $now=`date`; chop($now); print LOG "ftp engine finished $now\n\n"; if (! -r $DATA) { print LOG "No data retrieved (see previous error messages?)\n"; &bailout(); } if (system("$ISTEXT $DATA")>>8 == 1) # not plain text, so uuencode it { if ($subject =~ s/([^;]+);type=.*/$1/io) { $name=`/usr/bin/basename $subject`; } else { print LOG "I think your data may be corrupted: next time use the\n"; print LOG "\";type=i\" option to select binary mode.\n"; $name=`/usr/bin/basename $subject`; } if (!open(DATA, "$UUENCODE $DATA $name|")) { print LOG "Couldn't open pipe to uuencode to read data: $!\n"; &bailout(); } } else { if (!open(DATA, "<$DATA")) { print LOG "Couldn't open data file for incorporation in mail: $!\n"; &bailout(); } } $oldfh = select(LOG); $| = 1; print LOG "\n"; # flush log &mail($SESLOG, "and1000@hermes.cam.ac.uk"); # mail it to me $|=0; select($oldfh); # set it to be buffered again print LOG "\n--------------- ftp data starts here ---------------\n"; while(<DATA>) { print LOG; } close(DATA); print LOG "--------------- ftp data ends ---------------\n"; # that's all! # flush & close, then mail it out! close(LOG); &mail($SESLOG, $from); # clean up tmp files unlink($SESLOG); unlink($CONTROL); # if possible... unlink($DATA); # if possible... # # END!!! # # # useful sub routines # # maildie("foo") mails me the text foo & exits sub maildie { local($msg) = @_; system("echo ftpproxy: $msg | $SENDMAIL -odi -oem -oi and1000@hermes.cam.ac.uk"); exit(0); } # mail("filename", "address") mails address the file sub mail { local($file, $address) = @_; system("$SENDMAIL -odi -oem -oi $address <$file"); } # close & flush the log file, mail it to me, clean up tmp files, then exit sub bailout { print LOG "\n\n"; close(LOG); &mail($SESLOG, "and1000@hermes.cam.ac.uk"); &mail($SESLOG, $from) if ($from ne ""); unlink($SESLOG); unlink($CONTROL); # if possible... unlink($DATA); # if possible... exit(0); }