コード例 #1
0
ファイル: swf_injector.py プロジェクト: algas/tomato
def _maketag(d, encode_option):
    tag = '\x3f\x03'
    tag += _h32(_calctaglen(d, encode_option))
    for k in d:
        value = unicode(d[k]).encode(encode_option, 'ignore')
        tag += '\x96' + _h16(len(k)+2) + '\x00' + k + '\x00'
        tag += '\x96' + _h16(len(value)+2) + '\x00' + value + '\x00'
        tag += '\x1d'
    tag += '\x00'
    return tag
コード例 #2
0
ファイル: swf_injector.py プロジェクト: algas/tomato
def create_swf(base_swf, params):
    "パラメーターを埋め込んだ Flash lite 1.1/2.0 ファイルを生成"
    # 圧縮されている場合は展開する
    decomp_swf = decompress(base_swf)
    
    # パラメーターを埋め込む
    tag = _maketag(params, get_encode(decomp_swf))
    rectbit = ord(decomp_swf[8]) >> 3
    head_len = int(((( 8 - ((rectbit*4+5)&7) )&7)+ rectbit*4 + 5 )/8) + 12 + 5;
    head = decomp_swf[:head_len]
    tail = decomp_swf[head_len:]
    newhead = head[:4] + _h32(len(decomp_swf) + len(tag)) + head[8:]
    out_swf = newhead + tag + tail

    # もし圧縮されていた場合は、圧縮し直す
    out_swf = compress(out_swf)
    return out_swf    
コード例 #3
0
ファイル: structure.py プロジェクト: algas/tomato
    def set_length(self, num):
        """
        タグ(block)の length を変える. length の長さによって形式が変わる
        See swf_file_format_spec_v10.pdf (p.27)
        """
        old_tag_code_and_length = le2byte(self.value[:2])
        length = old_tag_code_and_length & 0x3f

        if length != 63:
            """
            short. TagCodeAndLength は 2 byte のみ
            """
            tag_code_and_length = (self.tag << 6) + num
            self.value = _h16(tag_code_and_length) + self.value[2:]
        else:
            """
            large. TagCodeAndLength は 2 byte + 4 byte
            後ろの 4 byte の length を変えれば良い
            """
            self.value = self.value[:(self.content_offset - 4)] + _h32(num) + \
                self.value[self.content_offset:]
        self.length = num
コード例 #4
0
ファイル: swf_processor.py プロジェクト: algas/tomato
    def update_file_header(self):
        fl = len(self.swf_head)
        for block in self.blocks:
            fl += len(block)

        self.swf_head = self.swf_head[:4] + _h32(fl) + self.swf_head[8:]