Giter Site home page Giter Site logo

Comments (5)

GEEKiDoS avatar GEEKiDoS commented on June 22, 2024

I did't get padding bytes using System.Security.Cryptography of .NET Framework with those code

var rijndaelManaged = new RijndaelManaged();

rijndaelManaged.Mode = CipherMode.CBC;

rijndaelManaged.IV = s_EmptyIv16;
rijndaelManaged.Key = GeneratePkgListKey(flag, fileName);

var decryptor = rijndaelManaged.CreateDecryptor();

var outBuffer = decryptor.TransformFinalBlock(inBuffer, 0, inBuffer.Length);

I guess you just misconfigured crypto options.

from uncso2.

GEEKiDoS avatar GEEKiDoS commented on June 22, 2024

Or your could remove the extra padding by hand:

uint32_t GetRealBufferSize(uint8_t* pOutBuffer, size_t iBufferSize)
{
	uint8_t currentByte = 0;
	int paddingLength = 0;
	for (int i = iBufferSize - 16; i < iBufferSize; i++)
	{
		if (pOutBuffer[i] != currentByte)
		{
			currentByte = pOutBuffer[i];
			paddingLength = 1;
		}
		else
		{
			paddingLength++;
		}
	}

	return iBufferSize - paddingLength;
}

if ( !DecryptEncFile( targetFile, pBuffer, iBufferSize ) ) { /* ... */ }
iBufferSize = GetRealBufferSize(pBuffer, iBufferSize);

That's working.

from uncso2.

L-Leite avatar L-Leite commented on June 22, 2024

Wouldn't that not work if the padding bytes are different? What if a file for ends with ////////////////?

from uncso2.

GEEKiDoS avatar GEEKiDoS commented on June 22, 2024

Wouldn't that not work if the padding bytes are different? What if a file for ends with ////////////////?

The game is using PKCS7 padding mode, after some searching I find that all the padding byte will be the length of padding data, That function is not needed anymore.

iBufferSize -= pOutBuffer[iBufferSize - 1] ;

The padding modes I searched on internet: (DD is random data, after that is padding bytes, 05 is size of padding bytes)

ANSI X.923
 | DD DD DD DD DD DD DD DD | DD DD DD 00 00 00 00 05 | 

ISO 10126
 | DD DD DD DD DD DD DD DD | DD DD DD 95 81 28 A7 05 |

PKCS7
 | DD DD DD DD DD DD DD DD | DD DD DD 05 05 05 05 05 |

But the Zero mode is padding with 0 and ISO/IEC 7816-4 is using the 0x80 as mark of start, then padding with 0:

ISO/IEC 7816-4
 | DD DD DD DD DD DD DD DD | DD DD DD 80 00 00 00 00 |

Zero padding
 | DD DD DD DD DD DD DD DD | DD DD DD 00 00 00 00 00 |

from uncso2.

L-Leite avatar L-Leite commented on June 22, 2024

Should be fixed in Release v2.0.4

from uncso2.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.