Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ RUN touch /tmp/before-pip
# Install dependancies as Assemblyline
USER assemblyline

# Install pyswf
RUN pip install --no-cache-dir --user https://github.com/cccs-rs/pyswf/archive/master.zip && rm -rf ~/.cache/pip

# Downgrade Pillow for compatibility reasons
#RUN pip install --no-cache-dir --user Pillow==2.3.0 && rm -rf ~/.cache/pip
# Install dependencies for local pyswf library
RUN pip install --no-cache-dir --user lxml>=3.3.0 Pillow>=2.3.0 pylzma>=0.4.6 six && rm -rf ~/.cache/pip

# Delete files that are not to be kept
RUN find /var/lib/assemblyline/.local -type f ! -newer /tmp/before-pip -delete
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Swiffer Service

This Assemblyline service extracts metadata and performs anomaly detection on 'audiovisual/flash' files.
This Assemblyline service uses the Python pyswf library to extract metadata and perform anomaly detection on 'audiovisual/flash' files.

**NOTE**: This service does not require you to buy any licence and is preinstalled and working after a default installation

Expand Down
1 change: 1 addition & 0 deletions swiffer/swf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.5.4"
190 changes: 190 additions & 0 deletions swiffer/swf/actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@

from __future__ import absolute_import
import six
class Action(object):
def __init__(self, code, length):
self._code = code
self._length = length

@property
def code(self):
return self._code

@property
def length(self):
return self._length;

@property
def version(self):
return 3

def parse(self, data):
# Do nothing. Many Actions don't have a payload.
# For the ones that have one we override this method.
pass

def __repr__(self):
return "[Action] Code: 0x%x, Length: %d" % (self._code, self._length)

class ActionUnknown(Action):
''' Dummy class to read unknown actions '''
def __init__(self, code, length):
super(ActionUnknown, self).__init__(code, length)

def parse(self, data):
if self._length > 0:
#print "skipping %d bytes..." % self._length
data.skip_bytes(self._length)

def __repr__(self):
return "[ActionUnknown] Code: 0x%x, Length: %d" % (self._code, self._length)

class Action4(Action):
''' Base class for SWF 4 actions '''
def __init__(self, code, length):
super(Action4, self).__init__(code, length)

@property
def version(self):
return 4

class Action5(Action):
''' Base class for SWF 5 actions '''
def __init__(self, code, length):
super(Action5, self).__init__(code, length)

@property
def version(self):
return 5

class Action6(Action):
''' Base class for SWF 6 actions '''
def __init__(self, code, length):
super(Action6, self).__init__(code, length)

@property
def version(self):
return 6

class Action7(Action):
''' Base class for SWF 7 actions '''
def __init__(self, code, length):
super(Action7, self).__init__(code, length)

@property
def version(self):
return 7

# =========================================================
# SWF 3 actions
# =========================================================
class ActionGetURL(Action):
CODE = 0x83
def __init__(self, code, length):
self.urlString = None
self.targetString = None
super(ActionGetURL, self).__init__(code, length)

def parse(self, data):
self.urlString = data.readString()
self.targetString = data.readString()

class ActionGotoFrame(Action):
CODE = 0x81
def __init__(self, code, length):
self.frame = 0
super(ActionGotoFrame, self).__init__(code, length)

def parse(self, data):
self.frame = data.readUI16()

class ActionGotoLabel(Action):
CODE = 0x8c
def __init__(self, code, length):
self.label = None
super(ActionGotoLabel, self).__init__(code, length)

def parse(self, data):
self.label = data.readString()

class ActionNextFrame(Action):
CODE = 0x04
def __init__(self, code, length):
super(ActionNextFrame, self).__init__(code, length)

class ActionPlay(Action):
CODE = 0x06
def __init__(self, code, length):
super(ActionPlay, self).__init__(code, length)

def __repr__(self):
return "[ActionPlay] Code: 0x%x, Length: %d" % (self._code, self._length)

class ActionPreviousFrame(Action):
CODE = 0x05
def __init__(self, code, length):
super(ActionPreviousFrame, self).__init__(code, length)

class ActionSetTarget(Action):
CODE = 0x8b
def __init__(self, code, length):
self.targetName = None
super(ActionSetTarget, self).__init__(code, length)

def parse(self, data):
self.targetName = data.readString()

class ActionStop(Action):
CODE = 0x07
def __init__(self, code, length):
super(ActionStop, self).__init__(code, length)

def __repr__(self):
return "[ActionStop] Code: 0x%x, Length: %d" % (self._code, self._length)

class ActionStopSounds(Action):
CODE = 0x09
def __init__(self, code, length):
super(ActionStopSounds, self).__init__(code, length)

class ActionToggleQuality(Action):
CODE = 0x08
def __init__(self, code, length):
super(ActionToggleQuality, self).__init__(code, length)

class ActionWaitForFrame(Action):
CODE = 0x8a
def __init__(self, code, length):
self.frame = 0
self.skipCount = 0
super(ActionWaitForFrame, self).__init__(code, length)

def parse(self, data):
self.frame = data.readUI16()
self.skipCount = data.readUI8()

# =========================================================
# SWF 4 actions
# =========================================================
class ActionAdd(Action4):
CODE = 0x0a
def __init__(self, code, length):
super(ActionAdd, self).__init__(code, length)

class ActionAnd(Action4):
CODE = 0x10
def __init__(self, code, length):
super(ActionAnd, self).__init__(code, length)

# urgh! some 100 to go...

ActionTable = {}
for name, value in six.iteritems(dict(locals())):
if type(value) == type and issubclass(value, Action) and hasattr(value, 'CODE'):
ActionTable[value.CODE] = value

class SWFActionFactory(object):
@classmethod
def create(cls, code, length):
return ActionTable.get(code, ActionUnknown)(code, length)

Loading