spamchronic 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # MailPot
1
+ # Spam Chronic
2
2
 
3
- MailPot is a simple SMTP honeypot that will catch email and save it to a database
4
- MailPot works to gain some automatic analysis and probe detection
3
+ Spam Chronic is a simple SMTP honeypot that will catch email and save it to a database
4
+ Spam Chronic works to gain some automatic analysis and probe detection
5
5
 
6
6
  ## Features
7
7
  * Catches all email and stores it
@@ -10,5 +10,5 @@ MailPot works to gain some automatic analysis and probe detection
10
10
  * Written in EventMachine
11
11
 
12
12
  ## How
13
- 1. `gem install mailpot`
14
- 2. `mailpot`
13
+ 1. `gem install spamchronic`
14
+ 2. `spamchronic`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/bin/spamchronic CHANGED
@@ -2,4 +2,58 @@
2
2
  require "rubygems"
3
3
  require "bundler/setup"
4
4
  require 'mailpot'
5
+ Mailpot::Configuration.config do
6
+ parameter :smtp_ip, :smtp_port, :verbose, :daemon, :key_file, :banner
7
+ end
8
+
9
+ Mailpot::Configuration.config do
10
+ smtp_ip '127.0.0.1'
11
+ smtp_port '1025'
12
+ verbose false
13
+ daemon true
14
+ key_file '/etc/mailpot/keys.yml'
15
+ banner '{host} ESMTP'
16
+ end
17
+
18
+
19
+ opt_parse = OptionParser.new do |parser|
20
+ parser.banner = "Usage: mailpot [options]"
21
+ parser.version = File.open(File.expand_path("../../VERSION", __FILE__), 'rb') { |f| f.read }
22
+
23
+ parser.on("--ip IP", "Set the ip address of the smtp server") do |ip|
24
+ Mailpot::Configuration.config do
25
+ smtp_ip ip
26
+ end
27
+ end
28
+
29
+ parser.on("--keys KEYFILE", "Set the key file that contains AWS creds") do |f|
30
+ Mailpot::Configuration.config do
31
+ key_file f
32
+ end
33
+ end
34
+
35
+ parser.on("--port PORT", Integer, "Set the port of the smtp server") do |port|
36
+ Mailpot::Configuration.config do
37
+ smtp_port port
38
+ end
39
+ end
40
+
41
+ parser.on('-f', '--foreground', 'Run in forground') do
42
+ Mailpot::Configuration.config do
43
+ daemon ""
44
+ end
45
+ end
46
+
47
+ parser.on('-v', '--verbose', 'Be more verbose') do
48
+ Mailpot::Configuration.config do
49
+ verbose true
50
+ end
51
+ end
52
+
53
+ parser.on('-h', '--help', 'Display help information') do
54
+ puts parser
55
+ exit!
56
+ end
57
+ end
58
+ opt_parse.parse!
5
59
  Mailpot.run!
@@ -0,0 +1,25 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require 'active_support/all'
4
+
5
+ module Mailpot::Configuration
6
+ extend self
7
+
8
+ def parameter(*names)
9
+ names.each do |name|
10
+ attr_accessor name
11
+
12
+ # For each given symbol we generate accessor method that sets option's
13
+ # value being called with an argument, or returns option's current value
14
+ # when called without arguments
15
+ define_method name do |*values|
16
+ value = values.first
17
+ value ? self.send("#{name}=", value) : instance_variable_get("@#{name}")
18
+ end
19
+ end
20
+ end
21
+
22
+ def config(&block)
23
+ instance_eval &block
24
+ end
25
+ end
data/lib/mailpot/mail.rb CHANGED
@@ -7,6 +7,7 @@ require 'digest/md5'
7
7
  require 'aws'
8
8
  require 'mail'
9
9
  require 'net/smtp'
10
+ require 'json/pure'
10
11
 
11
12
  module Mailpot::Mail
12
13
  module_function
@@ -14,8 +15,9 @@ module_function
14
15
  @initialized = false
15
16
  # setup connections etc
16
17
  def initialize
17
- config = Mailpot.get_config
18
- yml = YAML.load_file config[:key_file]
18
+ yml = File.open("#{Mailpot::Configuration.key_file}") do |f|
19
+ YAML::load(f)
20
+ end
19
21
  @bucket = yml['bucket']
20
22
  @queue = yml['queue']
21
23
  @s3 = AWS::S3.new(yml)
