rex-text 0.2.42 → 0.2.43

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
  SHA256:
3
- metadata.gz: 5316dd362fddbaf996e0a087a07d597caf1161d863dd0db11b21cdeabe6f46ed
4
- data.tar.gz: 57a82d23c177b15a6f8f74a2ed6e248a9af0a0c781d173d5bf2f0116f6cd4422
3
+ metadata.gz: e65388b19aabaf76461efffee8b8b0b5c23265a5eff2f9adee5300a5664210c6
4
+ data.tar.gz: 4d697d31bf0464783450ff70494bb08f5d00e9186cea660e426e693bc6d025b6
5
5
  SHA512:
6
- metadata.gz: 1e88f3f3a165d96e27437bc9ccf237bd2d00c7324f4de1a7ba968ef6dda2faa74923fcdf53d4d8f656d6676d083c7cd40228c5cfcbbe3de81de4821984bfdfbb
7
- data.tar.gz: c2d1b0e804f3fcb61cbda3cb2340dacc3a9f80d4ba02d531adf9c0f5748d481d9288caf1f6cb63cd6427b3dcb0f6bcb7663444eea6f5644d373c79caaa5c7b95
6
+ metadata.gz: ef32b2087d8fd1016e69a7584baf2a44999d661d8261468b5e8a462ee42523336b32b5e6dad59b6308b7fdac2b006d848e71bdb3b9c81798c7c70364f0d15ec6
7
+ data.tar.gz: 14edb8ce455acae1c6caaca90ee259dbc0d29df0b539440f8242c29e919ebc6ad8954d398c00166f74f7bf14b08e9ddb03b0a886e674447cb8b1c98ec30245a4
checksums.yaml.gz.sig CHANGED
@@ -1 +1,3 @@
1
- o�,�̵;�`�:ݗ�WyK8{���G���^� j v�2yk���k��@-���$����"6������\��s���a��V
1
+ u˧_<) ��# xg�+'4�%g+?e�-�$����lV7��/��C���lT��&�rK�`�e?��3yf�����Æ�
2
+ PA�l*���9�r�\a��u��>L�܃�!r�,����'r�@�vv��y���Д
3
+ �_XN�z��$Uk��,~������-��{�u�م(��m-�������O���Ȑ��)�>i{�o ���,I!M��7�"�p���leȣ��+
data/lib/rex/text/hex.rb CHANGED
@@ -127,51 +127,22 @@ module Rex
127
127
  # Converts a string to a hex version with wrapping support
128
128
  #
129
129
  def self.hexify(str, col = DefaultWrap, line_start = '', line_end = '', buf_start = '', buf_end = '')
130
- output = buf_start
131
- cur = 0
132
- count = 0
133
- new_line = true
134
-
135
- # Go through each byte in the string
136
- str.each_byte { |byte|
137
- count += 1
138
- append = ''
139
-
140
- # If this is a new line, prepend with the
141
- # line start text
142
- if (new_line == true)
143
- append << line_start
144
- new_line = false
145
- end
146
-
147
- # Append the hexified version of the byte
148
- append << sprintf("\\x%.2x", byte)
149
- cur += append.length
150
-
151
- # If we're about to hit the column or have gone past it,
152
- # time to finish up this line
153
- if ((cur + line_end.length >= col) or (cur + buf_end.length >= col))
154
- new_line = true
155
- cur = 0
130
+ if col < line_start.length + 4 + line_end.length
131
+ # raise an exception
132
+ raise ArgumentError.new('insufficient column width')
133
+ end
156
134
 
157
- # If this is the last byte, use the buf_end instead of
158
- # line_end
159
- if (count == str.length)
160
- append << buf_end + "\n"
161
- else
162
- append << line_end + "\n"
163
- end
135
+ ret = buf_start.dup
136
+ ret << line_start if ret.end_with?("\n")
137
+ str.each_char do |char|
138
+ # "\x##".length is 4, check if we're going over the wrap boundary
139
+ if (ret.split("\n").last || '').length + 4 + line_end.length > col
140
+ ret << "#{line_end}\n#{line_start}"
164
141
  end
165
-
166
- output << append
167
- }
168
-
169
- # If we were in the middle of a line, finish the buffer at this point
170
- if (new_line == false)
171
- output << buf_end + "\n"
142
+ ret << "\\x" << char.unpack('H*')[0]
172
143
  end
173
-
174
- return output
144
+ ret << "\n" if ret.split("\n").last.length + buf_end.length > col
145
+ ret << "#{buf_end}\n"
175
146
  end
176
147
 
177
148
  #
data/lib/rex/text/lang.rb CHANGED
@@ -29,13 +29,14 @@ module Rex
29
29
 
30
30
  def self.to_csharp(str, wrap = DefaultWrap, name = "buf")
31
31
  ret = "byte[] #{name} = new byte[#{str.length}] {"
32
- i = -1;
33
- while (i += 1) < str.length
34
- ret << "\n" if i%(wrap/4) == 0
35
- ret << "0x" << str[i].unpack("H*")[0] << ","
32
+ str.each_char do |char|
33
+ # "0x##,".length is 5, check if we're going over the wrap boundary
34
+ ret << "\n" if ret.split("\n").last.length + 5 > wrap
35
+ ret << "0x" << char.unpack('H*')[0] << ","
36
36
  end
37
- ret = ret[0..ret.length-2] #cut off last comma
38
- ret << " };\n"
37
+ ret = ret[0..ret.length - 2] unless str.empty? # cut off last comma
38
+ ret << "\n" if ret.split("\n").last.length + 2 > wrap
39
+ ret << "};\n"
39
40
  end
40
41
 
41
42
  #
@@ -43,21 +44,21 @@ module Rex
43
44
  #
44
45
  def self.to_golang(str, wrap = DefaultWrap, name = "buf")
45
46
  ret = "#{name} := []byte{"
46
- i = -1;
47
- while (i += 1) < str.length
48
- ret << "\n" if i%(wrap/4) == 0
49
- ret << "0x" << str[i].unpack("H*")[0] << ", "
47
+ str.each_char do |char|
48
+ # "0x##,".length is 5, check if we're going over the wrap boundary
49
+ ret << "\n" if ret.split("\n").last.length + 5 > wrap
50
+ ret << "0x" << char.unpack('H*')[0] << ","
50
51
  end
51
- ret = ret[0..ret.length-3] #cut off last comma
52
- ret << " }\n"
53
-
52
+ ret = ret[0..ret.length - 2] unless str.empty? # cut off last comma
53
+ ret << "\n" if ret.split("\n").last.length + 2 > wrap
54
+ ret << "};\n"
54
55
  end
55
-
56
+
56
57
  #
57
58
  # Creates a golang style comment
58
59
  #
59
60
  def self.to_golang_comment(str, wrap = DefaultWrap)
60
- return "/*\n" + wordwrap(str, 0, wrap, '', '') + "*/\n"
61
+ return "/*\n" + wordwrap(str, 0, wrap, '', '') + "*/\n"
61
62
  end
62
63
 
63
64
  #
@@ -181,6 +182,5 @@ module Rex
181
182
  return wordwrap(str, 0, wrap, '', '# ')
182
183
  end
183
184
 
184
-
185
185
  end
186
186
  end
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Text
3
- VERSION = "0.2.42"
3
+ VERSION = "0.2.43"
4
4
  end
5
5
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex-text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.42
4
+ version: 0.2.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
metadata.gz.sig CHANGED
Binary file