DarkCat09/Math_BruteForce
This commit is contained in:
parent
99d8952ce0
commit
aa154d83e3
3 changed files with 153 additions and 0 deletions
27
math_bruteforce/control_equation_bruteforce.py
Normal file
27
math_bruteforce/control_equation_bruteforce.py
Normal file
|
@ -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")
|
43
math_bruteforce/mathsigns_bruteforce_light.py
Normal file
43
math_bruteforce/mathsigns_bruteforce_light.py
Normal file
|
@ -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...")
|
83
math_bruteforce/xbruteforce_div.py
Normal file
83
math_bruteforce/xbruteforce_div.py
Normal file
|
@ -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")
|
Loading…
Add table
Reference in a new issue