Skip to content

Commit 977d319

Browse files
committed
PWN::Plugins::XXD module - implement optional parameter to return a hexdump as a single hash instead of an array of hashes in #dump method #bugfix
1 parent 5e474b6 commit 977d319

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ cd /opt/pwn
3737
$ ./install.sh
3838
$ ./install.sh ruby-gem
3939
$ pwn
40-
pwn[v0.4.995]:001 >>> PWN.help
40+
pwn[v0.4.996]:001 >>> PWN.help
4141
```
4242

4343
[![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](https://youtu.be/G7iLUY4FzsI)
@@ -52,7 +52,7 @@ $ rvm use ruby-3.3.0@pwn
5252
$ gem uninstall --all --executables pwn
5353
$ gem install --verbose pwn
5454
$ pwn
55-
pwn[v0.4.995]:001 >>> PWN.help
55+
pwn[v0.4.996]:001 >>> PWN.help
5656
```
5757

5858
If you're using a multi-user install of RVM do:
@@ -62,7 +62,7 @@ $ rvm use ruby-3.3.0@pwn
6262
$ rvmsudo gem uninstall --all --executables pwn
6363
$ rvmsudo gem install --verbose pwn
6464
$ pwn
65-
pwn[v0.4.995]:001 >>> PWN.help
65+
pwn[v0.4.996]:001 >>> PWN.help
6666
```
6767

6868
PWN periodically upgrades to the latest version of Ruby which is reflected in `/opt/pwn/.ruby-version`. The easiest way to upgrade to the latest version of Ruby from a previous PWN installation is to run the following script:

lib/pwn/plugins/xxd.rb

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,28 @@ module XXD
3333
io.write(fmt_row)
3434

3535
if hashed
36-
hashed_hexdump[fmt_row.split.first.delete(':').to_s] = {
37-
hex: fmt_row.split[1..8],
38-
ascii: fmt_row.split[9..-1].join
36+
# TODO: Fix NoMethodError: undefined method `join' for nil
37+
# when fmt_row looks like:
38+
# 000f4b20: 0000 0000 0000 0000 ........
39+
# fmt_row_col_len = fmt_row.split.length
40+
# if fmt_row_col_len > 10
41+
# fmt_row.split[9..-1].join
42+
# end
43+
this_key = fmt_row.split.first.delete(':').to_s
44+
hashed_hexdump[this_key] = {
45+
hex: fmt_row.split[1..-2],
46+
ascii: fmt_row.split[-1]
3947
}
48+
49+
hhh_len = hashed_hexdump[this_key][:hex].length
50+
# TODO: address last line if the hashed_hexdump[this_key][:hex] length is less than 8
51+
if hhh_len > 8
52+
mov_to_ascii = (hhh_len - 8) * -1
53+
last_ascii = hashed_hexdump[this_key][:ascii]
54+
hashed_hexdump[this_key][:hex][-1] = "#{hashed_hexdump[this_key][:hex].last}\s"
55+
hashed_hexdump[this_key][:ascii] = "#{hashed_hexdump[this_key][:hex][mov_to_ascii..-1].join(' ')}#{last_ascii}"
56+
hashed_hexdump[this_key][:hex] = hashed_hexdump[this_key][:hex][0..7]
57+
end
4058
end
4159
end
4260

lib/pwn/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module PWN
4-
VERSION = '0.4.995'
4+
VERSION = '0.4.996'
55
end

0 commit comments

Comments
 (0)