コード例 #1
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def sign_apk(sample_file_name):  # Sign an apk file with a SHA1 key
    try:
        if enable_logging:
            u.logger('Sign: ' + sample_file_name)
        popen('jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore ' + obfuscator_resource_dir + '/resignKey.keystore -storepass resignKey ' + sample_file_name + ' resignKey')
    except OSError as ex:
        raise e.OpenToolException(str(ex) + '\nUnable to sign ' + sample_file_name)
コード例 #2
0
async def giverole(ctx, role_name:str, *, color_code:str):
  logger('giverole',ctx)
  
  if color_code == '#000000': # '000000' seems to not behave as expected, therefore it is replaced with '111111' 
    color_code = '#111111'
    print(f'Color Code Exception. Color Replaced With: {color_code}')
  else:
    pass

  color_code = color_code.split('#') # remove the #
  color_code.insert(0, '0x') # replace it with 0x
  color_code = ''.join(color_code) # join the string back
  color_code = int(color_code, 16) # cast to base 16 int

  guild = ctx.guild
  member = ctx.author
  role = discord.utils.get(member.guild.roles, name=role_name)

  if role not in guild.roles: # if role doesnt exist, create it
    await guild.create_role(name=role_name,color=discord.Color(color_code))
  
  if role == None:
    await ctx.send('something went wrong :D')
  
  await member.add_roles(role) # assign the role to the member
  await ctx.send('role added')
コード例 #3
0
async def pasta(ctx, filename):
  logger('pasta',ctx)

  dir = f'copypasta/{filename}.txt'
  with open(dir, 'r') as f: # retrieve the copypasta and send it as a message
    pasta = f.read()
    await ctx.send(pasta)
コード例 #4
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def smali(sample_tf_dir, sample_file_name):  # Smali an apk file
    try:
        if enable_logging:
            u.logger('Smali: ' + sample_file_name + ' from ' + sample_tf_dir)
        popen('apktool b --force-all ' + sample_tf_dir + '/app' + ' ' + sample_file_name)
    except OSError as ex:
        raise e.OpenToolException(str(ex) + '\nUnable to smali ' + sample_file_name + ' from ' + sample_tf_dir)
コード例 #5
0
async def disconnect(ctx):
  logger('disconnect',ctx)

  voice = get(bot.voice_clients, guild=ctx.guild)
  await voice.disconnect() # disconnect the bot from a voice channel
  if os.path.exists('source.m4a'):
    os.remove('source.m4a')
コード例 #6
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def clean_temp(sample_tf_dir):  # Clear the temporary support directory
    try:
        if enable_logging:
            u.logger('Directory cleaned: ' + sample_tf_dir)
        popen('rm -rf ' + sample_tf_dir + '/app')
    except OSError as ex:
        raise e.OpenToolException(str(ex) + '\nUnable to clean ' + sample_tf_dir)
コード例 #7
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def run_obfuscator_zip(sample_file_name, sample_tf_dir):
    try:
        if enable_logging:
            u.logger('Obfuscator Align')
        apply_zip(sample_file_name)
    except e.RunningObfuscatorException as ex:
        raise e.RunningObfuscatorException(str(ex) + '\nUnable to apply Align')
コード例 #8
0
async def help(ctx):
  logger('help',ctx)

  embed = discord.Embed(title='Available Commands')

  embed.add_field(name='!ping', value='returns the ping', inline = False)
  embed.add_field(name='!echo', value='usage: !echo [number of times to echo] [text to echo]', inline = False)
  embed.add_field(name='!giverole', value='usage: !giverole "name here" [html color code]', inline = False)
  embed.add_field(name='!removerole', value='usage: !removerole "name here"', inline = False)
  embed.add_field(name='!flip', value='flips a coin', inline = False)
  embed.add_field(name='!copypasta', value='usage: !copypasta [name] [copypasta here]', inline = False)
  embed.add_field(name='!pasta', value='recall the copypasta, !pasta [name]')
  embed.add_field(name='!emoji', value='emojifys the text', inline = False)
  embed.add_field(name='!wordcloud', value='generates a wordcloud', inline = False)
  embed.add_field(name='!wolfram', value='wolfram search', inline = False)
  embed.add_field(name='!wolfram_image', value='wolfram search but returns an image', inline = False)
  embed.add_field(name='!google', value='usage: !google [keywords]', inline = False)
  embed.add_field(name='!oof', value='plays /sounds/oof.m4a', inline = False)
  embed.add_field(name='!echoes', value='plays /sounds/echoes.mp3', inline = False)
  embed.add_field(name='!youtube', value='usage: !youtube [youtube link]', inline = False)
  embed.add_field(name='!disconnect', value='disconnects the bot from the voice channel', inline = False)
  embed.add_field(name='!meme clown', value='usage: !clown (text)', inline = False)
  embed.add_field(name='!votemute', value='usage: !votemute (tag the user to mute)', inline = False)
  embed.add_field(name='!voteunmute', value='usage: !voteunmute (tag the user to mute)', inline = False)

  await ctx.send(embed=embed)
