Skip to content

Commit 8f8b584

Browse files
Create KRNL key automation script with web and GUI automation
Co-authored-by: oicne4 <oicne4@gmail.com>
1 parent 15ea6e6 commit 8f8b584

3 files changed

Lines changed: 117 additions & 137 deletions

File tree

README.md

Lines changed: 32 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,46 @@
1-
# Agent Development Kit (ADK)
1+
# KRNL Key Automation Script
22

3-
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
4-
[![Python Unit Tests](https://github.com/google/adk-python/actions/workflows/python-unit-tests.yml/badge.svg)](https://github.com/google/adk-python/actions/workflows/python-unit-tests.yml)
5-
[![r/agentdevelopmentkit](https://img.shields.io/badge/Reddit-r%2Fagentdevelopmentkit-FF4500?style=flat&logo=reddit&logoColor=white)](https://www.reddit.com/r/agentdevelopmentkit/)
6-
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/google/adk-python)
3+
This Python script automates the process of retrieving KRNL keys and injecting them into the KRNL exploit.
74

8-
<html>
9-
<h2 align="center">
10-
<img src="https://raw.githubusercontent.com/google/adk-python/main/assets/agent-development-kit.png" width="256"/>
11-
</h2>
12-
<h3 align="center">
13-
An open-source, code-first Python toolkit for building, evaluating, and deploying sophisticated AI agents with flexibility and control.
14-
</h3>
15-
<h3 align="center">
16-
Important Links:
17-
<a href="https://google.github.io/adk-docs/">Docs</a>,
18-
<a href="https://github.com/google/adk-samples">Samples</a>,
19-
<a href="https://github.com/google/adk-java">Java ADK</a> &
20-
<a href="https://github.com/google/adk-web">ADK Web</a>.
21-
</h3>
22-
</html>
5+
## Features
236

24-
Agent Development Kit (ADK) is a flexible and modular framework for developing and deploying AI agents. While optimized for Gemini and the Google ecosystem, ADK is model-agnostic, deployment-agnostic, and is built for compatibility with other frameworks. ADK was designed to make agent development feel more like software development, to make it easier for developers to create, deploy, and orchestrate agentic architectures that range from simple tasks to complex workflows.
7+
- **Automatic Key Retrieval**: Automatically navigates to krnl.gg/getkey and retrieves a valid key
8+
- **Key Validation**: Checks if a provided key matches the correct format
9+
- **Clipboard Integration**: Automatically copies retrieved keys to clipboard
10+
- **Automated Injection**: Uses pyautogui to automate the injection process
2511

12+
## Installation
2613

27-
---
14+
1. Install Python 3.7+ if you haven't already
15+
2. Install the required dependencies:
16+
```bash
17+
pip install -r requirements.txt
18+
```
2819

29-
## ✨ Key Features
20+
## Usage
3021

31-
- **Rich Tool Ecosystem**: Utilize pre-built tools, custom functions,
32-
OpenAPI specs, or integrate existing tools to give agents diverse
33-
capabilities, all for tight integration with the Google ecosystem.
22+
1. Run the script:
23+
```bash
24+
python krnl_automation.py
25+
```
3426

35-
- **Code-First Development**: Define agent logic, tools, and orchestration
36-
directly in Python for ultimate flexibility, testability, and versioning.
27+
2. The script will ask if you already have a KRNL key:
28+
- If you have a valid key, enter it and the script will proceed with injection
29+
- If you don't have a key or enter an invalid one, the script will automatically retrieve one
3730

38-
- **Modular Multi-Agent Systems**: Design scalable applications by composing
39-
multiple specialized agents into flexible hierarchies.
31+
## Important Notes
4032

41-
- **Deploy Anywhere**: Easily containerize and deploy agents on Cloud Run or
42-
scale seamlessly with Vertex AI Agent Engine.
33+
- **Coordinate Adjustment**: The `inject_krnl()` function uses hardcoded coordinates (500, 400) and (600, 500) for clicking. You'll need to adjust these coordinates based on your screen resolution and KRNL window position.
34+
- **Browser Automation**: The script uses Chrome WebDriver to automate the key retrieval process.
35+
- **Safety**: Make sure KRNL is the active window when the injection process starts.
4336

44-
## 🤖 Agent2Agent (A2A) Protocol and ADK Integration
37+
## Dependencies
4538

46-
For remote agent-to-agent communication, ADK integrates with the
47-
[A2A protocol](https://github.com/google-a2a/A2A/).
48-
See this [example](https://github.com/a2aproject/a2a-samples/tree/main/samples/python/agents)
49-
for how they can work together.
39+
- `selenium`: Web automation
40+
- `webdriver-manager`: Chrome driver management
41+
- `pyautogui`: GUI automation
42+
- `pyperclip`: Clipboard operations
5043

51-
## 🚀 Installation
44+
## Disclaimer
5245

53-
### Stable Release (Recommended)
54-
55-
You can install the latest stable version of ADK using `pip`:
56-
57-
```bash
58-
pip install google-adk
59-
```
60-
61-
The release cadence is weekly.
62-
63-
This version is recommended for most users as it represents the most recent official release.
64-
65-
### Development Version
66-
Bug fixes and new features are merged into the main branch on GitHub first. If you need access to changes that haven't been included in an official PyPI release yet, you can install directly from the main branch:
67-
68-
```bash
69-
pip install git+https://github.com/google/adk-python.git@main
70-
```
71-
72-
Note: The development version is built directly from the latest code commits. While it includes the newest fixes and features, it may also contain experimental changes or bugs not present in the stable release. Use it primarily for testing upcoming changes or accessing critical fixes before they are officially released.
73-
74-
## 📚 Documentation
75-
76-
Explore the full documentation for detailed guides on building, evaluating, and
77-
deploying agents:
78-
79-
* **[Documentation](https://google.github.io/adk-docs)**
80-
81-
## 🏁 Feature Highlight
82-
83-
### Define a single agent:
84-
85-
```python
86-
from google.adk.agents import Agent
87-
from google.adk.tools import google_search
88-
89-
root_agent = Agent(
90-
name="search_assistant",
91-
model="gemini-2.0-flash", # Or your preferred Gemini model
92-
instruction="You are a helpful assistant. Answer user questions using Google Search when needed.",
93-
description="An assistant that can search the web.",
94-
tools=[google_search]
95-
)
96-
```
97-
98-
### Define a multi-agent system:
99-
100-
Define a multi-agent system with coordinator agent, greeter agent, and task execution agent. Then ADK engine and the model will guide the agents works together to accomplish the task.
101-
102-
```python
103-
from google.adk.agents import LlmAgent, BaseAgent
104-
105-
# Define individual agents
106-
greeter = LlmAgent(name="greeter", model="gemini-2.0-flash", ...)
107-
task_executor = LlmAgent(name="task_executor", model="gemini-2.0-flash", ...)
108-
109-
# Create parent agent and assign children via sub_agents
110-
coordinator = LlmAgent(
111-
name="Coordinator",
112-
model="gemini-2.0-flash",
113-
description="I coordinate greetings and tasks.",
114-
sub_agents=[ # Assign sub_agents here
115-
greeter,
116-
task_executor
117-
]
118-
)
119-
```
120-
121-
### Development UI
122-
123-
A built-in development UI to help you test, evaluate, debug, and showcase your agent(s).
124-
125-
<img src="https://raw.githubusercontent.com/google/adk-python/main/assets/adk-web-dev-ui-function-call.png"/>
126-
127-
### Evaluate Agents
128-
129-
```bash
130-
adk eval \
131-
samples_for_testing/hello_world \
132-
samples_for_testing/hello_world/hello_world_eval_set_001.evalset.json
133-
```
134-
135-
## 🤝 Contributing
136-
137-
We welcome contributions from the community! Whether it's bug reports, feature requests, documentation improvements, or code contributions, please see our
138-
- [General contribution guideline and flow](https://google.github.io/adk-docs/contributing-guide/).
139-
- Then if you want to contribute code, please read [Code Contributing Guidelines](./CONTRIBUTING.md) to get started.
140-
141-
## Vibe Coding
142-
143-
If you are to develop agent via vibe coding the [llms.txt](./llms.txt) and the [llms-full.txt](./llms-full.txt) can be used as context to LLM. While the former one is a summarized one and the later one has the full information in case your LLM has big enough context window.
144-
145-
## 📄 License
146-
147-
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
148-
149-
---
150-
151-
*Happy Agent Building!*
46+
This script is for educational purposes only. Use responsibly and in accordance with applicable terms of service.

krnl_automation.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import re
2+
import time
3+
import pyautogui
4+
import pyperclip
5+
from selenium import webdriver
6+
from selenium.webdriver.chrome.service import Service
7+
from webdriver_manager.chrome import ChromeDriverManager
8+
from selenium.webdriver.common.by import By
9+
from selenium.webdriver.support.ui import WebDriverWait
10+
from selenium.webdriver.support import expected_conditions as EC
11+
12+
# キー形式チェック
13+
def check_krnl_key(key: str):
14+
pattern = re.compile(r'^[0-9a-fA-F]{4}(-[0-9a-fA-F]{4}){3}$')
15+
return bool(pattern.match(key))
16+
17+
# KRNLキー自動取得
18+
def auto_get_key_full():
19+
print("\n[+] KRNLキー取得自動化を開始します...")
20+
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
21+
driver.get("https://krnl.gg/getkey")
22+
23+
wait = WebDriverWait(driver, 60)
24+
krnl_key = None
25+
26+
try:
27+
# 「次へ」クリック
28+
next_btn = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), '次へ')]")))
29+
time.sleep(1)
30+
next_btn.click()
31+
print("[+] '次へ'ボタンをクリックしました")
32+
33+
# 「続行」クリック
34+
time.sleep(5)
35+
continue_btn = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), '続行')]")))
36+
continue_btn.click()
37+
print("[+] '続行'ボタンをクリックしました")
38+
39+
# キー取得
40+
key_element = wait.until(EC.presence_of_element_located((By.XPATH, "//code")))
41+
krnl_key = key_element.text.strip()
42+
pyperclip.copy(krnl_key)
43+
print(f"[+] 取得したキー: {krnl_key} (クリップボードにコピーしました)")
44+
45+
except Exception as e:
46+
print("[-] 自動化中にエラー:", e)
47+
finally:
48+
driver.quit()
49+
50+
return krnl_key
51+
52+
# KRNLにキーを入力してInject
53+
def inject_krnl(key):
54+
print("\n[+] KRNLにキーを入力してInjectします...")
55+
time.sleep(5) # ユーザーにKRNL画面をアクティブにしてもらう時間
56+
57+
# キー入力欄クリック(座標は環境に合わせて調整)
58+
pyautogui.click(500, 400) # 仮の座標
59+
time.sleep(0.5)
60+
61+
# キー貼り付け
62+
pyautogui.hotkey("ctrl", "v")
63+
time.sleep(0.5)
64+
65+
# Submitクリック(座標も調整必要)
66+
pyautogui.click(600, 500)
67+
time.sleep(1)
68+
69+
print("[+] キー送信完了、Injectが開始されます。")
70+
71+
if __name__ == "__main__":
72+
user_key = input("既にKRNLキーを持っていますか?(なければEnter): ").strip()
73+
74+
if user_key and check_krnl_key(user_key):
75+
print("\nこのキーは形式上OKです。Injectを開始します。")
76+
inject_krnl(user_key)
77+
else:
78+
print("\nキーが無効 or 入力なしのため、自動取得します。")
79+
key = auto_get_key_full()
80+
if key:
81+
inject_krnl(key)

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
selenium>=4.0.0
2+
webdriver-manager>=3.8.0
3+
pyautogui>=0.9.54
4+
pyperclip>=1.8.2

0 commit comments

Comments
 (0)