-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathchall.py
executable file
·108 lines (96 loc) · 3.34 KB
/
chall.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! /usr/bin/python3
import os
class account:
def __init__(self, amount, user):
self.balance = amount
self.user = user
def wireMoney(self, amount, receiver):
if amount > self.balance:
print("[!] DEBUG MESSAGE : You don't have enough money on your account to make this transfer")
return False
else:
self.balance -= amount
receiver.balance += amount
return True
def printBalance(self):
print(f"{self.user} has {self.balance} on his account")
FLAG = open("./flag.txt", "r").read()
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
# Creating the two accounts
ctf_player = account(10, "ctf_player")
BANK = account(100, "Bank")
# Main loop
menu = "dashboard"
clear()
while menu != "quit":
if menu == "dashboard":
print("=== Dashboard ===")
print()
print("Welcome to your HeroBank dashboard ! ")
print("From here, you can choose to wire money to another account, or to buy some premium features on the HeroStore.")
print()
print(f"You currently have {ctf_player.balance}$ on your account")
print("Choose an option :")
print("1 - HeroStore")
print("2 - Transfer money")
print("3 - Quit")
option = 0
try:
option = int(input(">> "))
if option == 1:
menu = "store"
elif option == 2:
menu = "transfer"
elif option == 3:
menu = "quit"
else:
1/0
except:
print("An error has occured, enter only 1,2 or 3")
input("Press enter to continue...")
clear()
elif menu == "store":
print("=== HeroStore ===")
print()
print("Welcome to the HeroStore !")
print("Here you can buy all sorts of things. Sadly, our stocks suffered from our success, and only one item remains. It's therefore pretty expensive.")
print()
print("Choose an option :")
print("1 - Fl4g (100$)")
print("2 - Back to Dashboard")
option = 0
try:
option = int(input(">> "))
if option == 1:
if ctf_player.balance >= 100:
print(f"Congratz ! Here is your item : {FLAG}")
input("Press enter to continue...")
menu = "quit"
else:
print()
print("Sorry, but you need more money to make that purchase...")
input("Press enter to continue...")
menu = "store"
elif option == 2:
menu = "dashboard"
else:
1/0
except:
print("An error has occured, enter only 1 or 2")
input("Press enter to continue...")
clear()
elif menu == "transfer":
print("=== Transfer Protocol ===")
print()
print("How much do you want to transfer the bank ?")
try:
amount = int(input(">> "))
if ctf_player.wireMoney(amount, BANK):
print("Transfer completed !")
menu = "dashboard"
input("Press enter to continue...")
except:
print("You have to enter an integer")
input("Press enter to continue...")
clear()