コード例 #1
0
void libmngrDlgRemoteLink::WriteFields()
{
  wxConfig *config = new wxConfig(APP_NAME);
  wxString field;

  field = m_txtURL->GetValue();
  config->Write(wxT("repository/url"), field);

  field = m_txtUserName->GetValue();
  config->Write(wxT("repository/user"), field);

  field = m_txtPassword->GetValue();
  field = Scramble(field);
  config->Write(wxT("repository/pwd"), field);

  field = m_txtAuthUser->GetValue();
  config->Write(wxT("repository/hostuser"), field);

  field = m_txtAuthPWD->GetValue();
  field = Scramble(field);
  config->Write(wxT("repository/hostpwd"), field);

  long flags = 0;
  if (m_checkVerifyPeer->GetValue())
	  flags |= 0x01;
  if (m_checkVerifyHost->GetValue())
	  flags |= 0x02;
  config->Write(wxT("repository/hostverify"), flags);

  delete config;
}
コード例 #2
0
void libmngrDlgRemoteLink::ReadFields()
{
  wxConfig *config = new wxConfig(APP_NAME);
  wxString field;

  field = config->Read(wxT("repository/url"));
  m_txtURL->SetValue(field);

  field = config->Read(wxT("repository/user"));
  m_txtUserName->SetValue(field);

  field = config->Read(wxT("repository/pwd"));
  field = Scramble(field);	/* this un-scrambles the string */
  m_txtPassword->SetValue(field);

  field = config->Read(wxT("repository/hostuser"));
  m_txtAuthUser->SetValue(field);

  field = config->Read(wxT("repository/hostpwd"));
  field = Scramble(field);	/* this un-scrambles the string */
  m_txtAuthPWD->SetValue(field);

  long flags;
  config->Read(wxT("repository/hostverify"), &flags, 0x03);
  m_checkVerifyPeer->SetValue((flags & 0x01) != 0);
  m_checkVerifyHost->SetValue((flags & 0x02) != 0);

  delete config;
}
コード例 #3
0
void *interpretor( void *arg )
{
  char command[256];
  CUBE *cube = (CUBE*)arg;
  
  printf(
         "Welcome to the Rubik's Cube Simulotor vers 0.1\n"
         "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n"
         );
  printhelp(NULL);
  for(;;) {
    fgets(command,256,stdin);
    command[strlen(command)-1]=0;
    if(!strcmp(command,"help")) {
      printhelp(NULL);
    } else if(!strncmp(command,"help ",5)) {
      printhelp(command+5);
    } else if(!strcmp(command,"reset")) {
      Reset(cube);
      printf("OK\n");
    } else if(!strcmp(command,"scramble")) {
      Scramble(cube);
      printf("OK\n");
    } else if(!strcmp(command,"exit")) {
      exit(0);
    } else if(!strcmp(command,"test")) {
      test(cube);
      printf("OK\n");
    } else if((!strcmp(command,"rxy"))||(!strcmp(command,"ryx"))) {
      r_xy(cube);
      printf("OK\n");
    } else if((!strcmp(command,"rxy'"))||(!strcmp(command,"rxy-"))||
              (!strcmp(command,"ryx'"))||(!strcmp(command,"ryx-"))) {
      r_xy_inv(cube);
      printf("OK\n");
    } else if((!strcmp(command,"rxz"))||(!strcmp(command,"rzx"))) {
      r_xz(cube);
      printf("OK\n");
    } else if((!strcmp(command,"rxz'"))||(!strcmp(command,"rxz-"))||
              (!strcmp(command,"rzx'"))||(!strcmp(command,"rzx-"))) {
      r_xz_inv(cube);
      printf("OK\n");
    } else if((!strcmp(command,"ryz"))||(!strcmp(command,"rzy"))) {
      r_xy(cube);
      printf("OK\n");
    } else if((!strcmp(command,"ryz'"))||(!strcmp(command,"ryz-"))||
              (!strcmp(command,"rzy'"))||(!strcmp(command,"rzy-"))) {
      r_xy_inv(cube);
      printf("OK\n");
    } else if(check(command)) {
      Exec(cube,command);
      printf("OK\n");
    } else {
      printf("Invalid command\n");
    }
  }
#ifndef _WIN32
  pthread_exit(0);
#endif //_WIN32
}
コード例 #4
0
void libmngrDlgRemoteSignUp::OnOK( wxCommandEvent& event )
{
  wxString url = m_txtURL->GetValue();
  wxString name = m_txtUserName->GetValue();
  wxString email = m_txtEmail->GetValue();
  wxString hostuser = m_txtAuthUser->GetValue();
  wxString hostpwd = m_txtAuthPWD->GetValue();
  long hostverify = 0;
  if (m_checkVerifyPeer->GetValue())
	  hostverify |= 0x01;
  if (m_checkVerifyHost->GetValue())
	  hostverify |= 0x02;

  wxString msg = curlAddUser(url, name, email, hostuser, hostpwd, hostverify);
  if (msg.length() == 0) {
    wxConfig *config = new wxConfig(APP_NAME);
    config->Write(wxT("repository/url"), url);
    config->Write(wxT("repository/user"), name);
    config->Write(wxT("repository/email"), email);
    config->Write(wxT("repository/hostuser"), hostuser);
    config->Write(wxT("repository/hostpwd"), Scramble(hostpwd));
    config->Write(wxT("repository/hostverify"), hostverify);
    delete config;

    wxMessageBox(wxT("Sign-up succeeded\nYou will receive a password on the supplied e-mail address."));
    event.Skip();
  } else {
    wxMessageBox(wxT("Sign-up failure\nServer message: ") + msg);
  }
}
コード例 #5
0
libmngrDlgRemoteSignUp::libmngrDlgRemoteSignUp( wxWindow* parent )
:
DlgRemoteSignUp( parent )
{
  wxConfig *config = new wxConfig(APP_NAME);
  wxString field;

  field = config->Read(wxT("repository/url"));
  m_txtURL->SetValue(field);

  field = config->Read(wxT("repository/user"));
  m_txtUserName->SetValue(field);

  field = config->Read(wxT("repository/email"));
  m_txtEmail->SetValue(field);

  field = config->Read(wxT("repository/hostuser"));
  m_txtAuthUser->SetValue(field);

  field = config->Read(wxT("repository/hostpwd"));
  field = Scramble(field);	/* this un-scrambles the string */
  m_txtAuthPWD->SetValue(field);

  long flags;
  config->Read(wxT("repository/hostverify"), &flags, 0x03);
  m_checkVerifyPeer->SetValue((flags & 0x01) != 0);
  m_checkVerifyHost->SetValue((flags & 0x02) != 0);

  delete config;
}
コード例 #6
0
void viterbi_module::Send(char* data)
{
	// First encode the data
	_encodedData = _encoder.Encode(data);

	// Filp some bits to simulate bus interference
	Scramble(_encodedData);
}
コード例 #7
0
static int DecryptPRX2(const u8 *inbuf, u8 *outbuf, u32 size, u32 tag)
{
	const TAG_INFO2 *pti = GetTagInfo2(tag);

	if (!pti)
	{
		return -1;
	}
	if (!HasKey(pti->code))
	{
		return MISSING_KEY;
	}

	// only type2 and type6 can be process by this code.
	if(pti->type!=2 && pti->type!=6)
		return -12;

	s32_le retsize = *(const s32_le *)&inbuf[0xB0];
	u8 tmp1[0x150] = {0};
	u8 tmp2[ROUNDUP16(0x90+0x14)] = {0};
	u8 tmp3[ROUNDUP16(0x90+0x14)] = {0};
	u8 tmp4[ROUNDUP16(0x20)] = {0};

	if (inbuf != outbuf)
		memcpy(outbuf, inbuf, size);

	if (size < 0x160)
	{
		return -2;
	}

	if (((int)size - 0x150) < retsize)
	{
		return -4;
	}

	memcpy(tmp1, outbuf, 0x150);

	int i;
	u8 *p = tmp2 + 0x14;

	// Writes 0x90 bytes to tmp2 + 0x14.
	for (i = 0; i < 9; i++)
	{
		memcpy(p+(i<<4), pti->key, 0x10);
		p[(i << 4)] = i;   // really? this is very odd
	}

	if (Scramble((u32_le  *)tmp2, 0x90, pti->code) < 0)
	{
		return -5;
	}

	memcpy(outbuf, tmp1+0xD0, 0x5C);
	memcpy(outbuf+0x5C, tmp1+0x140, 0x10);
	memcpy(outbuf+0x6C, tmp1+0x12C, 0x14);
	memcpy(outbuf+0x80, tmp1+0x080, 0x30);
	memcpy(outbuf+0xB0, tmp1+0x0C0, 0x10);
	memcpy(outbuf+0xC0, tmp1+0x0B0, 0x10);
	memcpy(outbuf+0xD0, tmp1+0x000, 0x80);

	memcpy(tmp3+0x14, outbuf+0x5C, 0x60);

	if (Scramble((u32_le  *)tmp3, 0x60, pti->code) < 0)
	{
		return -6;
	}

	memcpy(outbuf+0x5C, tmp3, 0x60);
	memcpy(tmp3, outbuf+0x6C, 0x14);
	memcpy(outbuf+0x70, outbuf+0x5C, 0x10);

	if(pti->type == 6)
	{
		memcpy(tmp4, outbuf+0x3C, 0x20);
		memcpy(outbuf+0x50, tmp4, 0x20);
		memset(outbuf+0x18, 0, 0x38);
	}else
		memset(outbuf+0x18, 0, 0x58);

	memcpy(outbuf+0x04, outbuf, 0x04);
	*((u32_le *)outbuf) = 0x014C;
	memcpy(outbuf+0x08, tmp2, 0x10);

	/* sha-1 */

	if (sceUtilsBufferCopyWithRange(outbuf, 3000000, outbuf, 3000000, 0x0B) != 0)
	{
		return -7;
	}

	if (memcmp(outbuf, tmp3, 0x14) != 0)
	{
		return -8;
	}

	for (i=0; i<0x40; i++)
	{
		tmp3[i+0x14] = outbuf[i+0x80] ^ tmp2[i+0x10];
	}

	if (Scramble((u32_le  *)tmp3, 0x40, pti->code) != 0)
	{
		return -9;
	}

	for (i=0; i<0x40; i++)
	{
		outbuf[i+0x40] = tmp3[i] ^ tmp2[i+0x50];
	}

	if (pti->type == 6)
	{
		memcpy(outbuf+0x80, tmp4, 0x20);
		memset(outbuf+0xA0, 0, 0x10);
		*(u32_le*)&outbuf[0xA4] = 1;
		*(u32_le*)&outbuf[0xA0] = 1;
	}
	else
	{
		memset(outbuf+0x80, 0, 0x30);
		*(u32_le*)&outbuf[0xA0] = 1;
	}

	memcpy(outbuf+0xB0, outbuf+0xC0, 0x10);
	memset(outbuf+0xC0, 0, 0x10);

	// The real decryption
	if (sceUtilsBufferCopyWithRange(outbuf, size, outbuf + 0x40, size - 0x40, 0x1) != 0)
	{
		return -1;
	}

	if (retsize < 0x150)
	{
		// Fill with 0
		memset(outbuf+retsize, 0, 0x150-retsize);
	}

	return retsize;
}
コード例 #8
0
static int DecryptPRX1(const u8* pbIn, u8* pbOut, int cbTotal, u32 tag)
{
	int i;
	s32_le retsize;
	u8 bD0[0x80], b80[0x50], b00[0x80], bB0[0x20];

	const TAG_INFO *pti = GetTagInfo(tag);
	if (pti == NULL)
	{
		return -1;
	}
	if (!HasKey(pti->code) || 
		(pti->codeExtra != 0 && !HasKey(pti->codeExtra)))
	{
		return MISSING_KEY;
	}

	retsize = *(s32_le*)&pbIn[0xB0];

	for (i = 0; i < 0x14; i++)
	{
		if (pti->key[i] != 0)
			break;
	}

	// Scramble the key (!)
	//
	// NOTE: I can't make much sense out of this code. Scramble seems really odd, appears
	// to write to stuff that should be before the actual key.
	u8 key[0x90];
	memcpy(key, pti->key, 0x90);
	if (i == 0x14)
	{
		Scramble((u32_le *)key, 0x90, pti->code);
	}

	// build conversion into pbOut

	if (pbIn != pbOut)
		memcpy(pbOut, pbIn, cbTotal);

	memcpy(bD0, pbIn+0xD0, 0x80);
	memcpy(b80, pbIn+0x80, 0x50);
	memcpy(b00, pbIn+0x00, 0x80);
	memcpy(bB0, pbIn+0xB0, 0x20);

	memset(pbOut, 0, 0x150);
	memset(pbOut, 0x55, 0x40); // first $40 bytes ignored

	// step3 demangle in place
	u32_le* pl = (u32_le*)(pbOut+0x2C);
	pl[0] = 5; // number of ulongs in the header
	pl[1] = pl[2] = 0;
	pl[3] = pti->code; // initial seed for PRX
	pl[4] = 0x70;   // size

	// redo part of the SIG check (step2)
	u8 buffer1[0x150];
	memcpy(buffer1+0x00, bD0, 0x80);
	memcpy(buffer1+0x80, b80, 0x50);
	memcpy(buffer1+0xD0, b00, 0x80);
	if (pti->codeExtra != 0)
		ExtraV2Mangle(buffer1+0x10, pti->codeExtra);
	memcpy(pbOut+0x40, buffer1+0x40, 0x40);

	int ret;
	int iXOR;
	for (iXOR = 0; iXOR < 0x70; iXOR++)
#ifdef COMMON_BIG_ENDIAN
		pbOut[0x40+iXOR] = pbOut[0x40+iXOR] ^ key[(0x14+iXOR) ^3];
#else
		pbOut[0x40+iXOR] = pbOut[0x40+iXOR] ^ key[0x14+iXOR];
#endif

	ret = sceUtilsBufferCopyWithRange(pbOut+0x2C, 20+0x70, pbOut+0x2C, 20+0x70, 7);
	if (ret != 0)
	{
		return -1;
	}

	for (iXOR = 0x6F; iXOR >= 0; iXOR--)
#ifdef COMMON_BIG_ENDIAN
		pbOut[0x40+iXOR] = pbOut[0x2C+iXOR] ^ key[(0x20+iXOR) ^ 3];
#else
		pbOut[0x40+iXOR] = pbOut[0x2C+iXOR] ^ key[0x20+iXOR];
#endif

	memset(pbOut+0x80, 0, 0x30); // $40 bytes kept, clean up
	pbOut[0xA0] = 1;
	// copy unscrambled parts from header
	memcpy(pbOut+0xB0, bB0, 0x20); // file size + lots of zeros
	memcpy(pbOut+0xD0, b00, 0x80); // ~PSP header

	// step4: do the actual decryption of code block
	//  point 0x40 bytes into the buffer to key info
	ret = sceUtilsBufferCopyWithRange(pbOut, cbTotal, pbOut+0x40, cbTotal-0x40, 0x1);
	if (ret != 0)
	{
		return -1;
	}

	// return cbTotal - 0x150; // rounded up size
	return retsize;
}