-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6050e6e
Showing
163 changed files
with
3,721 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
|
||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v37 | ||
|
||
- name: List changed | ||
run: | | ||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | ||
echo "$file was changed" | ||
done | ||
- name: Log in to registry | ||
# This is where you will update the personal access token to GITHUB_TOKEN | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | ||
|
||
|
||
- name: Build and push the Docker image | ||
run: | | ||
declare -a built_images=() | ||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | ||
if [[ "$file" =~ ^(Pwn|Web)/[a-zA-Z0-9_-]+/deployment/.+ ]]; then | ||
IMAGE_NAME=$(echo -n $file | cut -d "/" -f2) | ||
NORM_IMAGE_NAME=$(echo $IMAGE_NAME | tr A-Z a-z | tr - _) | ||
CATEGORY=$(echo -n $file | cut -d "/" -f1) | ||
if [[ " ${built_images[*]} " != *" $IMAGE_NAME "* ]]; then | ||
echo "building and pushing: $CATEGORY/$IMAGE_NAME/deployment/" | ||
docker build $CATEGORY/$IMAGE_NAME/deployment/ --tag $NORM_IMAGE_NAME | ||
built_images+=("$NORM_IMAGE_NAME") | ||
IMAGE_ID=ghcr.io/guzzwho/$NORM_IMAGE_NAME | ||
echo "pushing to $IMAGE_ID" | ||
VERSION=latest | ||
docker tag $NORM_IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION | ||
else echo "already built $NORM_IMAGE_NAME" | ||
fi | ||
fi | ||
done |
21 changes: 21 additions & 0 deletions
21
Crypto/Primapocalypse/Handout/Primapocalypse/Primapocalypse.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from Crypto.Util.number import getPrime, bytes_to_long as b2l | ||
from sympy import nextprime | ||
|
||
flag = b2l(b"inctfj{?????}") | ||
|
||
L = [getPrime(2048)] | ||
for i in range(3): | ||
L.append(nextprime(L[-1])) | ||
|
||
e = 0x10001 | ||
|
||
cipher = flag | ||
for i in range(3): | ||
a, b = L[i], L[i + 1] | ||
N = a * b | ||
cipher = pow(cipher, e, N) | ||
|
||
with open('output.txt', 'w') as output_file: | ||
output_file.write(f"cipher: {hex(cipher)}\n") | ||
output_file.write(f"e: {hex(e)}\n") | ||
output_file.write(f"leak: {hex(L[0]*L[3])}, {hex(L[1]*L[2])}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cipher: 0x564f4d70f46f89dc2fa3635a89c2959812d038fa702c62783befdbb24fc02e8a3ea9405eb4fa9f1f7be87123c44858d35fc1544329c12664cb3a90735454ae10a81b317bff2273532be6838e684163cd6f7c6c4ea376ec44bfcb872496bc88938c21fcf30a25d55a661e51cd73748a00a44fe3c5b99ca3d7415bccbbda6175d34881f2f2510d3030dd7fca905e895ff27e7d4468b2926931fc2b7b6911786eff9fcdc9c40d5f0124e8dca814e3e3181e5e91b88d30f607beab25874bc5a47b8c2d5d55b7681efef4f67138c611f5284740689abdcd814e1c9f56f498dfe5990d003dba1ed577fcbfd983a075bee762e375fb25ec95b5dd617e2e5b7b8d00640a51e64da644a7264554ad74b440917760566eae9480113fede3ed97420c6c16610fe8a235b8a3d1870f39cb606781f9b9629159287c5592da5fa17685eabd0797edc69355a4c3bf1dc88d3083d5fec27ca9417fbb84e79613c2efc1510222b2979348e5177339e0e5b0f14635e9b85db82030c95eb2f4c4a8d5add07b3b91edb1a1d5f7a85698333047f841eb46007bc5d26ade3416ad054d44110fe72a4883ff798483c1c8b2fc732b6e3a571d7f5d8802f3020396c20d26580e4ad4aadf3ef9d274870ec4739c5ba37897dfa253b8cc0dd831f255a492e3a088df6e29bcf1f71d1148ec4652715f857df52b7bb8a34acb0554e78959b6f8e64ca92b7f2afc27 | ||
e: 0x10001 | ||
leak: 0x7a759c247b8e820c9b40915addfac71388587db324a55159754f4cad25c32dc7c5b847547777f7affdba42f6fc6b88f4e872893c92d5802248ffe1474f5f93656e1d312f58433adb92ca71af52f410053183c6c6ffd4509fc626e44839c97f2739496832cc7883a416ca48585987e1b0c27e582e60b71339013c6892fdf8b41ce6bbd6737452052e63d35fcbde793814c7ce1816490c8acac7809bcaab4caabda599b2e3b9306018fac24121fb119217432582cb938027f931bf953cd3ed6fa9feeed7ea1f584c8bcb6ad9573f51ffe2cfeb0ad734debb91d720b1b6efbdf784d6dedff6a885b122f8be4ee95075ea17e2377aff79c124c2245a6709564819bf0531d339d0694e1cfcc0effa528729c01fc99322da2f49ff2cca9fd3ac75dac4c96a5839959199df0c838b29bbbffec6622a26ce5aa265fd0b185b6d93848d021e22d5d4e5579cee16056d246a99e76d74e2e09286113987e84d487ed3d245e80acfca91d58201c57408dffa5505d0c3c5e33e18923dde17d0759b081d26552929e8b413262d422677d351fa580cc9049c43edbb371ecb67156d71f2a7ce737216a2c08c89171463c5138f4b0d3ac4e10d8c43f2a52de669ff22a239d10578edd1f62d5b04e148cea88e9036001dddd3bf7a1ec2f7c8ef125582934065579c270da91a8076f3a476a27f5455f1e8664ebe620b483da7d83c0883474d5588e54b, 0x7a759c247b8e820c9b40915addfac71388587db324a55159754f4cad25c32dc7c5b847547777f7affdba42f6fc6b88f4e872893c92d5802248ffe1474f5f93656e1d312f58433adb92ca71af52f410053183c6c6ffd4509fc626e44839c97f2739496832cc7883a416ca48585987e1b0c27e582e60b71339013c6892fdf8b41ce6bbd6737452052e63d35fcbde793814c7ce1816490c8acac7809bcaab4caabda599b2e3b9306018fac24121fb119217432582cb938027f931bf953cd3ed6fa9feeed7ea1f584c8bcb6ad9573f51ffe2cfeb0ad734debb91d720b1b6efbdf784d6dedff6a885b122f8be4ee95075ea17e2377aff79c124c2245a670956481a3ce5c9f8dfe8a8c8d3852c561f58d948ee6da1a63dd53295d90026b47c9b907c954079c28593f62662a76f1c3bf82b6543963c5053d5091d83a514d9a50348585f99f5c01c6808c0080cafd6f7bd8dcf11c1b2bc19502418e92cbf24069ef7b465d31b22a793d53d35fd72a138d125c1b8e31a8cbee85f0ffa3d0a4aafa9aa71809a7e747065d53ad8c11b6ddab6ee75b52a55f7cefe379a07a33f38c2925ef2c91b7f56bd767f012b2b2bf382a9df09b6abee1f9f6ed70f211c920429476657ade2229ab2824d5e605e461e2145b6be87a7a7f325d3f3f9b6631e3105405d3231221bf24a072c2be7f2c7562d8ab7b40eb9263de5cd6e8142d8e7d50fcd3df0a1 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Primapocalypse | ||
|
||
### Challenge Description | ||
I was a bit lazy to generate 4 primes but at least the bit length is large right...? | ||
|
||
**Challenge File** | ||
+ [Primary Link](./Handout/chall.zip) | ||
+ [Mirror Link]() | ||
|
||
**MD5 Hash**: 31bab32c4988a357aa8668f75affeef0 | ||
|
||
### Short Writeup | ||
+ This RSA challenge involves generating a 2048 bit prime as well as the next three primes after that one. | ||
+ The flag goes through 3 rounds of RSA encryption with N being the product of the first and the second prime and in the next round N is the product of the second and third prime and so on. | ||
+ The ciphertext, e and the product of the first and last prime as well as the product of the 2nd and 3rd prime is written to a file. | ||
|
||
Solving this challenge involves factoring the two products given with the fermat's factoring algorithm (since the primes are close together). | ||
Since primes are generated in a successive manner, the factored values must be sorted and then the decryption can be done by considering the last two values first. | ||
|
||
### Flag | ||
|
||
inctfj{n0t_4_t0u4h_p51me_1s_i7} | ||
|
||
### Author | ||
|
||
**Ankith** | ||
**Devanandan** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cipher: 0x564f4d70f46f89dc2fa3635a89c2959812d038fa702c62783befdbb24fc02e8a3ea9405eb4fa9f1f7be87123c44858d35fc1544329c12664cb3a90735454ae10a81b317bff2273532be6838e684163cd6f7c6c4ea376ec44bfcb872496bc88938c21fcf30a25d55a661e51cd73748a00a44fe3c5b99ca3d7415bccbbda6175d34881f2f2510d3030dd7fca905e895ff27e7d4468b2926931fc2b7b6911786eff9fcdc9c40d5f0124e8dca814e3e3181e5e91b88d30f607beab25874bc5a47b8c2d5d55b7681efef4f67138c611f5284740689abdcd814e1c9f56f498dfe5990d003dba1ed577fcbfd983a075bee762e375fb25ec95b5dd617e2e5b7b8d00640a51e64da644a7264554ad74b440917760566eae9480113fede3ed97420c6c16610fe8a235b8a3d1870f39cb606781f9b9629159287c5592da5fa17685eabd0797edc69355a4c3bf1dc88d3083d5fec27ca9417fbb84e79613c2efc1510222b2979348e5177339e0e5b0f14635e9b85db82030c95eb2f4c4a8d5add07b3b91edb1a1d5f7a85698333047f841eb46007bc5d26ade3416ad054d44110fe72a4883ff798483c1c8b2fc732b6e3a571d7f5d8802f3020396c20d26580e4ad4aadf3ef9d274870ec4739c5ba37897dfa253b8cc0dd831f255a492e3a088df6e29bcf1f71d1148ec4652715f857df52b7bb8a34acb0554e78959b6f8e64ca92b7f2afc27 | ||
e: 0x10001 | ||
leak: 0x7a759c247b8e820c9b40915addfac71388587db324a55159754f4cad25c32dc7c5b847547777f7affdba42f6fc6b88f4e872893c92d5802248ffe1474f5f93656e1d312f58433adb92ca71af52f410053183c6c6ffd4509fc626e44839c97f2739496832cc7883a416ca48585987e1b0c27e582e60b71339013c6892fdf8b41ce6bbd6737452052e63d35fcbde793814c7ce1816490c8acac7809bcaab4caabda599b2e3b9306018fac24121fb119217432582cb938027f931bf953cd3ed6fa9feeed7ea1f584c8bcb6ad9573f51ffe2cfeb0ad734debb91d720b1b6efbdf784d6dedff6a885b122f8be4ee95075ea17e2377aff79c124c2245a6709564819bf0531d339d0694e1cfcc0effa528729c01fc99322da2f49ff2cca9fd3ac75dac4c96a5839959199df0c838b29bbbffec6622a26ce5aa265fd0b185b6d93848d021e22d5d4e5579cee16056d246a99e76d74e2e09286113987e84d487ed3d245e80acfca91d58201c57408dffa5505d0c3c5e33e18923dde17d0759b081d26552929e8b413262d422677d351fa580cc9049c43edbb371ecb67156d71f2a7ce737216a2c08c89171463c5138f4b0d3ac4e10d8c43f2a52de669ff22a239d10578edd1f62d5b04e148cea88e9036001dddd3bf7a1ec2f7c8ef125582934065579c270da91a8076f3a476a27f5455f1e8664ebe620b483da7d83c0883474d5588e54b, 0x7a759c247b8e820c9b40915addfac71388587db324a55159754f4cad25c32dc7c5b847547777f7affdba42f6fc6b88f4e872893c92d5802248ffe1474f5f93656e1d312f58433adb92ca71af52f410053183c6c6ffd4509fc626e44839c97f2739496832cc7883a416ca48585987e1b0c27e582e60b71339013c6892fdf8b41ce6bbd6737452052e63d35fcbde793814c7ce1816490c8acac7809bcaab4caabda599b2e3b9306018fac24121fb119217432582cb938027f931bf953cd3ed6fa9feeed7ea1f584c8bcb6ad9573f51ffe2cfeb0ad734debb91d720b1b6efbdf784d6dedff6a885b122f8be4ee95075ea17e2377aff79c124c2245a670956481a3ce5c9f8dfe8a8c8d3852c561f58d948ee6da1a63dd53295d90026b47c9b907c954079c28593f62662a76f1c3bf82b6543963c5053d5091d83a514d9a50348585f99f5c01c6808c0080cafd6f7bd8dcf11c1b2bc19502418e92cbf24069ef7b465d31b22a793d53d35fd72a138d125c1b8e31a8cbee85f0ffa3d0a4aafa9aa71809a7e747065d53ad8c11b6ddab6ee75b52a55f7cefe379a07a33f38c2925ef2c91b7f56bd767f012b2b2bf382a9df09b6abee1f9f6ed70f211c920429476657ade2229ab2824d5e605e461e2145b6be87a7a7f325d3f3f9b6631e3105405d3231221bf24a072c2be7f2c7562d8ab7b40eb9263de5cd6e8142d8e7d50fcd3df0a1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from gmpy2 import isqrt | ||
from gmpy2 import is_square | ||
from Crypto.Util.number import long_to_bytes | ||
|
||
with open('output.txt', 'r') as output_file: | ||
cipher = int(output_file.readline().lstrip("cipher: "), 16) | ||
e = int(output_file.readline().lstrip("e: "), 16) | ||
leak = output_file.readline().lstrip("leak: ") | ||
|
||
N1, N2 = leak.split(", ") | ||
N1 = int(N1, 16) | ||
N2 = int(N2, 16) | ||
|
||
def factor(n): | ||
a = isqrt(n) | ||
b2 = a**2 - n | ||
|
||
while not is_square(b2): | ||
b2 += 2*a + 1 | ||
a += 1 | ||
|
||
p = int(a - isqrt(b2)) | ||
q = int(a + isqrt(b2)) | ||
|
||
assert p * q == n | ||
return p, q | ||
|
||
L = sorted(factor(N2) + factor(N1), reverse=True) | ||
e = 0x10001 | ||
|
||
for i in range(3): | ||
p, q = L[i], L[i+1] | ||
N = p*q | ||
phi = (p-1)*(q-1) | ||
d = pow(e,-1, phi) | ||
cipher = pow(cipher, d, N) | ||
|
||
print(long_to_bytes(cipher).decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from Crypto.Util.number import getPrime, bytes_to_long as b2l | ||
from sympy import nextprime | ||
|
||
flag = b2l(b"inctfj{n0t_4_t0u4h_p51me_1s_i7}") | ||
|
||
L = [getPrime(2048)] | ||
for i in range(3): | ||
L.append(nextprime(L[-1])) | ||
|
||
e = 0x10001 | ||
|
||
cipher = flag | ||
for i in range(3): | ||
a, b = L[i], L[i + 1] | ||
N = a * b | ||
cipher = pow(cipher, e, N) | ||
|
||
with open('output.txt', 'w') as output_file: | ||
output_file.write(f"cipher: {hex(cipher)}\n") | ||
output_file.write(f"e: {hex(e)}\n") | ||
output_file.write(f"leak: {hex(L[0]*L[3])}, {hex(L[1]*L[2])}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cipher: 0x564f4d70f46f89dc2fa3635a89c2959812d038fa702c62783befdbb24fc02e8a3ea9405eb4fa9f1f7be87123c44858d35fc1544329c12664cb3a90735454ae10a81b317bff2273532be6838e684163cd6f7c6c4ea376ec44bfcb872496bc88938c21fcf30a25d55a661e51cd73748a00a44fe3c5b99ca3d7415bccbbda6175d34881f2f2510d3030dd7fca905e895ff27e7d4468b2926931fc2b7b6911786eff9fcdc9c40d5f0124e8dca814e3e3181e5e91b88d30f607beab25874bc5a47b8c2d5d55b7681efef4f67138c611f5284740689abdcd814e1c9f56f498dfe5990d003dba1ed577fcbfd983a075bee762e375fb25ec95b5dd617e2e5b7b8d00640a51e64da644a7264554ad74b440917760566eae9480113fede3ed97420c6c16610fe8a235b8a3d1870f39cb606781f9b9629159287c5592da5fa17685eabd0797edc69355a4c3bf1dc88d3083d5fec27ca9417fbb84e79613c2efc1510222b2979348e5177339e0e5b0f14635e9b85db82030c95eb2f4c4a8d5add07b3b91edb1a1d5f7a85698333047f841eb46007bc5d26ade3416ad054d44110fe72a4883ff798483c1c8b2fc732b6e3a571d7f5d8802f3020396c20d26580e4ad4aadf3ef9d274870ec4739c5ba37897dfa253b8cc0dd831f255a492e3a088df6e29bcf1f71d1148ec4652715f857df52b7bb8a34acb0554e78959b6f8e64ca92b7f2afc27 | ||
e: 0x10001 | ||
leak: 0x7a759c247b8e820c9b40915addfac71388587db324a55159754f4cad25c32dc7c5b847547777f7affdba42f6fc6b88f4e872893c92d5802248ffe1474f5f93656e1d312f58433adb92ca71af52f410053183c6c6ffd4509fc626e44839c97f2739496832cc7883a416ca48585987e1b0c27e582e60b71339013c6892fdf8b41ce6bbd6737452052e63d35fcbde793814c7ce1816490c8acac7809bcaab4caabda599b2e3b9306018fac24121fb119217432582cb938027f931bf953cd3ed6fa9feeed7ea1f584c8bcb6ad9573f51ffe2cfeb0ad734debb91d720b1b6efbdf784d6dedff6a885b122f8be4ee95075ea17e2377aff79c124c2245a6709564819bf0531d339d0694e1cfcc0effa528729c01fc99322da2f49ff2cca9fd3ac75dac4c96a5839959199df0c838b29bbbffec6622a26ce5aa265fd0b185b6d93848d021e22d5d4e5579cee16056d246a99e76d74e2e09286113987e84d487ed3d245e80acfca91d58201c57408dffa5505d0c3c5e33e18923dde17d0759b081d26552929e8b413262d422677d351fa580cc9049c43edbb371ecb67156d71f2a7ce737216a2c08c89171463c5138f4b0d3ac4e10d8c43f2a52de669ff22a239d10578edd1f62d5b04e148cea88e9036001dddd3bf7a1ec2f7c8ef125582934065579c270da91a8076f3a476a27f5455f1e8664ebe620b483da7d83c0883474d5588e54b, 0x7a759c247b8e820c9b40915addfac71388587db324a55159754f4cad25c32dc7c5b847547777f7affdba42f6fc6b88f4e872893c92d5802248ffe1474f5f93656e1d312f58433adb92ca71af52f410053183c6c6ffd4509fc626e44839c97f2739496832cc7883a416ca48585987e1b0c27e582e60b71339013c6892fdf8b41ce6bbd6737452052e63d35fcbde793814c7ce1816490c8acac7809bcaab4caabda599b2e3b9306018fac24121fb119217432582cb938027f931bf953cd3ed6fa9feeed7ea1f584c8bcb6ad9573f51ffe2cfeb0ad734debb91d720b1b6efbdf784d6dedff6a885b122f8be4ee95075ea17e2377aff79c124c2245a670956481a3ce5c9f8dfe8a8c8d3852c561f58d948ee6da1a63dd53295d90026b47c9b907c954079c28593f62662a76f1c3bf82b6543963c5053d5091d83a514d9a50348585f99f5c01c6808c0080cafd6f7bd8dcf11c1b2bc19502418e92cbf24069ef7b465d31b22a793d53d35fd72a138d125c1b8e31a8cbee85f0ffa3d0a4aafa9aa71809a7e747065d53ad8c11b6ddab6ee75b52a55f7cefe379a07a33f38c2925ef2c91b7f56bd767f012b2b2bf382a9df09b6abee1f9f6ed70f211c920429476657ade2229ab2824d5e605e461e2145b6be87a7a7f325d3f3f9b6631e3105405d3231221bf24a072c2be7f2c7562d8ab7b40eb9263de5cd6e8142d8e7d50fcd3df0a1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Crypto | ||
|
||
|
||
| Challenge | Author | Difficulty | | ||
| ----------- | ----------- | ----------- | | ||
|bragcrid|Parvathy|Easy| | ||
|Primapocalypse|Ankith, Devanand|Medium| | ||
|Sums_n_Diffs|Ankith, Devanand|Medium| | ||
|beginner|Sans|Hard| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
flag = "inctfj{?????}" | ||
flag = list(flag.encode()) | ||
|
||
def product(arr): | ||
product = 1 | ||
for num in arr: | ||
product *= num | ||
return product | ||
|
||
def generatePs(arr): | ||
Ps = [] | ||
for i in range(len(arr)): | ||
Ps.append(product(arr[:i] + arr[i+1:])) | ||
return Ps | ||
|
||
def generateDs(Ps, P): | ||
Ds = [] | ||
for i in range(len(Ps)): | ||
Ds.append(P - Ps[i]) | ||
return Ds | ||
|
||
P = product(flag) | ||
Ps = generatePs(flag) | ||
Ds = generateDs(Ps, P) | ||
|
||
out = [hex(Ps[i] * Ds[i]) for i in range(len(flag))] | ||
|
||
with open('output.txt', 'w') as output_file: | ||
output_file.write(f"P: {hex(P)}\n") | ||
output_file.write(f"Out: {out}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
P: 0x45a0329fce551659417d40ab7b4860711bb82be95b102000000 | ||
Out: ['0x2dbab510cbc3dc98cfa31154fc18584d10369fe17b0f352c2a7547bd4dd432c6ab49ddaf46e51c2186eb47a0000000000000', '0x2bab77dda2486be1e5fafc7276dd5f300030aa53f6c35e9ccbc29a28ab3e85a03be502263fb0779805ab4add000000000000', '0x3078f81a1bac45c258aa7e97ee523dfd33e8e3cc565c1e35b59a814d3d4f1c8ac54030151d601a0b2e381d48000000000000', '0x296e4020e24081ab29514ce08123a29981d2e685dce07bf8d800bbe71c5b9106986d64649f9910be634a3536c00000000000', '0x2f0f9d368681c73c1ea4d3185b23e9e15035eebc7a60bc02155615bcf22f2990b7aa5a9c84739d0df366d0dd000000000000', '0x2d4d518d647c98ed6a13a8689436365d28d67d012502faf32592016365708155a7dcf3ecf64334c2f18dedf1000000000000', '0x271797c1e950793da20085219eaaa1487343d75b6579e894ee32920ce5b27c5dc3e48a84b69c3b67de6f5e28000000000000', '0x2a85519ed88d5be9342a62e37f97077edcbe3cbe07265ec05fff5d3c81ade1d5d1f527bdc4b02b83584d79c0000000000000', '0x2914615d12f843089e9c6c85b47cd97e13e1296bc9f2213507a6a5696e5ae94aca19765fdc1e30593bd9fc50000000000000', '0x5b6ee0fbb638d882c571670fa9dbf415b8a927a42ff6ebd78c7a3945022cd4376daf91d138f680da797d989ec00000000000', '0x2ffe220d568a2a474a9a6e5b2129d2163e6685a3e89a417bfb8ce4eeed0c15f42ea8a77e71d1bdf5d1ff3544c00000000000', '0x2a26adbbb7520d5bea9446377080f7ced8f30bb7693c63c82e078f02162284c0906510f687eb46b5abced0c1000000000000', '0x5b6ee0fbb638d882c571670fa9dbf415b8a927a42ff6ebd78c7a3945022cd4376daf91d138f680da797d989ec00000000000', '0x296e4020e24081ab29514ce08123a29981d2e685dce07bf8d800bbe71c5b9106986d64649f9910be634a3536c00000000000', '0x60ea221857d423e3cdbfab5ce6717c0a9aed229c5b34b9d4f5e9aef20c3a4770cbde0d4742412f28e9b0b8c0000000000000', '0x3078f81a1bac45c258aa7e97ee523dfd33e8e3cc565c1e35b59a814d3d4f1c8ac54030151d601a0b2e381d48000000000000', '0x327de568109b8f52a58c3039b5cc0e791773ca4061c94a7d10fca3b1aab0bc04d81a187cf2ebfa71c503b378000000000000', '0x2f0f9d368681c73c1ea4d3185b23e9e15035eebc7a60bc02155615bcf22f2990b7aa5a9c84739d0df366d0dd000000000000', '0x62e404b16d6a731808c9f473b1e460917f5247d78a2fa09c9d8c23efb10724b0605b8dd99b8d65c92823f88ddc0000000000', '0x2a26adbbb7520d5bea9446377080f7ced8f30bb7693c63c82e078f02162284c0906510f687eb46b5abced0c1000000000000', '0x2c11152330ca8d2f1475dc7d41b20cb5927e9fd3df3dd93a081c270b4c2e20ecee8727eb984535ca754a4e30000000000000', '0x2914615d12f843089e9c6c85b47cd97e13e1296bc9f2213507a6a5696e5ae94aca19765fdc1e30593bd9fc50000000000000', '0x60ea221857d423e3cdbfab5ce6717c0a9aed229c5b34b9d4f5e9aef20c3a4770cbde0d4742412f28e9b0b8c0000000000000', '0x5b6ee0fbb638d882c571670fa9dbf415b8a927a42ff6ebd78c7a3945022cd4376daf91d138f680da797d989ec00000000000', '0x327de568109b8f52a58c3039b5cc0e791773ca4061c94a7d10fca3b1aab0bc04d81a187cf2ebfa71c503b378000000000000', '0x2a26adbbb7520d5bea9446377080f7ced8f30bb7693c63c82e078f02162284c0906510f687eb46b5abced0c1000000000000', '0x2914615d12f843089e9c6c85b47cd97e13e1296bc9f2213507a6a5696e5ae94aca19765fdc1e30593bd9fc50000000000000', '0x2c788f97cec20f4f996fddc1d8b4b456242431ca6f3b01f4cb747af1dfd94071becc93711f4933c1f2fbef78c00000000000', '0x5d30a95f4c405a5db3cf41b17f3f8316e0bbe7f3f4ddf8186714ebade9b61a8b8f2dd972c46122b8c61a2b88000000000000', '0x29c9ab788e92d8471b8c676ba2b0b1ff650a1f472b1c54c369a7d49b2f281a0981e3c876e53cc6c6ef121888000000000000', '0x2678c3462aaf815c6b620a0f55a5322effdb06e67b5cef16bddaf69c90ec6a8d557fda26adc7ae198f33ce70000000000000'] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Sums_n_Diffs | ||
|
||
### Challenge Description | ||
polynomials... polynomials... | ||
|
||
**Challenge File** | ||
+ [Primary Link](./Handout/chall.zip) | ||
+ [Mirror Link]() | ||
|
||
**MD5 Hash**: 659500611fbaea0929833cc504b110af | ||
|
||
### Short Writeup | ||
|
||
+ The ascii value of each byte in the flag is taken and the product P of all of these values is calculated. | ||
+ Then, a list with values `Pi` where each value is the total product divided by the ascii value of the ith byte of the flag, is created. | ||
+ Next, a list with values `Di` where each value is `P-Pi` for every ith byte of the flag, is created. | ||
+ Finally, a list with the values `Pi * Di` is created. | ||
+ The value of P as well as the product list is written to a flag. | ||
|
||
This challenge can be solved using the quadratic equation. | ||
We have: | ||
``` | ||
Di = P-Pi | ||
prod = Pi * Di | ||
prod = Pi * (P-Pi) | ||
prod = Pi*P - Pi^2 | ||
Pi^2 - Pi*P + prod = 0 | ||
``` | ||
Since prod and P is known, each Pi can be calculated by finding the root of the equation. | ||
Calculating P/Pi gives each byte of the flag. | ||
|
||
### Flag | ||
|
||
inctfj{qu4dr4t1c_f0rmu14_rul3s} | ||
|
||
### Authors | ||
|
||
**Ankith** | ||
**Devanandan** |
Oops, something went wrong.