コード例 #9
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def run_obfuscator_lib(sample_file_name, sample_tf_dir):
    try:
        if enable_logging:
            u.logger('Obfuscator Lib')
        apply_py_obfuscator(sample_file_name, sample_tf_dir, obfuscator_lib)
    except e.RunningObfuscatorException as ex:
        raise e.RunningObfuscatorException(str(ex) + '\nUnable to apply Lib')
コード例 #10
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def clean_apk(sample_file_name):  # Clear the temporary apk
    try:
        if enable_logging:
            u.logger('Apk cleaned: ' + sample_file_name)
        popen('rm -f ' + sample_file_name)
    except OSError as ex:
        raise e.OpenToolException(str(ex) + '\nUnable to clean ' + sample_file_name)
コード例 #11
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def run_obfuscator_zip(sample_file_name, sample_tf_dir):
    try:
        if enable_logging:
            u.logger('Obfuscator Align')
        apply_zip(sample_file_name)
    except e.RunningObfuscatorException as ex:
        raise e.RunningObfuscatorException(str(ex) + '\nUnable to apply Align')
コード例 #12
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def run_obfuscator_resigned(sample_file_name, sample_tf_dir):
    try:
        if enable_logging:
            u.logger('Obfuscator Resign')
        apply_resign(sample_file_name)
    except e.OpenToolException as ex:
        raise e.RunningObfuscatorException(str(ex) + '\nUnable to apply Resign')
コード例 #13
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def run_obfuscator_lib(sample_file_name, sample_tf_dir):
    try:
        if enable_logging:
            u.logger('Obfuscator Lib')
        apply_py_obfuscator(sample_file_name, sample_tf_dir, obfuscator_lib)
    except e.RunningObfuscatorException as ex:
        raise e.RunningObfuscatorException(str(ex) + '\nUnable to apply Lib')
コード例 #14
0
ファイル: taxi.py プロジェクト: repogit44/RL-CS7642
    def train(self):
        '''Q learning algorithm'''

        for i in range(self.num_episodes):
            state = self.env.reset()
            if i % 10000 == 0 and i > 0:
                util.logger('Episode {}...'.format(i))

            done = False
            while not done:
                if '--render' in argv:
                    self.env.render()
                # pylint: disable=line-too-long
                action = util.select_epsilon_greedy_action(
                    state, self.q_value, self.epsilon, self.env)
                next_state, reward, done, _ = self.env.step(action)
                next_state_max_action = util.select_greedy_action(
                    next_state, self.q_value)
                # pylint: disable=line-too-long
                update = self.alpha * (
                    reward + self.gamma *
                    self.q_value[next_state, next_state_max_action] -
                    self.q_value[state, action])
                self.q_value[state, action] += update
                state = next_state

            if self.epsilon > 0.075:
                self.epsilon = self.epsilon * (1 - self.epsilon_decay)

        self.env.close()
コード例 #15
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def design_apk(sample_file_name):  # Remove a signature from an apk file
    try:
        if enable_logging:
            u.logger('DeSign: ' + sample_file_name)
        popen('zip -d ' + sample_file_name + ' /META-INF/*')  # Delete the META-INF folder from the apk root
    except OSError as ex:
        raise e.OpenToolException(str(ex) + '\nUnable to delete META-INF from ' + sample_file_name)
コード例 #16
0
def clean_mysql(con):
    """Remove SystemEvents matching regexps in trigger table"""
    total = 0
    for id, from_host, sys_log_tag, message in triggers(con):
        num_of_rows = clean_system_events(from_host, sys_log_tag, message)
        update_trigger_with_delete_stats(id, num_of_rows)
        total += num_of_rows
    logger('Deleted %s SystemEvents matched by triggers.' % total)
