示例#1
0
void realHandler(int sock) {
   int canary = CANARY;
   int i = 0;
   char buf[512];
   char ch;
   send(sock, getUser, strlen(getUser), 0);
   int len = recv(sock, buf, sizeof(buf) - 1, 0);
   buf[len] = 0;
   userId = strtoul(buf, NULL, 16);
   if (validateUser(userId)) {   
      send(sock, prompt, strlen(prompt), 0);
      do {
         if (recv(sock, &ch, 1, 0) != 1) {
            break;
         }
         buf[i] = (char) (ch ^ userId);
      } while (buf[i++] != '\n');
      if (canary != CANARY) {
         send(sock, wimpy, strlen(wimpy), 0);
         exit(1);
      }
   }
   else {
      send(sock, fail, strlen(fail), 0);
   }   
}
示例#2
0
int Buddies::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: countOnlineUsers(); break;
        case 1: setUserStatus(); break;
        case 2: loginUser(); break;
        case 3: loginCurrentStatus(); break;
        case 4: validateUser(); break;
        case 5: stopifNotConnected(); break;
        case 6: myexit(); break;
        case 7: focusTabEdit(); break;
        case 8: structUser(); break;
        case 9: startChat(); break;
        case 10: helpAbout(); break;
        case 11: getSysInfo(); break;
        case 12: onlineNotify(); break;
        case 13: WriteOnWall(); break;
        case 14: Information(); break;
        case 15: dbstatus(); break;
        case 16: openNotes(); break;
        case 17: setIcon((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 18: iconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break;
        case 19: messageClicked(); break;
        case 20: showMessage(); break;
        }
        _id -= 21;
    }
    return _id;
}
示例#3
0
void Buddies::loginUser()
{

	stopifNotConnected();

	validateUser();



	ui.lineEditLogin->text();
	QString Login = ui.lineEditLogin->text();
	ui.lineEditPasswd->text();
	QString Passwd = ui.lineEditPasswd->text();

	QSqlQuery query;

	query.exec("SELECT b_username,b_password from b_main where b_username='******'");

   	if (!query.isActive())
   	    QMessageBox::warning(this, tr("Database Error"),
	    		                         query.lastError().text());
	   	while (query.next()) {

   	QString vLogin = query.value(0).toString();
   	QString vPasswd = query.value(1).toString();

	   	if(Passwd == vPasswd){

	QSqlQuery query2;

	query2.exec("UPDATE b_main SET b_login='******' WHERE b_username='******'");


	if (!query2.isActive())
		    QMessageBox::warning(this, tr("Database Error"),
			                         query2.lastError().text());


	qDebug("=> update - login ok");

#if debug
	   		qDebug("login ok");
#endif


	   	}
	   	else {

	   		ui.StatusLabel->setPixmap(QPixmap("images/Error.png"));
	   		   	QMessageBox::warning(this, tr("Database Error"),
	   		   			                         "Login incorect");
	   	return;
	   	}

   	}


	loginCurrentStatus();
}
示例#4
0
int validateArgs(int argc, char **argv)
{
	int i;

	if(argc != 2)
		return 0;
	if(strcmp(argv[1], "key-gen") == 0){
		return 2;
	}
	else {
		if(validateUser(argv[1])){
			printf("user or server addr is wrong\n");
			return 0;
		}
		
	}
	return 1;
}
示例#5
0
int main() {
  printf("PID: %d\n", getpid());
  loadPasswords();
  while(1) {
    if(validateUser()) {
      printf("Welcome\n");
      if(fork() == 0) {
        char *argv[] = {"./sh", (char *) 0 };
        execvp("./sh", argv);
      } else  {
        int pid, status;
        pid = wait(&status);
        if(WEXITSTATUS(status) == 123)
          exit(123);
      }
    } else
    printf("Invalid username or password. Please try again.");
  }
  return 0;
}