This repository has been archived by the owner on Jun 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
corkamix.asm
301 lines (259 loc) · 8.62 KB
/
corkamix.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
; a binary that is a valid JAR, PE, ZIP, HTML
; mixed version
;Ange Albertini, BSD Licence, 2012
%include 'consts.inc'
IMAGEBASE equ 400000h
org IMAGEBASE
; PE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
db 'MZ'
; python;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
db '=1;print("CorkaMIX [python]")'
db 26 ; EOF
; PDF start ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
db '%PDF-1.', 0ah
db 'obj<<>>stream', 0ah
; HTML start ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
db '<html>'
; PE resumes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
e_lfanew dd NT_Signature - IMAGEBASE
NT_Signature:
istruc IMAGE_NT_HEADERS
at IMAGE_NT_HEADERS.Signature, db 'PE',0,0
iend
istruc IMAGE_FILE_HEADER
at IMAGE_FILE_HEADER.Machine, dw IMAGE_FILE_MACHINE_I386
at IMAGE_FILE_HEADER.Characteristics, dw IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_32BIT_MACHINE
iend
istruc IMAGE_OPTIONAL_HEADER32
at IMAGE_OPTIONAL_HEADER32.Magic, dw IMAGE_NT_OPTIONAL_HDR32_MAGIC
msg db 'CorkaMIX [PE]', 0
at IMAGE_OPTIONAL_HEADER32.AddressOfEntryPoint, dd EntryPoint - IMAGEBASE
at IMAGE_OPTIONAL_HEADER32.ImageBase, dd IMAGEBASE
at IMAGE_OPTIONAL_HEADER32.SectionAlignment, dd 4
at IMAGE_OPTIONAL_HEADER32.FileAlignment, dd 4
at IMAGE_OPTIONAL_HEADER32.MajorSubsystemVersion, dw 4
db "<body>"
at IMAGE_OPTIONAL_HEADER32.SizeOfImage, dd SIZEOFIMAGE
at IMAGE_OPTIONAL_HEADER32.SizeOfHeaders, dd SIZEOFIMAGE - 1
at IMAGE_OPTIONAL_HEADER32.Subsystem, db IMAGE_SUBSYSTEM_WINDOWS_CUI
at IMAGE_OPTIONAL_HEADER32.NumberOfRvaAndSizes, dd 13
iend
istruc IMAGE_DATA_DIRECTORY_16
at IMAGE_DATA_DIRECTORY_16.ImportsVA, dd Import_Descriptor - IMAGEBASE
at IMAGE_DATA_DIRECTORY_16.IATVA, dd ImportsAddressTable - IMAGEBASE
at IMAGE_DATA_DIRECTORY_16.IATSize, dd IMPORTSADDRESSTABLESIZE
iend
bits 32
EntryPoint:
db 0fh, 018h, 111b << 3
push msg
call [__imp__printf]
salc
add esp, 1 * 4
retn
Import_Descriptor: ; slightly messed up
ImportsAddressTable:
msvcrt.dll_iat:
__imp__printf:
dd hnprintf - IMAGEBASE
dd 0
IMPORTSADDRESSTABLESIZE equ $ - ImportsAddressTable
dd 0
dd msvcrt.dll - IMAGEBASE
dd msvcrt.dll_iat - IMAGEBASE
;terminator
msvcrt.dll db 'msvcrt'
hnprintf:
dw 0
db 'printf', 0
times 5 db 0
SIZEOFIMAGE equ $ - IMAGEBASE
; HTML ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
db "<style>body { visibility:hidden;} .n { visibility: visible; position: absolute; padding: 0 1ex 0 1ex; margin: 0; top: 0; left: 0; } h1 { margin-top: 0.4ex; margin-bottom: 0.8ex; }</style><div class=n>"
db " <script type='text/javascript'>alert('CorkaMIX [HTML+JavaScript]');</script><!--"
; ZIP start ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;unneeded for Java
CRC32class equ 0
CRC32manifest equ 0
header:
db 'PK', 3, 4
dw 0ah ; version_needed
dw 0 ; flags
dw 0 ; compression
dd 0 ; LASTMOD
dd 0 ; crc32
dd 0 ; compressed size
dd 0 ; uncompressed size
dw DIRLEN
dw 0 ; extra_length
dir:
db 'META-INF/'
DIRLEN equ $ - dir
file1:
db 'PK', 3, 4
dw 0ah ; version_needed
dw 0 ; flags
dw 0 ; compression
dd 0 ; LASTMOD
dd CRC32manifest ; crc32
dd FILESIZE1 ; compressed size
dd FILESIZE1 ; uncompressed size
dw FILENAMELEN1
dw 0 ; extra_length
filename1:
db 'META-INF/MANIFEST.MF'
FILENAMELEN1 equ $ - filename1
data1:
db 'Created-By: 1', 0ah
db 'Main-Class: corkamix', 0ah
FILESIZE1 equ $ - data1
file2:
db 'PK', 3, 4
dw 0ah ; version_needed
dw 0 ; flags
dw 0 ; compression
dd 0 ; LASTMOD
dd CRC32class ; crc32
dd FILESIZE2 ; compressed size
dd FILESIZE2 ; uncompressed size
dw FILENAMELEN2
dw 0 ; extra_length
filename2:
db 'corkamix.class'
FILENAMELEN2 equ $ - filename2
data2:
; CLASS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%include 'java.inc'
_dd 0CAFEBABEh ; signature
_dw 3 ; major version
_dw 2dh ; minor version
_dw 23 ;constant pool count
; this class
classref 2 ; 01
utf8 'corkamix' ; 02
; super class
classref 4 ; 03
utf8 'java/lang/Object' ; 04
; method name
utf8 'main' ; 05
; method type
utf8 '([Ljava/lang/String;)V' ; 06
; attribute name
utf8 'Code' ; 07
; getstatic
fieldref 9, 11 ; 08
classref 10 ; 09
utf8 'java/lang/System' ; 10
nat 12, 13 ; 11
utf8 'out' ; 12
utf8 'Ljava/io/PrintStream;' ; 13
; LDC
string 15 ; 14
utf8 'CorkaMIX [Java CLASS in JAR]' ; 15
; InvokeVirtual
metref 17, 19 ; 16
classref 18 ; 17
utf8 'java/io/PrintStream' ; 18
nat 20, 21 ; 19
utf8 'println' ; 20
utf8 '(Ljava/lang/String;)V' ; 21
; PDF end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ut8 containing the PDF's end
db 1 ;
_dw pdfend - 1 -$
db 'endstream', 0ah
db 'endobj', 0ah
db '1 0 obj<</Kids[<</Parent 1 0 R/Contents[2 0 R]>>]/Resources<<>>>>2 0 obj<<>>stream', 0ah
db 'BT/default 80 Tf 1 0 0 1 1 715 Tm(CorkaMIX [PDF])Tj ET', 0ah
db 'endstream', 0ah
db 'endobj', 0ah
db 'trailer<</Root<</Pages 1 0 R>>>>', 0ah
pdfend:
; CLASS resumes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_dw 1 ;access_flag: public
_dw 1 ;this class
_dw 3 ;super class
_dw 0 ; interfaces_count
_dw 0 ; fields_count
_dw 1 ; methods_count
_dw 9 ; flags: public, static
_dw 5 ; methodname: 'main'
_dw 6 ; return type: ([Ljava/lang/String;)V
_dw 1 ; attribute_count
_dw 7 ; attributename: Code
_dd 15h ; length
_dw 2 ; maxlocals
_dw 1 ; maxstack
_dd 9 ; length of bytecode
GETSTATIC 8
LDC 14
INVOKEVIRTUAL 16
RETURN
_dw 0 ; exceptions_count
_dw 0 ; attributes_count
_dw 0 ;attributes_count
; CLASS ends ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FILESIZE2 equ $ - data2
central_directory:
db 'PK', 1, 2
dw 014h ; version_made_by
dw 0ah ; version_needed
dw 0 ; flags
dw 0 ; compression
dd 0 ; last_mod time/date
dd 0 ; crc32
dd 0 ; compressed_size
dd 0 ; uncompressed_size
dw DIRLEN
dw 0 ; extra_length
dw 0 ; comment_length
dw 0 ; disk_number_start
dw 0 ; internal_attr
dd 10h ; external_attr
dd 0 ; offset_header
db 'META-INF/'
db 'PK', 1, 2
dw 014h ; version_made_by
dw 0ah ; version_needed
dw 0 ; flags
dw 0 ; compression
dd 0 ; last_mod time/date
dd CRC32manifest ; crc32
dd FILESIZE1 ; compressed_size
dd FILESIZE1 ; uncompressed_size
dw FILENAMELEN1
dw 0 ; extra_length
dw 0 ; comment_length
dw 0 ; disk_number_start
dw 0 ; internal_attr
dd 20h ; external_attr
dd file1 - header ; offset_header
db 'META-INF/MANIFEST.MF'
db 'PK', 1, 2
dw 014h ; version_made_by
dw 0ah ; version_needed
dw 0 ; flags
dw 0 ; compression
dd 0 ; last_mod time/date
dd CRC32class ; crc32
dd FILESIZE2 ; compressed_size
dd FILESIZE2 ; uncompressed_size
dw FILENAMELEN2
dw 0 ; extra_length
dw 0 ; comment_length
dw 0 ; disk_number_start
dw 0 ; internal_attr
dd 20h ; external_attr
dd file2 - header ; offset_header
db 'corkamix.class'
end_central_directory:
db 'PK', 5, 6
number_disk dw 0
number_disk2 dw 0
total_number_disk dw 3
total_number_disk2 dw 3
dd end_central_directory - central_directory;size
dd central_directory - header ;offset
dw 0 ; comment_length
; trick to prevent python to handle the file as a zip
; dd 0 ; will screw up the java loading