コード例 #17
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def clean_temp(sample_tf_dir):  # Clear the temporary support directory
    try:
        if enable_logging:
            u.logger('Directory cleaned: ' + sample_tf_dir)
        popen('rm -rf ' + sample_tf_dir + '/app')
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to clean ' + sample_tf_dir)
コード例 #18
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def clean_apk(sample_file_name):  # Clear the temporary apk
    try:
        if enable_logging:
            u.logger('Apk cleaned: ' + sample_file_name)
        popen('rm -f ' + sample_file_name)
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to clean ' + sample_file_name)
コード例 #19
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def init(sample_tf_dir):  # Initialize the obfuscator routine
    reload(sys)
    sys.setdefaultencoding('utf-8')
    u.obfuscator_dir = obfuscator_resource_dir
    u.global_dir = sample_tf_dir + '/app'
    logging.basicConfig(filename=obfuscator_log_file, level=logging.DEBUG)
    if enable_logging:
        u.logger('Obfuscators Initialize: ' + u.obfuscator_dir + ' ' + u.global_dir)
コード例 #20
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def run_obfuscator_resigned(sample_file_name, sample_tf_dir):
    try:
        if enable_logging:
            u.logger('Obfuscator Resign')
        apply_resign(sample_file_name)
    except e.OpenToolException as ex:
        raise e.RunningObfuscatorException(
            str(ex) + '\nUnable to apply Resign')
コード例 #21
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def design_apk(sample_file_name):  # Remove a signature from an apk file
    try:
        if enable_logging:
            u.logger('DeSign: ' + sample_file_name)
        popen('zip -d ' + sample_file_name +
              ' /META-INF/*')  # Delete the META-INF folder from the apk root
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to delete META-INF from ' + sample_file_name)
コード例 #22
0
async def wolfram(ctx, content):
  logger('wolfram',ctx)

  wolframAppId = 'APP_ID' # get your app id from here: https://products.wolframalpha.com/simple-api/documentation/
  wolframUrl = 'https://api.wolframalpha.com/v1/result'
  wolframParams = {'i':'{}'.format(content),'appid':'{}'.format(wolframAppId)}

  r = requests.get(wolframUrl, params=wolframParams) # make an http request to get results from wolframalpha with given params
  await ctx.send(r.text) # send results from wolframalpha
コード例 #23
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def zip_align(sample_file_name):  # Align the file
    try:
        if enable_logging:
            u.logger('Zip: ' + sample_file_name)
        popen('cp ' + sample_file_name + ' ' + sample_file_name + '_old.apk')
        popen('zipalign -f 8 ' + sample_file_name + '_old.apk' + ' ' + sample_file_name)
        popen('rm -f ' + sample_file_name + '_old.apk')
    except OSError as ex:
        raise e.OpenToolException(str(ex) + '\nUnable to zipalign ' + sample_file_name)
コード例 #24
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def init(sample_tf_dir):  # Initialize the obfuscator routine
    reload(sys)
    sys.setdefaultencoding('utf-8')
    u.obfuscator_dir = obfuscator_resource_dir
    u.global_dir = sample_tf_dir + '/app'
    logging.basicConfig(filename=obfuscator_log_file, level=logging.DEBUG)
    if enable_logging:
        u.logger('Obfuscators Initialize: ' + u.obfuscator_dir + ' ' +
                 u.global_dir)
コード例 #25
0
ファイル: run_test.py プロジェクト: wangzhenxa/Top1000APK
 def launchAPK(self, sn, apk):
     apk_cmp = apk
     logger(logname, sn + ": lunching %s" % apk_cmp)
     results = command("adb -s %s shell ' am start -W %s'" % (sn, apk_cmp),
                       timeout=30).strip().replace('\n', ';')
     if 'Complete' in results:
         return True
     else:
         return False
コード例 #26
0
def clean_apk(apk_path):  # Clear the temporary apk
    try:
        if enable_logging:
            u.logger('Apk cleaned: ' + apk_path)
        #popen('rm -f ' + apk_path)
        os.remove(apk_path)
        #os.system("del /f /q {0}".format(apk_path))
    except OSError as ex:
        raise e.OpenToolException(str(ex) + '\nUnable to clean ' + apk_path)
