| 1 |
#!/usr/bin/perl |
#!/usr/bin/perl |
| 2 |
|
|
| 3 |
# fluscate.pl 0.03 - The Flash Obfuscator |
# fluscate.pl 0.04 - The Flash Obfuscator |
| 4 |
|
|
| 5 |
# $Id$ |
# $Id$ |
| 6 |
# $Log$ |
# $Log$ |
| 7 |
|
# Revision 1.5 2004/07/26 16:11:58 joko |
| 8 |
|
# updated pod |
| 9 |
|
# included more complete list of flash event-handlers |
| 10 |
|
# fixed substitution regex #1: now using spaces around function names |
| 11 |
|
# |
| 12 |
|
# Revision 1.4 2004/07/26 13:51:54 joko |
| 13 |
|
# updated pod |
| 14 |
|
# |
| 15 |
|
# Revision 1.3 2004/07/23 12:56:07 joko |
| 16 |
|
# updated pod |
| 17 |
|
# |
| 18 |
|
# Revision 1.2 2004/07/23 12:24:52 joko |
| 19 |
|
# pod |
| 20 |
|
# |
| 21 |
# Revision 1.1 2004/07/23 12:13:14 joko |
# Revision 1.1 2004/07/23 12:13:14 joko |
| 22 |
# initial commit |
# initial commit |
| 23 |
# |
# |
| 24 |
|
|
| 25 |
=pod |
=pod |
|
This software is Copyright (C) 2004 Andreas Motl |
|
|
Ideas and future AppleScript integration by Holger Marseille. |
|
| 26 |
|
|
| 27 |
This program is free software; you can redistribute it and/or |
This software is Copyright (C) 2004 Andreas Motl |
| 28 |
modify it under the terms of the GNU General Public License |
Ideas and future AppleScript integration by Holger Marseille. |
| 29 |
as published by the Free Software Foundation; either version 2 |
|
| 30 |
of the License, or (at your option) any later version. |
This program is free software; you can redistribute it and/or |
| 31 |
|
modify it under the terms of the GNU General Public License |
| 32 |
This program is distributed in the hope that it will be useful, |
as published by the Free Software Foundation; either version 2 |
| 33 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
of the License, or (at your option) any later version. |
| 34 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 35 |
GNU General Public License for more details. |
This program is distributed in the hope that it will be useful, |
| 36 |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 37 |
You should have received a copy of the GNU General Public License |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 38 |
along with this program; if not, write to the Free Software |
GNU General Public License for more details. |
| 39 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 40 |
|
You should have received a copy of the GNU General Public License |
| 41 |
|
along with this program; if not, write to the Free Software |
| 42 |
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 43 |
|
|
| 44 |
=cut |
=cut |
| 45 |
|
|
| 46 |
|
|
| 48 |
|
|
| 49 |
=head1 Features |
=head1 Features |
| 50 |
|
|
| 51 |
=head2 Requests |
|
| 52 |
- komplexere verschlüsselung als "-1, -2 ..." z-b nicht in der numerischen reihenfolge sondern nach |
=head2 Obfuscation |
| 53 |
zufallsprinip (-21,-3,-89)? (->random) |
|
| 54 |
- evtl. constants nach abfrage ersetzen ? leider sehr aufwendig, bei vielen constants (->ask) |
See ASO Pro: http://www.genable.com/aso/preview.html |
| 55 |
- rausgeben des arrays mit den "neuen" werten um evtl die obfuscation rückgängig zu machen (->undo) |
|
|
- " push 0 |
|
|
ls: |
|
|
dup |
|
|
trace |
|
|
branchIfTrue ls" |
|
|
... after each "constants" declaration (->pollute) |
|
| 56 |
|
|
| 57 |
=head2 Functions |
=head2 Functions |
| 58 |
fluscate handles two different styles of function declarations: |
|
| 59 |
|
fluscate handles two different styles of function declarations: |
| 60 |
|
|
| 61 |
1. "Normal" ones |
1. "Normal" ones |
| 62 |
function mp3Player ('arg1', 'arg2') |
function mp3Player ('arg1', 'arg2') |
| 66 |
function () |
function () |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
=head1 Dependencies |
| 70 |
|
|
| 71 |
|
"flasm" is required to disassemble swf files, see http://www.nowrap.de/flasm.html |
| 72 |
|
ACKs go to Igor Kogan. |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
=head1 Usage |
| 76 |
|
|
| 77 |
|
=head2 win32 |
| 78 |
|
|
| 79 |
|
#> flasm.exe -d puzzle.swf > puzzle.flm |
| 80 |
|
#> cat puzzle.flm | perl fluscate.pl > puzzle_fusc.flm |
| 81 |
|
#> flasm.exe -a puzzle_fusc.flm |
| 82 |
|
|
| 83 |
|
=head2 *nix |
| 84 |
|
|
| 85 |
|
#> ./flasm -d puzzle.swf > puzzle.flm |
| 86 |
|
#> cat puzzle.flm | ./fluscate.pl > puzzle_fusc.flm |
| 87 |
|
#> ./flasm -a puzzle_fusc.flm |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
=head1 Development |
| 91 |
|
|
| 92 |
|
=head2 Todo |
| 93 |
|
|
| 94 |
|
- provide list of flash event handler names to exclude from symbol replacement |
| 95 |
|
|
| 96 |
|
=head2 Wishlist |
| 97 |
|
|
| 98 |
|
- komplexere verschlüsselung als "-1, -2 ..." z-b nicht in der numerischen reihenfolge sondern nach |
| 99 |
|
zufallsprinip (-21,-3,-89)? (->random) |
| 100 |
|
- evtl. constants nach abfrage ersetzen ? leider sehr aufwendig, bei vielen constants (->ask) |
| 101 |
|
- rausgeben des arrays mit den "neuen" werten um evtl die obfuscation rückgängig zu machen (->undo) |
| 102 |
|
- " push 0 |
| 103 |
|
ls: |
| 104 |
|
dup |
| 105 |
|
trace |
| 106 |
|
branchIfTrue ls" |
| 107 |
|
... after each "constants" declaration (->pollute) |
| 108 |
|
- what about other symbols beside "function"s? (e.g. variables) (->mode) |
| 109 |
|
- include list of ->keywords from: |
| 110 |
|
http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/ |
| 111 |
|
- replace symbols in multiple files (->multifile) |
| 112 |
|
|
| 113 |
|
=head2 Notes |
| 114 |
|
|
|
=head1 Notes |
|
| 115 |
- no function may be called "Initialize", rename it to (e.g.) "Initialize2", reassembling will not work otherwise |
- no function may be called "Initialize", rename it to (e.g.) "Initialize2", reassembling will not work otherwise |
| 116 |
(doesn't matter when obfuscating since function names will be replaced of course) |
(doesn't matter when obfuscating since function names will be replaced of course) |
| 117 |
- function names seem to be/work case insensitive (shuffle <-> Shuffle) |
- function names seem to be/work case insensitive (shuffle <-> Shuffle) |
| 121 |
- "getMember" and "getVariable" also do function calls! |
- "getMember" and "getVariable" also do function calls! |
| 122 |
- there are reserved function names which must not be replaced! (-> event handlers, e.g. "onPress") |
- there are reserved function names which must not be replaced! (-> event handlers, e.g. "onPress") |
| 123 |
|
|
|
=head1 Todo / Review |
|
|
- what about other symbols beside "function"s? |
|
| 124 |
|
|
| 125 |
=head1 Usage |
=head1 Links |
| 126 |
|
|
| 127 |
=head2 Usage (win32): |
=head2 ActionScript Decompilers / Disassemblers |
| 128 |
#> flasm.exe -d puzzle.swf > puzzle.flm |
|
| 129 |
#> cat puzzle.flm | perl fluscate.pl > puzzle_fusc.flm |
Flasm: |
| 130 |
#> flasm.exe -a puzzle_fusc.flm |
http://www.nowrap.de/flasm.html |
| 131 |
|
http://www.opaque.net/~dave/flasm/ |
| 132 |
|
Flare: http://www.nowrap.de/flare.html |
| 133 |
|
Sothink SWF Decompiler: http://www.srctec.com/flashdecompiler/ |
| 134 |
|
Imperator FLA: http://www.ave-imperator.com/ |
| 135 |
|
SWF Decompiler: http://www.19.5degs.com/swfdecompiler.php |
| 136 |
|
Gordon: http://www.futurecandy.com/ |
| 137 |
|
|
| 138 |
=head2 Usage (*nix): |
=head2 ActionScript Editors & Co. |
| 139 |
#> flasm -d puzzle.swf > puzzle.flm |
|
| 140 |
#> cat puzzle.flm | fluscate.pl > puzzle_fusc.flm |
URL Action Editor and Actionscript Viewer: |
| 141 |
#> flasm -a puzzle_fusc.flm |
http://www.buraks.com/ |
| 142 |
|
http://voisen.org/archives/2003/02/uae_303_and_asv_309.php |
| 143 |
|
SE|PY ActionScript Editor: http://www.sephiroth.it/python/sepy.php |
| 144 |
|
|
| 145 |
|
=head2 Obfuscators |
| 146 |
|
|
| 147 |
|
ASO Pro (ActionScript Obfuscator Pro): http://www.genable.com/aso/preview.html |
| 148 |
|
SWOB (swf obfuscator): http://home.byu.net/jtb64/Swob.htm |
| 149 |
|
OBFU - A Flash Actionscript obfuscator: http://opaque.net/~dave/obfu/ |
| 150 |
|
|
| 151 |
|
=head2 Misc |
| 152 |
|
|
| 153 |
|
ActionScript Protection: |
| 154 |
|
http://www.as-protect.com/ |
| 155 |
|
http://www.quasimondo.com/archives/000377.php |
| 156 |
|
Developer's SWF Guardian: http://anyrd.anyorganization.com/ |
| 157 |
|
Password Busting / SWF Protections: http://www.searchlores.org/cinix_fla.htm |
| 158 |
|
|
| 159 |
|
=head2 Off-Topic |
| 160 |
|
|
| 161 |
|
XPath for Actionscript and other stuff: http://www.xfactorstudio.com/Actionscript/ |
| 162 |
|
SerializerClass: http://sourceforge.net/projects/serializerclass/ |
| 163 |
|
AMF::Perl - Flash Remoting in Perl and Python - using Flash Remoting protocol (AMF): |
| 164 |
|
http://simonf.com/amfperl/ |
| 165 |
|
PEAR::SWF - Read and write SWF head tag: http://www.sephiroth.it/test/php/SWF/ |
| 166 |
|
AMFPHP - Flash Remoting for PHP: http://www.amfphp.org/ |
| 167 |
|
|
| 168 |
=cut |
=cut |
| 169 |
|
|
| 178 |
'function_stacked' => 'function(?:2|)\s\s\(.*?\)', |
'function_stacked' => 'function(?:2|)\s\s\(.*?\)', |
| 179 |
'push' => 'push\s\'(.+?)\'', |
'push' => 'push\s\'(.+?)\'', |
| 180 |
}; |
}; |
| 181 |
my @symbols_events = qw( onPress onReleaseOutside onRelease onMouseDown onEnterFrame ); |
my @symbols_events = qw( |
| 182 |
|
onDragOut |
| 183 |
|
onDragOver |
| 184 |
|
onKeyUp |
| 185 |
|
onKeyDown |
| 186 |
|
onKillFocus |
| 187 |
|
onPress |
| 188 |
|
onRelease |
| 189 |
|
onReleaseOutside |
| 190 |
|
onRollOut |
| 191 |
|
onRollOver |
| 192 |
|
onSetFocus |
| 193 |
|
onActivity |
| 194 |
|
onStatus |
| 195 |
|
onSelect |
| 196 |
|
onData |
| 197 |
|
onLoad |
| 198 |
|
allowDomain |
| 199 |
|
allowInsecureDomain |
| 200 |
|
onMouseDown |
| 201 |
|
onMouseMove |
| 202 |
|
onMouseUp |
| 203 |
|
onMouseWheel |
| 204 |
|
onEnterFrame |
| 205 |
|
onUnload |
| 206 |
|
onLoadComplete |
| 207 |
|
onLoadError |
| 208 |
|
onLoadInit |
| 209 |
|
onLoadProgress |
| 210 |
|
onLoadStart |
| 211 |
|
onID3 |
| 212 |
|
onSoundComplete |
| 213 |
|
onResize |
| 214 |
|
onChanged |
| 215 |
|
onScroller |
| 216 |
|
); |
| 217 |
my @symbols; |
my @symbols; |
| 218 |
|
|
| 219 |
# 1. read flasm code from STDIN |
# 1. read flasm code from STDIN |
| 256 |
|
|
| 257 |
# function declarations; single quotes might not be there! |
# function declarations; single quotes might not be there! |
| 258 |
if (m/$regex->{function}/) { |
if (m/$regex->{function}/) { |
| 259 |
s/'*$symbol'*/'$symbol_counter'/i; |
s/\s'*$symbol'*\s/ '$symbol_counter' /i; |
| 260 |
|
|
| 261 |
# "constants"-line at begin of each block; single quotes should already be there |
# "constants"-line at begin of each block; single quotes should already be there |
| 262 |
} elsif (m/$regex->{constants}/) { |
} elsif (m/$regex->{constants}/) { |