librex 0.0.39 → 0.0.40

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@
3
3
  A non-official re-packaging of the Rex library as a gem for easy of usage of the Metasploit REX framework in a non Metasploit application. I received permission from HDM to create this package.
4
4
 
5
5
  Currently based on:
6
- SVN Revision: 13058
6
+ SVN Revision: 13097
7
7
 
8
8
  # Credits
9
9
  The Metasploit development team <http://www.metasploit.com>
@@ -73,6 +73,7 @@ function getVersion(){
73
73
  case "344": // opera-9.0-20060616.1-static-qt.i386-en-344
74
74
  case "2091": // opera-9.52-2091.gcc3-shared-qt3.i386.rpm
75
75
  case "2444": // opera-9.60.gcc4-shared-qt3.i386.rpm
76
+ case "6386": // 10.61
76
77
  os_name = "#{oses::LINUX}";
77
78
  break;
78
79
  case "8502": // "Opera 9 Eng Setup.exe"
@@ -82,8 +83,12 @@ function getVersion(){
82
83
  case "8801": // "Opera_9.22_Eng_Setup.exe"
83
84
  case "10108": // "Opera_952_10108_en.exe"
84
85
  case "10467": // "Opera_962_en_Setup.exe"
86
+ case "3445": // 10.61
85
87
  os_name = "#{oses::WINDOWS}";
86
88
  break;
89
+ case "6386": // 10.61
90
+ os_name = "#{oses::MAC_OSX}";
91
+ break;
87
92
  //default:
88
93
  // document.write(opera.buildNumber('inconspicuous'));
89
94
  // break;
@@ -133,7 +138,7 @@ function getVersion(){
133
138
  if (platform.match(/x86_64/)) {
134
139
  arch = "#{ARCH_X86_64}";
135
140
  } else if (platform.match(/arm/)) {
136
- // Android
141
+ // Android and maemo
137
142
  arch = "#{ARCH_ARMLE}";
138
143
  }
139
144
  } else if (platform.match(/windows/)) {
@@ -185,7 +185,10 @@ protected
185
185
  end
186
186
 
187
187
  if( closed )
188
- self.close_write if self.respond_to?('close_write')
188
+ begin
189
+ self.close_write if self.respond_to?('close_write')
190
+ rescue IOError
191
+ end
189
192
  break
190
193
  end
191
194
  end
@@ -311,7 +311,8 @@ class ClientCore < Extension
311
311
  #
312
312
  def shutdown
313
313
  request = Packet.create_request('core_shutdown')
314
- response = self.client.send_packet_wait_response(request, 15)
314
+ # Don't wait for the response since the server will be dead
315
+ self.client.send_packet(request)
315
316
  true
316
317
  end
317
318
 
@@ -90,6 +90,47 @@ Separator = "\\"
90
90
  return response.get_tlv_value(TLV_TYPE_FILE_PATH)
91
91
  end
92
92
 
93
+
94
+ #
95
+ # Calculates the MD5 (16-bytes raw) of a remote file
96
+ #
97
+ def File.md5(path)
98
+ request = Packet.create_request('stdapi_fs_md5')
99
+
100
+ request.add_tlv(TLV_TYPE_FILE_PATH, path)
101
+
102
+ response = client.send_request(request)
103
+
104
+ return response.get_tlv_value(TLV_TYPE_FILE_NAME)
105
+ end
106
+
107
+ #
108
+ # Calculates the SHA1 (20-bytes raw) of a remote file
109
+ #
110
+ def File.sha1(path)
111
+ request = Packet.create_request('stdapi_fs_sha1')
112
+
113
+ request.add_tlv(TLV_TYPE_FILE_PATH, path)
114
+
115
+ response = client.send_request(request)
116
+
117
+ return response.get_tlv_value(TLV_TYPE_FILE_NAME)
118
+ end
119
+
120
+ #
121
+ # Expands a file path, substituting all environment variables, such as
122
+ # %TEMP%.
123
+ #
124
+ def File.expand_path(path)
125
+ request = Packet.create_request('stdapi_fs_file_expand_path')
126
+
127
+ request.add_tlv(TLV_TYPE_FILE_PATH, path)
128
+
129
+ response = client.send_request(request)
130
+
131
+ return response.get_tlv_value(TLV_TYPE_FILE_PATH)
132
+ end
133
+
93
134
  #
94
135
  # Performs a stat on a file and returns a FileStat instance.
95
136
  #
@@ -39,6 +39,26 @@ class Registry
39
39
  # the supplied permissions. Right now this is merely a wrapper around
40
40
  # create_key.
41
41
  #
42
+
43
+ def Registry.load_key(root_key,base_key,hive_file)
44
+ request = Packet.create_request('stdapi_registry_load_key')
45
+ request.add_tlv(TLV_TYPE_ROOT_KEY, root_key)
46
+ request.add_tlv(TLV_TYPE_BASE_KEY, base_key)
47
+ request.add_tlv(TLV_TYPE_FILE_PATH,hive_file)
48
+
49
+ response = client.send_request(request)
50
+ return response.get_tlv(TLV_TYPE_RESULT).value
51
+ end
52
+
53
+ def Registry.unload_key(root_key,base_key)
54
+ request = Packet.create_request('stdapi_registry_unload_key')
55
+ request.add_tlv(TLV_TYPE_ROOT_KEY, root_key)
56
+ request.add_tlv(TLV_TYPE_BASE_KEY, base_key)
57
+ response = client.send_request(request)
58
+ return response.get_tlv(TLV_TYPE_RESULT).value
59
+ end
60
+
61
+
42
62
  def Registry.open_key(root_key, base_key, perm = KEY_READ)
43
63
  # If no base key was provided, just return the root_key.
44
64
  if (base_key == nil or base_key.length == 0)
@@ -704,6 +704,30 @@ module Text
704
704
  Digest::MD5.hexdigest(str)
705
705
  end
706
706
 
707
+ #
708
+ # Convert hex-encoded characters to literals.
709
+ # Example: "AA\\x42CC" becomes "AABCC"
710
+ #
711
+ def self.dehex(str)
712
+ return str unless str.respond_to? :match
713
+ return str unless str.respond_to? :gsub
714
+ regex = /\x5cx[0-9a-f]{2}/mi
715
+ if str.match(regex)
716
+ str.gsub(regex) { |x| x[2,2].to_i(16).chr }
717
+ else
718
+ str
719
+ end
720
+ end
721
+
722
+ #
723
+ # Convert and replace hex-encoded characters to literals.
724
+ #
725
+ def self.dehex!(str)
726
+ return str unless str.respond_to? :match
727
+ return str unless str.respond_to? :gsub
728
+ regex = /\x5cx[0-9a-f]{2}/mi
729
+ str.gsub!(regex) { |x| x[2,2].to_i(16).chr }
730
+ end
707
731
 
708
732
  ##
709
733
  #
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: librex
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.39
5
+ version: 0.0.40
6
6
  platform: ruby
7
7
  authors:
8
8
  - Metasploit Development Team
@@ -11,11 +11,11 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-06-28 00:00:00 -05:00
14
+ date: 2011-07-04 00:00:00 -05:00
15
15
  default_executable:
16
16
  dependencies: []
17
17
 
18
- description: Rex provides a variety of classes useful for security testing and exploit development. Based on SVN Revision 13058
18
+ description: Rex provides a variety of classes useful for security testing and exploit development. Based on SVN Revision 13097
19
19
  email:
20
20
  - hdm@metasploit.com
21
21
  - jacob.hammack@hammackj.com