コード例 #27
0
def clean_temp(sample_tf_dir):  # Clear the temporary support directory
    try:
        if enable_logging:
            u.logger('Directory cleaned: ' + sample_tf_dir)
        app_dir = os.path.join(sample_tf_dir, 'app')
        rm_tree(app_dir)
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to clean ' + sample_tf_dir)
コード例 #28
0
def design_apk(sample_file_name):  # Remove a signature from an apk file
    try:
        if enable_logging:
            u.logger('DeSign: ' + sample_file_name)
        #NOTE: we dont need to remove META-INF because it will be just overwritten during signing
        #popen("rd /s /q {0}".format(os.path.join(sample_file_name, 'META-INF')))
        #popen('zip -d ' + sample_file_name + ' /META-INF/*')  # Delete the META-INF folder from the apk root
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to delete META-INF from ' + sample_file_name)
コード例 #29
0
async def removerole(ctx, role_name:str):
  logger('removerole',ctx)

  member = ctx.author
  role = discord.utils.get(member.guild.roles, name=role_name)
  if role is None:
    await ctx.send('something went wrong :D')
  else:
    await  member.remove_roles(role)
    await ctx.send('role removed')
コード例 #30
0
ファイル: obfuscators.py プロジェクト: yyg192/aamo
def smali(sample_tf_dir, sample_file_name):  # Smali an apk file
    try:
        if enable_logging:
            u.logger('Smali: ' + sample_file_name + ' from ' + sample_tf_dir)
        popen('apktool b --force-all ' + sample_tf_dir + '/app' + ' ' +
              sample_file_name)
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to smali ' + sample_file_name + ' from ' +
            sample_tf_dir)
コード例 #31
0
ファイル: run_test.py プロジェクト: wangzhenxa/Top1000APK
 def getAPKsList(self, apk_folder):
     apk_path = apk_folder
     apks = commands.getoutput('ls %s | grep apk' % apk_path)
     apk_list = apks.split('\n')
     if len(apk_list) != 0:
         return apk_list
     else:
         logger(logname, 'No APK file in %s' % apk_path)
         # r.set('apk_list',apk_list)
         return []
コード例 #32
0
def zip_align(sample_file_name):  # Align the file
    try:
        if enable_logging:
            u.logger('Zip: ' + sample_file_name)
        u.copy_file(sample_file_name, sample_file_name + '_old.apk')
        popen(config.zipalign_path + ' -f 8 ' + sample_file_name + '_old.apk' +
              ' ' + sample_file_name)
        os.remove(sample_file_name + '_old.apk')
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to zipalign ' + sample_file_name)
コード例 #33
0
def sign_apk(sample_file_name):  # Sign an apk file with a SHA1 key
    try:
        if enable_logging:
            u.logger('Sign: ' + sample_file_name)
        popen(config.jarsigner_path +
              ' -sigalg MD5withRSA -digestalg SHA1 -keystore ' +
              os.path.join(obfuscator_resource_dir, 'resignKey.keystore') +
              ' -storepass resignKey ' + sample_file_name + ' resignKey')
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to sign ' + sample_file_name)
コード例 #34
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def zip_align(sample_file_name):  # Align the file
    try:
        if enable_logging:
            u.logger('Zip: ' + sample_file_name)
        popen('cp ' + sample_file_name + ' ' + sample_file_name + '_old.apk')
        popen('zipalign -f 8 ' + sample_file_name + '_old.apk' + ' ' +
              sample_file_name)
        popen('rm -f ' + sample_file_name + '_old.apk')
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to zipalign ' + sample_file_name)
コード例 #35
0
def smali(sample_tf_dir, sample_file_name):  # Smali an apk file
    try:
        if enable_logging:
            u.logger('Smali: ' + sample_file_name + ' from ' + sample_tf_dir)
        cmd = "{0} b --force-all -o {1} {2}".format(
            config.apktool_path, sample_file_name,
            os.path.join(sample_tf_dir, 'app'))
        popen(cmd)
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to smali ' + sample_file_name + ' from ' +
            sample_tf_dir)
コード例 #36
0
def signal_handler(signum, frame):
    CURSOR_UP_ONE = '\x1b[1A'
    ERASE_LINE = '\x1b[2K'
    print(ERASE_LINE + CURSOR_UP_ONE)
    if time.time() - statics.startTime >= 5:
        mysql.close(conn,config)
        
        util.logger(util.colors.OKGREEN + "Bot stopped" + util.colors.ENDC, True, True)
        os.rename("logs/latest.log", "logs/{}.log".format(time.strftime("%Y-%m-%d_%H:%M:%S")))
        sys.exit(0)
    else:
        util.logger(util.colors.WARNING + "Too early stop" + util.colors.ENDC)
