|
You last visited: Today at 20:50
Advertisement
[Python] NDT files decryptor
Discussion on [Python] NDT files decryptor within the Atlantica Online forum part of the MMORPGs category.
08/10/2013, 21:29
|
#76
|
elite*gold: 0
Join Date: Aug 2009
Posts: 1,521
Received Thanks: 1,305
|
All battle logic is server side
|
|
|
09/20/2013, 01:23
|
#77
|
elite*gold: 0
Join Date: Sep 2013
Posts: 1
Received Thanks: 0
|
Quote:
Originally Posted by neuronet
All battle logic is server side
|
Not really Neuro, last week on ESPAO ppl managed to get all +10 equips even mounts, decos and outfits with cheat engine, and not only the looks also the stats, but they made a maint on this monday with a 7 days rollback and now it doesnt work. Hell...they even changed weaps stats and got 15kk might ON FL. I think it might worth the time to investigate this xD ill upload a video showing that
|
|
|
09/20/2013, 02:05
|
#78
|
elite*gold: 0
Join Date: Jun 2012
Posts: 58
Received Thanks: 9
|
anyone manage to figure out how to make this work on Int?
|
|
|
09/26/2013, 14:19
|
#79
|
elite*gold: 0
Join Date: Sep 2013
Posts: 7
Received Thanks: 1
|
Decryptor/encryptor in C#
Here is the NDT decryptor/encryptor code in C#, enjoy.
How to use:
1) compile using Visual C# into a binary
2) make it a default program to open NDT files
3) click on NDT file to extract.
P.S. Sorry, I don't trust binary files, so I'm not going to post one here for the others.
Code:
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace UnpackNdt
{
class Program
{
[StructLayout(LayoutKind.Sequential, Pack=1)]
public struct NdtFileHeader
{
public UInt32 MagicBytes;
public UInt32 Version;
public UInt32 FileSize;
public byte Key;
public byte Undefined1;
public byte Undefined2;
public byte Undefined3;
public UInt32 Undefined4;
public UInt32 Undefined5;
}
static void Main(string[] args)
{
if (args.Length != 1)
{
return;
}
string inputFilePath = args[0];
if (Path.GetExtension(inputFilePath).ToLowerInvariant() == ".ndt")
{
string outputFilePath = Path.Combine(Path.GetDirectoryName(inputFilePath), Path.GetFileNameWithoutExtension(inputFilePath) + ".txt");
byte[] input = File.ReadAllBytes(inputFilePath);
byte[] output = Decrypt(input);
File.WriteAllBytes(outputFilePath, output);
}
else
{
string outputFilePath = Path.Combine(Path.GetDirectoryName(inputFilePath), Path.GetFileNameWithoutExtension(inputFilePath) + ".ndt2");
byte[] input = File.ReadAllBytes(inputFilePath);
byte[] output = Encrypt(input, 77);
File.WriteAllBytes(outputFilePath, output);
}
}
static byte[] Decrypt(byte[] input)
{
int inputLength = input.Length;
int outputLength = inputLength - 24;
byte[] output = new byte[outputLength];
// extract header
byte[] headerArray = new byte[24];
Array.Copy(input, headerArray, 24);
NdtFileHeader header;
FromArray(headerArray, out header);
if (header.Version == 0x00010001)
{
// decode the data using the Key from the header
for (int i = 0; i < outputLength; i++)
{
byte c = input[i + 24];
c -= header.Key;
if (i + 1 != outputLength)
{
byte next = input[i + 1 + 24];
c ^= next;
}
output[i] = c;
}
}
else if (header.Version == 0x00030001)
{
int[] shufflingMap = new int[] { 1, 3, 2, 3, 1, 5, 4, 2, 1, 4, 2, 8, 4, 2, 6, 8, 2, 6, 4 };
int shufflingMapLength = shufflingMap.Length;
int numberOfDwords = outputLength / 4;
Array.Copy(input, 24, output, 0, outputLength);
for (int i = numberOfDwords - 1; i >= 0; i--)
{
// calculate which Dword to swap with
int shuffleBy = shufflingMap[i % shufflingMapLength];
int j = (i + shuffleBy) % numberOfDwords;
UInt32 iDword = GetUInt32(output, i * 4, 4);
UInt32 jDword = GetUInt32(output, j * 4, 4);
SetUInt32(jDword, output, i * 4, 4);
SetUInt32(iDword, output, j * 4, 4);
}
UInt32 adjustedKey = header.Key - (UInt32)0x57D3CEFF;
UInt32 sum = 0;
UInt32 carryOver = 0;
for (int i = 0; i < numberOfDwords; i++)
{
UInt32 iDword = GetUInt32(output, i * 4, 4);
UInt32 decodedValue = adjustedKey + iDword + sum + carryOver;
SetUInt32(decodedValue, output, i * 4, 4);
sum += header.Key;
carryOver = iDword;
}
}
return output;
}
static UInt32 GetUInt32(byte[] array, int index, int length)
{
UInt32 result = 0;
for (int i = length; i > 0; i--)
{
result = result << 8;
result += array[index + i - 1];
}
return result;
}
static void SetUInt32(UInt32 value, byte[] array, int index, int length)
{
for (int i = 0; i < length; i++)
{
array[index + i] = (byte)(value % 256);
value = value / 256;
}
}
static byte[] Encrypt(byte[] input, byte key)
{
int inputLength = input.Length;
int outputLength = inputLength + 24;
byte[] output = new byte[outputLength];
// output header header
NdtFileHeader header = new NdtFileHeader();
header.MagicBytes = 0x0052434e; // NCR
header.Version = 0x00010001; // v. 1.0.1
header.FileSize = (uint) outputLength;
header.Key = key;
byte[] headerArray = new byte[24];
ToArray(header, headerArray);
Array.Copy(headerArray, output, 24);
// encode the data using the Key
for (int i = inputLength - 1; i >= 0; i--)
{
byte c = input[i];
if (i != inputLength - 1)
{
byte next = output[i + 1 + 24];
c ^= next;
}
c += header.Key;
output[i + 24] = c;
}
return output;
}
private static void FromArray<T>(byte[] input, out T output)
{
// Pin the managed memory while, copy it out the data, then unpin it
GCHandle handle = GCHandle.Alloc(input, GCHandleType.Pinned);
output = (T) Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
handle.Free();
}
private static void ToArray<T>(T input, byte[] output)
{
// Pin the managed memory while, copy it out the data, then unpin it
GCHandle handle = GCHandle.Alloc(output, GCHandleType.Pinned);
Marshal.StructureToPtr(input, handle.AddrOfPinnedObject(), false);
handle.Free();
}
}
}
|
|
|
01/26/2023, 18:28
|
#80
|
elite*gold: 50
Join Date: Nov 2008
Posts: 46
Received Thanks: 18
|
encrypt v3 ndt
here is code from previous post but updated to be able to encrypt back to v3:
Code:
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace UnpackNdt
{
class Program
{
private static readonly int[] shufflingMap = { 1, 3, 2, 3, 1, 5, 4, 2, 1, 4, 2, 8, 4, 2, 6, 8, 2, 6, 4 };
private const int debugLength = 0;
private const int wordLength = 4;
private const int headerLength = 24;
private const UInt32 keyAdjustment = (UInt32)0x57D3CEFF;
private const UInt32 ncrMagicBytes = 0x0052434e;
private const UInt32 v3Bytes = 0x00030001;
private const byte defaultEncKey = 82;
[StructLayout(LayoutKind.Sequential, Pack=1)]
public struct NdtFileHeader
{
public UInt32 MagicBytes;
public UInt32 Version;
public UInt32 FileSize;
public byte Key;
public byte Undefined1;
public byte Undefined2;
public byte Undefined3;
public UInt32 Undefined4;
public UInt32 Undefined5;
}
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("No file path provided as single argument");
return;
}
string inputFilePath = args[0];
applyFor(inputFilePath);
}
static void runCycle(string inputFilePath) {
if (Path.GetExtension(inputFilePath).ToLowerInvariant() == ".ndt") {
string dirName = Path.GetDirectoryName(inputFilePath);
string fileName = Path.GetFileNameWithoutExtension(inputFilePath);
string decryptedFilePath = applyFor(inputFilePath);
string encryptedFilePath = applyFor(decryptedFilePath);
string resultFilePath =applyFor(encryptedFilePath);
}
}
static string applyFor(string inputFilePath) {
Console.WriteLine("Executing for: " + Path.GetFileName(inputFilePath));
string dirName = Path.GetDirectoryName(inputFilePath);
string fileName = Path.GetFileNameWithoutExtension(inputFilePath);
string outputFilePath;
if (Path.GetExtension(inputFilePath).ToLowerInvariant() == ".ndt") {
outputFilePath = Path.Combine(dirName, fileName + ".txt");
byte[] input = File.ReadAllBytes(inputFilePath);
byte[] output = Decrypt(input);
File.WriteAllBytes(outputFilePath, output);
} else {
outputFilePath = Path.Combine(dirName, fileName + "2.ndt");
byte[] input = File.ReadAllBytes(inputFilePath);
byte[] output = EncryptV3(input, defaultEncKey);
File.WriteAllBytes(outputFilePath, output);
}
return outputFilePath;
}
static byte[] deshuffle(byte[] input) {
int inputLength = input.Length;
byte[] output = new byte[inputLength];
Array.Copy(input, output, inputLength);
int shufflingMapLength = shufflingMap.Length;
int numberOfWords = inputLength / wordLength;
for (int i = numberOfWords - 1; i >= 0; i--) {
int shuffleBy = shufflingMap[i % shufflingMapLength];
int j = (i + shuffleBy) % numberOfWords;
int firstPos = i * wordLength;
int secondPos = j * wordLength;
UInt32 first = GetUInt32(output, firstPos, wordLength);
UInt32 second = GetUInt32(output, secondPos, wordLength);
SetUInt32(second, output, firstPos, wordLength);
SetUInt32(first, output, secondPos, wordLength);
}
return output;
}
static byte[] shuffle(byte[] input) {
int inputLength = input.Length;
byte[] output = new byte[inputLength];
Array.Copy(input, output, inputLength);
int shufflingMapLength = shufflingMap.Length;
int numberOfWords = inputLength / wordLength;
for (int i = 0; i < numberOfWords; i++) {
int shuffleBy = shufflingMap[i % shufflingMapLength];
int j = (i + shuffleBy) % numberOfWords;
int firstPos = i * wordLength;
int secondPos = j * wordLength;
UInt32 first = GetUInt32(output, firstPos, wordLength);
UInt32 second = GetUInt32(output, secondPos, wordLength);
SetUInt32(second, output, firstPos, wordLength);
SetUInt32(first, output, secondPos, wordLength);
}
return output;
}
static byte[] decryptV3(byte[] input, byte key) {
int inputLength = input.Length;
byte[] output = new byte[inputLength];
Array.Copy(input, output, inputLength);
UInt32 adjustedKey = key - keyAdjustment;
UInt32 sum = 0;
UInt32 carryOver = 0;
int numberOfWords = inputLength / wordLength;
for (int i = 0; i < numberOfWords; i++) {
int currentPos = i * wordLength;
UInt32 encoded = GetUInt32(output, currentPos, wordLength);
UInt32 word = adjustedKey + encoded + sum + carryOver;
SetUInt32(word, output, currentPos, wordLength);
sum += key;
carryOver = encoded;
if (i < debugLength) {
Console.WriteLine($"word={word}, encoded={encoded}, sum={sum}");
}
}
return output;
}
static byte[] encryptV3(byte[] input, byte key) {
int inputLength = input.Length;
byte[] output = new byte[inputLength];
Array.Copy(input, output, inputLength);
UInt32 adjustedKey = key - keyAdjustment;
UInt32 sum = 0;
UInt32 carryOver = 0;
int numberOfWords = inputLength / wordLength;
for (int i = 0; i < numberOfWords; i++) {
int currentPos = i * wordLength;
UInt32 word = GetUInt32(output, currentPos, wordLength);
UInt32 encoded = keyAdjustment - key + word - sum - carryOver;
SetUInt32(encoded, output, currentPos, wordLength);
sum += key;
carryOver = encoded;
if (i < debugLength) {
Console.WriteLine($"word={word}, encoded={encoded}, sum={sum}");
}
}
return output;
}
static byte[] Decrypt(byte[] input)
{
int inputLength = input.Length;
int outputLength = inputLength - headerLength;
byte[] output = new byte[outputLength];
// extract header
byte[] headerArray = new byte[headerLength];
Array.Copy(input, headerArray, headerLength);
NdtFileHeader header;
FromArray(headerArray, out header);
Console.WriteLine("Decrypting with header:\n" + string.Join(", ", headerArray));
Console.WriteLine($"Header details: version={header.Version:x}, key={header.Key}");
if (header.Version == 0x00010001) {
for (int i = 0; i < outputLength; i++) {
byte c = input[i + headerLength];
c -= header.Key;
if (i + 1 != outputLength)
{
byte next = input[i + 1 + headerLength];
c ^= next;
}
output[i] = c;
}
}
else if (header.Version == v3Bytes) {
int shufflingMapLength = shufflingMap.Length;
int numberOfDwords = outputLength / 4;
Array.Copy(input, headerLength, output, 0, outputLength);
output = deshuffle(output);
output = decryptV3(output, header.Key);
} else {
Console.WriteLine($"No supported: version={header.Version:x}");
return null;
}
return output;
}
static UInt32 GetUInt32(byte[] array, int index, int length)
{
UInt32 result = 0;
for (int i = length; i > 0; i--)
{
result = result << 8;
result += array[index + i - 1];
}
return result;
}
static void SetUInt32(UInt32 value, byte[] array, int index, int length)
{
for (int i = 0; i < length; i++)
{
array[index + i] = (byte)(value % 256);
value = value / 256;
}
}
static byte[] EncryptV3(byte[] input, byte key)
{
int inputLength = input.Length;
int outputLength = inputLength + headerLength;
byte[] output = new byte[outputLength];
NdtFileHeader header = new NdtFileHeader();
header.MagicBytes = ncrMagicBytes;
header.Version = v3Bytes;
header.FileSize = (uint) inputLength;
header.Key = key;
byte[] headerArray = new byte[headerLength];
ToArray(header, headerArray);
Array.Copy(headerArray, output, headerLength);
byte[] tempOutput = new byte[inputLength];
Array.Copy(input, tempOutput, inputLength);
tempOutput = encryptV3(tempOutput, key);
tempOutput = shuffle(tempOutput);
Array.Copy(tempOutput, 0, output, headerLength, inputLength);
return output;
}
private static void FromArray<T>(byte[] input, out T output)
{
// Pin the managed memory while, copy it out the data, then unpin it
GCHandle handle = GCHandle.Alloc(input, GCHandleType.Pinned);
output = (T) Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
handle.Free();
}
private static void ToArray<T>(T input, byte[] output)
{
// Pin the managed memory while, copy it out the data, then unpin it
GCHandle handle = GCHandle.Alloc(output, GCHandleType.Pinned);
Marshal.StructureToPtr(input, handle.AddrOfPinnedObject(), false);
handle.Free();
}
}
}
Do not remember why I needed this, but post it here just in case if I will be back playing AO
|
|
|
01/27/2023, 05:15
|
#81
|
elite*gold: 0
Join Date: Aug 2013
Posts: 323
Received Thanks: 92
|
Just a reminder, that you need to save the .txt file as UTF-16 LE encoding in order for the raw text file to be recognized by the game when renaming it to .ndt
|
|
|
02/04/2023, 20:41
|
#82
|
elite*gold: 0
Join Date: Feb 2023
Posts: 1
Received Thanks: 0
|
wht the function for this code?
|
|
|
 |