@@ -41,10 +43,18 @@ module_function
41
43
  end
42
44
 
43
45
  def detect_probe(msg)
44
- config = Mailpot.get_config
45
46
  mail = Mail.new(msg[:source])
46
- # First rule we want to detect is when the ip of the honeypot is in the subject
47
- if mail.subject.include? config[:smtp_ip]
47
+ puts msg[:recipients].length
48
+ # Probes only have one recipient
49
+ if msg[:recipients].length > 1
50
+ return [false, false]
51
+ end
52
+ # probes are short
53
+ if msg[:source].length > 1024
54
+ return [false, false]
55
+ end
56
+ # ip address will be in the subject sometimes
57
+ if mail.subject.include? Mailpot::Configuration.smtp_ip
48
58
  return [true, forward_probe(msg)]
49
59
  end
50
60
  return [false, false]
data/lib/mailpot/smtp.rb CHANGED
@@ -13,8 +13,7 @@ class Mailpot::Smtp < EventMachine::Protocols::SmtpServer
13
13
  end
14
14
 
15
15
  def get_server_greeting
16
- c = Mailpot.get_config
17
- yml = YAML.load_file c[:key_file]
16
+ yml = File.open(Mailpot::Configuration.key_file) { |f| YAML::load(f) }
18
17
  host = get_server_domain
19
18
  t = DateTime.now.strftime('%a, %d %b %Y %H:%M:%S %z')
20
19
  banner = yml['banner']
@@ -24,7 +23,11 @@ class Mailpot::Smtp < EventMachine::Protocols::SmtpServer
24
23
  end
25
24
 
26
25
  def get_server_domain
27
- Socket.gethostbyname(Socket.gethostname).first
26
+ begin
27
+ Socket.gethostbyname(Socket.gethostname).first
28
+ rescue Exception => e
29
+ puts e.inspect
30
+ end
28
31
  end
29
32
 
30
33
  def receive_sender(sender)
data/lib/mailpot.rb CHANGED
@@ -8,70 +8,19 @@ require 'rbconfig'
8
8
  module Mailpot extend ActiveSupport::Autoload
9
9
  autoload :Smtp
10
10
  autoload :Mail
11
+ autoload :Configuration
11
12
 
12
13
  module_function
13
-
14
- @@defaults = {
15
- :smtp_ip => '127.0.0.1',
16
- :smtp_port => '1025',
17
- :verbose => false,
18
- :daemon => true,
19
- :key_file => '/etc/mailpot/keys.yml',
20
- :banner => '{host} ESMTP'
21
- }
22
-
23
- def parse! arguments=ARGV, defaults=@@defaults
24
- @@defaults.dup.tap do |options|
25
- OptionParser.new do |parser|
26
- parser.banner = "Usage: mailpot [options]"
27
- parser.version = File.read(File.expand_path("../../VERSION", __FILE__))
28
-
29
- parser.on("--ip IP", "Set the ip address of the smtp server") do |ip|
30
- options[:smtp_ip] = ip
31
- end
32
-
33
- parser.on("--keys KEYFILE", "Set the key file that contains AWS creds") do |f|
34
- options[:key_file] = f
35
- end
36
-
37
- parser.on("--port PORT", Integer, "Set the port of the smtp server") do |port|
38
- options[:smtp_port] = port
39
- end
40
-
41
- parser.on('-f', '--foreground', 'Run in forground') do
42
- options[:daemon] = false
43
- end
44
-
45
- parser.on('-v', '--verbose', 'Be more verbose') do
46
- options[:verbose] = true
47
- end
48
-
49
- parser.on('-h', '--help', 'Display help information') do
50
- puts parser
51
- exit!
52
- end
53
- end.parse!
54
- end
55
- end
56
-
57
- def get_config
58
- options &&= @@defaults.merge options
59
- options ||= parse!
60
- end
61
14
 
62
- def run! options=nil
63
- #options &&= @@defaults.merge options
64
- #options ||= parse!
65
- #@config = options
66
- options = get_config
15
+ def run!
67
16
  puts "Starting MailPot"
68
17
  EventMachine.run do
69
- rescue_port options[:smtp_port] do
70
- EventMachine.start_server options[:smtp_ip], options[:smtp_port], Smtp
71
- puts "==> smtp://#{options[:smtp_ip]}:#{options[:smtp_port]}"
18
+ rescue_port Mailpot::Configuration.smtp_port do
19
+ EventMachine.start_server Mailpot::Configuration.smtp_ip, Mailpot::Configuration.smtp_port, Smtp
20
+ puts "==> smtp://#{Mailpot::Configuration.smtp_ip}:#{Mailpot::Configuration.smtp_port}"
72
21
  end