コード例 #37
0
ファイル: run_test.py プロジェクト: wangzhenxa/Top1000APK
 def run(self):
     global index
     testnum = 0
     while index < len(self.apk_list) - 1:
         lock.acquire()
         index = index + 1
         testnum = index
         lock.release()
         logger(
             logname, self.sn + ": run test begin apk =" +
             self.apk_list[testnum] + ";testnum =" + str(testnum))
         run_test(self.sn, self.apk_list[testnum], testnum)
コード例 #38
0
async def google(ctx, keywords):
  logger('google',ctx)
  
  response = google_images_download.googleimagesdownload()   # class instantiation

  arguments = {"keywords":keywords, "limit":5, "print_urls":False, "safe_search":True}   # creating list of arguments
  paths = response.download(arguments)   # passing the arguments to the function
  attachment = [
    discord.File(paths[0][keywords][random.randint(0,4)]), # get a random image from the 5 results
  ]

  await ctx.send(files=attachment) # send the image as an attachment
コード例 #39
0
async def copypasta(ctx, filename, content):
  logger('copypasta',ctx)

  try:
    print(f'file name: {filename}')
    print(f'copy pasta: {content}')
    
    dir = f'copypasta/{filename}.txt'
    with open(dir, 'w') as f: # save the copypasta to a text file
      f.write(f'{pasta_string}\n')
  except:
    print('something went wrong :D')
コード例 #40
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def sign_apk(sample_file_name):  # Sign an apk file with a SHA1 key
    try:
        if enable_logging:
            u.logger('Sign: ' + sample_file_name)
        popen('jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore ' +
              obfuscator_resource_dir +
              '/resignKey.keystore -storepass resignKey ' + sample_file_name +
              ' resignKey')
        #popen('/opt/jdk1.8.0_101/bin/jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore ' + obfuscator_resource_dir + '/resignKey.keystore -storepass resignKey ' + sample_file_name + ' resignKey')
    except OSError as ex:
        raise e.OpenToolException(
            str(ex) + '\nUnable to sign ' + sample_file_name)
コード例 #41
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def popen(com_str):
    p = sub.Popen(com_str, shell=True, stdout=sub.PIPE, stderr=sub.PIPE)
    out, err = p.communicate()
    if enable_logging:
        u.logger(out)
        u.logger(err)
    if 'Exception' in out or 'Exception' in err:
        if 'method index is too large' in out or 'method index is too large' in err:
            raise e.AndroidLimitException('Unable run :' + com_str)
        elif 'java.lang.ArrayIndexOutOfBoundsException' in out or 'java.lang.ArrayIndexOutOfBoundsException' in err:
            raise e.AndroidRandomException('Unable run :' + com_str)
        else:
            raise e.RunningObfuscatorException('Unable run :' + com_str)
コード例 #42
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def backsmali(sample_tf_dir, sample_file_name):  # Backsmali an apk file
    try:
        if enable_logging:
            u.logger('Backsmali: ' + sample_file_name + ' into ' + sample_tf_dir)
        popen('apktool d --force --no-debug-info ' + sample_file_name + ' ' + sample_tf_dir + '/app')
        if os.path.isdir(u.base_dir()+'/smali/com'):
            u.main_exec_dir = 'com'
        elif os.path.isdir(u.base_dir()+'/smali/org'):
            u.main_exec_dir = 'org'
        else:
            u.main_exec_dir = ''
    except OSError as ex:
        raise e.OpenToolException(str(ex) + '\nUnable to backsmali ' + sample_file_name + ' into ' + sample_tf_dir)
コード例 #43
0
ファイル: obfuscators.py プロジェクト: saba96/droidcat
def popen(com_str):
    p = sub.Popen(com_str, shell=True, stdout=sub.PIPE, stderr=sub.PIPE)
    out, err = p.communicate()
    if enable_logging:
        u.logger(out)
        u.logger(err)
    if 'Exception' in out or 'Exception' in err:
        if 'method index is too large' in out or 'method index is too large' in err:
            raise e.AndroidLimitException('Unable run :' + com_str)
        elif 'java.lang.ArrayIndexOutOfBoundsException' in out or 'java.lang.ArrayIndexOutOfBoundsException' in err:
            raise e.AndroidRandomException('Unable run :' + com_str)
        else:
            raise e.RunningObfuscatorException('Unable run :' + com_str)
