Advertisement
Guest User

Untitled

a guest
May 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package  {
  2.    
  3.     import flash.utils.ByteArray;
  4.     import flash.display.Bitmap;
  5.     import flash.display.BitmapData;
  6.     import flash.geom.Point;
  7.    
  8.     import com.hurlant.math.BigInteger;
  9.    
  10.     public class BitmapFunctions {
  11.        
  12.         private var Banner:habboBanner;
  13.         private var pixels:ByteArray;
  14.        
  15.         private var decodeResult:String = "";
  16.         private var xorResult:String = "";
  17.        
  18.         private var firstLength:int = 0;
  19.         private var secondLength:int = 0;
  20.        
  21.         private var firstKey:String = "";
  22.         private var secondKey:String = "";
  23.        
  24.         public function BitmapFunctions() {
  25.            
  26.             trace("Constructed bitmap decoding class");
  27.            
  28.             this.Banner = new habboBanner(0,0);
  29.             this.pixels = this.Banner.getPixels(this.Banner.rect);
  30.            
  31.             this.decodeResult = this.decodeBitmap(this.pixels, this.Banner.width, 4, new Point(4, 39), new Point(80, 30));
  32.             this.xorResult = this.xorTest(this.decodeResult, this.randomKey(30));
  33.             //6d14d6c1682bf00e7c61c584e5c4f5b3 << Token
  34.             this.firstLength = this.xorResult.charCodeAt(0);
  35.             this.secondLength = this.xorResult.charCodeAt((this.firstLength + 1));
  36.            
  37.             this.firstKey = this.xorResult.substr(1, this.firstLength);
  38.             this.secondKey = this.xorResult.substr(this.firstLength + 2, this.secondLength);
  39.            
  40.             trace("First Length -> " + this.firstLength);
  41.             trace("First Key -> " + this.firstKey);
  42.             trace("");
  43.             trace("Second Length -> " + this.secondLength);
  44.             trace("Second Key -> " + this.secondKey);
  45.            
  46.             var first:BigInteger = new BigInteger();
  47.             var second:BigInteger = new BigInteger();
  48.            
  49.             first.fromRadix(this.firstKey, 10);
  50.             second.fromRadix(this.secondKey, 10);
  51.            
  52.             trace("Prime -> " + first.toString());
  53.             trace();
  54.             trace("Generator -> " + second.toString());
  55.         }
  56.        
  57.         private function randomKey(length:uint = 16) : String {
  58.             var _loc_4:uint = 0;
  59.             var _loc_2:String = "";
  60.             var _loc_3:int = 0;
  61.            
  62.             while(_loc_3 < length){
  63.                 _loc_4 = uint(Math.random() * 255);
  64.                 _loc_2 = _loc_2 + _loc_4.toString(16);
  65.                 _loc_3++;
  66.             }
  67.             trace("Random 'secret' Key: " + _loc_2);
  68.             trace();
  69.             return _loc_2;
  70.         }
  71.        
  72.         private function xorTest(pixelStr:String, token:String) : String {
  73.            
  74.             var pixelCode:uint = 0;
  75.             var resultStr:String = "";
  76.             var tokenIterate:int = 0;
  77.            
  78.             for (var pixelIterate:int = 0; pixelIterate < pixelStr.length; pixelIterate++) {
  79.                
  80.                 pixelCode = pixelStr.charCodeAt(pixelIterate);
  81.                 resultStr = resultStr + String.fromCharCode(pixelCode ^ token.charCodeAt(tokenIterate));
  82.                 tokenIterate++;
  83.                
  84.                 if (tokenIterate == token.length) {
  85.                    
  86.                     tokenIterate = 0;
  87.                 }
  88.                
  89.             }
  90.            
  91.             return resultStr;
  92.         }
  93.        
  94.         private function decodeBitmap(bitmap:ByteArray, bitmapWidth:int, aCount:int, pos1:Point, pos2:Point) : String {
  95.            
  96.             var pos1X:int = 0; // loc12
  97.             var pos1Y:int = 0; // loc11
  98.            
  99.             var pixelPos:uint = 0; //loc13
  100.            
  101.             var rowStart:int = 0; //loc10
  102.             var rowRemainder:uint = 0; //loc9
  103.             var tRow:uint = 0;  // loc14
  104.            
  105.             var uByte:uint = 0; // loc15
  106.             var uByteMasked:uint = 0; // loc16
  107.             var bitCount:uint = 0; // loc7
  108.             var shiftBuffer:uint = 0; // loc8
  109.            
  110.             var resultBuffer:String = "";
  111.            
  112.             if (aCount == 4) {
  113.                
  114.                 // Starting row will be 1
  115.                 rowStart = 1;
  116.             }
  117.            
  118.             pos1Y = pos1.y;
  119.            
  120.             while (pos1Y < pos1.y + pos2.y) {
  121.                
  122.                 pos1X = pos1.x;
  123.                
  124.                 while (pos1X < pos1.x + pos2.x) {
  125.                    
  126.                     pixelPos = ((pos1Y + rowRemainder) * bitmapWidth + pos1X) * aCount;
  127.                     tRow = rowStart;
  128.                    
  129.                     while (tRow < aCount) {
  130.                        
  131.                         bitmap.position = pixelPos + tRow;
  132.                        
  133.                         uByte = bitmap.readUnsignedByte();
  134.                         uByteMasked = uByte & 1;
  135.                         shiftBuffer = shiftBuffer | uByteMasked << 7 - bitCount;
  136.                        
  137.                         if (bitCount == 7) {
  138.                            
  139.                             resultBuffer = resultBuffer + String.fromCharCode(shiftBuffer);
  140.                             shiftBuffer = 0;
  141.                             bitCount = 0;
  142.                         }
  143.                         else {
  144.                            
  145.                             bitCount = bitCount + 1;
  146.                         }
  147.                        
  148.                         tRow++;
  149.                     }
  150.                    
  151.                     if (pos1X % 2 == 0) {
  152.                        
  153.                         rowRemainder = rowRemainder + 1;
  154.                     }
  155.                    
  156.                     pos1X++;
  157.                 }
  158.                
  159.                 rowRemainder = 0;
  160.                 pos1Y++;
  161.             }
  162.            
  163.             return resultBuffer;
  164.         }
  165.     }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement