def replace_pyzzer_entry_point_shebang(all_data, placeholder, new_prefix):
 launcher = shebang = None
 pos = all_data.rfind('PK\x05\x06')
 if (pos >= 0):
  end_cdr = all_data[(pos + 12):(pos + 20)]
  (cdr_size, cdr_offset) = struct.unpack(u'<LL', end_cdr)
  arc_pos = ((pos - cdr_size) - cdr_offset)
  data = all_data[arc_pos:]
  if (arc_pos > 0):
   pos = all_data.rfind('#!', 0, arc_pos)
   if (pos >= 0):
    shebang = all_data[pos:arc_pos]
    if (pos > 0):
     launcher = all_data[:pos]
  if (data and shebang and launcher):
   if hasattr(placeholder, u'encode'):
    placeholder = placeholder.encode(u'utf-8')
   if hasattr(new_prefix, u'encode'):
    new_prefix = new_prefix.encode(u'utf-8')
   shebang = shebang.replace(placeholder, new_prefix)
   all_data = ''.join([launcher, shebang, data])
 return all_data

def replace_pyzzer_entry_point_shebang ( all_data , placeholder , new_prefix ) : launcher = shebang = None pos = all_data . rfind ( 'PK\x05\x06' ) if ( pos >= 0 ) : end_cdr = all_data [ ( pos + 12 ) : ( pos + 20 ) ] ( cdr_size , cdr_offset ) = struct . unpack ( u'<LL' , end_cdr ) arc_pos = ( ( pos - cdr_size ) - cdr_offset ) data = all_data [ arc_pos : ] if ( arc_pos > 0 ) : pos = all_data . rfind ( '#!' , 0 , arc_pos ) if ( pos >= 0 ) : shebang = all_data [ pos : arc_pos ] if ( pos > 0 ) : launcher = all_data [ : pos ] if ( data and shebang and launcher ) : if hasattr ( placeholder , u'encode' ) : placeholder = placeholder . encode ( u'utf-8' ) if hasattr ( new_prefix , u'encode' ) : new_prefix = new_prefix . encode ( u'utf-8' ) shebang = shebang . replace ( placeholder , new_prefix ) all_data = '' . join ( [ launcher , shebang , data ] ) return all_data
code adapted from pyzzer .