コード例 #44
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def apply_py_obfuscator(sample_file_name, sample_tf_dir, obfuscatorPy):
    '''Apply an obfuscator'''
    try:
        if enable_logging:
            u.logger('Python Obfuscator!')
        #backsmali(sample_tf_dir, sample_file_name)
        obfuscatorPy.obfuscate()
        if debug:
            smali(sample_tf_dir, sample_file_name)
        #sign_apk(sample_file_name)
        #clean_temp(sample_tf_dir)
    except (e.OpenToolException, e.LoadFileException) as ex:
        raise e.RunningObfuscatorException(str(ex) + '\nUnable run python obfuscator')
コード例 #45
0
ファイル: index.py プロジェクト: gsathya/slyer
    def _load(self):
        config_filename = "config.ini"
        self.config = util.parse_config(config_filename)

        #Set up logging
        self.logger = util.logger(self.config['loglevel'], self.config['logfile'])
        self.logger.info("Loaded config")
コード例 #46
0
ファイル: publish.py プロジェクト: gsathya/slyer
    def _load(self):
        config_filename = "config.ini"
        self.config = util.parse_config(config_filename)

        #Set up logging
        self.logger = util.logger(self.config['loglevel'], self.config['logfile'])
        self.logger.info("Loaded config")

        #Read file and store header and content
        with open(self.name, 'r') as f:
            self.raw_header, self.raw_content = f.read().split('---')
        self.logger.info("Read raw header and content")

        self.header = util.parse_header(self.raw_header)
        self.logger.info("Parsed header into a dict")
コード例 #47
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def apply_dir(filename, obfuscator_to_apply, mode=0, retry=0):
    try:
        obfuscate_sample(adam_base_dir + 'input/' + filename, obfuscator_to_apply, adam_base_dir + 'temp/' + filename[:-4])
        sys.exit(0)
    except e.AndroidLimitException as ex:
        u.logger('### ERROR ### ' + str(ex) + ' ### ERROR ###')
        u.logger('### WARNING ###')
        if mode == 0:
            apply_dir(filename, [o for o in obfuscator_to_apply if o != 'Reflection'], 1)
        elif mode == 1:
            apply_dir(filename, [o for o in obfuscator_to_apply if o != 'Indirections'], 2)
        else:
            sys.exit(1)
    except e.AndroidRandomException as ex:
        u.logger('### ERROR ### ' + str(ex) + ' ### ERROR ###')
        if retry == 0:
            u.logger('### WARNING ###')
            apply_dir(filename, obfuscator_to_apply, mode, retry + 1)
        else:
            u.logger('### FAILURE ###')
            sys.exit(2)
    except Exception as ex:
        u.logger('### ERROR ### ' + str(ex) + ' ### ERROR ###')
        u.logger('### FAILURE ###')
        sys.exit(2)
コード例 #48
0
ファイル: main.py プロジェクト: tiwilliam/syscollect

# List all commands
def mgmt_help(conn, args):
    conn.wfile.write("commands:")

    for item in conn.server.cmds:
        conn.wfile.write(" " + item[0])

    conn.wfile.write("\n")


## Main program ########################################################
addsignal(2, gotsignal)  # SIGINT

logger = util.logger(static.loglevel)
params = (static.name, static.version, static.fqdn)
logger.info("Starting %s version %s (%s)" % params)

repo = repository.Repository()
loaded_plugins = repo.get_plugins()

if loaded_plugins:
    for p in loaded_plugins:
        p.start()
else:
    logger.error("No plugins found - bye")
    sys.exit(1)

server = tcp.ThreadedServer(("", 8090), tcp.RequestHandler)
コード例 #49
0
ファイル: scanner.py プロジェクト: YFPUSHKIN/kukuruku_freebsd
  (opts, args) = getopt.getopt(sys.argv[1:], "d:p:")
except getopt.GetoptError as e:
  usage()

ppm = 0
device = ""
for opt, arg in opts:
  if opt == "-d":
    device = arg
  elif opt == "-p":
    ppm = int(arg)
  else:
    usage()
    assert False

l = util.logger()
l.setloglevel("DBG")

(fd_r,fd_w) = os.pipe()

scanner = KukurukuScanner(l)

