Monifa
S@T Compiler and Decompiler
Monifa can be used to compile STKML documents to S@T bytecode. It is also
able to decompile a complete deck or a piece of bytecode and analyze it,
providing comments about SIMAlliance compliance, detecting common errors,
like badly formatted STK macros, duplicate S@T entities and so on.
You can use Monifa as a standalone tool, as a plugin for Service Development Kit
or even reuse the Monifa API in your own projects.
S@T Compiler
Monifa
<stkml>
<card>
<display><text>Test Encrypt</text></display>
<input type="password">
<response-length min="1" max="20"/>
<variable-ref>INPUT</variable-ref>
<text>Enter Password:</text>
</input>
<encrypt SPI="03" Kic="00" Kid="10“
var-ref="CypheredData">
<parameter-list>
<variable-ref>INPUT</variable-ref>
</parameter-list>
</encrypt>
<go>
<hyper-link>
<url>sc:decrypt</url>
</hyper-link>
</go>
</card>
</stkml>
814D2002013105472D122181
020D0DF45465737420456E63
727970742D1A2304820D10F4
456E7465722050617373776F
72643A910201141526070300
1016090115290C8D0A100E07
64656372797074
S@T Decompiler
Monifa
<stkml>
<url>1</url>
<card>
<display>
<text>Test Encrypt</text>
</display>
<input format="digits" type="password">
<text>Enter Password:</text>
<response-length min="1" max="20"/>
<variable-ref>tmp_15</variable-ref>
</input>
<encrypt SPI="03" Kic="00" Kid="10“
var-ref="tmp_16">
<parameter-list>
<variable-ref>tmp_15</variable-ref>
</parameter-list>
</encrypt>
<go>
<híper-link>
<url type="smartcard">decrypt</url>
</hyper-link>
</go>
</card>
</stkml>
814D2002013105472D122181
020D0DF45465737420456E63
727970742D1A2304820D10F4
456E7465722050617373776F
72643A910201141526070300
1016090115290C8D0A100E07
64656372797074
Command-line examples
$ echo 811020050D2D0B2181020D06F448656C6C6F | Monifa
<stkml>
<card>
<display>
<text>Hello</text>
</display>
</card>
</stkml>
Decompile:
Compile:
$ Monifa <hello.stkml
811320020170050D2D0B2181020D060048656C6C6F
Interactive mode:
$ Monifa
Input the XML to compile / bytecode to decompile, followed by Ctrl+D
Ctrl+C to exit.
_
Extract the Bytecode
When the original STKML/SATML/WML looks OK, but it doesn’t seem to work correctly at the
SIMcard side, decompiling the bytecode may help debugging the issue.
Monifa is able to inspect the bytecode internals and expose common compilation bugs and other
errors.
The first step is extracting the bytecode. To avoid dealing with 03.40 concatenation, consider taking
the bytecode at the OSG  OSGLB level instead of OSGLB  SMSC. For example:
25.06.09/16:20:56>
sr/SC(3/4)<[0000016C.00000004.00000000.00000063.00020139323800010135313139393739383032383900007F0000000000F60000020B0
002F0010424005B0301000000000000000000000000000000000000000000000000015340541020020020020135813320020180852D20AC024021
AC024024200B150A0800000000000000002E0A02030B0608011608011529098D07100E046D656E75020A00020001020400CD7B353131393937393
8303238392D33322D312055524C3D687474703A2F2F3132372E302E302E313A393038302F626D732F4F70656E53657373696F6E3F6D736973646E
3D35313139393739383032383926703D2563322561302531372563322562312531352530372530312530342531652563332562622563322561302
56333253832712533612563332562312535632563322539382531352530312531302530312B714333256333256232266D3D4C4770256332256264
2563332538392535622563332562652532337D7B7D]
The S@T 01.00 bytecode is highlighted in red.
GUI
There is a user-friendly GUI available in the LinqUs Service Developer Kit:
The actual STK
deck/card sent to the
SIMcard, it may be
very different from the
original source. The
differences are key to
debug the errors!
tmp_16: an uninitialized
variable may lead to
random errors!