73
-
74
- if options[:daemon]
22
+ puts "Daemon #{Mailpot::Configuration.daemon}"
23
+ if Mailpot::Configuration.daemon === true
75
24
  EventMachine.next_tick do
76
25
  puts "*** Mailpot now runs as a daemon by default"
77
26
  Process.daemon
metadata CHANGED
@@ -1,160 +1,124 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: spamchronic
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Matt Jezorek
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-02-16 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-17 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: activesupport
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &81440310 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 7
29
- segments:
30
- - 3
31
- - 0
32
- version: "3.0"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: eventmachine
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *81440310
25
+ - !ruby/object:Gem::Dependency
26
+ name: eventmachine
27
+ requirement: &81430870 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
29
+ requirements:
41
30
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 19
44
- segments:
45
- - 0
46
- - 12
47
- version: "0.12"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.12'
48
33
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: aws-sdk
52
34
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *81430870
36
+ - !ruby/object:Gem::Dependency
37
+ name: aws-sdk
38
+ requirement: &81430460 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
62
44
  type: :runtime
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: mail
66
45
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *81430460
47
+ - !ruby/object:Gem::Dependency
48
+ name: mail
49
+ requirement: &81429640 !ruby/object:Gem::Requirement
68
50
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
76
55
  type: :runtime
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
79
- name: rake
80
56
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *81429640
58
+ - !ruby/object:Gem::Dependency
59
+ name: rake
60
+ requirement: &81429150 !ruby/object:Gem::Requirement
82
61
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
90
66
  type: :development
91
- version_requirements: *id005
92
- - !ruby/object:Gem::Dependency
93
- name: rdoc
94
67
  prerelease: false
95
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *81429150
69
+ - !ruby/object:Gem::Dependency
70
+ name: rdoc
71
+ requirement: &81428640 !ruby/object:Gem::Requirement
96
72
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
104
77
  type: :development
105
- version_requirements: *id006
106
- description: " MailPot is a simple SMTP server honeypot that will catch emails and store\n them in S3 and then pop a message into SQS for later processing\n"
78
+ prerelease: false
79
+ version_requirements: *81428640
80
+ description: ! " MailPot is a simple SMTP server honeypot that will catch emails
81
+ and store\n them in S3 and then pop a message into SQS for later processing\n"
107
82
  email: mjezorek@gmail.com
108
- executables:
83
+ executables:
109
84
  - spamchronic
110
85
  extensions: []
111
-
112
- extra_rdoc_files:
86
+ extra_rdoc_files:
113
87
  - README.md
114
88
  - LICENSE
115
- files:
89
+ files:
116
90
  - README.md
117
91
  - LICENSE
118
92
  - VERSION
119
93
  - bin/spamchronic
94
+ - lib/mailpot.rb
120
95
  - lib/mailpot/events.rb
121
96
  - lib/mailpot/mail.rb
122
97
  - lib/mailpot/smtp.rb
123
- - lib/mailpot.rb
98
+ - lib/mailpot/configuration.rb
124
99
  homepage: http://mattjezorek.com/
125
100
  licenses: []
126
-
127
101
  post_install_message:
128
102
  rdoc_options: []
129
-
130
- require_paths:
103
+ require_paths:
131
104
  - lib
132
- required_ruby_version: !ruby/object:Gem::Requirement
105
+ required_ruby_version: !ruby/object:Gem::Requirement
133
106
  none: false
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- hash: 57
138
- segments:
139
- - 1
140
- - 8
141
- - 7
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
142
110
  version: 1.8.7
143
- required_rubygems_version: !ruby/object:Gem::Requirement
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
112
  none: false
145
- requirements:
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- hash: 3
149
- segments:
150
- - 0
151
- version: "0"
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
152
117
  requirements: []
153
-
154
118
  rubyforge_project:
155
- rubygems_version: 1.7.2
119
+ rubygems_version: 1.8.10
156
120
  signing_key:
157
121
  specification_version: 3
158
- summary: Runs an SMTP Server and catches emails, will pass probes when identified as a probe
122
+ summary: Runs an SMTP Server and catches emails, will pass probes when identified
123
+ as a probe
159
124
  test_files: []
160
-