diff --git a/Day 14/decode.py b/Day 14/decode.py
old mode 100644
new mode 100755
index 15c739d..7fd51cb
--- a/Day 14/decode.py
+++ b/Day 14/decode.py
@@ -3,8 +3,10 @@
import math
c = int("2A4C9AA52257B56837369D5DD7019451C0EC04427EB95EB741D0273D55", 16)
-t = int("1398ED7F59A62962D5A47DD0D32B71156DD6AF6B46BEA949976331B8E1", 16)
n = int("0D8A7A45D9BE42BB3F03F710CF105628E8080F6105224612481908DC721", 16)
+t = int("1398ED7F59A62962D5A47DD0D32B71156DD6AF6B46BEA949976331B8E1", 16)
+
+# print(len(hex(t)[2:])*4)
def linear_diophantine_equation(a, b):
if b > a:
@@ -26,13 +28,101 @@ def gcd(a, b):
d, x, y = linear_diophantine_equation(a, b)
return d
+def test_solution(m):
+ return (m**2) % n == c
+
+def is_square_num(n):
+ if n <= 0:
+ return False
+ return math.sqrt(n)**2 == n
+
+def is_int(n):
+ return int(n) == n
+
+# m*m - k*n = c
+# (m*m)/c - (k*n)/c = 1 k' = k * c
+# m * m * c^-1 - k' * n = 1
+
+# c = m*m - k*n
+# c = 1*x - k*n mit x = m^2
+
+# c = gcd(m, n)
+
+d, x, y = linear_diophantine_equation(n, c)
+print(d, x, y)
+
+for i in range(-10, 10):
+ print(i, test_solution(y + i * t))
+ # h = hex(y)[2:]
+ # print(''.join([chr(int(h[i:i+2], 16)) for i in range(len(h))]))
+
+# print(y * c + x * n)
+
+# y1 * c + x1 * n = 1
+# y2 * m*m + x2 * n = 1
+
+# y2 * m*m + x2 * n = y1 * c + x1 * n
+# y2 * m*m + (x2-x1)*n = y1 * c
+# -y1*c + (x2-x1)*n = y2*m*m
+
+lcm = c * n
+while not is_square_num(lcm):
+ lcm += n
+
+print(hex(lcm))
+print(is_square_num(lcm))
+
+# tmp = -1 * y * c - x * n
+#
+# solution = tmp + n*n
+# while not is_square_num(solution) and not test_solution(math.sqrt(solution)):
+# solution += n
+#
+# if is_square_num(solution):
+# print(len(hex(math.sqrt(solution))[2:]), hex(int(math.sqrt(solution))))
+#
+
+#
+# print(is_square_num(x))
+# print(test_solution(x))
+# # print(hex(d))
+
+# ggT(m², n) = ggT(c, n)
+
+# print(gcd(c,n))
+
+# gcd(m**2, n) = 1
+#
+# 1 = x*m**2 + y*n
+# 1 = x*m**2*c + y*n
+#
+# x1*m**2 + y1*n = x2*m**2*c + y2*n
+# 0 = m**2*x2*c-x1*m**2 + (y1-y2)*n
+#
+# gcd(m**2*c, n) = gcd(m**2, n)
+#
+# print(gcd(c, n))
+
+# m = int("c20cd4b471c96cc2eaab1d1c6e33494219679ae97e48506e311ddbba35", 16)
+# print(m**2 % n - c)
+# print(test_solution(m))
+
+# mult_inverse = multiplicative_inverse(c, n)
+#
+# d, x, y = linear_diophantine_equation(mult_inverse, n)
+# print(d,x,y)
+#
+# print(mult_inverse*x - y*n)
+#
+# print(is_square_num(x))
+# print(is_square_num(y))
+
+# print(is_square_num(c))
+
# n > t > c
# m = flag
-def test_solution(m):
- return m**2 % n == c
-
# m**2 % n = x**2
# m**2 + k*n = c
# m % n = x
@@ -45,11 +135,10 @@ def test_solution(m):
# x += n
# print(hex(x), hex(((x**2)%n)-c))
# print(x)
-
-mult_inverse = multiplicative_inverse(c, n)
-
-d, x, y = linear_diophantine_equation(mult_inverse, mult_inverse*n)
-print(hex(d + 6*t - 2*c), test_solution(d + 6*t - 2*c))
+#
+#
+# d, x, y = linear_diophantine_equation(mult_inverse, mult_inverse*n)
+# print(hex(d + 6*t - 2*c), test_solution(d + 6*t - 2*c))
# x = math.sqrt(n)
# print(x)
diff --git a/Day 15/HACKvent-2018_by_the_oneandonly_HaRdLoCk.ipa b/Day 15/HACKvent-2018_by_the_oneandonly_HaRdLoCk.ipa
new file mode 100644
index 0000000..02838e8
Binary files /dev/null and b/Day 15/HACKvent-2018_by_the_oneandonly_HaRdLoCk.ipa differ
diff --git a/Day 15/Payload/HACKvent-2018.app/Assets.car b/Day 15/Payload/HACKvent-2018.app/Assets.car
new file mode 100644
index 0000000..f48788a
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/Assets.car differ
diff --git a/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC.nib b/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC.nib
new file mode 100644
index 0000000..c1bcf2b
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/BYZ-38-t0r-view-8bC-Xf-vdC.nib differ
diff --git a/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/Info.plist b/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/Info.plist
new file mode 100644
index 0000000..9a41f2c
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/Info.plist differ
diff --git a/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/Info.xml b/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/Info.xml
new file mode 100644
index 0000000..efd853d
--- /dev/null
+++ b/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/Info.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ UIViewControllerIdentifiersToNibNames
+
+ UIViewController-BYZ-38-t0r
+ UIViewController-BYZ-38-t0r
+
+ UIStoryboardDesignatedEntryPointIdentifier
+ UIViewController-BYZ-38-t0r
+ UIStoryboardVersion
+ 1
+
+
diff --git a/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/UIViewController-BYZ-38-t0r.nib b/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/UIViewController-BYZ-38-t0r.nib
new file mode 100644
index 0000000..7bcc6f7
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/Base.lproj/Main.storyboardc/UIViewController-BYZ-38-t0r.nib differ
diff --git a/Day 15/Payload/HACKvent-2018.app/HACKvent-2018 b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018
new file mode 100755
index 0000000..c62a584
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018 differ
diff --git a/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.id0 b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.id0
new file mode 100644
index 0000000..0892707
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.id0 differ
diff --git a/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.id1 b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.id1
new file mode 100644
index 0000000..990b895
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.id1 differ
diff --git a/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.nam b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.nam
new file mode 100644
index 0000000..f035481
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.nam differ
diff --git a/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.til b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.til
new file mode 100644
index 0000000..9b7645c
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/HACKvent-2018.til differ
diff --git a/Day 15/Payload/HACKvent-2018.app/Info.plist b/Day 15/Payload/HACKvent-2018.app/Info.plist
new file mode 100644
index 0000000..967b0b0
Binary files /dev/null and b/Day 15/Payload/HACKvent-2018.app/Info.plist differ
diff --git a/Day 15/Payload/HACKvent-2018.app/Info.xml b/Day 15/Payload/HACKvent-2018.app/Info.xml
new file mode 100644
index 0000000..a15aa91
--- /dev/null
+++ b/Day 15/Payload/HACKvent-2018.app/Info.xml
@@ -0,0 +1,88 @@
+
+
+
+
+ BuildMachineOSBuild
+ 17G65
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ HACKvent-2018
+ CFBundleIcons
+
+ CFBundlePrimaryIcon
+ App Icon
+
+ CFBundleIdentifier
+ com.hacking-lab.HACKvent-2018
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ HACKvent-2018
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSupportedPlatforms
+
+ AppleTVOS
+
+ CFBundleVersion
+ 1
+ DTCompiler
+ com.apple.compilers.llvm.clang.1_0
+ DTPlatformBuild
+ 16J364
+ DTPlatformName
+ appletvos
+ DTPlatformVersion
+ 12.0
+ DTSDKBuild
+ 16J364
+ DTSDKName
+ appletvos12.0
+ DTXcode
+ 1000
+ DTXcodeBuild
+ 10A255
+ LSRequiresIPhoneOS
+
+ MinimumOSVersion
+ 12.0
+ UIDeviceFamily
+
+ 3
+
+ UILaunchImages
+
+
+ UILaunchImageMinimumOSVersion
+ 11.0
+ UILaunchImageName
+ LaunchImage
+ UILaunchImageOrientation
+ Landscape
+ UILaunchImageSize
+ {1920, 1080}
+
+
+ UILaunchImageMinimumOSVersion
+ 9.0
+ UILaunchImageName
+ LaunchImage
+ UILaunchImageOrientation
+ Landscape
+ UILaunchImageSize
+ {1920, 1080}
+
+
+ UIMainStoryboardFile
+ Main
+ UIRequiredDeviceCapabilities
+
+ arm64
+
+ UIUserInterfaceStyle
+ Automatic
+
+
diff --git a/Day 15/Payload/HACKvent-2018.app/PkgInfo b/Day 15/Payload/HACKvent-2018.app/PkgInfo
new file mode 100644
index 0000000..bd04210
--- /dev/null
+++ b/Day 15/Payload/HACKvent-2018.app/PkgInfo
@@ -0,0 +1 @@
+APPL????
\ No newline at end of file
diff --git a/Day 15/decode.py b/Day 15/decode.py
new file mode 100755
index 0000000..62fc11a
--- /dev/null
+++ b/Day 15/decode.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+
+import base64
+from Crypto import Random
+from Crypto.Cipher import AES
+
+key = list("uQA\\-nM@=1wl\x1EbN!")
+b64 = "xQ34V+MHmhC8V88KyU66q0DE4QeOxAbp1EGy9tlpkLw="
+
+key[0] = chr(120)
+
+offset = 1
+while True:
+
+ key[offset] = chr(ord(key[offset]) + 3)
+ offset += 1
+
+ if len(key) <= offset:
+ break
+
+key = "".join(key)
+
+# print(len(key))
+# print(len(base64.b64decode(b64)))
+
+def decrypt(key, encrypted):
+ # IV = Random.new().read(BLOCK_SIZE)
+ aes = AES.new(key, AES.MODE_ECB)
+ return aes.decrypt(base64.b64decode(b64))
+
+decrypted = decrypt(key.encode("utf-8"), b64)
+print(decrypted.decode("utf-8"))