#!/bin/sh

#
# $Id: revscan,v 1.1.1.1 2008/03/17 09:18:45 raptor Exp $
#
# nuascan - Proof-of-concept of l33t X.25 rvcharge scanner
# Copyright (c) 2008 Marco Ivaldi <raptor@0xdeadbeef.info>
#
# "There is no Law beyond Do what thou wilt" -- A. Crowley
#
# Quick'n'dirty proof-of-concept of an X.25 reverse charge scanner. I'm 
# proud to confirm that X.25 hacking is still alive and kicking as of 2008;) 
# Dedicated to "my" beautiful lady z*
#
# Other l33t X.25 goodies: ADMscanLink.tgz, ADMx25_2.6.0.5.tar.gz, cudscan,
# fvudu, nuascan, padxploit.c, psibrute.com, vudu, x25bru.c, x25cat.pl,
# xotclient.tgz.
#       

# Some vars (change them if needed)
tmp=vudu.tmp
valid=vudu.rev
pad=pad

# Response codes (SCO netX.25 pad)
com="Verbindung hergestellt"
comdte="Verbindungsdauer"
dte="Call cleared by remote DTE"
der="Remote DTE is out of order"
rpe="Remote procedure error"
na="Access barred"
nc="Network congestion"
occ="Remote DTE is busy"

# Command line
nuafile="$1"
if [ "$nuafile" = "" ]; then
        echo "err: specify a filename"
        exit 1
fi

# Input control
if [ "`cat $nuafile 2>/dev/null`" = "" ]; then
        echo "err: corrupted input file"
        exit 1
fi

# Interactive logging
echo ""
echo "*** VUDU X.25 Scanner for Unix ***"
echo ""
echo "[ Starting reading NUAs from: ${nuafile} ]"

# Perform the scan
for nua in `cat $nuafile`
do
	$pad r $nua >$tmp 2>$tmp

# COM
       	if fgrep "$com" $tmp > /dev/null; then
               	echo "${nua}  (OK)"
               	echo "${nua}  (OK)" >> $valid
# COM+DTE
       	elif fgrep "$comdte" $tmp > /dev/null; then
               	echo "${nua}  COM+DTE"
               	echo "${nua}  COM+DTE" >> $valid
# DTE
       	elif fgrep "$dte" $tmp > /dev/null; then
               	echo "${nua}  DTE"
               	echo "${nua}  DTE" >> $valid
# DER
       	elif fgrep "$der" $tmp > /dev/null; then
               	echo "${nua}  DER"
               	echo "${nua}  DER" >> $valid
# RPE
       	elif fgrep "$rpe" $tmp > /dev/null; then
               	echo "${nua}  RPE"
               	echo "${nua}  RPE" >> $valid
# NA
       	elif fgrep "$na" $tmp > /dev/null; then
               	echo "${nua}  N/A"
               	echo "${nua}  N/A" >> $valid
# NC
       	elif fgrep "$nc" $tmp > /dev/null; then
               	echo "${nua}  NC"
               	echo "${nua}  NC" >> $valid
# OCC
       	elif fgrep "$occ" $tmp > /dev/null; then
               	echo "${nua}  OCC"
               	echo "${nua}  OCC" >> $valid
       	else
               	echo "${nua}"
       	fi
done

rm $tmp
echo "[ Ended scan from file: ${nuafile} ]"
echo ""
