one_gadget 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f4b89f8c349c0a4032f783f731292e1ef351c6e
4
- data.tar.gz: 826c333bc9cf1aa3821e4aef5e8a424230267a4c
3
+ metadata.gz: 4a6779c684ad439f1cf8fe2decda8d8bc59ef190
4
+ data.tar.gz: 125913223a512eab64d76c52026e03e7c2535ddc
5
5
  SHA512:
6
- metadata.gz: 13558c2beeb1cdfe30f22e67abc5bcac41f24c91fb005201a14bb2c198bb9ee279c65705176d1bf01f5b2c0f7824fae067d1e02e177a5644a0bff4d002b152d9
7
- data.tar.gz: 17783b51d03eecb5ad9adcad404d24ca82aec3eddd7b29c06df9f7706ab66aaac18026824b7bed56362eff342ed43ee0d128d3ab3a8def689d0cfeb5f754c20a
6
+ metadata.gz: 460f93ea54b9a0b8c5554bfcd941e58bbc901a54c5072ea036246e0e6c18f1bb0d135db9b255de50c8d7341970db11af5042a501447582805165ee19dab45a87
7
+ data.tar.gz: a1ae45ffd14c9a2a432bf0b4f7411cdadf9e005440ca74eb62b1cb83a196714932096743491176960cbfb635f98cde59757d544a9a15070f3131afbafaaea00c
data/README.md CHANGED
@@ -28,7 +28,7 @@ Note: require ruby version >= 2.1.0, you can use `ruby --version` to check.
28
28
 
29
29
  ## Implementation
30
30
 
31
- OneGadget use simple self-implement symbolic execution to find the constraints of gadgets.
31
+ OneGadget uses simple self-implement symbolic execution to find the constraints of gadgets to success.
32
32
 
33
33
  The article introducing how I develop this tool can be found [here](https://david942j.blogspot.com/2017/02/project-one-gadget-in-glibc.html).
34
34
 
@@ -67,6 +67,9 @@ def one_gadget(arg = nil, **options)
67
67
  OneGadget.gadgets(**options)
68
68
  end
69
69
 
70
+ require 'one_gadget/update'
71
+ OneGadget::Update.check!
72
+
70
73
  require 'one_gadget/fetcher'
71
74
  require 'one_gadget/helper'
72
75
  require 'one_gadget/logger'
@@ -29,7 +29,7 @@ module OneGadget
29
29
  # @param [String] cmd
30
30
  # @return [Boolean]
31
31
  def match?(cmd)
32
- cmd.include?(inst)
32
+ cmd.include?(inst + ' ')
33
33
  end
34
34
  end
35
35
  end
@@ -10,7 +10,7 @@ module OneGadget
10
10
  prep = ' ' * 12
11
11
  message = msg.lines.map.with_index do |str, i|
12
12
  next str if i.zero?
13
- prep + str
13
+ str.strip.empty? ? str : prep + str
14
14
  end
15
15
  color = case severity
16
16
  when 'WARN' then :warn
@@ -0,0 +1,61 @@
1
+ require 'fileutils'
2
+
3
+ require 'one_gadget/helper'
4
+ require 'one_gadget/logger'
5
+ require 'one_gadget/version'
6
+
7
+ module OneGadget
8
+ # For automatically check update.
9
+ module Update
10
+ # At least 7 days between check for new version.
11
+ FREQUENCY = 7 * 24 * 60 * 60
12
+ # Path to cache file.
13
+ CACHE_FILE = File.join(ENV['HOME'], '.cache', 'one_gadget', 'update').freeze
14
+
15
+ class << self
16
+ # Check if new releases have been drafted.
17
+ #
18
+ # @return [void]
19
+ def check!
20
+ return unless need_check?
21
+ FileUtils.touch(cache_file)
22
+ OneGadget::Logger.info("Checking for new versions of OneGadget\n" \
23
+ "To disable this functionality, do\n$ echo never > #{CACHE_FILE}\n\n")
24
+ latest = Helper.latest_tag[1..-1] # remove 'v'
25
+ if Gem::Version.new(latest) <= Gem::Version.new(OneGadget::VERSION)
26
+ return OneGadget::Logger.info("You have the latest version of OneGadget (#{latest})!\n\n")
27
+ end
28
+
29
+ # show update message
30
+ msg = format("A newer version of OneGadget is available (%s --> %s).\n", OneGadget::VERSION, latest)
31
+ msg << "Update with: $ gem update one_gadget\n\n"
32
+ OneGadget::Logger.info(msg)
33
+ end
34
+
35
+ private
36
+
37
+ # check ~/.cache/one_gadget/update
38
+ def need_check?
39
+ cache = cache_file
40
+ return false if cache.nil? # cache file fails, no update check.
41
+ return false if IO.binread(cache).strip == 'never'
42
+ Time.now >= last_check + FREQUENCY
43
+ end
44
+
45
+ def last_check
46
+ cache = cache_file
47
+ return Time.now if cache.nil?
48
+ File.open(cache, &:mtime)
49
+ end
50
+
51
+ def cache_file
52
+ dir = File.dirname(CACHE_FILE)
53
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
54
+ IO.binwrite(CACHE_FILE, '') unless File.exist?(CACHE_FILE)
55
+ CACHE_FILE
56
+ rescue # prevent dir is not writable
57
+ return nil
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,4 +1,4 @@
1
1
  module OneGadget
2
2
  # Current gem version.
3
- VERSION = '1.4.0'.freeze
3
+ VERSION = '1.4.1'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: one_gadget
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - david942j
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2017-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elftools
@@ -775,6 +775,7 @@ files:
775
775
  - lib/one_gadget/gadget.rb
776
776
  - lib/one_gadget/helper.rb
777
777
  - lib/one_gadget/logger.rb
778
+ - lib/one_gadget/update.rb
778
779
  - lib/one_gadget/version.rb
779
780
  homepage: https://github.com/david942j/one_gadget
780
781
  licenses:
@@ -796,7 +797,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
796
797
  version: '0'
797
798
  requirements: []
798
799
  rubyforge_project:
799
- rubygems_version: 2.6.10
800
+ rubygems_version: 2.5.2
800
801
  signing_key:
801
802
  specification_version: 4
802
803
  summary: one_gadget