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.
- checksums.yaml +4 -4
- data/bin/patch_alarm +36 -0
- data/lib/elf.rb +3 -1
- data/rubypwn.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15594288c94490fa55f43adba1741c7dd28bf10b
|
4
|
+
data.tar.gz: 2364bc322529d57c70afc4faade693b370412c59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aef042a4a901d751da43015b676549f110a0af22bf39ac749d9126898fff4050806477d9fd6a9190c55b5f5b8c033b03ddc92665b69e99a0c2d935d2bf4bfaa0
|
7
|
+
data.tar.gz: ad8b17b64561fbb11d64f44c4e4f3da599b649e5b0b7842e452fb5a71b0662f0fbd04e6303d196261f40ed1b450b16bdf43f4fcb0eaa67fd982c9c73ee90baf9
|
data/bin/patch_alarm
ADDED
@@ -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]["
|
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
|
data/rubypwn.gemspec
CHANGED
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.
|
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
|