My Root Kit Note

本文深入探讨了Rootkit技术,包括其目的与实现手段。详细介绍了通过API、SSDT及IRP等方式进行Hook的方法,并讨论了如何利用TDI和NDIS进行内核级网络操作。此外,还介绍了KDOM技术及其潜在风险。

原创 My Root Kit Note 收藏

by vxk

My Root Kit Note

0. What the Root kit Real Mean For?

Root Kit is a kind of tools to hide itself or other files or process from normal users' eyes or take privileges for whom could control it...

1. Live With Hooks: Hook and Anti-Hook

To Hide Some Files or Process or Even Rebuild a Root kit’s Network may use hooking.

1.1 API HOOK

It's a long time this kind of hooking existed working with IAT or EAT or some time maybe inline. But it is very easy to defeat them, only to read and map a file in correct way then do right relocations, And then you would get real API address or the right code of API’s entry point.

1.2 SSDT HOOK

Sometimes when the API hook (base on pe-file structure) failed to defeat the hook-check, and some apiz wanted is non-exported, I got to SSDT way to hook, it is also a very long time since it turned to normal. And it is easy to find and fix too. One who can only read ntos kernel file and remap the SSDT could remove or check this kind of hooks.

1.3 IRP HOOK

PDriverObject->MajorFunction [MajorFunction] =XX XX XX XX

ZZ=MajorFunction*4+0x38

C7 46 ZZ [<80] XX XX XX XX mov dword ptr [esi+50h], offset _FsdSetInformation@8

C7 86 ZZ[>=80] XX XX XX XX

C7 43 ZZ [<80] XX XX XX XX mov dword ptr [ebx+50h], offset _FsdSetInformation@8

C7 83 ZZ[>=80] XX XX XX XX

Whatever FSD, TDI or other devices and drivers, they have the same thing IRP-Dispatch-Routine, which we hook only by rewrite an address in driver object structure, And it is more powerful then filter-driver(if a root kit is a filter driver it will be easy to find out. Even easily to bypass...)But still some one can read driver files ,and from the DrvierEntry point to get the real irps' VA (just taking a look at icesword by pjf),to make every one understand how to get real irps' VA,I give some details follow:

1.4 Interrupt Hook

For an example, a key logger root kit hook keyboard interrupts. Many powerful root kits to make themselves more useful use interrupts hook. It is hard to find out an interrupt hook on the range out of KiTrapXX's range (910920 put a way to read KiTrapXX’s Address from file...), and also hard to recover. But there is a will there is a way... (I do not know how to get a real address of an ISR which is not set by ntos kernel. But keyboard driver can tell me the real keyboard interrupt, it is hardcode searching...not good way)

1.5 NDIS Open Block Hook

A powerful root kit must support network in kernel mode. For this target, it may use TDI or NDIS,but TDI is easy to find or be defeated by anti-spy, so NDIS may be a good choice. Some root kit use IpFltDrv to reuse sock and do its own network,however, it is not nice ,many anti-spy can find the IpFltDrv changing, and IpFltDrv can only register one, it would be registered by others. As far as I see, the root kit uty_rk@winXp use protocols open block hooks to own the network. But actually it would crash when it were running with some anti-spy. So there is another way on Miniport layer,it is to hook NDISWAN Miniport Open Block, but there is a problem in how to get the list of NDIS miniport , see the NDIS IM Driver register course ,we know NdisIMRegisterLayeredMiniport can return a verb which is the a pointer to the list. And we can just register a fake IM to get the list pointer and then we could hook them just like hook protocol open blocks. To find this kind of hook must using hardcode search to find some VA from ndis.sys and tcpip.sys and ndiswan.sys.

1.6 Non-exported Inline Hook

Anti-spy may use inline hook to hook some important non-exported kernel mode calls and makes root kit difficult to do its work. And root kit can also use inline hook to bypass some checks. To find or recover an inline hook must use remap files and redo relocations, then compare the mappings and memory just like SVV. The recover of an inline hook might turn to a BSOD in the end.

2. Kernel Network: TDI and NDISBlue or Goal 

Every useful root kit must support networking with kernel socket.

2.1 TDI

       Most of free versions of root kit are using TDI Client Technology to make a kernel socket. But with the time changing, it is not useful today.

2.2 NDIS

       hug_ntrootkit4.0@winNt/2k used registering NDIS Protocol to do its networking; uty_rk@winXp used NDIS Protocol Open Block Hooks to do the same thing. EVA_rk@winNt (no public version) used NDIS Miniport Open Block Hooks, and iceberg wrote a full-version tcp sock based on NDIS Miniport Open Block Hooks. But in my project bdrk and winss (no public version and still in construction), NDIS Miniport Open Block Hooks sit many blue screens…