Monifa: S@T Bytecode Compiler and Decompiler

  • 1.
    Monifa S@T Compiler andDecompiler Monifa can be used to compile STKML documents to S@T bytecode. It is also able to decompile a complete deck or a piece of bytecode and analyze it, providing comments about SIMAlliance compliance, detecting common errors, like badly formatted STK macros, duplicate S@T entities and so on. You can use Monifa as a standalone tool, as a plugin for Service Development Kit or even reuse the Monifa API in your own projects.
  • 2.
    S@T Compiler Monifa <stkml> <card> <display><text>Test Encrypt</text></display> <inputtype="password"> <response-length min="1" max="20"/> <variable-ref>INPUT</variable-ref> <text>Enter Password:</text> </input> <encrypt SPI="03" Kic="00" Kid="10“ var-ref="CypheredData"> <parameter-list> <variable-ref>INPUT</variable-ref> </parameter-list> </encrypt> <go> <hyper-link> <url>sc:decrypt</url> </hyper-link> </go> </card> </stkml> 814D2002013105472D122181 020D0DF45465737420456E63 727970742D1A2304820D10F4 456E7465722050617373776F 72643A910201141526070300 1016090115290C8D0A100E07 64656372797074
  • 3.
    S@T Decompiler Monifa <stkml> <url>1</url> <card> <display> <text>Test Encrypt</text> </display> <inputformat="digits" type="password"> <text>Enter Password:</text> <response-length min="1" max="20"/> <variable-ref>tmp_15</variable-ref> </input> <encrypt SPI="03" Kic="00" Kid="10“ var-ref="tmp_16"> <parameter-list> <variable-ref>tmp_15</variable-ref> </parameter-list> </encrypt> <go> <híper-link> <url type="smartcard">decrypt</url> </hyper-link> </go> </card> </stkml> 814D2002013105472D122181 020D0DF45465737420456E63 727970742D1A2304820D10F4 456E7465722050617373776F 72643A910201141526070300 1016090115290C8D0A100E07 64656372797074
  • 4.
    Command-line examples $ echo811020050D2D0B2181020D06F448656C6C6F | Monifa <stkml> <card> <display> <text>Hello</text> </display> </card> </stkml> Decompile: Compile: $ Monifa <hello.stkml 811320020170050D2D0B2181020D060048656C6C6F Interactive mode: $ Monifa Input the XML to compile / bytecode to decompile, followed by Ctrl+D Ctrl+C to exit. _
  • 5.
    Extract the Bytecode Whenthe original STKML/SATML/WML looks OK, but it doesn’t seem to work correctly at the SIMcard side, decompiling the bytecode may help debugging the issue. Monifa is able to inspect the bytecode internals and expose common compilation bugs and other errors. The first step is extracting the bytecode. To avoid dealing with 03.40 concatenation, consider taking the bytecode at the OSG  OSGLB level instead of OSGLB  SMSC. For example: 25.06.09/16:20:56> sr/SC(3/4)<[0000016C.00000004.00000000.00000063.00020139323800010135313139393739383032383900007F0000000000F60000020B0 002F0010424005B0301000000000000000000000000000000000000000000000000015340541020020020020135813320020180852D20AC024021 AC024024200B150A0800000000000000002E0A02030B0608011608011529098D07100E046D656E75020A00020001020400CD7B353131393937393 8303238392D33322D312055524C3D687474703A2F2F3132372E302E302E313A393038302F626D732F4F70656E53657373696F6E3F6D736973646E 3D35313139393739383032383926703D2563322561302531372563322562312531352530372530312530342531652563332562622563322561302 56333253832712533612563332562312535632563322539382531352530312531302530312B714333256333256232266D3D4C4770256332256264 2563332538392535622563332562652532337D7B7D] The S@T 01.00 bytecode is highlighted in red.
  • 6.
    GUI There is auser-friendly GUI available in the LinqUs Service Developer Kit: The actual STK deck/card sent to the SIMcard, it may be very different from the original source. The differences are key to debug the errors! tmp_16: an uninitialized variable may lead to random errors!

Editor's Notes

  • #1 Monifa is a S@T compiler and decompiler. It supports STKML 5.1+.
  • #2 Compile STKML document and generate the S@T bytecode
  • #3 Decompile S@T bytecode and generate the equivalent STKML document
  • #4 Invoke Monifa using Monifa.bat in Windows or Monifa.sh in Unix/Linux
  • #5 Basic knowledge in SMPP, GSM 03.40 and S@T protocols is required
  • #6 http://products.tools.gemalto.com