summaryrefslogtreecommitdiffstats
path: root/modules/noise/modules/sendmail
blob: 182d96e3c51b4d22d8de8ea8414becba9f29cf4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
import os,sys,smtplib,string
'''
  Mail Plugin for the noise telnet suite
  See: http://docs.python.org/library/smtplib.html
  Author: Felix
'''

# help
if len(sys.argv) == 2:
    if sys.argv[1] == "--help":
      print "send an e-mail ( \"TO(s)\" \"SUBJECT\" [string instead of EOF])"
      sys.exit(0)

# sanity 
if len(sys.argv) <= 2:
  print "wrong number of parameters, see help"
  sys.exit(1)

# write variables 
# check of EOF
if len(sys.argv) == 4 : 
  EOFstring="%s\n"% sys.argv[3]
else:
  EOFstring="EOF\n"

fromaddr=u"Karl Koch<shockspasm@googlemail.com>"
toaddrs=sys.argv[1]
subject=sys.argv[2]


#write header:
msg = u"From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, toaddrs,subject)
print "Write your text now, finish with %s" % EOFstring
sys.stdout.flush() # flushing is important to make sure the line is written

while 1:
  try:
    line = sys.stdin.readline()
    if line == EOFstring:
      break
    msg = msg + line
  except EOFError:
    break

msg = msg + "[!] Written with NOISE telnet"

print "Thank you for your message! Delivering it now..."
sys.stdout.flush()
server = smtplib.SMTP('localhost')
#server.set_debuglevel(1)
server.sendmail(fromaddr,toaddrs.split(','),msg)
server.quit()
print "mail send successfully"
sys.exit(0)