Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.

Commit c3f28d6

Browse files
author
Zaczero
committed
Speed up injection methods
1 parent 0b57103 commit c3f28d6

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

SharpLoader/Core/SourceRandomizer.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,12 @@ private void Encrypt(ref string str)
653653
$"private static int {b};" +
654654
$"private static int {c};" +
655655
$"private static int {d};" +
656-
$"public static string {funcName}(string {baseEncrypted}, string {baseDecryptor})" +
656+
$"public static string {funcName}(string {baseEncrypted}, short {baseDecryptor})" +
657657
$"{{" +
658658
$"<flow>" +
659659
$"<swap>" +
660660
$"{tmp1} = Convert.FromBase64String({baseEncrypted});" +
661-
$"{tmp2} = Convert.FromBase64String({baseDecryptor});" +
661+
$"{tmp2} = BitConverter.GetBytes({baseDecryptor});" +
662662
$"<trash>" +
663663
$"<swap/>" +
664664
$"<swap>" +
@@ -724,9 +724,9 @@ private void Encrypt(ref string str)
724724
var tmp2 = new[] { decryptorOne, decryptorTwo };
725725

726726
var baseEncrypted = Convert.ToBase64String(tmp1);
727-
var baseDecryptor = Convert.ToBase64String(tmp2);
727+
var baseDecryptor = BitConverter.ToInt16(tmp2, 0);
728728

729-
var output = $"{_stringDecryptorFunction}(\"{baseEncrypted}\",\"{baseDecryptor}\")";
729+
var output = $"{_stringDecryptorFunction}(\"{baseEncrypted}\",{baseDecryptor})";
730730

731731
// Replace
732732
str = str.Remove(tagIndex, tagLength + 1).Insert(tagIndex, output);
@@ -774,12 +774,12 @@ private void Encrypt(ref string str)
774774
$"private static int {b};" +
775775
$"private static int {c};" +
776776
$"private static int {d};" +
777-
$"public static char {funcName}(string {baseEncrypted}, string {baseDecryptor})" +
777+
$"public static char {funcName}(string {baseEncrypted}, short {baseDecryptor})" +
778778
$"{{" +
779779
$"<flow>" +
780780
$"<swap>" +
781781
$"{tmp1} = Convert.FromBase64String({baseEncrypted});" +
782-
$"{tmp2} = Convert.FromBase64String({baseDecryptor});" +
782+
$"{tmp2} = BitConverter.GetBytes({baseDecryptor});" +
783783
$"<trash>" +
784784
$"<swap/>" +
785785
$"<swap>" +
@@ -845,9 +845,9 @@ private void Encrypt(ref string str)
845845
var tmp2 = new[] { decryptorOne, decryptorTwo };
846846

847847
var baseEncrypted = Convert.ToBase64String(tmp1);
848-
var baseDecryptor = Convert.ToBase64String(tmp2);
848+
var baseDecryptor = BitConverter.ToInt16(tmp2, 0);
849849

850-
var output = $"{_charDecryptorFunction}(\"{baseEncrypted}\",\"{baseDecryptor}\")";
850+
var output = $"{_charDecryptorFunction}(\"{baseEncrypted}\",{baseDecryptor})";
851851

852852
// Replace
853853
str = str.Remove(tagIndex, tagLength + 1).Insert(tagIndex, output);
@@ -890,12 +890,12 @@ private void Encrypt(ref string str)
890890
$"private static int {a};" +
891891
$"private static int {b};" +
892892
$"private static int {c};" +
893-
$"public static int {funcName}(string {baseEncrypted}, string {baseDecryptor})" +
893+
$"public static int {funcName}(string {baseEncrypted}, short {baseDecryptor})" +
894894
$"{{" +
895895
$"<flow>" +
896896
$"<swap>" +
897897
$"{tmp1} = Convert.FromBase64String({baseEncrypted});" +
898-
$"{tmp2} = Convert.FromBase64String({baseDecryptor});" +
898+
$"{tmp2} = BitConverter.GetBytes({baseDecryptor});" +
899899
$"<trash>" +
900900
$"<swap/>" +
901901
$"<swap>" +
@@ -960,9 +960,9 @@ private void Encrypt(ref string str)
960960
var tmp2 = new[] {decryptorOne, decryptorTwo};
961961

962962
var baseEncrypted = Convert.ToBase64String(tmp1);
963-
var baseDecryptor = Convert.ToBase64String(tmp2);
963+
var baseDecryptor = BitConverter.ToInt16(tmp2, 0);
964964

965-
var output = $"{_valueDecryptorFunction}(\"{baseEncrypted}\", \"{baseDecryptor}\")";
965+
var output = $"{_valueDecryptorFunction}(\"{baseEncrypted}\", {baseDecryptor})";
966966

967967
// Replace
968968
str = str.Remove(tagIndex, tagLength + 1).Insert(tagIndex, output);
@@ -1102,9 +1102,9 @@ private void Flow(ref string str)
11021102
$"private static int {decryptorOne};" +
11031103
$"private static int {decryptorTwo};" +
11041104
$"private static int {result};" +
1105-
$"public static int {funcName}(string {baseDecryptor})" +
1105+
$"public static int {funcName}(long {baseDecryptor})" +
11061106
$"{{" +
1107-
$"{tmp1} = Convert.FromBase64String({baseDecryptor});" +
1107+
$"{tmp1} = BitConverter.GetBytes({baseDecryptor});" +
11081108
$"<swap>" +
11091109
$"Array.Copy({tmp1}, 0, {tmp2}, 0, 4);" +
11101110
$"Array.Copy({tmp1}, 4, {tmp3}, 0, 4);" +
@@ -1193,9 +1193,9 @@ private void Flow(ref string str)
11931193
var tmp1 = new byte[8];
11941194
Array.Copy(tmp2, 0, tmp1, 0, 4);
11951195
Array.Copy(tmp3, 0, tmp1, 4, 4);
1196-
var baseDecryptor = Convert.ToBase64String(tmp1);
1196+
var baseDecryptor = BitConverter.ToInt64(tmp1, 0);
11971197

1198-
cases[i] = $"case {switchValues[i]}:{{{finalBlocks[i]}{switchName}={_xorDecryptorFunction}(\"{baseDecryptor}\");break;}}<block>";
1198+
cases[i] = $"case {switchValues[i]}:{{{finalBlocks[i]}{switchName}={_xorDecryptorFunction}({baseDecryptor});break;}}<block>";
11991199
}
12001200
}
12011201

0 commit comments

Comments
 (0)