heapinfo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/heapinfo/arena.rb +4 -1
- data/lib/heapinfo/version.rb +1 -1
- data/spec/dumper_spec.rb +31 -10
- data/spec/files/victim.cpp +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3afc942b75cd48a72f4d699b68423d2b6e23ff01
|
4
|
+
data.tar.gz: 69bbf96563700cdf3275b680229f65c6ba20e8e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3cceb98b2e06f7c02a6ce16c9d9322de0a554742a213aeb26e8e7dce945fb35f9e425cf2e316e9317128df0ef061317c57fbcf449842888c9a35886c6549783
|
7
|
+
data.tar.gz: b1285f36856258f0834707b54252cc2989050fc72f99a9ebead0fadc565ab10e0e090fe03bbd42bb1c3ebd6e52c293ea1ef49e237451dcc81f33d43d9f5f30ac
|
data/lib/heapinfo/arena.rb
CHANGED
@@ -35,7 +35,10 @@ module HeapInfo
|
|
35
35
|
return self if top_ptr == 0 # arena not init yet
|
36
36
|
@top_chunk = Chunk.new size_t, top_ptr, @dumper
|
37
37
|
@last_remainder = Chunk.new size_t, top_ptr_offset + 8, @dumper
|
38
|
-
|
38
|
+
# this offset diff after 2.23
|
39
|
+
@system_mem = 2.times.map do |off|
|
40
|
+
Helper.unpack(size_t, @dumper.call(top_ptr_offset + 258 * size_t + 16 + off * size_t, size_t))
|
41
|
+
end.find { |val| val >= 0x21000 and (val & 0xfff) == 0 }
|
39
42
|
@fastbin = Array.new(7) do |idx|
|
40
43
|
f = Fastbin.new(size_t, @base + 8 - size_t * 2 + size_t * idx, @dumper, head: true)
|
41
44
|
f.index = idx
|
data/lib/heapinfo/version.rb
CHANGED
data/spec/dumper_spec.rb
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
# encoding: ascii-8bit
|
2
2
|
require 'heapinfo'
|
3
3
|
describe HeapInfo::Dumper do
|
4
|
+
before(:all) do
|
5
|
+
@self_maps = IO.binread('/proc/self/maps').lines.map do |seg|
|
6
|
+
s = seg.split(/\s/)
|
7
|
+
s[0] = s[0].split('-').map { |addr| addr.to_i(16) }
|
8
|
+
[s[0][0], s[0][1], s[1], s[-1]] # start, end, perm, name
|
9
|
+
end
|
10
|
+
|
11
|
+
@get_elf_base = ->() do
|
12
|
+
exe = File.readlink('/proc/self/exe')
|
13
|
+
@self_maps.find { |arr| arr[3] == exe }[0]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
4
17
|
describe 'dump' do
|
5
18
|
before(:each) do
|
6
19
|
@mem_filename = '/proc/self/mem'
|
20
|
+
@elf_base = @get_elf_base.call
|
7
21
|
end
|
8
22
|
it 'simple' do
|
9
23
|
dumper = HeapInfo::Dumper.new(nil, @mem_filename)
|
10
|
-
expect(dumper.dump(
|
24
|
+
expect(dumper.dump(@elf_base, 4)).to eq "\x7fELF"
|
11
25
|
end
|
12
26
|
it 'segment' do
|
13
|
-
class S;def elf; HeapInfo::Segment.new(
|
14
|
-
dumper = HeapInfo::Dumper.new(S.new, @mem_filename)
|
27
|
+
class S;def initialize(base);@base = base;end; def elf; HeapInfo::Segment.new(@base, 'elf'); end; end
|
28
|
+
dumper = HeapInfo::Dumper.new(S.new(@elf_base), @mem_filename)
|
15
29
|
expect(dumper.dump(:elf, 4)).to eq "\x7fELF"
|
16
30
|
end
|
17
31
|
it 'invalid' do
|
@@ -34,26 +48,33 @@ describe HeapInfo::Dumper do
|
|
34
48
|
|
35
49
|
describe 'find' do
|
36
50
|
before(:all) do
|
37
|
-
|
38
|
-
|
51
|
+
@elf_base = @get_elf_base.call
|
52
|
+
class S; def bits; 64; end; end
|
53
|
+
@dumper = HeapInfo::Dumper.new(S.new(@elf_base), '/proc/self/mem')
|
54
|
+
@end_of_maps = ->() do
|
55
|
+
@self_maps.find.with_index do |seg, i|
|
56
|
+
seg[2].include?('r') and seg[1] != @self_maps[i][0] # incontinuously segment
|
57
|
+
end[1]
|
58
|
+
end
|
39
59
|
end
|
40
60
|
it 'simple' do
|
41
|
-
expect(@dumper.find("ELF", :elf, 4)).to eq
|
61
|
+
expect(@dumper.find("ELF", :elf, 4)).to eq @elf_base + 1
|
42
62
|
expect(@dumper.find("ELF", :elf, 3)).to be nil
|
43
63
|
end
|
44
64
|
it 'regexp' do
|
45
|
-
addr = @dumper.find(/
|
46
|
-
expect(@dumper.dump(addr,
|
65
|
+
addr = @dumper.find(/lin.x/, :elf, 0x1000)
|
66
|
+
expect(@dumper.dump(addr, 5) =~ /lin.x/).to eq 0
|
47
67
|
end
|
48
68
|
it 'invalid' do
|
49
69
|
expect(@dumper.find(nil, :elf, 1)).to be nil
|
50
70
|
end
|
51
71
|
it 'parser' do
|
52
|
-
expect(@dumper.find("ELF", ':elf + 1', 3)).to eq
|
72
|
+
expect(@dumper.find("ELF", ':elf + 1', 3)).to eq @elf_base + 1
|
53
73
|
end
|
54
74
|
it 'reach end' do
|
75
|
+
mem = @end_of_maps.call
|
55
76
|
# check dumper won't return nil when remain readable memory less than one page
|
56
|
-
expect(@dumper.find("\x00",
|
77
|
+
expect(@dumper.find("\x00", mem - 0xff0, 0x1000).nil?).to be false
|
57
78
|
end
|
58
79
|
end
|
59
80
|
|
data/spec/files/victim.cpp
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heapinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- david942j
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: create an interactive memory info interface while pwn / exploiting
|
14
14
|
email:
|