|
Similar Threads
|
[Req/Help] .dat decryptor for Conquer 1.0?
11/10/2009 - CO2 Weapon, Armor, Effects & Interface edits - 0 Replies
Hey sorry for having to make a new post (also, toss up between here or the programing section seeing as it's both but w/e). I'm messing around a bit with the 1.0 source and trying to fix a few things on it and add some new features. One of the problems I'm having though is that none of the posted .dat decryptors work for 1.0.
Main thing I'm trying to decrypt right now is the ItemType so I can replace the item list in the source, as it is right now it will let you create 2.0 items which...
|
< request> <Dat decryptor>
02/02/2009 - Conquer Online 2 - 2 Replies
Can someone give me a dat decryptor for item type couse i deleted mine by mistake.... Thx in advance;)
|
Decryptor Encryptor
04/21/2008 - General Coding - 2 Replies
I have yet to find out if any other games .dat file may be decrypted. I need to find what games are compatiable with this program.
http://www.elitepvpers.com/forum/co2-exploits-hack s-tools/44730-easy-monster-dat-encrypter-decrypter .html
If you are getting a readable decrypted.txt file for that certain game's .dat please post here the game that it is compatiable with.
Thank you
|
l2 ini decryptor
10/30/2004 - Lineage 2 - 1 Replies
hey does anyone one know were i can find the l2 ini decryptor?
|
All times are GMT +1. The time now is 20:52.
|
|