有人知道如何解开 pl/sql 代码吗?我使用 https://www.codecrete.net/UnwrapIt/ 网站来解包代码。它有效,但我更喜欢自己做。如果有人知道在我的计算机上执行此过程的java代码等。 谢谢
这里有一些 C# 代码,您可以轻松地将其转换为 Java。这取自 GitHub PlSqlUnwrapper。
using System.IO;
using System;
using System.IO.Compression;
using System.Text;
using System.Text.RegularExpressions;
namespace PlSqlUnwrapper
{
public static class PlSqlUnwrapper
{
private static readonly byte[] substitutionTable =
{
0x3D, 0x65, 0x85, 0xB3, 0x18, 0xDB, 0xE2, 0x87, 0xF1, 0x52, 0xAB, 0x63, 0x4B, 0xB5, 0xA0, 0x5F,
0x7D, 0x68, 0x7B, 0x9B, 0x24, 0xC2, 0x28, 0x67, 0x8A, 0xDE, 0xA4, 0x26, 0x1E, 0x03, 0xEB, 0x17,
0x6F, 0x34, 0x3E, 0x7A, 0x3F, 0xD2, 0xA9, 0x6A, 0x0F, 0xE9, 0x35, 0x56, 0x1F, 0xB1, 0x4D, 0x10,
0x78, 0xD9, 0x75, 0xF6, 0xBC, 0x41, 0x04, 0x81, 0x61, 0x06, 0xF9, 0xAD, 0xD6, 0xD5, 0x29, 0x7E,
0x86, 0x9E, 0x79, 0xE5, 0x05, 0xBA, 0x84, 0xCC, 0x6E, 0x27, 0x8E, 0xB0, 0x5D, 0xA8, 0xF3, 0x9F,
0xD0, 0xA2, 0x71, 0xB8, 0x58, 0xDD, 0x2C, 0x38, 0x99, 0x4C, 0x48, 0x07, 0x55, 0xE4, 0x53, 0x8C,
0x46, 0xB6, 0x2D, 0xA5, 0xAF, 0x32, 0x22, 0x40, 0xDC, 0x50, 0xC3, 0xA1, 0x25, 0x8B, 0x9C, 0x16,
0x60, 0x5C, 0xCF, 0xFD, 0x0C, 0x98, 0x1C, 0xD4, 0x37, 0x6D, 0x3C, 0x3A, 0x30, 0xE8, 0x6C, 0x31,
0x47, 0xF5, 0x33, 0xDA, 0x43, 0xC8, 0xE3, 0x5E, 0x19, 0x94, 0xEC, 0xE6, 0xA3, 0x95, 0x14, 0xE0,
0x9D, 0x64, 0xFA, 0x59, 0x15, 0xC5, 0x2F, 0xCA, 0xBB, 0x0B, 0xDF, 0xF2, 0x97, 0xBF, 0x0A, 0x76,
0xB4, 0x49, 0x44, 0x5A, 0x1D, 0xF0, 0x00, 0x96, 0x21, 0x80, 0x7F, 0x1A, 0x82, 0x39, 0x4F, 0xC1,
0xA7, 0xD7, 0x0D, 0xD1, 0xD8, 0xFF, 0x13, 0x93, 0x70, 0xEE, 0x5B, 0xEF, 0xBE, 0x09, 0xB9, 0x77,
0x72, 0xE7, 0xB2, 0x54, 0xB7, 0x2A, 0xC7, 0x73, 0x90, 0x66, 0x20, 0x0E, 0x51, 0xED, 0xF8, 0x7C,
0x8F, 0x2E, 0xF4, 0x12, 0xC6, 0x2B, 0x83, 0xCD, 0xAC, 0xCB, 0x3B, 0xC4, 0x4E, 0xC0, 0x69, 0x36,
0x62, 0x02, 0xAE, 0x88, 0xFC, 0xAA, 0x42, 0x08, 0xA6, 0x45, 0x57, 0xD3, 0x9A, 0xBD, 0xE1, 0x23,
0x8D, 0x92, 0x4A, 0x11, 0x89, 0x74, 0x6B, 0x91, 0xFB, 0xFE, 0xC9, 0x01, 0xEA, 0x1B, 0xF7, 0xCE
};
public static string Unwrap(string wrappedPlSql, Encoding encoding)
{
Match m = Regex.Match(wrappedPlSql, @"wrapped\s*\r?\n(.*\n){19}");
int pos = m.Index + m.Length;
string base64Str = wrappedPlSql.Substring(pos).TrimEnd();
int headerSize = 22;
byte[] data = Convert.FromBase64String(base64Str);
for (int i = headerSize; i < data.Length; i++)
data[i] = substitutionTable[data[i]];
string unwrappedPlSql = "";
using (MemoryStream inputStream = new MemoryStream(data, headerSize, data.GetLength(0) - headerSize))
using (DeflateStream decompressionStream = new DeflateStream(inputStream, CompressionMode.Decompress))
using (StreamReader reader = new StreamReader(decompressionStream, encoding))
unwrappedPlSql = reader.ReadToEnd();
return unwrappedPlSql.TrimEnd('\0');
}
}
}
这里是调用
Unwrap
方法的示例。
[TestMethod]
public void TestLatin1()
{
string wrappedPlSql = @"
CREATE OR REPLACE FUNCTION get_latin1_string wrapped
a000000
1f
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
8f b6
HQrJ6ceqqsLh5Gs63gvHZtDzzoUwg8eZgcfLCNL+XlquYvRyoVb6R4JfltE+l0cM6ufAsr2y
m17nx3TAM7h0ZQmldIsJaedtKMu9m9LHB5n2BKsEEaPHrb5FEpKo2boxxRatSejtw8I5GBVf
rPKjx76SvhZTmEDb+FdAMJKIFQKIpjusSSY=";
string unwrappedPlSql = PlSqlUnwrapper.Unwrap(wrappedPlSql, Encoding.Latin1).Replace("\n", "\r\n").TrimEnd('\0');
Assert.AreEqual(unwrappedPlSql,
@"FUNCTION get_latin1_string RETURN VARCHAR2 IS
V_STRING VARCHAR2(100);
BEGIN
V_STRING := ""Café"";
RETURN V_STRING;
END GET_LATIN1_STRING;
");
}