void *test_list(void *param){ thlist_data *d = (thlist_data *)param; int j,len=0,found=0; *(d->progress)=0; for(j=0;j<d->num;j++){ *(d->progress)= *(d->progress)+1; len = strlen(d->list[j]); found = open_key(d->list[j], len, &(d->header), d->iv_mode, d->chain_mode, d->crypt_disk, d->fast_check, d->keyslot, d->pbk_hash); if(found){ /* entering mutex section */ pthread_mutex_lock(&condition_mutex); pthread_cond_signal(&condition_cond); memset(d->win_pwd,0,d->max_l); sprintf(d->win_pwd,"%s",d->list[j]); /* exiting mutex section */ pthread_mutex_unlock(&condition_mutex); } } for(j=0;j<d->num;j++){ free(d->list[j]); } pthread_exit(NULL); }
void lemur::file::Keyfile::open( const char* filename, int cacheSize, bool readOnly) { _buildHandle( cacheSize ); int error = open_key( _handle, const_cast<char*>(filename), _handleSize, readOnly ? 1 : 0); if( error ) LEMUR_THROW(LEMUR_KEYFILE_IO_ERROR, "Unable to open '" + filename + "'"); }
/* * Enumerates all of the values at the supplied HKEY. * * TLVs: * * req: TLV_TYPE_ROOT_KEY - The root key * req: TLV_TYPE_BASE_KEY - The base key * opt: TLV_TYPE_PERMISSION - Permissions with which to open the key */ DWORD request_registry_enum_value_direct(Remote *remote, Packet *packet) { HKEY rootkey, hkey = NULL; open_key(packet, &rootkey, &hkey); enum_value(remote, packet, hkey); if (hkey) RegCloseKey(hkey); return ERROR_SUCCESS; }
static int net_registry_enumerate(struct net_context *c, int argc, const char **argv) { WERROR werr; struct registry_key *key = NULL; TALLOC_CTX *ctx = talloc_stackframe(); char *subkey_name; NTTIME modtime; uint32_t count; char *valname = NULL; struct registry_value *valvalue = NULL; int ret = -1; if (argc != 1 || c->display_usage) { d_printf("Usage: net registry enumerate <path>\n"); d_printf("Example: net registry enumerate " "'HKLM\\Software\\Samba'\n"); goto done; } werr = open_key(ctx, argv[0], REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "open_key failed: %s\n", win_errstr(werr)); goto done; } for (count = 0; werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime), W_ERROR_IS_OK(werr); count++) { print_registry_key(subkey_name, &modtime); } if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { goto done; } for (count = 0; werr = reg_enumvalue(ctx, key, count, &valname, &valvalue), W_ERROR_IS_OK(werr); count++) { print_registry_value_with_name(valname, valvalue); } if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { goto done; } ret = 0; done: TALLOC_FREE(ctx); return ret; }
main(int argc,char *argv[]) { int op; op = atoi(argv[3]); printf("op is %d\n",op); spi_modules_init(argv[1]); if(!strcmp(argv[2],"-r")) { } else if(!strcmp(argv[2],"-g")) { printf("the voltage is %d\n",read_voltage()); } else if(!strcmp(argv[2],"-p")) { } else if(!strcmp(argv[2],"-c")) { poweroff_now(); } else if(!strcmp(argv[2],"-l1")) { operation_lm1(op); } else if(!strcmp(argv[2],"-o")) { out_12(op); } else if(!strcmp(argv[2],"-l2")) { operation_lm2(op); } else if(!strcmp(argv[2],"-l3")) { operation_lm2(op); } else if(!strcmp(argv[2],"-b")) { printf("operation_bark\n"); operation_backlight(op); }else if(!strcmp(argv[2],"-k")) { open_key(); }else if(!strcmp(argv[2],"-re")) { restart_system(); } }
result_t rmdir_path_action(cli_t *context, const char * name_) { result_t result; memid_t key; if(failed(result = open_key(get_context(context), name_, false, &key)) || failed(result = reg_delete_key(key))) { stream_puts(context->cfg.console_err, "Error when deleting key\r\n"); return result; } return s_ok; }
void *th_force(void *param){ thforce_data *d = (thforce_data *)param; char *guess; int i,n,k,found; if((guess = calloc(d->len+1,sizeof(char)))==NULL){ errprint("malloc error!\n"); return 0; } *(d->progress)=0; found=0; for (i=0;i<d->comb;i++) { n = i; guess[0]=d->set[d->start + (i % d->num)]; n/= d->num; for (k=1; k<d->len; k++){ guess[k] = d->set[n % d->set_len]; n /= d->set_len; } found = open_key(guess, d->len, &(d->header), d->iv_mode, d->chain_mode, d->crypt_disk, d->fast_check, d->keyslot, d->pbk_hash); *(d->progress)=*(d->progress) + 1; if(found){ /* entering mutex section */ pthread_mutex_lock(&condition_mutex); pthread_cond_signal(&condition_cond); memset(d->win_pwd,0,d->len); sprintf(d->win_pwd,"%s",guess); /* exiting mutex section */ pthread_mutex_unlock(&condition_mutex); goto end; } } end: free(guess); pthread_exit(NULL); }
static int open_jpsystem_init(void) { int i; int voltage = 0; struct timespec rem = { 0, 5000000}; for (i = 0; i < 4; i++) { voltage = read_voltage(); nanosleep(&rem, &rem); DEBUG_OUT(DEBUG_GZQ, "read voltage = %d\n", voltage); } operation_lm2(1); operation_12v(1); open_key(); return 0; }
static int net_registry_getvaluesraw(struct net_context *c, int argc, const char **argv) { WERROR werr; int ret = -1; struct registry_key *key = NULL; TALLOC_CTX *ctx = talloc_stackframe(); uint32_t idx; if (argc != 1 || c->display_usage) { d_fprintf(stderr, "usage: net rpc registry getvaluesraw " "<key>\n"); goto done; } werr = open_key(ctx, argv[0], REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "open_key failed: %s\n", win_errstr(werr)); goto done; } idx = 0; while (true) { struct registry_value *val; werr = reg_enumvalue(talloc_tos(), key, idx, NULL, &val); if (W_ERROR_EQUAL(werr, WERR_NO_MORE_ITEMS)) { ret = 0; break; } if (!W_ERROR_IS_OK(werr)) { break; } print_registry_value(val, true); TALLOC_FREE(val); idx += 1; } done: TALLOC_FREE(ctx); return ret; }
/* * Opens a registry key and returns the associated HKEY to the caller if the * operation succeeds. * * TLVs: * * req: TLV_TYPE_ROOT_KEY - The root key * req: TLV_TYPE_BASE_KEY - The base key * opt: TLV_TYPE_PERMISSION - Permissions with which to open the key */ DWORD request_registry_open_key(Remote *remote, Packet *packet) { Packet *response = packet_create_response(packet); DWORD result; HKEY rootKey, resKey; result = open_key(packet, &rootKey, &resKey); // Add the HKEY if we succeeded, but always return a result if (result == ERROR_SUCCESS) { packet_add_tlv_qword(response, TLV_TYPE_HKEY, (QWORD)resKey); } packet_add_tlv_uint(response, TLV_TYPE_RESULT, result); packet_transmit(remote, response, NULL); return ERROR_SUCCESS; }
// sign a hash of input using private key void sign (void) { char *p; // initialize crypto API if (open_crypt()) { // import our private key if (open_key (RSA_PRIVATE_BIN)) { // hash the input if (open_hash ()) { // obtain size of signature CryptSignHash (hHash, AT_SIGNATURE, NULL, 0, NULL, &dwSigLen); pbSignature=xmalloc (dwSigLen); // sign the hash to obtain signature if (CryptSignHash (hHash, AT_SIGNATURE, NULL, 0, pbSignature, &dwSigLen)) { p=sig2hex(); if (p) { printf (" [ signature is: %i::%s\n", lstrlen(p), p); } xfree (pbSignature); } else { xstrerror ("CryptSignHash()"); } close_hash(); } else { xstrerror ("open_hash()"); } close_key(); } else { xstrerror ("open_key()"); } close_crypt(); } else { xstrerror ("open_crypt()"); } }
NTSTATUS NTAPI NtOpenKey( PHANDLE KeyHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes ) { OBJECT_ATTRIBUTES oa; unicode_string_t us; NTSTATUS r; regkey_t *key = NULL; trace("%p %08lx %p\n", KeyHandle, DesiredAccess, ObjectAttributes ); // copies the unicode string before validating object attributes struct r = copy_from_user( &oa, ObjectAttributes, sizeof oa ); if (r < STATUS_SUCCESS) return r; r = us.copy_from_user( oa.ObjectName ); if (r < STATUS_SUCCESS) return r; oa.ObjectName = &us; if (oa.Length != sizeof oa) return STATUS_INVALID_PARAMETER; trace("len %08lx root %p attr %08lx %pus\n", oa.Length, oa.RootDirectory, oa.Attributes, oa.ObjectName); r = open_key( &key, &oa ); trace("open_key returned %08lx\n", r); if (r == STATUS_SUCCESS) { r = alloc_user_handle( key, DesiredAccess, KeyHandle ); //release( event ); } return r; }
// verify a signature using public key BOOL verify(void) { BOOL bStatus = FALSE; // initialize crypto API if (open_crypt()) { // import public key if (open_key(DSA_PUBLIC_BIN)) { // hash the input if (open_hash()) { // convert signature to binary sig2bin(); if (pbSignature != NULL) { // verify signature bStatus = CryptVerifySignature(hHash, pbSignature, dwSigLen, hKey, NULL, 0); printf(" [ signature is %s\n", bStatus ? "valid" : "invalid"); xfree(pbSignature); } close_hash(); } else { printf("open_hash()"); } close_key(); } else { printf("open_key()"); } close_crypt(); } else { printf("open_crypt()"); } return bStatus; }
result_t cd_path_action(cli_t *context, const char * name_) { // open a sub-key result_t result; memid_t memid = 0; if(failed(result = open_key(get_context(context), name_, false, &memid))) { stream_puts(context->cfg.console_err, "Error when creating key\r\n"); return result; } // update the submode const char * dirname = get_full_path(memid); char prompt[MAX_PROMPT_LENGTH]; snprintf(prompt, MAX_PROMPT_LENGTH, "%s %s ", node_name, dirname); neutron_free((void *)dirname); strncpy(context->prompt[context->root_level], prompt, MAX_PROMPT_LENGTH); context->current[context->root_level] = memid; return s_ok; }
static int net_registry_getvalue_internal(struct net_context *c, int argc, const char **argv, bool raw) { WERROR werr; int ret = -1; struct registry_key *key = NULL; struct registry_value *value = NULL; TALLOC_CTX *ctx = talloc_stackframe(); if (argc != 2 || c->display_usage) { d_fprintf(stderr, "%s\n%s", _("Usage:"), _("net registry getvalue <key> <valuename>\n")); goto done; } werr = open_key(ctx, argv[0], REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, _("open_key failed: %s\n"), win_errstr(werr)); goto done; } werr = reg_queryvalue(ctx, key, argv[1], &value); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, _("reg_queryvalue failed: %s\n"), win_errstr(werr)); goto done; } print_registry_value(value, raw); ret = 0; done: TALLOC_FREE(ctx); return ret; }