#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.0.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2004-12-17 15:42 CEST by <user@portabl>.
# Source directory was `/home/user'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 3827 -rwxr--r-- hidemsg.py
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
if test "$gettext_dir" = FAILED && test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
set `$dir/gettext --version 2>&1`
if test "$3" = GNU
then
gettext_dir=$dir
fi
fi
if test "$locale_dir" = FAILED && test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
echo=echo
else
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then
shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then
shar_touch='touch -am $3$4$5$6$2 "$8"'
else
shar_touch=:
echo
$echo 'WARNING: not restoring timestamps. Consider getting and'
$echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
#
if mkdir _sh11693; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= hidemsg.py ==============
if test -f 'hidemsg.py' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'hidemsg.py' '(file already exists)'
else
$echo 'x -' extracting 'hidemsg.py' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'hidemsg.py' &&
#!/usr/bin/python
import base64
import os
import getopt
import sys
import GnuPGInterface
X
#Subject of news message
sb="Very suspicious subject "
#Contents of message if not read from file
msg="This is a very important message to be hidden in random contents\n"\
X "It will be difficult to discover it"
#Length of random contents
mlen=5312
#Keyring containing recipient key
keyring="./foo.pub"
#Mail address of recipient - to identify GPG key
recipient='
jsm...@strict.secret.com'
#Real name of recipient
recipient_name='John Smith'
X
help="This is a tool generating either Echelon jamming message\n\
or a real hidden message. Each of them is sent anonymously\n\
to the usenet groups alt.test and alt.test.test.\n\
Therefore it is impossible to trace both sender and recipient.\n\
Usage:\n\
hidemsg.py -r recipient -f msg_file -n recipient_name -s news_subject -k keyring \n\
or hidemsg.py -h \n\
\n\
recipient = e-mail address or fingerprint (better) to identify recipient's GPG key\n\
X don't use published GPG keys - it will disclose recipient's identity\n\
X use specialy prepared fake keys with fake names\n\
msg_file = file with real message to send\n\
recipient_name = \"real recipient name\" - fake of course\n\
news_subjec = subject of the fake or encrypted message in usenet group\n\
keyring = path to file containing recipient's key\n\
"
X
dontgen=False
X
opts,args = getopt.getopt(sys.argv[1:], "r:f:n:s:k:h")
for o,a in opts:
X if o=="-h":
X print help
X sys.exit(0)
X if o=="-r":
X recipient=a
X dontgen=True
X if o=="-n":
X recipient_name=a
X dontgen=True
X if o=="-f":
X f=open(a,"r")
X msg=f.read()
X f.close()
X if o=="-s":
X sb=a
X if o=="-k":
X keyring=a
X
gnupg = GnuPGInterface.GnuPG()
gnupg.options.meta_interactive = 0
X
X
# Set recipient to the random e-mail address
X
print "I'm generating a random envelope message..."
f=open('/dev/random','r')
b=f.read(1)
# Set length of the message below
l=mlen+ord(b)
a=f.read(l)
# Calculate the length of the first random part
l1=ord(f.read(1))
l2=ord(f.read(1))
l1=int((l*(l1+256*l2))/65536.0)
a1=a[0:l1]
a2=a[l1:l]
a=a1+"\n\n"+msg+"\n\n"+a2
s=base64.encodestring(a)
a=f.read(103)
passphrase=base64.encodestring(a)
b=f.read(1)
sb=sb+str(ord(b))
b=f.read(1)
sb=sb+str(ord(b))
b=f.read(1)
sb=sb+str(ord(b))
X
# Either generate the key, or import it from a file
# Set the key length in Subkey-Length line, 4096 is a good value but the key generation is long
# 1024 - a good value for testing
if not dontgen:
X print "I'm generating a random GPG key..."
X proc = gnupg.run(['--gen-key'], create_fhs=['stdin', 'stdout','logger'])
X proc.handles['stdin'].write('''Key-Type: DSA
X Key-Length: 1024
X Subkey-Type: ELG-E
X Subkey-Length: 4096
X Name-Real: '''+recipient_name+'''
X Name-Email: '''+recipient+'''
X Expire-Date: 2y
X Passphrase: abc
X %pubring foo.pub
X %secring foo.sec
X ''')
X proc.handles['stdin'].close()
X report = proc.handles['logger'].read()
X proc.handles['logger'].close()
X print report
X proc.wait()
print "I'm encrypting the message..."
gnupg.options.armor = 1
gnupg.passphrase = 'abc'
gnupg.options.recipients = [ recipient ]
p1=gnupg.run( ['--encrypt',
'--keyring',keyring,
'--trust-model','always'],create_fhs=['stdin', 'stdout', 'passphrase'])
p1.handles['passphrase'].write(passphrase)
p1.handles['passphrase'].close()
p1.handles['stdin'].write(s)
p1.handles['stdin'].close()
s = p1.handles['stdout'].read()
p1.handles['stdout'].close()
p1.wait()
print s
# Debug
f2=open("/tmp/m","w")
f2.write(s)
f2.close()
print "I'm sending a message through the mixmaster chain..."
p=os.popen("mixmaster -s \""+sb+"\" -c 7 -l \*,\*,\*,\* -g alt.test,alt.test.test",'w')
p.write(s)
p.close()
X
SHAR_EOF
(set 20 05 06 07 12 41 35 'hidemsg.py'; eval "$shar_touch") &&
chmod 0744 'hidemsg.py' ||
$echo 'restore of' 'hidemsg.py' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'hidemsg.py:' 'MD5 check failed'
634d1ab5d5aaa1d5b54a8b34a52a6d28 hidemsg.py
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'hidemsg.py'`"
test 3827 -eq "$shar_count" ||
$echo 'hidemsg.py:' 'original size' '3827,' 'current size' "$shar_count!"
fi
fi
rm -fr _sh11693
exit 0