rubypwn 0.0.12 → 0.0.13

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/patch_alarm +36 -0
  3. data/lib/elf.rb +3 -1
  4. data/rubypwn.gemspec +1 -1
  5. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdbfa39fcd07f0f3e67209c9a003dd00cc7b4b94
4
- data.tar.gz: a0abc8b6851725653437381ecbfc328509a3ba97
3
+ metadata.gz: 15594288c94490fa55f43adba1741c7dd28bf10b
4
+ data.tar.gz: 2364bc322529d57c70afc4faade693b370412c59
5
5
  SHA512:
6
- metadata.gz: a33b7b98a23449ac36c0bea51a1bb0bafab344f6d2717e1cfa21ff6eb12f2b199fe5a617124bab6d652ee18ccfbb3046272f1207e6a282e0eca61177b2b88825
7
- data.tar.gz: f6ff1e327082bb8c3c21d71a45814cfe76d684ad8477ab0491f9079837a6d5af5bbfa07236d24733bd801678c01ca7325304eb6b8b82776bef5ed5f812a3fb18
6
+ metadata.gz: aef042a4a901d751da43015b676549f110a0af22bf39ac749d9126898fff4050806477d9fd6a9190c55b5f5b8c033b03ddc92665b69e99a0c2d935d2bf4bfaa0
7
+ data.tar.gz: ad8b17b64561fbb11d64f44c4e4f3da599b649e5b0b7842e452fb5a71b0662f0fbd04e6303d196261f40ed1b450b16bdf43f4fcb0eaa67fd982c9c73ee90baf9
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ require 'rubypwn'
4
+ require 'fileutils'
5
+
6
+ if ARGV.size != 1
7
+ puts "%s binary" % $0
8
+ exit
9
+ end
10
+
11
+ filename = ARGV[0]
12
+
13
+ # Get the section size and offset of STRTAB
14
+ e = Elf.new filename
15
+ off_dynstr = e.sections[".dynstr"]["offset"]
16
+ size = e.sections[".dynstr"]["size"]
17
+
18
+ new_filename = filename + ".patch"
19
+
20
+ binary = File.read(filename).force_encoding("binary")
21
+
22
+ # find alarm in strtab, patch it.
23
+ off_alarm = binary[off_dynstr, size].index "\x00alarm\x00"
24
+
25
+ if not off_alarm.nil?
26
+ binary[off_dynstr + off_alarm + 1, 5] = "isnan"
27
+
28
+ File.open(new_filename, "w") do |fh|
29
+ fh.write binary
30
+ end
31
+ FileUtils.chmod "a+x", new_filename
32
+ puts "Done."
33
+ else
34
+ puts 'No "alarm" found.'
35
+ end
36
+
data/lib/elf.rb CHANGED
@@ -308,7 +308,9 @@ class Elf
308
308
  flag += (elf.sh[i].sh_flags & 1) > 0 ? "w" : "-"
309
309
  flag += (elf.sh[i].sh_flags & 4) > 0 ? "x" : "-"
310
310
 
311
- @sections[elf.sh[i].name_str.to_s]["offset"] = elf.sh[i].sh_addr.to_i
311
+ @sections[elf.sh[i].name_str.to_s]["addr"] = elf.sh[i].sh_addr.to_i
312
+ @sections[elf.sh[i].name_str.to_s]["offset"] = elf.sh[i].sh_offset.to_i
313
+ @sections[elf.sh[i].name_str.to_s]["size"] = elf.sh[i].sh_size.to_i
312
314
  @sections[elf.sh[i].name_str.to_s]["flag"] = flag
313
315
  end
314
316
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rubypwn'
3
- s.version = '0.0.12'
3
+ s.version = '0.0.13'
4
4
  s.date = '2015-09-09'
5
5
  s.summary = "ruby pwn tools"
6
6
  s.description = <<-DESCRIPTION.strip.gsub(/\s+/, " ")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubypwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - atdog
@@ -93,13 +93,15 @@ dependencies:
93
93
  description: A simple library for CTF pwning challenges. Like Python's pwntools, it's
94
94
  used to help you write exploit quickly.
95
95
  email: atdog.tw@gmail.com
96
- executables: []
96
+ executables:
97
+ - patch_alarm
97
98
  extensions: []
98
99
  extra_rdoc_files: []
99
100
  files:
100
101
  - ".gitignore"
101
102
  - Gemfile
102
103
  - README.md
104
+ - bin/patch_alarm
103
105
  - docs/.gitignore
104
106
  - docs/Makefile
105
107
  - docs/source/about.rst