Permalink
Browse files

idiocy

  • Loading branch information...
1 parent 755d4c9 commit 08142f0f81c6d2d7782a85699f6908d343cbc0db @comex committed Jun 22, 2011
View
@@ -16,6 +16,7 @@
PROT_WRITE = 2
PROT_EXEC = 4
+
mode, version, cachefile, kernfile, patchfile, kcode, outfile = sys.argv[1:8]
four_dot_three = '4.3' in version
cachefiles = [cachefile] + sys.argv[8:]
@@ -261,6 +262,8 @@ def do_main_thing():
old_fa = dmini.data.b_find_anywhere
def new_fa(binary, pattern, align, flags):
+ print '>>', pattern
+
result = dmini.data.find_data(dmini.data.b_macho_segrange(dmini.cur.binaries['ft'], '__TEXT'), pattern, align, flags)
return result
@@ -294,6 +297,8 @@ def new_fa(binary, pattern, align, flags):
# add sp, #392; pop {r2, r5, r6, pc}
parse_callback = reloc_value(dmini.cur.find('+ 50 b0 30 bd'))
actual_parse_callback = reloc_value(dmini.cur.sym('ft._T1_Parse_Glyph', 'private'))
+ parse_callback = 0xdeadbeef
+ print dmini.cur.path, hex(parse_callback), parse_callback - actual_parse_callback
final = final.unpack()
View
@@ -37,21 +37,30 @@ def importOldStuff():
'devicetree': 'DeviceTree',
}
def importWiki(data, string):
- # I don't know if these capitalizations mean anything, but "KernelCache" is used by the other plists and I need to normalize
+ # I don't know if these capitalizations mean anything, but "KernelCache" is used by the other plists and I need to pick one
f = StringIO.StringIO(data.strip())
+ def readline():
+ while True:
+ line = f.readline()
+ if line == '': return line
+ line = line.lower().replace("'''", '').replace('[[', '').replace(']]', '').strip()
+ if line: return line
while True:
- line = f.readline().lower()
+ line = readline()
if line == '': break
- if 'root filesystem' in line:
- line2 = f.readline()
- print string + '.fs: ' + re.search('VFDecrypt( Key)?:\s*([a-zA-Z0-9]*)', line2).group(2)
+ if 'root filesystem' in line or 'main filesystem' in line:
+ line2 = readline()
+ print string + '.fs: ' + re.search('vfdecrypt( key)?:\s*([a-zA-Z0-9]*)', line2).group(2)
continue
for k, v in thingsICareAbout.items():
if k in line:
- ivline = f.readline()
- if 'KBAG' in ivline: ivline = f.readline()
- keyline = f.readline()
- print string + '.' + v + ': ' + re.search('Key:\s*([a-zA-Z0-9]*)', keyline).group(1) + ' ' + re.search('IV:\s*([a-zA-Z0-9]*)', ivline).group(1)
+ ivline = readline()
+ if 'not encrypted' in ivline:
+ print string + '.' + v + ': X'
+ continue
+ if 'kbag' in ivline: ivline = readline()
+ keyline = readline()
+ print string + '.' + v + ': ' + re.search('k(ey)?:\s*([a-zA-Z0-9]*)', keyline).group(2) + ' ' + re.search('iv:\s*([a-zA-Z0-9]*)', ivline).group(1)
break
print
@@ -72,5 +81,6 @@ def importMultilineGenpass(data, string):
for k, v in thingsICareAbout.items():
if k in line:
m = v
-{'wiki': importWiki, 'genpass': importGenpass, 'multiline_genpass': importMultilineGenpass}[sys.argv[1]](sys.stdin.read(), sys.argv[2])
+if __name__ == '__main__':
+ {'wiki': importWiki, 'genpass': importGenpass, 'multiline_genpass': importMultilineGenpass}[sys.argv[1]](sys.stdin.read(), sys.argv[2])
#importOldStuff()
View
@@ -0,0 +1,24 @@
+import urllib, re, traceback, sys
+import keyz
+def page(name):
+ return urllib.urlopen('http://theiphonewiki.com/wiki/index.php?title=%s&action=raw' % urllib.quote(name)).read()
+firmware = page('Firmware')
+morekeyz = open('morekeyz.txt', 'w')
+urls = open('urls.txt', 'w')
+for pagename, _, url in re.findall('\[\[([^\|]+).*\n(.*\[\[[0-9].*\n)?.*(http://appldn[^ ]*) ', firmware):
+ #if 'iPad1,1_4.2.1_8C148' not in url: continue
+ version = re.search('/([^/]*)_Restore', url).group(1)
+ print >> urls, url
+ print url,
+ orig, sys.stdout = sys.stdout, morekeyz
+ try:
+ p = page(pagename)
+ keyz.importWiki(p, version)
+ except Exception, e:
+ print >> orig, 'FAIL'
+ #print p
+ #traceback.print_exc()
+ else:
+ print >> orig, 'ok'
+ finally:
+ sys.stdout = orig
View
@@ -14,11 +14,9 @@
# 344 0x5d0: buildchar = <heap>
# 345 0x5d4: len_buildchar = 3
# 346 0x5d8: seac = 0
-# 347 0x5dc: ?
-# 348 0x5e0: ? = 0x208
-# 349 0x5e4: ? = 0
-# 350 0x5e8: ? = 0
-# 351 0x5ec: ? = t1_driver_class
+# ...
+# ...
+# 399 0x6ac: ? = __gxx_personality_sj0+1
# first overwrite funcs.done and funcs.parse_charstrings using end flex
# then use THAT to overwrite hint_mode and parse_callback
@@ -32,8 +30,6 @@
# 3: idx
# 31000: [start of data]
-#/0 string currentfile readstring
-
import struct, sys
import cPickle as pickle
import zlib
View
129 fs/fs.h
@@ -28,22 +28,141 @@ static void x_lck_mtx_lock(lck_mtx_t *lck) {
#define lck_mtx_lock x_lck_mtx_lock
#endif
-inline int eopnotsupp() {
+static int x_eopnotsupp() {
return ENOTSUP;
}
-#define vn_default_error eopnotsupp
+#define vn_default_error x_eopnotsupp
+#define eopnotsupp x_eopnotsupp
-inline int nullop() {
+static int x_nullop() {
return 0;
}
+#define nullop x_nullop
-inline void buf_setvnode(buf_t bp, vnode_t vp) {
+static void x_buf_setvnode(buf_t bp, vnode_t vp) {
bp->b_vp = vp;
}
+#define buf_setvnode x_buf_setvnode
#define bcopy(a, b, c) memcpy(b, a, c)
+#define memcpy memmove
+// support from white_loader
+extern struct vnodeop_desc *vfs_op_descs[];
+
+#if VERSION >= 0x040300
+#define vnop_default_desc (*vfs_op_descs[0])
+#define vnop_strategy_desc (*vfs_op_descs[1])
+#define vnop_bwrite_desc (*vfs_op_descs[2])
+#define vnop_lookup_desc (*vfs_op_descs[3])
+#define vnop_create_desc (*vfs_op_descs[4])
+#define vnop_mknod_desc (*vfs_op_descs[5])
+#define vnop_whiteout_desc (*vfs_op_descs[6])
+#define vnop_open_desc (*vfs_op_descs[7])
+#define vnop_compound_open_desc (*vfs_op_descs[8])
+#define vnop_close_desc (*vfs_op_descs[9])
+#define vnop_access_desc (*vfs_op_descs[10])
+#define vnop_getattr_desc (*vfs_op_descs[11])
+#define vnop_setattr_desc (*vfs_op_descs[12])
+#define vnop_read_desc (*vfs_op_descs[13])
+#define vnop_write_desc (*vfs_op_descs[14])
+#define vnop_ioctl_desc (*vfs_op_descs[15])
+#define vnop_select_desc (*vfs_op_descs[16])
+#define vnop_exchange_desc (*vfs_op_descs[17])
+#define vnop_kqfilt_add_desc (*vfs_op_descs[18])
+#define vnop_kqfilt_remove_desc (*vfs_op_descs[19])
+#define vnop_revoke_desc (*vfs_op_descs[21])
+#define vnop_mmap_desc (*vfs_op_descs[22])
+#define vnop_mnomap_desc (*vfs_op_descs[23])
+#define vnop_fsync_desc (*vfs_op_descs[24])
+#define vnop_remove_desc (*vfs_op_descs[25])
+#define vnop_compound_remove_desc (*vfs_op_descs[26])
+#define vnop_link_desc (*vfs_op_descs[27])
+#define vnop_rename_desc (*vfs_op_descs[28])
+#define vnop_compound_rename_desc (*vfs_op_descs[29])
+#define vnop_mkdir_desc (*vfs_op_descs[30])
+#define vnop_compound_mkdir_desc (*vfs_op_descs[31])
+#define vnop_rmdir_desc (*vfs_op_descs[32])
+#define vnop_compound_rmdir_desc (*vfs_op_descs[33])
+#define vnop_symlink_desc (*vfs_op_descs[34])
+#define vnop_readdir_desc (*vfs_op_descs[35])
+#define vnop_readdirattr_desc (*vfs_op_descs[36])
+#define vnop_readlink_desc (*vfs_op_descs[37])
+#define vnop_inactive_desc (*vfs_op_descs[38])
+#define vnop_reclaim_desc (*vfs_op_descs[39])
+#define vnop_pathconf_desc (*vfs_op_descs[40])
+#define vnop_advlock_desc (*vfs_op_descs[41])
+#define vnop_allocate_desc (*vfs_op_descs[42])
+#define vnop_pagein_desc (*vfs_op_descs[43])
+#define vnop_pageout_desc (*vfs_op_descs[44])
+#define vnop_searchfs_desc (*vfs_op_descs[45])
+#define vnop_copyfile_desc (*vfs_op_descs[46])
+#define vnop_getxattr_desc (*vfs_op_descs[47])
+#define vnop_setxattr_desc (*vfs_op_descs[48])
+#define vnop_removexattr_desc (*vfs_op_descs[49])
+#define vnop_listxattr_desc (*vfs_op_descs[50])
+#define vnop_blktooff_desc (*vfs_op_descs[51])
+#define vnop_offtoblk_desc (*vfs_op_descs[52])
+#define vnop_blockmap_desc (*vfs_op_descs[53])
+#define vnop_monitor_desc (*vfs_op_descs[54])
+#else
+#if VERSION >= 0x040201
+#define vnop_default_desc (*vfs_op_descs[0])
+#define vnop_strategy_desc (*vfs_op_descs[1])
+#define vnop_bwrite_desc (*vfs_op_descs[2])
+#define vnop_lookup_desc (*vfs_op_descs[3])
+#define vnop_create_desc (*vfs_op_descs[4])
+#define vnop_mknod_desc (*vfs_op_descs[5])
+#define vnop_whiteout_desc (*vfs_op_descs[6])
+#define vnop_open_desc (*vfs_op_descs[7])
+#define vnop_close_desc (*vfs_op_descs[8])
+#define vnop_access_desc (*vfs_op_descs[9])
+#define vnop_getattr_desc (*vfs_op_descs[10])
+#define vnop_setattr_desc (*vfs_op_descs[11])
+#define vnop_read_desc (*vfs_op_descs[12])
+#define vnop_write_desc (*vfs_op_descs[13])
+#define vnop_ioctl_desc (*vfs_op_descs[14])
+#define vnop_select_desc (*vfs_op_descs[15])
+#define vnop_exchange_desc (*vfs_op_descs[16])
+#define vnop_kqfilt_add_desc (*vfs_op_descs[17])
+#define vnop_kqfilt_remove_desc (*vfs_op_descs[18])
+#define vnop_revoke_desc (*vfs_op_descs[20])
+#define vnop_mmap_desc (*vfs_op_descs[21])
+#define vnop_mnomap_desc (*vfs_op_descs[22])
+#define vnop_fsync_desc (*vfs_op_descs[23])
+#define vnop_remove_desc (*vfs_op_descs[24])
+#define vnop_link_desc (*vfs_op_descs[25])
+#define vnop_rename_desc (*vfs_op_descs[26])
+#define vnop_mkdir_desc (*vfs_op_descs[27])
+#define vnop_rmdir_desc (*vfs_op_descs[28])
+#define vnop_symlink_desc (*vfs_op_descs[29])
+#define vnop_readdir_desc (*vfs_op_descs[30])
+#define vnop_readdirattr_desc (*vfs_op_descs[31])
+#define vnop_readlink_desc (*vfs_op_descs[32])
+#define vnop_inactive_desc (*vfs_op_descs[33])
+#define vnop_reclaim_desc (*vfs_op_descs[34])
+#define vnop_pathconf_desc (*vfs_op_descs[35])
+#define vnop_advlock_desc (*vfs_op_descs[36])
+#define vnop_allocate_desc (*vfs_op_descs[37])
+#define vnop_pagein_desc (*vfs_op_descs[38])
+#define vnop_pageout_desc (*vfs_op_descs[39])
+#define vnop_searchfs_desc (*vfs_op_descs[40])
+#define vnop_copyfile_desc (*vfs_op_descs[41])
+#define vnop_getxattr_desc (*vfs_op_descs[42])
+#define vnop_setxattr_desc (*vfs_op_descs[43])
+#define vnop_removexattr_desc (*vfs_op_descs[44])
+#define vnop_listxattr_desc (*vfs_op_descs[45])
+#define vnop_blktooff_desc (*vfs_op_descs[46])
+#define vnop_offtoblk_desc (*vfs_op_descs[47])
+#define vnop_blockmap_desc (*vfs_op_descs[48])
+#define vnop_monitor_desc (*vfs_op_descs[49])
+#else
+#error unknown desc layout
+#endif
+#endif
+
+extern void *union_dircheckp asm("$ldr_$_T_4d_4b_1b_68_73_b1_0d_f5_92_60");
extern void IOLog(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
-#define printf(args...) ((void) (args))
+//#define printf(args...) ((void) (args))
View
@@ -138,8 +138,7 @@ union_init(__unused struct vfsconf *vfsp)
LIST_INIT(&unhead[i]);
bzero((caddr_t) unvplock, sizeof(unvplock));
/* add the hook for getdirentries */
- extern void *sysctl__vfs_generic_children[];
- sysctl__vfs_generic_children[2] = union_dircheck;
+ union_dircheckp = union_dircheck;
return (0);
}
View
@@ -574,14 +574,19 @@ struct vfs_fsentry fe = {
{NULL, NULL}
};
+extern void init_vnodeop_entries();
+
vfstable_t ft;
__attribute__((constructor))
static void init() {
+ init_vnodeop_entries();
printf("vfs_fsadd: %d\n", vfs_fsadd(&fe, &ft));
+ printf("whiteout: %p\n", &vnop_whiteout_desc);
}
__attribute__((destructor))
static void fini() {
// it's very dangerous to do this if you have anything mounted ;p
printf("vfs_fsremove: %d\n", vfs_fsremove(ft));
+ union_dircheckp = NULL;
}
View
@@ -1390,48 +1390,52 @@ STUB(union_offtoblk, struct vnop_offtoblk_args *, a_vp)
* Global vfs data structures
*/
int (**union_vnodeop_p)(void *);
-struct vnodeopv_entry_desc union_vnodeop_entries[] = {
- { &vnop_default_desc, (VOPFUNC)vn_default_error },
- { &vnop_lookup_desc, (VOPFUNC)union_lookup }, /* lookup */
- { &vnop_create_desc, (VOPFUNC)union_create }, /* create */
- { &vnop_whiteout_desc, (VOPFUNC)union_whiteout }, /* whiteout */
- { &vnop_mknod_desc, (VOPFUNC)union_mknod }, /* mknod */
- { &vnop_open_desc, (VOPFUNC)union_open }, /* open */
- { &vnop_close_desc, (VOPFUNC)union_close }, /* close */
- { &vnop_access_desc, (VOPFUNC)union_access }, /* access */
- { &vnop_getattr_desc, (VOPFUNC)union_getattr }, /* getattr */
- { &vnop_setattr_desc, (VOPFUNC)union_setattr }, /* setattr */
- { &vnop_read_desc, (VOPFUNC)union_read }, /* read */
- { &vnop_write_desc, (VOPFUNC)union_write }, /* write */
- { &vnop_ioctl_desc, (VOPFUNC)union_ioctl }, /* ioctl */
- { &vnop_select_desc, (VOPFUNC)union_select }, /* select */
- { &vnop_revoke_desc, (VOPFUNC)union_revoke }, /* revoke */
- { &vnop_mmap_desc, (VOPFUNC)union_mmap }, /* mmap */
- { &vnop_mnomap_desc, (VOPFUNC)union_mnomap }, /* mnomap */
- { &vnop_fsync_desc, (VOPFUNC)union_fsync }, /* fsync */
- { &vnop_remove_desc, (VOPFUNC)union_remove }, /* remove */
- { &vnop_link_desc, (VOPFUNC)union_link }, /* link */
- { &vnop_rename_desc, (VOPFUNC)union_rename }, /* rename */
- { &vnop_mkdir_desc, (VOPFUNC)union_mkdir }, /* mkdir */
- { &vnop_rmdir_desc, (VOPFUNC)union_rmdir }, /* rmdir */
- { &vnop_symlink_desc, (VOPFUNC)union_symlink }, /* symlink */
- { &vnop_readdir_desc, (VOPFUNC)union_readdir }, /* readdir */
- { &vnop_readlink_desc, (VOPFUNC)union_readlink }, /* readlink */
- { &vnop_inactive_desc, (VOPFUNC)union_inactive }, /* inactive */
- { &vnop_reclaim_desc, (VOPFUNC)union_reclaim }, /* reclaim */
- { &vnop_strategy_desc, (VOPFUNC)union_strategy }, /* strategy */
- { &vnop_pathconf_desc, (VOPFUNC)union_pathconf }, /* pathconf */
- { &vnop_advlock_desc, (VOPFUNC)union_advlock }, /* advlock */
-#ifdef notdef
- { &vnop_bwrite_desc, (VOPFUNC)union_bwrite }, /* bwrite */
-#endif
- { &vnop_pagein_desc, (VOPFUNC)union_pagein }, /* Pagein */
- { &vnop_pageout_desc, (VOPFUNC)union_pageout }, /* Pageout */
- { &vnop_copyfile_desc, (VOPFUNC)eopnotsupp }, /* Copyfile */
- { &vnop_blktooff_desc, (VOPFUNC)union_blktooff }, /* blktooff */
- { &vnop_offtoblk_desc, (VOPFUNC)union_offtoblk }, /* offtoblk */
- { &vnop_blockmap_desc, (VOPFUNC)union_blockmap }, /* blockmap */
- { (struct vnodeop_desc*)NULL, (int(*)())NULL }
-};
+struct vnodeopv_entry_desc union_vnodeop_entries[40];
struct vnodeopv_desc union_vnodeop_opv_desc =
{ &union_vnodeop_p, union_vnodeop_entries };
+void init_vnodeop_entries() {
+ struct vnodeopv_entry_desc foo[] = {
+ { &vnop_default_desc, (VOPFUNC)vn_default_error },
+ { &vnop_lookup_desc, (VOPFUNC)union_lookup }, /* lookup */
+ { &vnop_create_desc, (VOPFUNC)union_create }, /* create */
+ { &vnop_whiteout_desc, (VOPFUNC)union_whiteout }, /* whiteout */
+ { &vnop_mknod_desc, (VOPFUNC)union_mknod }, /* mknod */
+ { &vnop_open_desc, (VOPFUNC)union_open }, /* open */
+ { &vnop_close_desc, (VOPFUNC)union_close }, /* close */
+ { &vnop_access_desc, (VOPFUNC)union_access }, /* access */
+ { &vnop_getattr_desc, (VOPFUNC)union_getattr }, /* getattr */
+ { &vnop_setattr_desc, (VOPFUNC)union_setattr }, /* setattr */
+ { &vnop_read_desc, (VOPFUNC)union_read }, /* read */
+ { &vnop_write_desc, (VOPFUNC)union_write }, /* write */
+ { &vnop_ioctl_desc, (VOPFUNC)union_ioctl }, /* ioctl */
+ { &vnop_select_desc, (VOPFUNC)union_select }, /* select */
+ { &vnop_revoke_desc, (VOPFUNC)union_revoke }, /* revoke */
+ { &vnop_mmap_desc, (VOPFUNC)union_mmap }, /* mmap */
+ { &vnop_mnomap_desc, (VOPFUNC)union_mnomap }, /* mnomap */
+ { &vnop_fsync_desc, (VOPFUNC)union_fsync }, /* fsync */
+ { &vnop_remove_desc, (VOPFUNC)union_remove }, /* remove */
+ { &vnop_link_desc, (VOPFUNC)union_link }, /* link */
+ { &vnop_rename_desc, (VOPFUNC)union_rename }, /* rename */
+ { &vnop_mkdir_desc, (VOPFUNC)union_mkdir }, /* mkdir */
+ { &vnop_rmdir_desc, (VOPFUNC)union_rmdir }, /* rmdir */
+ { &vnop_symlink_desc, (VOPFUNC)union_symlink }, /* symlink */
+ { &vnop_readdir_desc, (VOPFUNC)union_readdir }, /* readdir */
+ { &vnop_readlink_desc, (VOPFUNC)union_readlink }, /* readlink */
+ { &vnop_inactive_desc, (VOPFUNC)union_inactive }, /* inactive */
+ { &vnop_reclaim_desc, (VOPFUNC)union_reclaim }, /* reclaim */
+ { &vnop_strategy_desc, (VOPFUNC)union_strategy }, /* strategy */
+ { &vnop_pathconf_desc, (VOPFUNC)union_pathconf }, /* pathconf */
+ { &vnop_advlock_desc, (VOPFUNC)union_advlock }, /* advlock */
+ #ifdef notdef
+ { &vnop_bwrite_desc, (VOPFUNC)union_bwrite }, /* bwrite */
+ #endif
+ { &vnop_pagein_desc, (VOPFUNC)union_pagein }, /* Pagein */
+ { &vnop_pageout_desc, (VOPFUNC)union_pageout }, /* Pageout */
+ { &vnop_copyfile_desc, (VOPFUNC)eopnotsupp }, /* Copyfile */
+ { &vnop_blktooff_desc, (VOPFUNC)union_blktooff }, /* blktooff */
+ { &vnop_offtoblk_desc, (VOPFUNC)union_offtoblk }, /* offtoblk */
+ { &vnop_blockmap_desc, (VOPFUNC)union_blockmap }, /* blockmap */
+ { (struct vnodeop_desc*)NULL, (int(*)())NULL }
+ };
+ memcpy(union_vnodeop_entries, foo, sizeof(foo));
+}
Oops, something went wrong.

0 comments on commit 08142f0

Please sign in to comment.