sdr = top_block(device, scanner.conf.rate, ppm, fd_w)

for i in range(0, 4):
  sdr.set_gain(i, int(scanner.conf.gainpcs[i]))

file_r = os.fdopen(fd_r, "rb")

t = threading.Thread(target=scanner.work, args = (sdr,file_r))
t.daemon = True
コード例 #50
0
ファイル: test.py プロジェクト: pombredanne/integrity-1
import unittest

import formatting
import descriptiveness

import os
import util
import json
from formatting import Formatting
from descriptiveness import Descriptiveness

logger = util.logger(__name__, 'debug', verbosity=2)


def test_file(Metric):
    test_file = "./metric.py"  # the file to test
    meter = Metric(scale=100)
    logger.info(meter.report(test_file))


def test_module(Metric):
    reports = {}
    for fn in os.listdir('.'):
        if ".py" not in fn and "__init__" not in fn:
            continue
        meter = Metric(scale=100)
        reports[fn] = meter.report(fn)
    logger.info(json.dumps(reports, sort_keys=True,
                           indent=4, separators=(',', ': ')))

コード例 #51
0
ファイル: obfuscators.py プロジェクト: dstmath/aamo
def obfuscate_sample(sample_file_name, obfuscator_list, sample_tf_dir):
    '''This function obfucate a sample with the obfuscators in the list using a temporary directory as support'''
    init(sample_tf_dir)
    if enable_logging:
        u.logger('Obfuscate Request: %s - %s - %s' % (sample_file_name, obfuscator_list, sample_tf_dir))
    else:
        u.logger('Obfuscate Request')
    if not debug:
        clean_temp(sample_tf_dir)
    backsmali(sample_tf_dir, sample_file_name)
    start_time = datetime.utcnow()
    if enable_logging:
        u.logger('Obfuscate Start: ' + str(start_time))
    try:
        for obfuscator_item in obfuscator_list:
            obfuscator_method = obfuscator_mapping[obfuscator_item]
            obfuscator_method(sample_file_name, sample_tf_dir)
    except KeyError as ex:
        raise e.RunningObfuscatorException('Invalid obfuscator id ' + str(ex))
    end_time = datetime.utcnow()
    if enable_logging:
        u.logger('Obfuscate Stop: ' + str(end_time))
    u.logger('Obfuscate Time: ' + str(end_time-start_time))
    if cleanup:
        sample_ob_file_name = sample_file_name + 'Ob'
    else:
        sample_ob_file_name = sample_file_name
    smali(sample_tf_dir, sample_ob_file_name)
    sign_apk(sample_ob_file_name)
    if not debug:
        clean_temp(sample_tf_dir)
        if cleanup:
            clean_apk(sample_file_name)
    u.logger('### SUCCESS ### {' + str(end_time-start_time) + '}')
コード例 #52
0
ファイル: stun.py プロジェクト: db005/stunclient
secondName   = None#stun服务器的第二个地址,用于再次发送test1型消息
secondPort   = None

externalIP1   = None#本机在外网的IP和port
externalPort1 = None

externalIP2   = None#本机在外网的IP和port
externalPort2 = None

natType       = constants.Uncomplete

localIP = util.getLocalIP()

logFileName = "stun.txt"

logger = util.logger(logFileName)

stunAtrChangeRequest = None

messageID = [util.GenTranID(), util.GenTranID(), 
             util.GenTranID(), util.GenTranID()]

class responseMessage:
    #msgType, msgLength, attributeDict
    #attributeDict = {attributeType1:value1,......}
    def __init__(self):
        self.msgType       = None
        self.msgLength     = None
        self.msgTranID     = None
        self.attributeDict = {}
    
コード例 #53
0
ファイル: project.py プロジェクト: jamesw/SublimeAndroid
import os
import re
from xml.etree import ElementTree as ET

import sublime

from util import logger, get_setting, get_xml_attrib

log = logger(__name__)

# map views to android project paths
_project_map = {}


def get_path():
    """Gets android project path from one of the top level folders in sublime project.

    TODO there are instances where a project may contain subprojects and
    even where sublime may be used in a fashion to include multiple top-level
    folders to show multiple projects. It would be nice to support these cases.

    Returns:
        String pointing to absolute path of android project root.
    """
    p = get_setting("sublimeandroid_project_path", "")
    if p:
        log.debug("Returning project path from settings")
        return p

    view = sublime.active_window().active_view()