void CDrumWidget::addPads(QList<SPad> *pads2Add){ for(int i=0;i<pads2Add->length();i++) { SPad pad = pads2Add->at(i); addPad(&pad, false); } repaint(); }
//==================================== // addPad //------------------------------------ int SaXManipulateTablets::addPad ( const QString& vendor, const QString& model ) { // .../ //! add a new Pad associated with the given group name to //! the current pointer data. The group name consists of the //! vendor and model name separated by a colon. The contents of the //! data record will set the InputFashion type for this addon //! pointer device // ---- return addPad (vendor+":"+model); }
static int gotoStatePtkInitNegoTx(tAuthRsnFsm *fsm) { tAniEapolRsnKeyDesc txDesc; v_BOOL_t retransmit = eANI_BOOLEAN_FALSE; v_U8_t *rsnWpaIe = NULL; int rsnWpaIeLen; static tAniPacket *keyData; // The longest length...the extra 8 bytes account for RSN key data // encapsulation v_U8_t paddedGroupKeyEncaps[1024]; int padLen = 0; v_U8_t *groupKeyBytes; int groupKeyLen; v_U8_t *wrappedKey = NULL; // Variables used for RC4 GTK wrap //v_U8_t keyIv[ANI_EAPOL_KEY_RSN_IV_SIZE]; //v_U32_t keyIvLsb; int retVal = 0; //invalidate this fsm->msg4TimeOut = VOS_FALSE; fsm->currentState = PTK_INIT_NEGO_TX ; if (keyData == NULL) { // Allocate the packet the first time around that you enter retVal = aniAsfPacketAllocateExplicit(&keyData, 1024, 10); if( !ANI_IS_STATUS_SUCCESS( retVal ) ) { return retVal; } } else { // Just empty out the packet aniAsfPacketEmptyExplicit(keyData, 10); } do { // Create a new EAPOL frame if we don't have one to retransmit //if (aniAsfPacketGetLen(fsm->lastEapol) == 0) #if 0 if( fsm->lastEapol ) { aniAsfPacketFree( fsm->lastEapol ); fsm->lastEapol = NULL; retVal = aniAsfPacketAllocateExplicit(&fsm->lastEapol, RSN_MAX_PACKET_SIZE, EAPOL_TX_HEADER_SIZE ); #endif aniAsfPacketEmptyExplicit(fsm->lastEapol, EAPOL_TX_HEADER_SIZE); // } if (1) { vos_mem_zero( &txDesc, sizeof(txDesc) ); // The Key Information bits... if (fsm->staCtx->pwCipherType == eCSR_ENCRYPT_TYPE_AES) { txDesc.info.keyDescVers = ANI_EAPOL_KEY_DESC_VERS_AES; } else { txDesc.info.keyDescVers = ANI_EAPOL_KEY_DESC_VERS_RC4; } txDesc.info.unicastFlag = eANI_BOOLEAN_TRUE; txDesc.info.installFlag = eANI_BOOLEAN_TRUE; txDesc.info.ackFlag = eANI_BOOLEAN_TRUE; txDesc.info.micFlag = eANI_BOOLEAN_TRUE; txDesc.keyLen = aagGetKeyMaterialLen(fsm->staCtx->pwCipherType); aniSsmReplayCtrNext(fsm->staCtx->localReplayCtr, txDesc.replayCounter); vos_mem_copy(txDesc.keyNonce, fsm->aNonce, sizeof(txDesc.keyNonce)); // Add the RSN IE (but not any WPA IE) rsnWpaIeLen = getRsnIeFromAdvertizedIes(fsm, &rsnWpaIe); if( !ANI_IS_STATUS_SUCCESS( rsnWpaIeLen) ) break; retVal = aniAsfPacketAppendBuffer(keyData, rsnWpaIe, rsnWpaIeLen); if( !ANI_IS_STATUS_SUCCESS( retVal ) ) break; // Add the RSN group key encapsulation retVal = aagAppendGroupKeyForRsn ( keyData ); if( !ANI_IS_STATUS_SUCCESS( retVal ) ) break; groupKeyLen = aniAsfPacketGetBytes(keyData, &groupKeyBytes); if( !ANI_IS_STATUS_SUCCESS( groupKeyLen ) ) { retVal = ANI_E_FAILED; break; } txDesc.info.secureFlag = eANI_BOOLEAN_TRUE; txDesc.info.encKeyDataFlag = eANI_BOOLEAN_TRUE; if ( fsm->staCtx->pwCipherType == eCSR_ENCRYPT_TYPE_AES ) { /* * Use the AES key wrap algorithm if either one of the pairwise * key or the group key is an AES key. * * If the key being sent is not a multiple of * ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE, then pad it with * zeroes. e.g., if we are sending a WEP key of 5 or 13 * bytes. */ VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "AES Key Wrap invoked. groupKeyLen = %d", groupKeyLen); padLen = groupKeyLen % ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE; if (padLen != 0) { padLen = ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE - padLen; VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Before AES Key Wrap: padLen = %d", padLen); if (groupKeyLen + padLen > sizeof(paddedGroupKeyEncaps)) { #if 0 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Cannot encode group key encapsulation of len %d and cipher type %s " "to send to %s %s (aid %d, radio %d, user %s)", groupKeyLen, aniSsmIntGetCipherStr(AAG_GROUP_CIPHER(fsm->ctx->radioId)), (fsm->ctx->bpIndicator ? "BP" : "STA"), aniAsfHexStr(fsm->ctx->suppMac, sizeof(tAniMacAddr)), fsm->ctx->aid, fsm->ctx->radioId, aagGetStaUserId(fsm->ctx)); #endif retVal = ANI_E_FAILED; } // OK, after you compute the pad length, you need to // add the padding - 0xdd followed by 0x00's addPad( groupKeyBytes , groupKeyLen , padLen ); // add the padding length groupKeyLen += padLen; // IMMEDIATELY adjust the packet size to reflect the pad aniAsfPacketMoveRight(keyData, padLen); if( !ANI_IS_STATUS_SUCCESS( retVal) ) break; } VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Before AES Key Wrap: padded groupKeyLen = %d", groupKeyLen); retVal = aniSsmAesKeyWrap(fsm->cryptHandle, groupKeyBytes, groupKeyLen, fsm->staCtx->ptk + ANI_EAPOL_KEY_RSN_MIC_SIZE, ANI_EAPOL_KEY_RSN_ENC_KEY_SIZE, &wrappedKey); if( !ANI_IS_STATUS_SUCCESS( retVal) ) break; // This doesn't work... //groupKeyBytes = wrappedKey; //groupKeyLen += ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE; // ...here is the right way to do it // Add the length of the prepended IV A[0] if (NULL == wrappedKey) { break; } groupKeyLen += ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE; memcpy( groupKeyBytes, wrappedKey, groupKeyLen); // Free the array used to hold the wrapped key if (wrappedKey) vos_mem_free( wrappedKey); // IMMEDIATELY adjust the packet size to reflect the IV aniAsfPacketMoveRight(keyData, ANI_SSM_AES_KEY_WRAP_BLOCK_SIZE); } else { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Auth RC4 Key Wrap invoked. groupKeyLen = %d", groupKeyLen); } txDesc.keyDataLen = aniAsfPacketGetBytes(keyData, &txDesc.keyData); retVal = aniEapolWriteKey(fsm->cryptHandle, fsm->lastEapol, fsm->staCtx->suppMac, fsm->staCtx->authMac, ANI_EAPOL_KEY_DESC_TYPE_RSN_NEW, &txDesc, fsm->staCtx->ptk, CSR_AES_KEY_LEN); if( !ANI_IS_STATUS_SUCCESS( retVal) ) break; } else { retransmit = eANI_BOOLEAN_TRUE; } if( VOS_IS_STATUS_SUCCESS( bapRsnSendEapolFrame( fsm->ctx->pvosGCtx, fsm->lastEapol ) ) ) { retVal = ANI_OK; } else { //we fail to send the eapol frame disconnect bapAuthDisconnect( fsm->ctx ); retVal = ANI_ERROR; } }while( 0 ); return retVal; } static int gotoStatePtkInitDone(tAuthRsnFsm *fsm, tAniEapolKeyAvailEventData *data) { int retVal; tAniEapolRsnKeyDesc *rxDesc; tCsrRoamSetKey setKeyInfo; fsm->currentState = PTK_INIT_DONE; rxDesc = data->keyDesc; vos_mem_zero( &setKeyInfo, sizeof( tCsrRoamSetKey ) ); setKeyInfo.encType = eCSR_ENCRYPT_TYPE_AES; setKeyInfo.keyDirection = eSIR_TX_RX; vos_mem_copy( setKeyInfo.peerMac, fsm->staCtx->suppMac, sizeof( tAniMacAddr ) ); setKeyInfo.paeRole = 0; //this is a supplicant setKeyInfo.keyId = 0; //always setKeyInfo.keyLength = CSR_AES_KEY_LEN; vos_mem_copy( setKeyInfo.Key, (v_U8_t *)fsm->staCtx->ptk + (2 * CSR_AES_KEY_LEN ), CSR_AES_KEY_LEN ); //fsm->suppCtx->ptk contains the 3 16-bytes keys. We need the last one. if( VOS_IS_STATUS_SUCCESS( bapSetKey( fsm->ctx->pvosGCtx, &setKeyInfo ) ) ) { //Done aniAsfPacketEmptyExplicit(fsm->lastEapol, EAPOL_TX_HEADER_SIZE); retVal = ANI_OK; } else { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Auth: gotoStatePtkInitDone fail to set key\n" ); retVal = ANI_ERROR; } return retVal; }
// THE MAIN char* main(int argc, char *argv[]) // param options: // decrypt some aes encrypted string: enc_string key // set a new flag d with id=a and token='b-.-c': a 'b-.-c' d // add a new fzn with value: fzn value { if (strcmp(argv[1], "-h") == 0) { // decryption not really needed but management want me to leave it... char* encrypted_flag = argv[2]; char* aeskey = argv[3]; char tmpstr[8096]; sprintf(tmpstr, "echo %s | openssl enc -d -aes-256-cbc -a -k %s", encrypted_flag, aeskey); FILE *fp; int status; char path[4096]; char content[4096]; fp = popen(tmpstr, "r"); if (fp == NULL) /* Handle error */; fgets(path, 4096, fp); sprintf(content, "%s", path); if (strlen(content) < 5) { printf("gcry_cipher_decrypt failed:"); } else { printf("%s\n", content); } // dec: echo U2FsdGVkX18eaVlEUPTR47GFaEoh3u9DMHgqvtZS1Ko= | openssl enc -d -aes-256-cbc -a -k mykey } else if (strcmp(argv[1], "-h") == 0) { // decryption not really needed but management want me to leave it... char* encrypted_flag = argv[2]; char* aes_key = argv[3]; //printf("encrypted_flag: %s (%i)\n", encrypted_flag, (int)(strlen(encrypted_flag))); char* ascii_flag = hexToString(encrypted_flag); //printf("ascii_flag: %s (%i)\n", ascii_flag, (int)(strlen(ascii_flag))); decryptString2(ascii_flag, aes_key); //printf("passing ascii_flag: %s (%i)\n", ascii_flag, (int)(strlen(ascii_flag))); remPad(ascii_flag, strlen(ascii_flag)); //printf("%s\n", ascii_flag); //printf("ascii_flag: %s (%i)\n", ascii_flag, (int)(strlen(ascii_flag))); printf("%s\n", ascii_flag); return ascii_flag; // is decryped } else if (argc == 4) { char* flag_id = argv[1]; // FahrzeugnummerBeginnWortBeginn char* password = argv[2]; // ( komplette Fahrzeugnummer-.-komplettes Wort ) char* content_arg = argv[3]; // the flag itself char content[4096]; strcpy(content, content_arg); char delimiter[] = "-.-"; char *ptr; ptr = strtok(password, delimiter); char* fzn = ptr; ptr = strtok(NULL, delimiter); char* bayWord = ptr; char* aeskey = randstring(16); printf("%s\n", aeskey); char hex_content[4096]; char tmpstr[8096]; sprintf(tmpstr, "echo %s | openssl enc -e -aes-256-cbc -a -k %s", argv[3], aeskey); FILE *fp; int status; char path[4096]; fp = popen(tmpstr, "r"); if (fp == NULL) /* Handle error */; fgets(path, 4096, fp); sprintf(hex_content, "%s", path); // dec: echo U2FsdGVkX18eaVlEUPTR47GFaEoh3u9DMHgqvtZS1Ko= | openssl enc -d -aes-256-cbc -a -k mykey // printf("hex: ||%s||", hex_content); // printf("aes: ||%s||", aeskey); // printf("-----------"); printf("fzn: %s\n", fzn); printf("bayWord: %s\n", bayWord); printf("encrypted: %s\n", hex_content); printf("aeskey: %s\n", aeskey); // ADD TO FILES addFznAndEncContentToFznCsv(fzn, hex_content); // printf("Alles3: ||%s|| ; ||%s|| ; ||%s|| ; ||%s|| ; ||%s||\n", bayWord, aeskey, fzn, hex_content, aeskey); addBayWordAndKeyToBayCsv(bayWord, aeskey); // printf("Alles4: ||%s|| ; ||%s|| ; ||%s|| ; ./setflag -h %s %s\n", bayWord, aeskey, fzn, hex_content, aeskey); } else if (argc == 4) { // for managers only!!11 int done = 0; int tries = 0; char* flag_id = argv[1]; // FahrzeugnummerBeginnWortBeginn char* password = argv[2]; // ( komplette Fahrzeugnummer-.-komplettes Wort ) char* content_arg = argv[3]; // the flag itself char content[4096]; strcpy(content, content_arg); printf("content_arg: %s (%i)\n", content_arg, (int)(strlen(content_arg))); printf("Alles::content: %s (%i)\n", content, (int)(strlen(content))); printf("content1: %s\n", content); char delimiter[] = "-.-"; char *ptr; ptr = strtok(password, delimiter); char* fzn = ptr; printf("fzn: %s\n", fzn); ptr = strtok(NULL, delimiter); char* bayWord = ptr; printf("Alles::bayWord: %s\n", bayWord); char aeskey[1024]; char hex_content[4096]; while (done == 0) { // some weird workaround... tries++; strcpy(content, content_arg); printf("Alles0: || %i ||%s (%i)|| ; ||%s(%i)|| ; ||%s(%i)|| ; ||%s(%i)|| ; ||%s(%i)||\n", tries, bayWord, (int)(strlen(bayWord)), aeskey,(int)(strlen(aeskey)), fzn, (int)(strlen(fzn)), hex_content, (int)(strlen(hex_content)), content, (int)(strlen(content))); // char* aeskey = randstring(16); strcpy(aeskey, randstring(16)); printf("aeskey: ||%s||\n", aeskey); printf("passing content: %s (%i)\n", content, (int)(strlen(content))); addPad(content, sizeof(content)); printf("AllesX: || %i ||%s (%i)|| ; ||%s(%i)|| ; ||%s(%i)|| ; ||%s(%i)||; ||%s(%i)||\n", tries, bayWord, (int)(strlen(bayWord)), aeskey,(int)(strlen(aeskey)), fzn, (int)(strlen(fzn)), hex_content, (int)(strlen(hex_content)), content, (int)(strlen(content))); printf("after addpad: %s (%i)\n", content, (int)(strlen(content))); int index = 0; printf("AllesS: "); for (index = 0; index<strlen(content)+1; index++) { printf("%02X", (unsigned char)content[index]); } printf("\n"); encryptString2(content, aeskey); printf("AllesY: || %i ||%s (%i)|| ; ||%s(%i)|| ; ||%s(%i)|| ; ||%s(%i)||; ||%s(%i)||\n", tries, bayWord, (int)(strlen(bayWord)), aeskey,(int)(strlen(aeskey)), fzn, (int)(strlen(fzn)), hex_content, (int)(strlen(hex_content)), content, (int)(strlen(content))); printf("after enc: %s (%i)\n", content, (int)(strlen(content))); if (strlen(content) < 32) { printf("strlen %i\n", (int)(strlen(content))); int rofl = 0; printf("As s: ||"); for (rofl = 0; rofl < 32; rofl++) { printf("%c", content[rofl]); } printf("||\nAs x02: ||"); for (rofl = 0; rofl < 32; rofl = rofl+2) { printf("%02X", content[rofl]); } printf("||\n"); } printAsHex(content); // char* hex_content = stringToHex(content); strcpy(hex_content, stringToHex(content)); printf("after hex: %s (%i)\n", content, (int)(sizeof(content))); printf("Alles1: || %i ||%s (%i)|| ; ||%s(%i)|| ; ||%s(%i)|| ; ||%s(%i)||; ||%s(%i)||\n", tries, bayWord, (int)(strlen(bayWord)), aeskey,(int)(strlen(aeskey)), fzn, (int)(strlen(fzn)), hex_content, (int)(strlen(hex_content)), content, (int)(strlen(content))); if ((( strlen(hex_content) > 0 && strlen(content) > 0 && (strlen(hex_content) % 16) == 0 && (strlen(content) % 16) == 0) ) || tries > 4 ) { done = 1; printf("Alles2: || %i ||%s|| ; ||%s|| ; ||%s|| ; ||%s|| ; ||%s||\n", tries, bayWord, aeskey, fzn, hex_content, aeskey); addFznAndEncContentToFznCsv(fzn, hex_content); printf("Alles3: || %i ||%s|| ; ||%s|| ; ||%s|| ; ||%s|| ; ||%s||\n", tries, bayWord, aeskey, fzn, hex_content, aeskey); addBayWordAndKeyToBayCsv(bayWord, aeskey); printf("Alles4: || %i ||%s|| ; ||%s|| ; ||%s|| ; ./setflag -h %s %s\n", tries, bayWord, aeskey, fzn, hex_content, aeskey); } // char tmpstr[8096]; // sprintf(tmpstr, "echo 'tries: %i || done: %i || strlen content: (%i) || hex_content: %s (%i) || content_arg: %s (%i) || ' >> setflaglog.log", tries, done, (int)(strlen(content)), hex_content, (int)(strlen(hex_content)), content_arg, (int)(strlen(content_arg))); // popen(tmpstr, "r"); } } else { // official functionality char* fzn = argv[1]; char* value = argv[2]; if (fzn != NULL && value != NULL) { addFznAndEncContentToFznCsv(fzn, value); printf("FZN ADDED\n"); } else { printf("you have to provide fzn and value\n"); } } }