# Path: mobsf/StaticAnalyzer/views/common/shared_func.py
# def is_secret(inp):
#     """Check if captures string is a possible secret."""
#     inp = inp.lower()
#     iden = (
#         'api"', 'key"', 'api_', 'key_', 'secret"',
#         'password"', 'aws', 'gcp', 's3_', '_s3', 'secret_',
#         'token"', 'username"', 'user_name"', 'user"',
#         'bearer', 'jwt', 'certificate"', 'credential',
#         'azure', 'webhook', 'twilio_', 'bitcoin',
#         '_auth', 'firebase', 'oauth', 'authorization',
#         'private', 'pwd', 'session', 'token_',
#     )
#     not_string = (
#         'label_', 'text', 'hint', 'msg_', 'create_',
#         'message', 'new', 'confirm', 'activity_',
#         'forgot', 'dashboard_', 'current_', 'signup',
#         'sign_in', 'signin', 'title_', 'welcome_',
#         'change_', 'this_', 'the_', 'placeholder',
#         'invalid_', 'btn_', 'action_', 'prompt_',
#         'lable', 'hide_', 'old', 'update', 'error',
#         'empty', 'txt_', 'lbl_',
#     )
#     not_str = any(i in inp for i in not_string)
#     return any(i in inp for i in iden) and not not_str
# 
# def url_n_email_extract(dat, relative_path):
#     """Extract URLs and Emails from Source Code."""
#     urls = []
#     emails = []
#     urllist = []
#     url_n_file = []
#     email_n_file = []
#     # URLs Extraction My Custom regex
#     pattern = re.compile(
#         (
#             r'((?:https?://|s?ftps?://|'
#             r'file://|javascript:|data:|www\d{0,3}[.])'
#             r'[\w().=/;,#:@?&~*+!$%\'{}-]+)'
#         ),
#         re.UNICODE)
#     urllist = re.findall(pattern, dat)
#     uflag = 0
#     for url in urllist:
#         if url not in urls:
#             urls.append(url)
#             uflag = 1
#     if uflag == 1:
#         url_n_file.append(
#             {'urls': urls, 'path': escape(relative_path)})
# 
#     # Email Extraction Regex
#     regex = re.compile(r'[\w.-]{1,20}@[\w-]{1,20}\.[\w]{2,10}')
#     eflag = 0
#     for email in regex.findall(dat.lower()):
#         if (email not in emails) and (not email.startswith('//')):
#             emails.append(email)
#             eflag = 1
#     if eflag == 1:
#         email_n_file.append(
#             {'emails': emails, 'path': escape(relative_path)})
#     return urllist, url_n_file, email_n_file


import logging
import os
from androguard.core.bytecodes import apk
from mobsf.StaticAnalyzer.views.common.shared_func import (
    is_secret,
    url_n_email_extract,
)
        logger.info('Extracting Strings from APK')
        dat = []
        secrets = []
        urls = []
        urls_nf = []
        emails_nf = []
        apk_file = os.path.join(app_dir, app_file)
        and_a = apk.APK(apk_file)
        rsrc = and_a.get_android_resources()
        if rsrc:
            pkg = rsrc.get_packages_names()[0]
            rsrc.get_strings_resources()
            for i in rsrc.values[pkg].keys():
                res_string = rsrc.values[pkg][i].get('string')
                if res_string:
                    for duo in res_string:
                        cap_str = '"' + duo[0] + '" : "' + duo[1] + '"'
                        if is_secret(duo[0] + '"') and ' ' not in duo[1]:
                            secrets.append(cap_str)
                        dat.append(cap_str)
            data_string = ''.join(dat)
            urls, urls_nf, emails_nf = url_n_email_extract(
                data_string, 'Android String Resource')
        if elf_strings:
            for solib in elf_strings:
                for so, str_list in solib.items():
                    # add to strings from jar
                    dat.extend(str_list)
                    # extract url, email
                    so_str = ' '.join(str_list)

