VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /usr/share/emscripten/tools/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/emscripten/tools/file2json.py
'''
Converts a binary file into JSON.

This lets you transform a binary file into something you can
easily bundle inside a web page.

Usage: file2json.py FILENAME VARNAME

FILENAME - the binary file
VARNAME - the variable to store it in (the output will be VARNAME = [...])
'''

import os, sys

data = open(sys.argv[1], 'r').read()
sdata = map(lambda x: str(ord(x)) + ',', data)
sdata[-1] = sdata[-1].replace(',', '')
lined = []
while len(sdata) > 0:
  lined += sdata[:30]
  sdata = sdata[30:]
  if len(sdata) > 0:
    lined += ['\n']
json = '[' + ''.join(lined) + ']'

if len(sys.argv) < 3:
  print json
else:
  print 'var ' + sys.argv[2] + '=' + json + ';'

'''
or (but this fails, we get a string at runtime?)

data = open(sys.argv[1], 'r').read()
counter = 0
print '[',
for i in range(len(data)):
  last = i == len(data)-1
  print ord(data[i]),
  counter += 1
  if counter % 20 == 0:
    print
  if counter % 1005 == 0 and not last:
    print '] + [',
  elif not last: print ',',

print ']'
'''


VaKeR 2022