3. KDOM: Fast to Die or

A Good Way
?

       Fu_rk@winNT brings a new way to hide process and get privileges and do some things only by modifying some structures in system memory.

      Every coin has two faces, KDOM can do nearly every things but the target which will be modified is hard to get the right positions. And hardcode the offset or address may cause the system crashed. To find the KDOM modified is easy, only to use another link list or another database head…

4. Final

       I am Chinese, and my English is very poor.

       Contact me:

                            cvcvxk@gmail.com

Google Cloud Tools¶ Google Cloud tools make it easier to connect your agents to Google Cloud’s products and services. With just a few lines of code you can use these tools to connect your agents with: Any custom APIs that developers host in Apigee. 100s of prebuilt connectors to enterprise systems such as Salesforce, Workday, and SAP. Automation workflows built using application integration. Databases such as Spanner, AlloyDB, Postgres and more using the MCP Toolbox for databases. Google Cloud Tools Apigee API Hub Tools¶ ApiHubToolset lets you turn any documented API from Apigee API hub into a tool with a few lines of code. This section shows you the step by step instructions including setting up authentication for a secure connection to your APIs. Prerequisites Install ADK Install the Google Cloud CLI. Apigee API hub instance with documented (i.e. OpenAPI spec) APIs Set up your project structure and create required files project_root_folder | `-- my_agent |-- .env |-- __init__.py |-- agent.py `__ tool.py Create an API Hub Toolset¶ Note: This tutorial includes an agent creation. If you already have an agent, you only need to follow a subset of these steps. Get your access token, so that APIHubToolset can fetch spec from API Hub API. In your terminal run the following command gcloud auth print-access-token # Prints your access token like 'ya29....' Ensure that the account used has the required permissions. You can use the pre-defined role or assign the following permissions:roles/apihub.viewer apihub.specs.get (required) apihub.apis.get (optional) apihub.apis.list (optional) apihub.versions.get (optional) apihub.versions.list (optional) apihub.specs.list (optional) Create a tool with . Add the below to APIHubToolsettools.py If your API requires authentication, you must configure authentication for the tool. The following code sample demonstrates how to configure an API key. ADK supports token based auth (API Key, Bearer token), service account, and OpenID Connect. We will soon add support for various OAuth2 flows. from google.adk.tools.openapi_tool.auth.auth_helpers import token_to_scheme_credential from google.adk.tools.apihub_tool.apihub_toolset import APIHubToolset # Provide authentication for your APIs. Not required if your APIs don't required authentication. auth_scheme, auth_credential = token_to_scheme_credential( "apikey", "query", "apikey", apikey_credential_str ) sample_toolset_with_auth = APIHubToolset( name="apihub-sample-tool", description="Sample Tool", access_token="...", # Copy your access token generated in step 1 apihub_resource_name="...", # API Hub resource name auth_scheme=auth_scheme, auth_credential=auth_credential, ) For production deployment we recommend using a service account instead of an access token. In the code snippet above, use and provide your security account credentials instead of the token.service_account_json=service_account_cred_json_str For apihub_resource_name, if you know the specific ID of the OpenAPI Spec being used for your API, use . If you would like the Toolset to automatically pull the first available spec from the API, use `projects/my-project-id/locations/us-west1/apis/my-api-id/versions/version-id/specs/spec-id``projects/my-project-id/locations/us-west1/apis/my-api-id` Create your agent file Agent.py and add the created tools to your agent definition: from google.adk.agents.llm_agent import LlmAgent from .tools import sample_toolset root_agent = LlmAgent( model='gemini-2.0-flash', name='enterprise_assistant', instruction='Help user, leverage the tools you have access to', tools=sample_toolset.get_tools(), ) Configure your `__init__.py` to expose your agent from . import agent Start the Google ADK Web UI and try your agent: # make sure to run `adk web` from your project_root_folder adk web Then go to http://localhost:8000 to try your agent from the Web UI. Application Integration Tools¶ With ApplicationIntegrationToolset you can seamlessly give your agents a secure and governed to enterprise applications using Integration Connector’s 100+ pre-built connectors for systems like Salesforce, ServiceNow, JIRA, SAP, and more. Support for both on-prem and SaaS applications. In addition you can turn your existing Application Integration process automations into agentic workflows by providing application integration workflows as tools to your ADK agents. Prerequisites Install ADK An existing Application Integration workflow or Integrations Connector connection you want to use with your agent To use tool with default credentials: have Google Cloud CLI installed. See installation guide. Run: gcloud config set project <project-id> gcloud auth application-default login gcloud auth application-default set-quota-project <project-id> Set up your project structure and create required files project_root_folder |-- .env `-- my_agent |-- __init__.py |-- agent.py `__ tools.py When running the agent, make sure to run adk web in project_root_folder Use Integration Connectors¶ Connect your agent to enterprise applications using Integration Connectors. Prerequisites To use a connector from Integration Connectors, you need to provision Application Integration in the same region as your connection by clicking on "QUICK SETUP" button. Google Cloud Tools Go to Connection Tool template from the template library and click on "USE TEMPLATE" button. Google Cloud Tools Fill the Integration Name as ExecuteConnection (It is mandatory to use this integration name only) and select the region same as the connection region. Click on "CREATE". Publish the integration by using the "PUBLISH" button on the Application Integration Editor. Google Cloud Tools Steps: Create a tool with ApplicationIntegrationToolset from google.adk.tools.application_integration_tool.application_integration_toolset import ApplicationIntegrationToolset connector_tool = ApplicationIntegrationToolset( project="test-project", # TODO: replace with GCP project of the connection location="us-central1", #TODO: replace with location of the connection connection="test-connection", #TODO: replace with connection name entity_operations={"Entity_One": ["LIST","CREATE"], "Entity_Two": []},#empty list for actions means all operations on the entity are supported. actions=["action1"], #TODO: replace with actions service_account_credentials='{...}', # optional tool_name="tool_prefix2", tool_instructions="..." ) Note: - You can provide service account to be used instead of using default credentials. - To find the list of supported entities and actions for a connection, use the connectors apis: listActions or listEntityTypes Add the tool to your agent. Update your fileagent.py from google.adk.agents.llm_agent import LlmAgent from .tools import connector_tool root_agent = LlmAgent( model='gemini-2.0-flash', name='connector_agent', instruction="Help user, leverage the tools you have access to", tools=connector_tool.get_tools(), ) Configure your `__init__.py` to expose your agent from . import agent Start the Google ADK Web UI and try your agent. # make sure to run `adk web` from your project_root_folder adk web Then go to http://localhost:8000, and choose my_agent agent (same as the agent folder name) Use App Integration Workflows¶ Use existing Application Integration workflow as a tool for your agent or create a new one. Steps: Create a tool with ApplicationIntegrationToolset integration_tool = ApplicationIntegrationToolset( project="test-project", # TODO: replace with GCP project of the connection location="us-central1", #TODO: replace with location of the connection integration="test-integration", #TODO: replace with integration name trigger="api_trigger/test_trigger",#TODO: replace with trigger id service_account_credentials='{...}', #optional tool_name="tool_prefix1", tool_instructions="..." ) Note: You can provide service account to be used instead of using default credentials Add the tool to your agent. Update your fileagent.py from google.adk.agents.llm_agent import LlmAgent from .tools import integration_tool, connector_tool root_agent = LlmAgent( model='gemini-2.0-flash', name='integration_agent', instruction="Help user, leverage the tools you have access to", tools=integration_tool.get_tools(), ) Configure your `__init__.py` to expose your agent from . import agent Start the Google ADK Web UI and try your agent. # make sure to run `adk web` from your project_root_folder adk web Then go to http://localhost:8000, and choose my_agent agent (same as the agent folder name) Toolbox Tools for Databases¶ MCP Toolbox for Databases is an open source MCP server for databases. It was designed with enterprise-grade and production-quality in mind. It enables you to develop tools easier, faster, and more securely by handling the complexities such as connection pooling, authentication, and more. Google’s Agent Development Kit (ADK) has built in support for Toolbox. For more information on getting started or configuring Toolbox, see the documentation. GenAI Toolbox Configure and deploy¶ Toolbox is an open source server that you deploy and manage yourself. For more instructions on deploying and configuring, see the official Toolbox documentation: Installing the Server Configuring Toolbox Install client SDK¶ ADK relies on the python package to use Toolbox. Install the package before getting started:toolbox-langchain pip install toolbox-langchain langchain Loading Toolbox Tools¶ Once you’ve Toolbox server is configured and up and running, you can load tools from your server using the ADK: from google.adk.tools.toolbox_tool import ToolboxTool toolbox = ToolboxTool("https://127.0.0.1:5000") # Load a specific set of tools tools = toolbox.get_toolset(toolset_name='my-toolset-name'), # Load single tool tools = toolbox.get_tool(tool_name='my-tool-name'), root_agent = Agent( ..., tools=tools # Provide the list of tools to the Agent ) Advanced Toolbox Features¶ Toolbox has a variety of features to make developing Gen AI tools for databases. For more information, read more about the following features: Authenticated Parameters: bind tool inputs to values from OIDC tokens automatically, making it easy to run sensitive queries without potentially leaking data Authorized Invocations: restrict access to use a tool based on the users Auth token OpenTelemetry: get metrics and tracing from Toolbox with OpenTelemetry帮我画一张思维导图
05-02
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值