# Path: mobsf/StaticAnalyzer/views/common/shared_func.py
# def is_secret(inp):
#     """Check if captures string is a possible secret."""
#     inp = inp.lower()
#     iden = (
#         'api"', 'key"', 'api_', 'key_', 'secret"',
#         'password"', 'aws', 'gcp', 's3_', '_s3', 'secret_',
#         'token"', 'username"', 'user_name"', 'user"',
#         'bearer', 'jwt', 'certificate"', 'credential',
#         'azure', 'webhook', 'twilio_', 'bitcoin',
#         '_auth', 'firebase', 'oauth', 'authorization',
#         'private', 'pwd', 'session', 'token_',
#     )
#     not_string = (
#         'label_', 'text', 'hint', 'msg_', 'create_',
#         'message', 'new', 'confirm', 'activity_',
#         'forgot', 'dashboard_', 'current_', 'signup',
#         'sign_in', 'signin', 'title_', 'welcome_',
#         'change_', 'this_', 'the_', 'placeholder',
#         'invalid_', 'btn_', 'action_', 'prompt_',
#         'lable', 'hide_', 'old', 'update', 'error',
#         'empty', 'txt_', 'lbl_',
#     )
#     not_str = any(i in inp for i in not_string)
#     return any(i in inp for i in iden) and not not_str
# 
# def url_n_email_extract(dat, relative_path):
#     """Extract URLs and Emails from Source Code."""
#     urls = []
#     emails = []
#     urllist = []
#     url_n_file = []
#     email_n_file = []
#     # URLs Extraction My Custom regex
#     pattern = re.compile(
#         (
#             r'((?:https?://|s?ftps?://|'
#             r'file://|javascript:|data:|www\d{0,3}[.])'
#             r'[\w().=/;,#:@?&~*+!$%\'{}-]+)'
#         ),
#         re.UNICODE)
#     urllist = re.findall(pattern, dat)
#     uflag = 0
#     for url in urllist:
#         if url not in urls:
#             urls.append(url)
#             uflag = 1
#     if uflag == 1:
#         url_n_file.append(
#             {'urls': urls, 'path': escape(relative_path)})
# 
#     # Email Extraction Regex
#     regex = re.compile(r'[\w.-]{1,20}@[\w-]{1,20}\.[\w]{2,10}')
#     eflag = 0
#     for email in regex.findall(dat.lower()):
#         if (email not in emails) and (not email.startswith('//')):
#             emails.append(email)
#             eflag = 1
#     if eflag == 1:
#         email_n_file.append(
#             {'emails': emails, 'path': escape(relative_path)})
#     return urllist, url_n_file, email_n_file


# Path: mobsf/StaticAnalyzer/views/android/strings.py
import logging
import os
from androguard.core.bytecodes import apk
from mobsf.StaticAnalyzer.views.common.shared_func import (
    is_secret,
    url_n_email_extract,
)

        logger.info('Extracting Strings from APK')
        dat = []
        secrets = []
        urls = []
        urls_nf = []
        emails_nf = []
        apk_file = os.path.join(app_dir, app_file)
        and_a = apk.APK(apk_file)
        rsrc = and_a.get_android_resources()
        if rsrc:
            pkg = rsrc.get_packages_names()[0]
            rsrc.get_strings_resources()
            for i in rsrc.values[pkg].keys():
                res_string = rsrc.values[pkg][i].get('string')
                if res_string:
                    for duo in res_string:
                        cap_str = '"' + duo[0] + '" : "' + duo[1] + '"'
                        if is_secret(duo[0] + '"') and ' ' not in duo[1]:
                            secrets.append(cap_str)
                        dat.append(cap_str)
            data_string = ''.join(dat)
            urls, urls_nf, emails_nf = url_n_email_extract(
                data_string, 'Android String Resource')
        if elf_strings:
            for solib in elf_strings:
                for so, str_list in solib.items():
                    # add to strings from jar
                    dat.extend(str_list)
                    # extract url, email
                    so_str = ' '.join(str_list)

                    su, suf, sem = url_n_email_extract(