(Obsfucate data) embed an swf as a hexadecimal string in your …swf

September 26, 2009 – 2:47 am

You can embed an swf, or any other binary octet stream, containing -harder to get to- data as a hexadecimal string into your project.

Note: This is not true data security. Nothing is securable in actionscript, but you CAN make it hard(er) to get to.

So to describe my last attempt to hide some game xml data that I embedded in an second swf i went ahead like this to embed that swf as a hex string in my main project like this:

  • 1) Create a seperate empty project along your main project and create a simple swf containing the protectable data.
  • 2) I'm not a smoker but let's say you want secure the class "SensimillaPlantagesXml.as" containing your sensitive sensimilla location xml data. Compile that class into "sensitive.swf" (uhum). Make sure that that class is embedded into the swf by including a reference to it in your document's main class new SensimillaPlantagesXml() or just put 'SensimillaPlantagesXml' as a word in your documentclass's constructor
  • 3)Create a second project along your main project that will serve as a hexadecimal tracer: Embed the swf in it with the Embed tag. We will now convert the binary application octet stream from 'sensitive.swf' to a hexadecimal string:
  • 4) This will leave us with a long hexadecimal string in the trace output window, representing your swf as hexadecimal data.
    The class to do the Binary to Hexadecimal conversion I will include later, below in this post.
  • Trace Output: 4357530a2a60000078dad55c4d6cdbd87626f547cbffae6399444f9274a3d4a642b4e9cc4719eedb.........

  • 5)Copy that string without additional spaces and paste it in a 'Data' class under a variable, called var _hexData here.
  • 6)So let me show you now how you load this hexadcimal string, and parse it as an accessible swf within you main project:


  • The only easy way to get to ALL the data of the embedded-hex-swf is (including bitmaps) is
    making an swf file from it; Now be my guest and write me a short (AIR?) tutorial please :).

    This procedure is not super secure but discourages our fast'n easy decompiler friends.
    Still better then posting the data over http.
    If the process is not clear by now, please let me know, so I can improve above instructions.

    Here you can see the transformation class that contains the two static functions binToHex() and hexToBin();

    And here you can see BinHex.as:

    Download BinHex.as

    Ciao !

    See this post as raw text

    FlashDevelop: duplicate a text selection block with a shortcut

    August 18, 2009 – 8:14 pm

    Want to duplicate multiple lines of code with a keyboard shortcut in flashdevelop ?
    FlashDevelop->Tools->Macros->Add-> Entries->... :

    
    
    ScintillaCommand|SelectionDuplicate

    Label: &BlockDupe
    Shortcut: Alt+DOWN (my own choice)

    
    

    text block duplication trough flashdevelop macro

    Dupe'm :)
    Cheers to Joel Stransky ;)

    FlashDevelop Syntax Coloring: Dark Theme

    August 15, 2009 – 1:47 am

    Back in time I used Sepy as a texteditor as an alternative to the Flash IDE Non-Code-Editor.
    Now my snappy editor of choice is FlashDevelop, totally tailored towards Flex SDK publishing.

    In Sepy I had a nice dark background theme, but since the switch to FD I never took the time to configure colors in FD.
    It really can make a difference for your eyes, a darker background; Less radiation or flickerHz effects I 'd say.

    For everybody who wants to get AS3 coding  'darker', here is my theme for you to grab. It's a flash develop zip file, and should install by just running it after download and answer the dialog with..YES! . (  A restart of FD might be necessary ? )
    If you're not sure yet, backup your current brightwhite scheme first.
    Grab here: SyntaxColorAS3_FD_Latcho.fdz

    You can alter and save your settings by opening the menu Tools>Syntax Coloring:AS3.

    The font I just started using is named 'Inconsolata'  (as seen in the screenshot);
    Seems to be  a 1st choice of a bunch-a-folks. Looks peacefull to me on first sight.
    The original Inconsolata Open Type font wasn't received by FD's font enumerator, but I found a ported TTF that does well.
    Grab here:  Inconsolata.ttf

    Enjoy.

    preview SyntaxColorAS3_FD_Latcho

    Why wouldn't I be a

    sponsor

    setting breakpoints, debug swf via console / terminal /prompt with fdb

    August 13, 2009 – 12:00 am

    Finally found a nice article that explains how flex sdk's fdb command line debug tool works :)

    Reminder for myself:

    http://installingcats.com/2007/12/07/how-to-use-command-line-debugger-fdb-to-debug-flex-flash-on-mac-os-x/

    Got into it for a moment ----> this will be a messy post :)

    found some extra info / commands within fdb now:

    New to fdb? Do 'tutorial' for basic info.
    List of fdb commands:
    bt (bt)             Print backtrace of all stack frames
    break (b)           Set breakpoint at specified line or function
    cf (cf)             Display the name and number of the current file
    clear (cl)          Clear breakpoint at specified line or function
    condition (cond)    Apply/remove conditional expression to a breakpoint
    continue (c)        Continue execution after stopping at breakpoint
    commands (com)      Sets commands to execute when breakpoint hit
    delete (d)          Delete breakpoints or auto-display expressions
    directory (dir)     Add a directory to the search path for source files
    disable (disab)     Disable breakpoints or auto-display expressions
    disassemble (disas) Disassemble source lines or functions
    display (disp)      Add an auto-display expressions
    enable (e)          Enable breakpoints or auto-display expressions
    file (fil)          Specify application to be debugged.
    finish (f)          Execute until current function returns
    handle (han)        Specify how to handle a fault
    help (h)            Display help on fdb commands
    home (ho)           Set listing location to where execution is halted
    info (i)            Display information about the program being debugged
    kill (k)            Kill execution of program being debugged
    list (l)            List specified function or line
    next (n)            Step program
    print (p)           Print value of variable EXP
    pwd (pw)            Print working directory
    quit (q)            Exit fdb
    run (r)             Start debugged program
    set (se)            Set the value of a variable
    source (so)         Read fdb commands from a file
    step (s)            Step program until it reaches a different source line
    tutorial (t)        Display a tutorial on how to use fdb
    undisplay (u)       Remove an auto-display expression
    viewswf (v)         Set or clear filter for file listing based on swf
    what (wh)           Displays the context of a variable
    where (w)           Same as bt
    Type 'help' followed by command name for full documentation.
    (fdb)

    Start an application with 'run'.
    View file names with 'info sources'.
    List a file with 'list'.
    Set breakpoints with 'break'.
    Execute program with 'continue' until a breakpoint is hit.
    Examine state of program with 'where', 'print', 'info locals'.
    Execute individual statements with 'next', 'step', and 'finish'.
    Resume execution with 'continue'.
    Quit fdb with 'quit'.

    It boils down to launching FDB.EXE in your flexsdk's 'bin' dir.
    - Typing run:
    (fdb) run

    - Open a debug-enabled swf (preferably on http in your browser since that ads-in network access if you don't have security configured for that local swf path)
    - set a breakpoint via a functionname (even if it is in another file, the name will match when fdb hits it), so for example type:
    (fdb) b registerModule<enter>
    You have now set a breakpoint for that function name that will be resolved later, linenumbers / filenames must be possible too.
    And then type continue + <enter> ( add more breakpoints if you like) and again continue + <enter>
    The swf will now run until it hits the breakpoint marked functionname 'registerModule':
    Resolved breakpoint 1 to registerModule() at ModuleManager.as:23
    (fdb) continue + <enter>
    Breakpoint 1, registerModule() at ModuleManager.as:23   (yeahaa!)
    23             public function registerModule(modRegName:String,instance:IModule):void {
    now by command p we want to know what the variable  'instance' holds
    ( note (!) if you end the variable name with  a dot (.) you get more info) !:
    (fdb) p instance.

    outputs:
    $7 = instance = [Object 758409729, class='nl.greenberry.gogeo.app::App']
    _appController = [Object 757300145, class='nl.greenberry.gogeo.app::AppController']
    _appDisplayModel = null
    _appEventModel = null
    _appModuleManager = null
    _appSoundModel = null
    _eventModel = [Object 758625729, class='nl.greenberry.gogeo.app::EventModel']
    _modelLocator = [Object 758703937, class='nl.greenberry.gogeo.app::ModelLocator']
    _moduleManager = [Object 760443361, class='nl.greenberry.gogeo.app::ModuleManager']
    _moduleName = null
    _stage = [Object 756722513, class='flash.display::Stage']
    displayModel = [Object 757301009, class='nl.greenberry.gogeo.app::DisplayModel']
    eventModel = [Object 758625729, class='nl.greenberry.gogeo.app::EventModel']
    moduleManager = [Object 760443361, class='nl.greenberry.gogeo.app::ModuleManager']
    moduleName = null
    NAME = "Go-Geo"
    soundModel = [Object 758409793, class='nl.greenberry.gogeo.app::SoundModel']
    stage = [Object 756722513, class='flash.display::Stage']
    VERSION = "0.0.1"

    and the rest you will find out !

    by the way you can alter variables realtime, and it displays your traces too:
    [trace] sayHello

    cheers !
    Flashdevelop now complete for me :)

    flex sdk compile time variables, switches and resources Hacks

    December 9, 2008 – 2:51 am

    Super nice article on how to create a compiletime conditional switch for for ex. calling an alternate version of the same function or adding compiletime var-values at  with the flex sdk command line
    http://code.awenmedia.com/node/34

    Code examples from his site:

    ADDING COMPILETIME VARS:
    
    
    mxmlc MyConfigClass.as -define+=CONFIG::someSetting,true
    or
    ...-define+=CONFIG::myString,"'Hello!'" -define+=CONFIG::myNumber,"7"

    for someSetting the AS3 class would be:

    package {
    public class MyConfigClass
    {
       public static const SOME_SETTING:Boolean=CONFIG::someSetting;  // Actual AS3 this time
    
       public function doSomething():void
       {
          if (SOME_SETTING)
          {
              // Do it!
          }
       }
    }
    }
    
    
    CONDITIONAL FUNCTION SWITCH:
    
    mxmlc MyClass.as -define+=CONFIG::isDebug,true  -define+=CONFIG::isRelease,false
    
    //AS3
    package
    {
    public class MyClass
    {
        CONFIG::isDebug
        public function doSomething():void
        {
            trace("This is a debug build!");
        }
    
        CONFIG::isRelease
        public function doSomething():void
        {
            trace("This is a release build!");
        }
    }
    }
    
    
    
    

    Another from usefull tip-set from awen on adding resources and css files at compiletime by abusing some flex buildin hacks:

    http://code.awenmedia.com/node/33

    
    

    AS3 textfield blinking caret after textfield focus / tabbing ? Solved!

    July 19, 2008 – 2:21 am

    To obtain focus on a textfield with a custom textformat on it can give you headaches:
    From wrong caret color to disapaering textcontent when you use tab button to unselectable text content.
    You just keep fumbling around with _Textfield.stage.focus = _Textfield without joy.
    I lost several hours to get the caret blinking where I wanted it.

    It is so simple if you just had known that you NEED TO SET THE
    Textfield.defaultTextFormat = myFormat wright before you had the line textfield.setTextformat(myFormat).

    It seems that focussing or unfocussing or tabbbing resets your textformat with the default textformat,
    and since that didn't exist... flash defaults to a STATIC textfield. YipiYoYO....
    Figure that, especially after the tab first killed your textcontent and then makes your field unselectable.

    But hey when you apply the defaulTextformat wright before you start playing,
    suddenly the focussing and caret'ing works like a charm.
    Hope you are happy to find this post ! I would have been ;)
    Here a little helper boyie class :

    use it like this after import CaretFocus;
    CaretFocus.atBegin(TField)
    CaretFocus.atEnd(TField)
    CaretFocus.atIndex(TField,5)
    CaretFocus.unfocus(TField)
    CaretFocus.focus(TField)

    usefull eclipse configuration for ANT + flex

    May 22, 2008 – 9:41 pm

    Step 1: Create ant-build Folder in your project

    1. Right click on your project name and click New.. Folder...
    2. For the sake of the example, call the folder "ant-build".
    3. Copy the lib folder from Adobe's flex_ant_tasks_mmddyy.zip to this new folder. The jar file in this lib directory can really go anywhere on your file system, but this is a good enough place for it while getting started.

    Step 2: Update Ant Runtime Preferences in Eclipse

    1. Update the Ant classpath.
      1. Go to Window... Preferences.... Expand the Ant entry on the left and click Runtime.
      2. Under the Classpath tab, click Global Entries. Then click Add External jars and add the flexTasks.jar file in the ant-build/lib folder created in Step 1.
      3. If Eclipse gives you a warning about missing a tools.jar file, refer to this site for guidance: http://www.dynamicobjects.com/d2r/archives/002591.html
    2. Map the Flex Tasks to the correct class. In this step, you are essentially configuring Eclipse with the mappings from the flexTasks.tasks file.
      1. Under the Tasks tab, click Add Task...
      2. In the name field, enter "mxmlc" (without the quotes).
      3. In the location dropdown, select the flexTasks.jar file from Step 1, #3.
      4. In the directory tree that appears, select /flex2/ant, and then select MxmlcTask.class.
      5. Click OK to add the Flex task.
      6. Repeat for "compc" and "html-wrapper", if you plan to use these tasks.
    3. Click OK to apply and exit the Preferences window.

    Step 3: Customizing the build.xml

    1. Under the "ant-build" folder, create a build.xml file.
    2. Copy the sample build file below into this file:
    3. Make sure the FLEX_HOME property points to the Flex SDK on your machine. If you installed the Flex Builder plugin, by default, it is located in C:\Program Files\Adobe\Flex Builder 2 Plug-in\Flex SDK 2\
    4. PROJECT_HOME should point to your Flex project on the file system.
    5. MAIN_SOURCE_FOLDER should be the location of your source files. And OUTPUT_FOLDER should be where the swf files are created when you run a build. These 2 properties correspond to the entries of the same name, under the Flex Build Path section of the project properties.

    <?xml version="1.0" encoding="utf-8"?>

    <project name="My App Builder" basedir=".">     <property name="FLEX_HOME" value="C:/flex/sdk"/>
    
    <property name="PROJECT_HOME" value="C:/flex/workspace/MyFlexProject"/>
    <property name="MAIN_SOURCE_FOLDER" value="${PROJECT_HOME}/src"/>
    <property name="OUTPUT_FOLDER" value="${PROJECT_HOME}/bin"/>
    
    <target name="main">
    <mxmlc file="${MAIN_SOURCE_FOLDER}/Main.mxml" output="${OUTPUT_FOLDER}/Main.swf" keep-generated-actionscript="true">
    <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
    <source-path path-element="${MAIN_SOURCE_FOLDER"/>
    </mxmlc>
    </target>
    </project>

    I hope that helps someone.

    ------

    Or a bigger one build.xml:

    <?xml version="1.0"?>
    <project name="statistics" default="production" basedir=".">
    
    <description>tatistics module</description>
    
    <!--// # # # # # # # # # # # # DEFINE YOUR RESOURCES # # # # # # # # # # # # //-->
    <property name="FLEX_HOME"     location="${basedir}/dependencies/flex_sdk_3.0.0.477/" />
    <property name="FLEX_TASKS"     location="${basedir}/dependencies/flex_sdk_3.0.0.477/ant" />
    
    <!--// # # # # # see folder 'dependencies' for archived resources # # # # # //-->
    
    <!--// properties //-->
    
    <property name="build.classpath"                 location="${basedir}/src"  />
    <property name="build.extraclasspath"             location="${basedir}/classes"  />
    
    <property name="build.assets"                    location="${basedir}/assets" />
    <property name="build.version"                   value="0.99"/>
    <property name="build.width"                       value="471"/>
    <property name="build.height"                   value="455"/>
    <property name="build.documentation.exec"         value="${FLEX_HOME}/bin/asdoc" />
    
    <property name="build.bin.production"  location="${basedir}/bin/main.swf" />
    <property name="build.bin.development" location="${basedir}/bin/dev.swf" />
    
    <property name="build.main.production" value="${build.classpath}/Main.as"/>
    
    <property name="build.version.path"    location="${build.classpath}/Build.as"/>
    <property name="build.version.package" value=""/>
    <property name="build.copyright"       value="Copyright(c) myteam"/>
    <property name="build.owner"           value="http://mylink.com"/>
    
    <!--// misc //-->
    
    <taskdef file="${FLEX_TASKS}/flexTasks.tasks" classpath="${FLEX_TASKS}/lib/flexTasks.jar" />
    
    <tstamp>
    <format property="build.time" pattern="dd-MM-yyyy" unit="day" />
    </tstamp>
    
    <buildnumber />
    
    <echo>${ant.project.name}
    ==========================
    Version: ${build.version}
    Build number: ${build.number}
    Build Time: ${build.time}</echo>
    
    <condition property="isWindows">
    <os family="windows" />
    
    </condition>
    
    <!-- builds //-->
    <target name="production" depends="version" description="Compile production release">
    <echo>Building project
    main:  ${build.main.production}
    output:${build.bin.production}</echo>
    <mxmlc file="${build.main.production}" output="${build.bin.production}"
    keep-generated-actionscript="false" actionscript-file-encoding="UTF-8"
    use-network="true" debug="false" optimize="true" incremental="false">
    
    <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
    <default-size width="${build.width}" height="${build.height}" />
    
    <source-path path-element="${FLEX_HOME}/frameworks" />
    <source-path path-element="${build.classpath}" />
    <source-path path-element="${build.extraclasspath}" />
    </mxmlc>
    </target>
    
    <target name="development" description="Compile development basic">
    
    <echo>Building project [development]</echo>
    <mxmlc file="${build.main.production}" output="${build.bin.development}"
    keep-generated-actionscript="false" actionscript-file-encoding="UTF-8"
    use-network="true" debug="true" optimize="true" incremental="false">
    
    <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
    
    <default-size width="${build.width}" height="${build.height}" />
    
    <source-path path-element="${FLEX_HOME}/frameworks" />
    <source-path path-element="${build.classpath}" />
    
    <source-path path-element="${build.classpath.bulk_loader}" />
    <source-path path-element="${build.classpath.nono_toolkit}" />
    
    <source-path path-element="${build.classpath.mc_toolkit}" />
    <source-path path-element="${build.classpath.tweener}" />
    </mxmlc>
    </target>
    
    <target name="correctIfWindows" if="isWindows">
    <property name="build.documentation.exec" value="${build.documentation.exec}.exe" />
    </target>
    
    <target name="version" description="Write version class">
    <echo>Create Version class</echo>
    <echo file="${build.version.path}" append="false">/**
    * Build class
    * machine generated class holding build info
    * please use 'Build.makeContextMenu(mySprite.stage);' to add build info to context menu
    * this will enable you to verify deployed versions by right-mouse-clicking on the swf at any time!
    **/
    package ${build.version.package}{
    import flash.ui.ContextMenu;
    import flash.ui.ContextMenuItem;
    import flash.events.ContextMenuEvent;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    import flash.display.DisplayObjectContainer;
    //import com.mediacatalyst.error.StaticClassError;
    
    public final class Build {
    public static const product:String = "${ant.project.name}";
    public static const version:String = "${build.version}";
    public static const time:String = "${build.time}";
    public static const number:Number = ${build.number};
    public static const copyright:String = "${build.copyright}";
    public static const owner:String = "${build.owner}";
    
    public static function makeContextMenu(obj:DisplayObjectContainer,useSeperator:Boolean=true):void{
    var menu:ContextMenu = new ContextMenu();
    menu.hideBuiltInItems();
    menu.builtInItems.print = true;
    var name:ContextMenuItem = new ContextMenuItem(product,useSeperator);
    menu.customItems.push(name);
    var version:ContextMenuItem = new ContextMenuItem("Version "+version+".b"+number+" ("+time+")",true);
    menu.customItems.push(version);
    var copy:ContextMenuItem = new ContextMenuItem(copyright);
    menu.customItems.push(copy);
    obj.contextMenu = menu;
    copy.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, _goOwner);
    }
    
    private static function _goOwner(e:ContextMenuEvent):void{
    navigateToURL(new URLRequest(owner),"owner");
    }
    
    public function Build(){
    //throw new StaticClassError("Build");
    }
    }
    }</echo>
    </target>
    </project>

    if you don't use eclipse you can still build by downloading ANT, add it to you system PATH
    and from the commandline use command ANT

    ant build.xml production
    ant build.xml development

    Easy Favourite Folder Access with SHORTY !

    March 16, 2008 – 7:41 pm

    Do you often have to save or open files from the same project folder?
    Do you hate programs forgetting your last accessed folder?
    Do you browse your filesystem more then you want ?

    Well then here come's SHORTY !
    Stijn De Ryck from Green Collective together with Virgil from Datadarling.com develloped this great mini utility that makes your life just more profitable :)

    Shorty gives you easy acces to a max of 5 favourite (project)folders from within ANY program.

    Simply asign a folder from within explorer to Shorty 1 to 5:

    assign a folder to shorty 1-5

    - Right click folder in explorer or from within the file open/save dialog.
    - Select Shorty 1,2,3,4 or 5 and you're set.

    Now when you want to save or open a file yto/from your favourite shorty folder ou can jump to that folder with only 1 click;
    The folder you assigned to "Shorty 1" will appear on the left in the vertical places bar.

    easy folder access with shorty shortcuts

    To reset back to the default windows places, just uninstall shorty.
    It is also possible to ad My Computer, Desktop, The Root of a drive or a network share to a Shorty Shortcut.

    We created it for ourselves but we love to share it because we want you ...
    to stop useless folder browsing NOW !

    Download our clean Short here:
    SHORTY V1.00 Installer (ZIP,Win32)

    That said:
    Another "little great" tool elsewhere on 'ze internetz' is Clippath, which enables you to easily copy a path to a folder or file. Extremely handy when you want for ex a path to paste in a dos-box or target a folder to unzip to:
    check here

    phi, the golden ratio: 1.61803399

    February 18, 2008 – 10:55 am

    Nature, art, your body, ... everything and the whole world is interwoven with this number :

    the so called golden ratio = 1.61803399.

    for any mathematician this might be ordinary playground,

    For me it's still a miracle :) Try to achieve this similar math outcomes with any other number !

    Whenever you play with this number, you're up for a good time.

    I did some color calculations in a flash app long time ago and will post it soon.

    phi, the golden ratio: 1.61803399

    by the way the image width/height ratio is phi'd;

    loadBitmap & external pixel peace

    February 17, 2008 – 4:18 pm

    Darn,
    Why can't we straightaway do a loadBitmap targetting a bitmap item in the library from a loaded external swf (within our own domain!) ?
    There must be some flashgod that sees evil in external pixels.
    Anyways here is a workaround (AS2).
    If we have a canvas.swf that wants to load external.swf
    and wants to peek in that external library for linked bitmaps we could have this:

    [canvas.swf]

    our web-cuisine solution to get to that external.swf's mybitmap_linkage_id is
    putting this code in in the root of the swf we are going to load:
    don't forget about the

      import flash.display.BitmapData

    !

    [external.swf]

    Offcourse there's other ways.
    But there all against Flashgod's intentions.
    External Pixel Peace, that's where we shall stand for.
    Join us;)

    Download: loadExternalBitmap AS2 example FLA’s