Skip to content

Instantly share code, notes, and snippets.

@samdmarshall
Created April 26, 2014 14:22
Show Gist options
  • Save samdmarshall/11321387 to your computer and use it in GitHub Desktop.
Save samdmarshall/11321387 to your computer and use it in GitHub Desktop.
function InstallMachIPCServer() {
var_56 = *__stack_chk_guard;
var_5224 = **__stack_chk_guard;
eax = getenv("HOME");
if ((eax != 0x0) && (*(int8_t *)eax != 0x0)) goto loc_22e1c;
goto loc_22fae;
loc_22e1c:
ebx = &var_3176;
strncpy(ebx, eax, 0x400);
if (stat(ebx, &var_184) == 0x0) {
eax = strlen(ebx);
*(int16_t *)(ebp + eax + 0xfffffffffffff804) = 0x73;
*(ebp + eax + 0xfffffffffffff800) = 0x746e6567;
*(ebp + eax + 0xfffffffffffff7fc) = 0x4168636e;
*(ebp + eax + 0xfffffffffffff7f8) = 0x75614c2f;
*(ebp + eax + 0xfffffffffffff7f4) = 0x79726172;
*(ebp + eax + 0xfffffffffffff7f0) = 0x62694c2f;
if ((var_196 != 0x0) && (var_200 != 0x0)) {
if ((stat(ebx, &var_88) == 0x0) && (var_100 == 0x0)) {
chown(ebx, var_196, var_200);
}
}
}
eax = strlen(ebx);
memcpy(ebp + eax + 0xfffffffffffff7f0, "/com.valvesoftware.steam.ipctool.plist", 0x27);
unlink(ebx);
if (getuid() == 0x0) goto loc_236dc;
goto loc_22f24;
loc_236dc:
eax = *var_56;
if (eax == var_5224) {
return eax;
}
else {
eax = __stack_chk_fail();
}
return eax;
loc_22f24:
_GetBaseUserDir(ebx, 0x400, 0x0);
CreateDirRecursive(ebx);
memcpy(ebp + strlen(ebx) + 0xfffffffffffff7f0, "/com.valvesoftware.steam.ipctool.plist", 0x27);
esi = &var_4200;
_GetSteamExePath(esi, 0x400);
eax = strrchr(esi, 0x2f);
if (eax != 0x0) {
strncpy(eax, "/ipcserver", &var_5224 - eax);
}
else {
eax = strlen(esi);
*(int8_t *)(ebp + eax + 0xfffffffffffffbfa) = 0x0;
*(int16_t *)(ebp + eax + 0xfffffffffffffbf8) = 0x7265;
*(ebp + eax + 0xfffffffffffffbf4) = 0x76726573;
*(ebp + eax + 0xfffffffffffffbf0) = 0x6370692f;
}
if (access(esi, 0x0) != 0x0) goto loc_236dc;
if ((access(esi, 0x0) == 0x0) && (stat(esi, &var_280) == 0x0)) {
chmod$UNIX2003(esi, var_288 & 0xffff | 0x1c0);
}
if ((access(ebx, 0x0) == 0x0) && (stat(ebx, &var_376) == 0x0)) {
chmod$UNIX2003(ebx, 0x180);
}
if ((access(ebx, 0x4) == 0x0) && (access(ebx, 0x4) == 0x0)) goto loc_230d1;
goto loc_2326e;
loc_230d1:
eax = CFStringCreateWithCString(**kCFAllocatorDefault, ebx, 0x8000100);
var_52 = eax;
eax = CFURLCreateWithFileSystemPath(**kCFAllocatorDefault, eax, 0x0, 0x0);
var_48 = eax;
eax = CFURLCreateDataAndPropertiesFromResource(**kCFAllocatorDefault, eax, &var_480, 0x0, 0x0, &var_476);
if (LOBYTE(eax) != 0x0) {
var_44 = **kCFAllocatorDefault;
eax = CFPropertyListCreateFromXMLData(**kCFAllocatorDefault, var_480, 0x0, 0x0);
if (eax != 0x0) {
ebx = edi;
edi = eax;
if (CFGetTypeID(eax) == CFDictionaryGetTypeID()) {
var_64 = ebx;
var_60 = edi;
esi = CFDictionaryGetValue(edi, ebx + 0x1938c9);
edi = CFGetTypeID(esi);
eax = CFStringGetTypeID();
if (edi == eax) {
edi = CFStringCreateWithCString(var_44, &var_4200, 0x8000100);
esi = CFStringCompare(edi, esi, 0x0);
CFRelease(edi);
}
}
else {
var_60 = edi;
var_64 = ebx;
}
CFRelease(var_60);
edi = var_64;
}
CFRelease(var_480);
}
CFRelease(var_52);
CFRelease(var_48);
ebx = &var_3176;
if (LOBYTE(ebx) == 0x0) goto loc_23512;
goto loc_2326e;
loc_23512:
memcpy(&var_2152, "launchctl load -S Background \\\"", 0x1f);
strncat(&var_2152, ebx, 0x400);
eax = strlen(&var_2152);
*(int16_t *)(ebp + eax + 0xfffffffffffff3fc) = 0x6c;
*(ebp + eax + 0xfffffffffffff3f8) = 0x6c756e2f;
*(ebp + eax + 0xfffffffffffff3f4) = 0x7665642f;
*(ebp + eax + 0xfffffffffffff3f0) = 0x3e262022;
system$UNIX2003(&var_2152);
var_76 = 0x0;
var_80 = 0x0;
eax = CIPCToolMachClient::Init(&var_72);
if (LOBYTE(eax) != 0x0) {
CIPCToolMachClient::DoBasicCommand(&var_72, 0x5, "", "", 0x0);
var_68 = 0x400;
ebx = &var_1128;
if (_NSGetExecutablePath(&var_1128, &var_68) == 0x0) {
esi = getpid();
memset(&var_584, 0x0, 0x220);
var_588 = 0x220;
var_608 = 0xd;
strncpy(&var_616, ebx, 0x200);
var_612 = esi;
var_584 = var_584 | 0x1413;
var_592 = var_80;
var_596 = var_76;
var_600 = 0x0;
var_604 = var_72;
mach_msg(&var_584, 0x11, var_588, 0x0, 0x0, 0x1388, 0x0);
}
}
CSimpleMachClient::~CSimpleMachClient(&var_72);
goto loc_236dc;
loc_2326e:
var_64 = edi;
memcpy(&var_2152, "launchctl remove \\\"com.valvesoftware.steam.ipctool\\\" &>/dev/null", 0x3f);
system$UNIX2003(&var_2152);
var_52 = *kCFTypeDictionaryValueCallBacks;
var_48 = *kCFTypeDictionaryKeyCallBacks;
var_40 = **kCFAllocatorDefault;
esi = CFDictionaryCreateMutable(**kCFAllocatorDefault, 0x0, *kCFTypeDictionaryKeyCallBacks, *kCFTypeDictionaryValueCallBacks);
eax = CFStringCreateWithCString(**kCFAllocatorDefault, &var_4200, 0x8000100);
var_60 = eax;
CFDictionarySetValue(esi, @"Program", eax);
var_44 = @"com.valvesoftware.steam.ipctool";
CFDictionarySetValue(esi, @"Label", @"com.valvesoftware.steam.ipctool");
CFDictionarySetValue(esi, @"LimitLoadToSessionType", @"Background");
CFDictionarySetValue(esi, var_64 + 0x193949, **kCFBooleanTrue);
CFDictionarySetValue(esi, var_64 + 0x1938e9, **(var_64 + 0x185245));
CFDictionarySetValue(esi, var_64 + 0x193959, **kCFBooleanTrue);
ebx = CFDictionaryCreateMutable(**kCFAllocatorDefault, 0x0, var_48, var_52);
CFDictionarySetValue(ebx, var_44, **kCFBooleanTrue);
CFDictionarySetValue(esi, var_64 + 0x193969, ebx);
CFRelease(var_60);
CFRelease(ebx);
eax = CFStringCreateWithCString(var_40, &var_3176, 0x8000100);
var_60 = eax;
ebx = CFURLCreateWithFileSystemPath(var_40, eax, 0x0, 0x0);
var_52 = ebx;
edi = CFPropertyListCreateXMLData(var_40, esi);
CFURLWriteDataAndPropertiesToResource(ebx, edi, 0x0, &var_484);
ebx = &var_3176;
CFRelease(var_60);
STK31 = edi;
CFRelease(STK31);
CFRelease(esi);
CFRelease(var_52);
if ((access(ebx, 0x0) == 0x0) && (stat(ebx, &var_488) == 0x0)) {
chmod$UNIX2003(ebx, 0x180);
}
goto loc_23512;
loc_22fae:
fwrite("$HOME could not be retrieved\\n", 0x1d, 0x1, **__stderrp);
goto loc_236dc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment