tarbit 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/bin/tarbit +4 -1
- data/lib/tarbit/server.rb +7 -2
- data/lib/tarbit/statistic.rb +2 -1
- data/lib/tarbit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94cb32b706a9f0bfd2a036dbc831aa6702b4a9795d212faa9b0c55ae9038e43c
|
4
|
+
data.tar.gz: 4da4a50fea4bca2a4e90bf5397cc5c302380f8623222223361c2b227401ddd43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17847c8874fe99434b8c9b1e47aaac142f506c2f2c97b5e24c9870052bdbc89751197d6e8a12f2b953a6a2a6ff35bf2032f9117a7503c69ca3919254f118c289
|
7
|
+
data.tar.gz: c8219d0ad15c5ece548d626a6049daf64d6aab085e2eb2a0780c2047c9794c4d83f8cfd8c7e5099f3795f29545da4f5c46d08839d20c9b5305b55e1730fe83ad
|
data/.gitignore
CHANGED
data/bin/tarbit
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'commander/import'
|
4
4
|
require 'tarbit'
|
5
|
+
require 'fileutils'
|
5
6
|
|
6
7
|
# :name is optional, otherwise uses the basename of this executable
|
7
8
|
program :name, 'Tarbit - SSH Tarpit using Ruby'
|
@@ -14,10 +15,12 @@ command :serve do |c|
|
|
14
15
|
c.option '--debug', nil, 'Runs the apollo server in debug mode'
|
15
16
|
c.option '--suffix STRING', String, 'Adds a suffix to bar'
|
16
17
|
c.action do |args, options|
|
18
|
+
|
19
|
+
FileUtils.mkdir_p File.expand_path ('~/.tarbit/stats/')
|
17
20
|
puts "Starting tarbit ssh tarpit"
|
18
21
|
|
19
22
|
server = Tarbit::Server.new
|
20
|
-
statistic = Tarbit::Statistic.new(server,
|
23
|
+
statistic = Tarbit::Statistic.new(server, 600)
|
21
24
|
|
22
25
|
Async do |task|
|
23
26
|
statistic.watch
|
data/lib/tarbit/server.rb
CHANGED
@@ -30,17 +30,22 @@ module Tarbit
|
|
30
30
|
stream = Async::IO::Stream.new(peer)
|
31
31
|
Async.logger.info "New connection: #{stream}"
|
32
32
|
|
33
|
+
id = SecureRandom.uuid
|
34
|
+
|
33
35
|
@connections << {
|
34
36
|
created_at: Date.new,
|
35
|
-
id:
|
37
|
+
id: id
|
36
38
|
}
|
37
39
|
|
38
40
|
while true do
|
39
41
|
task.sleep 1
|
42
|
+
if stream.eof?
|
43
|
+
raise Async::TimeoutError.new
|
44
|
+
end
|
40
45
|
stream.write "#{rand(10)}\r\n"
|
41
46
|
end
|
42
47
|
rescue Async::TimeoutError => e
|
43
|
-
@connections.
|
48
|
+
@connections = @connections.reject { |stats| stats.fetch(:id) == id }
|
44
49
|
Async.logger.info "Connection closed: #{stream}"
|
45
50
|
end
|
46
51
|
end
|
data/lib/tarbit/statistic.rb
CHANGED
@@ -22,6 +22,7 @@ module Tarbit
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def write_line_chart
|
25
|
+
return if @server.connections.size == 0 and @history.size == 0
|
25
26
|
|
26
27
|
# Add point in time
|
27
28
|
@history << {
|
@@ -38,7 +39,7 @@ module Tarbit
|
|
38
39
|
|
39
40
|
g.data :Bots, @history.map {|point_in_time| point_in_time.fetch(:connections).size }
|
40
41
|
|
41
|
-
g.write('
|
42
|
+
g.write(File.expand_path ('~/.tarbit/stats/line_chart.png'))
|
42
43
|
end
|
43
44
|
|
44
45
|
end
|
data/lib/tarbit/version.rb
CHANGED