#!/bin/sh
# This is a very messy beta version of a USENET news hacker
# It can be used to forge, cancel or anonymously post to
# moderated groups.  It can also post normally, so I'm
# not suggesting it's use for immoral purposes :)
#
# Make sure edit, inews, nntp and test are set to the correct
# full pathname for these commands
# Also note that you must have inews or nntp to use this script
# defhost is the default host to nntpxmit the article to
# there are many hosts that will accept xfers from anywhere
# **don't use sol.ctr.columbia.edu it logs the nntp source and
# appends it to the article 
# Tested on SunOS 4.1.3 and Pyramid OSx
# No warranties or responbilities implied.
# Irish_2

edit="/usr/ucb/vi"
inews="/usr/lib/news/inews"
nntp="/usr/lib/news/nntpxmit"
test="/bin/test"
defhost="localhost"
tmppart=$HOME/.harticle
echo 'Hacked Newsposter Version 1.0 beta'
echo 
echo -n 'Newsgroups: '
read newsg
echo
echo -n 'From: '
read from
echo
echo -n 'Path: [example: foo!bar!here!there]: '
read path
echo
echo -n 'Subject: '
read subject
echo
echo -n 'Enter Message-ID: [example: <12345@foo.bar>]: '
read messid
echo
echo  'Enter Date '
echo  'Format is important, [example: 4 May 93 03:07:43 GMT] '
echo -n '<return for current> : '
read date
 case $date in
   '') date=`date -u +'%d %h %y %T GMT`;;
    *) ;;
 esac
echo
echo -n 'Organization: '
read org
echo
echo -n 'Posting to Moderated Group [y,n] ? '
read ans
  case $ans in
     y|Y) echo  'Address or comment for "Approved" line: '
          read approv;
          echo $approv;;
       *) approv="";;
   esac
echo
echo -n 'Cancelling an Article [y,n] ? '
read ans
  case $ans in
    y|Y) echo 'Enter Article ID to cancel ';
         echo 'From: line must match From: line in cancelled article';
         echo -n 'Example <12345@foo.bar>: ';
         read cancid;
         echo $cancid;;
      *) ;;
  esac

case $approv in

  "") echo "Path: $path 
From: $from
Newsgroups: $newsg
Subject: $subject
Message-ID: $messid
Date: $date
Organization: $org" > $tmppart;;

  *) echo "Path: $path
From: $from
Newsgroups: $newsg
Subject: $subject
Message-ID: $messid
Date: $date
Organization: $org
Approved: $approv " > $tmppart;;

esac
 
case $cancid in

  "");;
   
   *) echo "Control: cancel $cancid" >> $tmppart;
      grep 'Approved:' $tmppart >> /dev/null \
      || echo "Approved: $from" >> $tmppart;; 
esac 
echo >> $tmppart
state="edit" 

while $test "$state" = "edit"; do
echo
echo -n "Edit, Send, Abort [E,S,A]:"
read ans
case $ans in
   e*|E*) state="edit";
          $edit $tmppart;;
   s*|S*) state="send";;
   a*|A*) exit 0;;
esac
done

while $test "$state" != "sent"; do
echo
echo -n 'Send via nntp or inews [n,i] ? '
read send
case $send in
   n*|N*) state=sent;
          echo -n "Host to nntpxmit to: [$defhost] ";
          read nntphost;
          $test "$nntphost" = "" && nntphost=$defhost;
          echo;
          $nntp -d -a $nntphost:$tmppart;;
   i*|I*) state=sent;
          chmod 644 $tmppart;
          $inews -p $tmppart;;
       *) ;;
esac
done
echo
