Beispiel #1
0
int
kdopen(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct kd_softc *kd;
	int error, s, unit;
	struct tty *tp;
static	int firstopen = 1;

	unit = minor(dev);
	if (unit != 0)
		return ENXIO;

	kd = &kd_softc; 	/* XXX */
	if (firstopen) {
		kd_init(kd);
		firstopen = 0;
	}

	tp = kd->kd_tty;

	/* It's simpler to do this up here. */
	if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp))
		return (EBUSY);

	s = spltty();
	if ((tp->t_state & TS_ISOPEN) == 0) {
		/* First open. */

		/* Notify the input device that serves us */
		struct cons_channel *cc = kd->kd_in;
		if (cc != NULL &&
		    (error = (*cc->cc_iopen)(cc)) != 0) {
			return (error);
		}

		ttychars(tp);
		tp->t_iflag = TTYDEF_IFLAG;
		tp->t_oflag = TTYDEF_OFLAG;
		tp->t_cflag = TTYDEF_CFLAG;
		tp->t_lflag = TTYDEF_LFLAG;
		tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
		(void) kdparam(tp, &tp->t_termios);
		ttsetwater(tp);
		tp->t_winsize.ws_row = kd->rows;
		tp->t_winsize.ws_col = kd->cols;
		/* Flush pending input?  Clear translator? */
		/* This (pseudo)device always has SOFTCAR */
		tp->t_state |= TS_CARR_ON;
	}

	splx(s);

	return ((*tp->t_linesw->l_open)(dev, tp));
}
bool BNCSHandler::HandleAuthInfo(DWORD LogonType, DWORD UDPValue, FILETIME MPQFileTime, char *MPQFileName, char *ValueString) {
    switch(LogonType) {
    case 0:
        break;

    case 1:
        global->logManip.logOutput(LOG_CONN_ERROR, true, "The nls is not supported by this bot.\n");
        return false;
        break;

    case 2:
        global->logManip.logOutput(LOG_CONN_ERROR, true, "The nls is not supported by this bot.\n");
        return false;
        break;

    default:
        global->logManip.logOutput(LOG_CONN_ERROR, true, "The suggested logon method is not supported by this client!\n");
        return false;
        break;
    }
    global->logManip.logOutput(LOG_STARTUP, true, "Checking CD key and file versions...\n");

    kd_init();
    unsigned int mpqNum = extractMPQNumber(MPQFileName);
    if(mpqNum < 0)
        return false;

    char *annoying1 = new char[global->configManip.getGamefile1().length() +1];
    char *annoying2 = new char[global->configManip.getGamefile2().length() +1];
    char *annoying3 = new char[global->configManip.getGamefile3().length() +1];
    strcpy(annoying1, global->configManip.getGamefile1().c_str());
    strcpy(annoying2, global->configManip.getGamefile2().c_str());
    strcpy(annoying3, global->configManip.getGamefile3().c_str());
    const char* files[] = { annoying1, annoying2, annoying3 };
    unsigned long Checksum;
    if(!checkRevision(ValueString, files, 3, mpqNum, &Checksum))
        return false;

    delete [] annoying1;
    delete [] annoying2;
    delete [] annoying3;

    DWORD exeVer;
    unsigned int Version;
    char exeInfo[300];
    char *annoying = new char[global->configManip.getGamefile1().length() + 1];
    strcpy(annoying, global->configManip.getGamefile1().c_str());
    exeVer = getExeInfo(annoying, exeInfo, 256, &Version, 0x1);
    delete [] annoying;
    if(!exeVer) {
        global->logManip.logOutput(LOG_CONN_ERROR, true, "Could not gather game file info!\n");
        return false;
    }

    global->packetManip.Buff.add(clientToken);
    global->packetManip.Buff.add(exeVer);
    global->packetManip.Buff.add(Checksum);
    global->packetManip.Buff.add((int)0x01);
    global->packetManip.Buff.add((int)0);

    CDKeyDecoder decoder(global->configManip.getCDKey().c_str(), global->configManip.getCDKey().length());
    if(!decoder.isKeyValid()) {
        global->logManip.logOutput(LOG_CONN_ERROR, true, "The provided CD key is invalid!\n");
        return false;
    }

    unsigned long getProd, getVal;
    getProd = decoder.getProduct();
    getVal = decoder.getVal1();
    global->packetManip.Buff.add((int)strlen(global->configManip.getCDKey().c_str()));
    global->packetManip.Buff.add(getProd);
    global->packetManip.Buff.add(getVal);
    global->packetManip.Buff.add((int)0x00);

    int hashLength = decoder.calculateHash(clientToken, serverToken);
    if(!hashLength)
        return false;

    char KeyHash[64];
    if(!decoder.getHash(KeyHash))
        return false;

    global->packetManip.Buff.add(KeyHash, 5 * 4);
    global->packetManip.Buff.add(exeInfo);
    global->packetManip.Buff.add(global->configManip.getUsername());
    global->packetManip.Buff.sendpacket(SID_AUTH_CHECK);
    return true;
}