All Projects → ahixon → swiffas

ahixon / swiffas

Licence: MIT license
SWF parser and AVM2 (Actionscript 3) bytecode parser

Programming Languages

python
139335 projects - #7 most used programming language
perl
6916 projects

Projects that are alternatives of or similar to swiffas

lvg
Lion Vector Graphics
Stars: ✭ 106 (+606.67%)
Mutual labels:  flash, swf
Ruffle
A Flash Player emulator written in Rust
Stars: ✭ 9,128 (+60753.33%)
Mutual labels:  flash, swf
flashmingo
Automatic analysis of SWF files based on some heuristics. Extensible via plugins.
Stars: ✭ 117 (+680%)
Mutual labels:  flash, swf
Jpexs Decompiler
JPEXS Free Flash Decompiler
Stars: ✭ 2,939 (+19493.33%)
Mutual labels:  flash, swf
yupi
🎲 open source gaming emulator for flash based games
Stars: ✭ 28 (+86.67%)
Mutual labels:  flash, swf
guepard
flash to html5 converter, as3 to javascript translator
Stars: ✭ 58 (+286.67%)
Mutual labels:  flash, swf
Starling Framework
The Cross Platform Game Engine
Stars: ✭ 2,399 (+15893.33%)
Mutual labels:  flash
toolchain
A cmake based toolchain with support for diffrent micrcocontrollers.
Stars: ✭ 16 (+6.67%)
Mutual labels:  flash
Online Privacy Test Resource List
Privacy Online Test and Resource Compendium (POTARC) 🕵🏻
Stars: ✭ 185 (+1133.33%)
Mutual labels:  flash
Layaair discard
This is old LayaAir veriosn writetten by ActionScript 3.0 ,now LayaAir is using TypeScript as the Engine Script,Please use https://github.com/layabox/LayaAir instead.
Stars: ✭ 1,858 (+12286.67%)
Mutual labels:  flash
anytone-flash-tools
Independend flash tools for Anytone D878UV radio (and maybe others)
Stars: ✭ 31 (+106.67%)
Mutual labels:  flash
remote-pinetime-bot
Telegram Bot to flash and test PineTime firmware remotely
Stars: ✭ 23 (+53.33%)
Mutual labels:  flash
Dragonbonesas
DragonBones ActionScript Runtime
Stars: ✭ 248 (+1553.33%)
Mutual labels:  flash
Vscode As3mxml
ActionScript & MXML language extension for Visual Studio Code. Develop apps for Adobe AIR, Adobe Flash Player, or Apache Royale.
Stars: ✭ 205 (+1266.67%)
Mutual labels:  flash
Virtual Controllers
Virtual controls for use in Flash based games on touch devices. Includes thumbstick and button ui elements
Stars: ✭ 16 (+6.67%)
Mutual labels:  flash
Aura.session
Tools for managing sessions, including session segments and read-once messages
Stars: ✭ 185 (+1133.33%)
Mutual labels:  flash
Dynamicaudio.js
An interface for the Web Audio API with a Flash shim for older browsers
Stars: ✭ 164 (+993.33%)
Mutual labels:  flash
Ailight
AiLight is a custom firmware for the esp8266 based Ai-Thinker (or equivalent) RGBW WiFi light bulbs
Stars: ✭ 248 (+1553.33%)
Mutual labels:  flash
kendryte-flash-windows
Kendryte flash utility for Windows
Stars: ✭ 28 (+86.67%)
Mutual labels:  flash
Mornui
Morn UI is an ActionScript 3 UI Components for Flash,with lightweight, high performance, and a visual ui editor
Stars: ✭ 247 (+1546.67%)
Mutual labels:  flash

swiffas

A small Python 2 library that provides:

  • a SWF parser (enough tags to get the Actionscript stuff out, but a few others too)
  • a complete AVM2 parser (Actionscript 3 bytecode)

Original intention was to provide a transpiler from compiled AS3 code to LLVM IR.

There are one or two in other languages, but most have bitrotted, or they were too incomplete to parse my target files.

Serialising back to SWF files should be relatively straightforward to add.

Installation

pip install swiffas

Usage

Take a look at example.py -- it prints a disassembly listing for all the Actionscript code it finds in a DoABC tag.

In any case, here's a quick rundown:

import swiffas
from swiffas import swftags

# parse the SWF file
p = swiffas.SWFParser ()
with open ('example.swf', 'rb') as f:
    p.parse (f)

print 'has', p.properties.frame_count, 'frames'
print 'has', len(p.record_headers), 'records; parsed', len(p.tags), 'of them'

# get each exported AS3 program in the SWF file
as3_exports = filter (lambda x: isinstance (x, swftags.DoABC), p.tags)

# print some information about them
for as3_export in as3_exports:
    as3 = swiffas.ABCFile (as3_export.bytecode)
    print as3_export.name, 'has', as3.method_count, 'methods'

    # print all the strings used in the program
    print '\n'.join (map (lambda sinfo: sinfo.value, as3.constant_pool.strings))

Parsed object structure

The structure of each parsed SWF and AVM2 object can be found in swiffas/swftags.py and swiffas/avm2.py, respectively. Each element of the _struct list is instantiated on the object during deserialisation (if its size is not None, False or 0).

Each tuple in _struct is of the form (type, name, optional size or existence boolean). The size may be an integer, or refer to a previous field's value.

A special case of a tuple is where its type is bytes, is the last element in the list and has size None. This represents a field that takes up the remainder of the object, and who's contents are those bytes.

Doing stuff with AS3

There's no AS3 VM packaged (yet), so you'll manually iterate over each method's body, and link all the indexes up.

Adding new SWF tags

See swiffas/swftags.py. Missing tags are listed at the bottom.

The current limitation is just that you can't encode a bitfields inside a byte aligned object. The BitObject and Unpackable classes just need to be combined.

Adding new AVM2 instructions

See swiffas/avm2ins.py.

All the ones from the specification are included, as are several undocumented instructions (including all the FlasCC ones).

There are a few undocumented ones in this table that we don't support, but be weary that some entries on there are wrong.

However, it's better to cross check with Adobe's source code drop of their Actionscript virtual machine (downside being you have to navigate through lots of cruft to get what you want).

License

Released under the MIT license. Refer to LICENSE for complete license text.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].