From aa154d83e337d767ccc5bae7a23938319f90e95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9?= <50486086+DarkCat09@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:11:29 +0400 Subject: [PATCH] DarkCat09/Math_BruteForce --- .../control_equation_bruteforce.py | 27 ++++++ math_bruteforce/mathsigns_bruteforce_light.py | 43 ++++++++++ math_bruteforce/xbruteforce_div.py | 83 +++++++++++++++++++ 3 files changed, 153 insertions(+) create mode 100644 math_bruteforce/control_equation_bruteforce.py create mode 100644 math_bruteforce/mathsigns_bruteforce_light.py create mode 100644 math_bruteforce/xbruteforce_div.py diff --git a/math_bruteforce/control_equation_bruteforce.py b/math_bruteforce/control_equation_bruteforce.py new file mode 100644 index 0000000..a7dd3fa --- /dev/null +++ b/math_bruteforce/control_equation_bruteforce.py @@ -0,0 +1,27 @@ +# Math equation brutforce + +print() +print("*** MATH EQUATION BRUTEFORCE ***") +print("********* by DarkCat09 *********") +print() + +if input("Press ENTER or type y for start\nType n to exit\n") == 'n': + quit() + +print() +print("START!") + +y = -1 +result = 0 +while result != (y + 10): + y += 1 + result = y + y - 25 + print(str(y) + " + " + str(y) + " - 25 = " + str(result)) + if y > 1000: + print("1000 iterations reached! Exiting!") + break + +print() +print(str(y)) +print() +input("Press ENTER") diff --git a/math_bruteforce/mathsigns_bruteforce_light.py b/math_bruteforce/mathsigns_bruteforce_light.py new file mode 100644 index 0000000..0ef61ee --- /dev/null +++ b/math_bruteforce/mathsigns_bruteforce_light.py @@ -0,0 +1,43 @@ +print("") +print("***MATH SIGNS BRUTEFORCE***") +print("*******light version*******") +print("") + +sucess = False + +#Entering values +a = int(input("Enter first number: ")) +b = int(input("Enter second number: ")) +eq = int(input("Enter result: ")) +print("") + +#Helper function +def checkResult(sign): + if (not (sign == "+" or sign == "-" or sign == "*" or sign == "/")): + return "Error!" + else: + #Calculator + if (sign == "+"): + return a+b + elif (sign == "-"): + return a-b + elif (sign == "*"): + return a*b + elif (sign == "/"): + return a/b + else: + return "Error." + +#Bruteforce +for s in ["+", "-", "*", "/"]: + if (checkResult(s) == eq): + print("Sucess!") + print("Correct sign for this expression:", s) + sucess = True + break + +if (not sucess): + print("Failed!") + +print("") +input("Press enter to exit...") diff --git a/math_bruteforce/xbruteforce_div.py b/math_bruteforce/xbruteforce_div.py new file mode 100644 index 0000000..850f3bf --- /dev/null +++ b/math_bruteforce/xbruteforce_div.py @@ -0,0 +1,83 @@ +from fractions import Fraction +import time + +print("***X BRUTEFORCE - DIVISION***") +print() + +imit = int(input("Включить имитацию брутфорс-взлома хэша (небольшая задержка при подборе)?\nответ: 0-выкл., 1-вкл., 2-в.скорость, 3-оч.в.скорость: ")) +print() + +accuracy = Fraction(input("Укажите точность числа с плавающей запятой (float).\nответ: 1-только целочисл. знач., 0.1=0.1, 0.01=0.01, ... : ")) +print(accuracy) +print() + +x = input("Первое число (x, если неизвестно): ") +y = input("Второе число (x, если неизвестно): ") +z = input("Результат (x, если не известен): ") +res = 0 +a = Fraction(0) + +#Checking - what number is X +#and Bruteforcing +if ((x == "x") and (not (y == "x")) and (not (z == "x"))): + while (not (Fraction(a) == (Fraction(z)*Fraction(y)))): + print(str(float(Fraction(a))) + "/" + str(float(Fraction(y))) + "=" + str(float((Fraction(a)/Fraction(y))))) + a = Fraction(a) + accuracy + if (imit == 1): + time.sleep(0.07) + if (imit == 2): + time.sleep(0.007) + if (imit == 3): + time.sleep(0.001) + print(str(float(Fraction(a))) + "/" + str(float(Fraction(y))) + "=" + str(float((Fraction(a)/Fraction(y))))) + print ("OK!") + print("x is", float(Fraction(a))) +elif ((y == "x") and (not (z == "x")) and (not (x == "x"))): + a = Fraction(a) + accuracy + while (not (Fraction(a) == (Fraction(x)/Fraction(z)))): + print(str(float(Fraction(x))) + "/" + str(float(Fraction(a))) + "=" + str(float((Fraction(x)/Fraction(a))))) + a = Fraction(a) + accuracy + if (imit == 1): + time.sleep(0.07) + if (imit == 2): + time.sleep(0.007) + if (imit == 3): + time.sleep(0.001) + print(str(float(Fraction(x))) + "/" + str(float(Fraction(a))) + "=" + str(float((Fraction(x)/Fraction(a))))) + print ("OK!") + print("x is", float(Fraction(a))) +elif ((z == "x") and (not (y == "x")) and (not (x == "x"))): + attempt = 0 + while (not (Fraction(a) == (Fraction(x)/Fraction(y)))): + print(str(float(Fraction(x))) + "/" + str(float(Fraction(y))) + "=" + str(float(Fraction(a)))) + #for debug + #print(Fraction(a), accuracy) + + if (attempt > 3000): + #Protection + print() + stopAndCalc = int(input("Попыток взлома уже больше 3000. Использовать обычный калькулятор?\nответ: 1-да, 0-нет: ")) + if (stopAndCalc): + a = Fraction(x)/Fraction(y) + break + else: + print("Что ж, это Ваше дело.\nВ любой момент можно остановить программу нажатием клавиш Ctrl+C") + print() + + a = Fraction(a) + accuracy + if (imit == 1): + time.sleep(0.07) + if (imit == 2): + time.sleep(0.007) + if (imit == 3): + time.sleep(0.001) + attempt = attempt + 1 + print(str(float(Fraction(x))) + "/" + str(float(Fraction(y))) + "=" + str(float(Fraction(a)))) + print("OK!") + print() + print("x is", float(Fraction(a))) +else: + print("Ошибка!") + +print() +input("Чтобы выйти, нажмите ENTER")