Skip to content

Instantly share code, notes, and snippets.

@ichitaso
Last active November 18, 2025 09:19
Show Gist options
  • Select an option

  • Save ichitaso/7b7f9deeaf56a2bc8240fda712d6dd9c to your computer and use it in GitHub Desktop.

Select an option

Save ichitaso/7b7f9deeaf56a2bc8240fda712d6dd9c to your computer and use it in GitHub Desktop.
Sending package list via email in Sileo environment
#import <MessageUI/MessageUI.h>
#import <dlfcn.h>
#import <sys/utsname.h>
#import "NSTask.h"
static CFStringRef (*$MGCopyAnswer)(CFStringRef);
static inline NSString *getUDID(void) {
void *gestalt(dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY));
$MGCopyAnswer = reinterpret_cast<CFStringRef (*)(CFStringRef)>(dlsym(gestalt, "MGCopyAnswer"));
CFStringRef result = $MGCopyAnswer(CFSTR("UniqueDeviceID"));
return (__bridge NSString *)(result);
}
static NSString *machineName() {
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}
- (void)mailSupport {
if (![MFMailComposeViewController canSendMail]) {
UIAlertController *alertController =
[UIAlertController alertControllerWithTitle:@"Email is not set"
message:@"Please set your Email in the Settings app."
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Close"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {}]];
[self presentViewController:alertController animated:YES completion:nil];
return;
}
MFMailComposeViewController *composeViewController = [[MFMailComposeViewController alloc] init];
[composeViewController setSubject:@"Tweak Support"];
[composeViewController setToRecipients:[NSArray arrayWithObjects:@"Name <[email protected]>", nil]];
NSString *systemStr = [NSString stringWithFormat:@"%@ %@ %@ - %@",machineName(),[[UIDevice currentDevice] systemName],[[UIDevice currentDevice] systemVersion],Version];
[composeViewController setMessageBody:[NSString stringWithFormat:@"\n\nCurrent Device: %@\n%@", getUDID(),systemStr] isHTML:NO];
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/.installed_unc0ver"]) {
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/sh"];
[task setArguments:@[@"-c", [NSString stringWithFormat:@"dpkg -l"]]];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
[task launch];
NSData *data = [[[task standardOutput] fileHandleForReading] readDataToEndOfFile];
[composeViewController addAttachmentData:data mimeType:@"text/plain" fileName:@"dpkgl.txt"];
} else {
NSString *filePath = jbroot(@"/var/lib/dpkg/status");
NSString *content = [NSString stringWithContentsOfFile:filePath
encoding:NSUTF8StringEncoding
error:nil];
NSMutableArray *resultArray = [NSMutableArray array];
__block NSString *currentPackage = nil;
__block NSString *currentVersion = nil;
__block NSString *currentDescription = nil;
__block BOOL isInstalled = NO;
__block BOOL descriptionStarted = NO;
[content enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) {
if (line.length == 0) {
if (currentPackage && currentVersion && isInstalled) {
NSString *desc = currentDescription ?: @"";
NSString *entry = [NSString stringWithFormat:@"%@ - %@ - %@", currentPackage, currentVersion, desc];
[resultArray addObject:entry];
}
// reset
currentPackage = nil;
currentVersion = nil;
currentDescription = nil;
isInstalled = NO;
descriptionStarted = NO;
return;
}
if ([line hasPrefix:@"Package: "]) {
currentPackage = [line substringFromIndex:[@"Package: " length]];
return;
}
if ([line hasPrefix:@"Version: "]) {
currentVersion = [line substringFromIndex:[@"Version: " length]];
return;
}
if ([line hasPrefix:@"Status: "]) {
if ([line containsString:@"install ok installed"]) {
isInstalled = YES;
}
return;
}
if ([line hasPrefix:@"Description: "]) {
descriptionStarted = YES;
// Get only the first line of Description:
currentDescription = [line substringFromIndex:[@"Description: " length]];
return;
}
// Continuation of Description (one or more indents)
if (descriptionStarted) {
if ([line hasPrefix:@" "]) {
// If you want to add it, just uncomment it
// currentDescription = [currentDescription stringByAppendingFormat:@" %@", [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
} else {
descriptionStarted = NO;
}
return;
}
}];
NSString *outputString = [resultArray componentsJoinedByString:@"\n"];
NSData *fileData = [outputString dataUsingEncoding:NSUTF8StringEncoding];
[composeViewController addAttachmentData:fileData mimeType:@"text/plain" fileName:@"status.txt"];
}
[self.navigationController presentViewController:composeViewController animated:YES completion:nil];
composeViewController.mailComposeDelegate = self;
}
@ichitaso
Copy link
Author

ichitaso commented Nov 16, 2025

Please replace using: setSubject:@"Tweak Support", @"Name [email protected]", jbroot, Version

@ichitaso
Copy link
Author

sileo uses apt, you could pipe the output of apt list --installed or similar

via Amy (@elihwyma Sileo dev)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment