strings 提取 features

本文探讨了Linux命令strings的功能,如何提取可执行文件中的字符串,并着重介绍了附近出现的其他特征以及.src文件的生成过程。
strings 是 Linux 命令,提取可执行文件中的字符串,你找到一个 Feature 名字,其他 Feature 名字就在附近,许多 .src 是这样生成的
from androguard.misc import AnalyzeAPK from click import pause import os import sys import json # a,d,dx=AnalyzeAPK("C:/Users/Lenovo/Desktop/A/lszz_jx_202412251645_1_0.2.0001_hardening.apk") # permissions=a.get_permissions() # for permission in permissions: # print(permission) # pause() def extract_features(apk_path):# try: out = AnalyzeAPK(apk_path) a, d, dx = out # dx.show_Permissions() # 提取权限 permissions = a.get_permissions() # 提取活动 activities = a.get_activities() # 提取服务 services = a.get_services() # 提取接收器 receivers = a.get_receivers() # 提取提供者 providers = a.get_providers() # 判断 APK 是否有效 valid = a.is_valid_APK() # 获取 APK 文件名,只保留文件名称部分 filename = os.path.basename(a.get_filename()) # 获取 APP 名 appname = a.get_app_name() # 获取 package 名 package = a.get_package() # 获取 android 版本名 version = a.get_androidversion_code() # 获取 APK 文件列表 filelist = a.get_files() # 提取 API 调用信息 api_calls = set() for method in dx.get_methods(): for _, calls, _ in method.get_xref_to(): class_name = calls.class_name[1:] method_name = calls.name descriptor = calls.descriptor api_call = f"{class_name}->{method_name}{descriptor}" api_calls.add(api_call) features = { "File": filename, "Permissions": permissions, "Activities": activities, "Services": services, "Receivers": receivers, "Providers": providers, "Valid": valid, "Filename": filename, "Appname": appname, "Package": package, "Version": version, "Filelist": filelist, "API_calls": list(api_calls) } return features except Exception as e: print(f"Error processing {apk_path}: {e}") return None def main(): apk_folder = "C:\\Users\\Lenovo\\Desktop\\yinsi\\mfm" output_file = "C:\\Users\\Lenovo\\Desktop\\yinsi\\mfm\\yanwu812.txt" all_features = [] for root, dirs, files in os.walk(apk_folder): for file in files: if file.endswith(".apk"): apk_path = os.path.join(root, file) features = extract_features(apk_path) if features: all_features.append(features) with open(output_file, 'w', encoding='utf-8') as f: json.dump(all_features, f, indent=4) print("APK features have been saved to:", output_file) if __name__ == '__main__': main()
08-14
### 如何从DeepSeek学术论文中提取数据 #### 工具和方法概述 为了有效地从DeepSeek学术论文中提取有价值的数据,可以采用多种工具和技术组合来实现自动化处理和高效的信息挖掘。具体来说,可以通过编程接口(APIs)获取文献资源,并利用自然语言处理(NLP)技术解析文档内容。 #### 利用API访问文献数据库 许多在线平台提供了开放的API接口用于检索科学出版物全文或元数据记录。通过调用这些服务端口并设置查询参数(如关键词、作者名),能够快速定位目标文章集合[^1]。 ```python import requests def fetch_papers(api_key, query_terms): url = "https://api.example.com/paper_search" params = { 'q': query_terms, 'key': api_key } response = requests.get(url, params=params) papers_data = response.json() return papers_data['results'] ``` #### 应用NLP技术进行文本分析 对于已下载的文章PDF文件或其他格式电子档,则需借助专门软件将其转换成可编辑纯文本形式;之后再运用Python库比如spaCy或者NLTK来进行分词、命名实体识别以及依存句法树构建等工作流操作,从而抽取出特定领域术语表征的知识片段[^2]。 ```python import spacy nlp = spacy.load('en_core_web_sm') def extract_entities(text): doc = nlp(text) entities = [(ent.text, ent.label_) for ent in doc.ents] return entities ``` #### 构建定制化的爬虫程序 当面对某些封闭型网站时,可能无法直接依赖官方提供的API接口。此时就需要开发自己的网络爬取脚本,在遵循robots协议前提下合法合规地抓取网页上的公开资料作为研究素材来源之一[^3]。 ```python from bs4 import BeautifulSoup import urllib.request def scrape_website(url): page = urllib.request.urlopen(url).read().decode('utf8') soup = BeautifulSoup(page, features="html.parser") # Remove any unwanted elements from the HTML structure. for script_or_style in soup(["script", "style"]): script_or_style.decompose() text = soup.stripped_strings joined_text = "\n".join(line.strip() for line in list(text)) return joined_text ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值