void PrintMembersPass::run_pass(DexStoresVector& stores, ConfigFiles&, PassManager&) { for (auto const& dex : DexStoreClassesIterator(stores)) { for (auto const& cls : dex) { if (m_config.only_these_classes.empty() || m_config.only_these_classes.count(cls) > 0) { printf("class: %s\n", SHOW(cls)); if (m_config.show_sfields) { for (auto const& m : cls->get_sfields()) { printf("sfield: %s\n", SHOW(m)); } } if (m_config.show_ifields) { for (auto const& m : cls->get_ifields()) { printf("ifield: %s\n", SHOW(m)); } } for (auto const& m : cls->get_dmethods()) { handle_method(m, "dmethod"); } for (auto const& m : cls->get_vmethods()) { handle_method(m, "vmethod"); } } } } }
void handle_singleton(void) { trace(TRACE_SINGLETON, "Adding a singleton"); char *name = next_token(); if (name == NULL) { error(ERROR_USERDATA, "Expected a name for the singleton"); } struct singleton *node = parsed_singletons; while (node != NULL && strcmp(node->name, name)) { node = node->next; } if (node == NULL) { trace(TRACE_SINGLETON, "Allocating new singleton for %s", name); node = (struct singleton *)allocate(sizeof(struct singleton)); node->name = (char *)allocate(strlen(name) + 1); strcpy(node->name, name); node->next = parsed_singletons; parsed_singletons = node; } // read type char *type = next_token(); if (type == NULL) { error(ERROR_SINGLETON, "Expected an access type for userdata %s", name); } if (strcmp(type, keyword_method) != 0) { error(ERROR_SINGLETON, "Singletons only support method access types (got %s)", type); } // method name handle_method(TRACE_USERDATA, node->name, &(node->methods)); }
void handle_userdata(void) { trace(TRACE_USERDATA, "Adding a userdata"); char *name = next_token(); if (name == NULL) { error(ERROR_USERDATA, "Expected a name for the userdata"); } struct userdata *node = parsed_userdata; while (node != NULL && strcmp(node->name, name)) { node = node->next; } if (node == NULL) { trace(TRACE_USERDATA, "Allocating new userdata for %s", name); node = (struct userdata *)allocate(sizeof(struct userdata)); node->name = (char *)allocate(strlen(name) + 1); strcpy(node->name, name); node->next = parsed_userdata; parsed_userdata = node; } else { trace(TRACE_USERDATA, "Found exsisting userdata for %s", name); } // read type char *type = next_token(); if (type == NULL) { error(ERROR_USERDATA, "Expected an access type for userdata %s", name); } // match type if (strcmp(type, keyword_field) == 0) { handle_userdata_field(node); } else if (strcmp(type, keyword_method) == 0) { handle_method(TRACE_USERDATA, node->name, &(node->methods)); } else { error(ERROR_USERDATA, "Unknown or unsupported type for userdata: %s", type); } }
static void http_server_handler(int c) { int code; struct socket_buffer sock; struct http_request request; char *buf; socket_buffer_init(&sock, c); #if HAVE_OPENSSL if (o.ssl) { sock.fdn.ssl = new_ssl(sock.fdn.fd); if (SSL_accept(sock.fdn.ssl) != 1) { loguser("Failed SSL connection: %s\n", ERR_error_string(ERR_get_error(), NULL)); fdinfo_close(&sock.fdn); return; } } #endif code = http_read_request_line(&sock, &buf); if (code != 0) { if (o.verbose) logdebug("Error reading Request-Line.\n"); send_string(&sock.fdn, http_code2str(code)); fdinfo_close(&sock.fdn); return; } if (o.debug > 1) logdebug("Request-Line: %s", buf); code = http_parse_request_line(buf, &request); free(buf); if (code != 0) { if (o.verbose) logdebug("Error parsing Request-Line.\n"); send_string(&sock.fdn, http_code2str(code)); fdinfo_close(&sock.fdn); return; } if (!method_is_known(request.method)) { if (o.debug > 1) logdebug("Bad method: %s.\n", request.method); http_request_free(&request); send_string(&sock.fdn, http_code2str(405)); fdinfo_close(&sock.fdn); return; } code = http_read_header(&sock, &buf); if (code != 0) { if (o.verbose) logdebug("Error reading header.\n"); http_request_free(&request); send_string(&sock.fdn, http_code2str(code)); fdinfo_close(&sock.fdn); return; } if (o.debug > 1) logdebug("Header:\n%s", buf); code = http_request_parse_header(&request, buf); free(buf); if (code != 0) { if (o.verbose) logdebug("Error parsing header.\n"); http_request_free(&request); send_string(&sock.fdn, http_code2str(code)); fdinfo_close(&sock.fdn); return; } /* Check authentication. */ if (o.proxy_auth) { struct http_credentials credentials; int ret, stale; if (http_header_get_proxy_credentials(request.header, &credentials) == NULL) { /* No credentials or a parsing error. */ send_proxy_authenticate(&sock.fdn, 0); http_request_free(&request); fdinfo_close(&sock.fdn); return; } ret = check_auth(&request, &credentials, &stale); http_credentials_free(&credentials); if (!ret) { /* Password doesn't match. */ /* RFC 2617, section 1.2: "If a proxy does not accept the credentials sent with a request, it SHOULD return a 407 (Proxy Authentication Required). */ send_proxy_authenticate(&sock.fdn, stale); http_request_free(&request); fdinfo_close(&sock.fdn); return; } } if (strcmp(request.method, "CONNECT") == 0) { code = handle_connect(&sock, &request); } else if (strcmp(request.method, "GET") == 0 || strcmp(request.method, "HEAD") == 0 || strcmp(request.method, "POST") == 0) { code = handle_method(&sock, &request); } else { code = 500; } http_request_free(&request); if (code != 0) { send_string(&sock.fdn, http_code2str(code)); fdinfo_close(&sock.fdn); return; } fdinfo_close(&sock.fdn); }