Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco149 committed Mar 23, 2014
0 parents commit de986fa
Show file tree
Hide file tree
Showing 40 changed files with 5,770 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I'm currently in the process of writing this readme with instructions on how to compile this. Please wait for the next commit.
20 changes: 20 additions & 0 deletions wxPloiter.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxPloiter", "wxPloiter\wxPloiter.vcxproj", "{2C8BAC1D-B028-4557-9FBB-AE5935FBB79A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2C8BAC1D-B028-4557-9FBB-AE5935FBB79A}.Debug|Win32.ActiveCfg = Debug|Win32
{2C8BAC1D-B028-4557-9FBB-AE5935FBB79A}.Debug|Win32.Build.0 = Debug|Win32
{2C8BAC1D-B028-4557-9FBB-AE5935FBB79A}.Release|Win32.ActiveCfg = Release|Win32
{2C8BAC1D-B028-4557-9FBB-AE5935FBB79A}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
98 changes: 98 additions & 0 deletions wxPloiter/aes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#include "aes.hpp"

#include <botan/pipe.h>
#include <botan/filters.h>

namespace maple
{
const signed_dword aes::cb_aeskey = 32;

const byte aes::aeskey[aes::cb_aeskey] =
{
0x13, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00,
0xB4, 0x00, 0x00, 0x00,
0x1B, 0x00, 0x00, 0x00,
0x0F, 0x00, 0x00, 0x00,
0x33, 0x00, 0x00, 0x00,
0x52, 0x00, 0x00, 0x00
};

const signed_dword aes::blocksize = 1460;

aes *aes::get()
{
static aes inst;
return &inst;
}

aes::aes()
: botankey(Botan::SymmetricKey(aeskey, cb_aeskey))
{
// empty
}

aes::~aes()
{
// empty
}

void aes::encrypt(byte *buffer, byte *iv, signed_dword cb)
{
signed_dword pos = 0;
byte first = 1;
signed_dword tpos = 0;
signed_dword cbwrite = 0;
Botan::InitializationVector initvec(iv, 16);

while (cb > pos)
{
tpos = blocksize - first * 4;
cbwrite = (cb > (pos + tpos) ? tpos : (cb - pos));

Botan::Pipe pipe(Botan::get_cipher("AES-256/OFB/NoPadding",
botankey, initvec, Botan::ENCRYPTION));
pipe.start_msg();
pipe.write(buffer + pos, cbwrite);
pipe.end_msg();

// process the message and write it into the buffer
pipe.read(buffer + pos, cbwrite);

pos += tpos;

if (first)
first = 0;
}
}

void aes::decrypt(byte *buffer, byte *iv, signed_dword cb)
{
signed_dword pos = 0;
byte first = 1;
signed_dword tpos = 0;
signed_dword cbread = 0;
Botan::InitializationVector initvec(iv, 16);

while (cb > pos)
{
tpos = blocksize - first * 4;
cbread = (cb > (pos + tpos) ? tpos : (cb - pos));

Botan::Pipe pipe(Botan::get_cipher("AES-256/OFB/NoPadding",
botankey, initvec, Botan::DECRYPTION));
pipe.start_msg();
pipe.write(buffer + pos, cbread);
pipe.end_msg();

// process the message and write it into the buffer
pipe.read(buffer + pos, cbread);

pos += tpos;

if (first)
first = 0;
}
}
}
29 changes: 29 additions & 0 deletions wxPloiter/aes.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "common.h"

#include <botan/lookup.h>

namespace maple
{
// utility for maplestory's aes encryption
// note: botan must be initialized before using this class
// credits to vana for this slimmer encryption using botan
class aes
{
public:
static aes *get();
virtual ~aes();
void decrypt(byte *buffer, byte *iv, signed_dword cb);
void encrypt(byte *buffer, byte *iv, signed_dword cb);

protected:
static const signed_dword cb_aeskey; // size of the aes key
static const byte aeskey[]; // aes key
static const signed_dword blocksize; // aes block size

Botan::OctetString botankey; // symmetric key for AES encryption

aes();
};
}
Loading

0 comments on commit de986fa

Please sign in to comment.