OTP Generator Added
This commit is contained in:
+37
-10
@@ -11,10 +11,6 @@ import utils.pathfunctions as pathf
|
||||
import utils.policyfunctions as policyf
|
||||
from utils.perstscheduler import register_function, run_once_job, recurring_job, reload_jobs, start_scheduler
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def getActiveOTP(url):
|
||||
|
||||
endpoint = url + f'/v1/otp/usage'
|
||||
@@ -36,7 +32,6 @@ def getActiveOTP(url):
|
||||
if not otp.empty:
|
||||
ct.style_dataframe_dark(otp, f"newest_active_OTP.html")
|
||||
|
||||
|
||||
def getOTPActivities(url, otpid):
|
||||
endpoint = url + f'/v1/otp/activities'
|
||||
payload = {"otpid": f"{otpid}"}
|
||||
@@ -137,10 +132,6 @@ def monitorOTP(url, pups):
|
||||
os.remove(f"OTP\\PARQ\\otp_activities_{pid}.parquet")
|
||||
del finalhashesadded
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def addOTPHashes(url, clientid, otpid, pups):
|
||||
path = f"OTP\\PARQ\\otp_activities_{otpid}.parquet"
|
||||
activities = pd.read_parquet(path)
|
||||
@@ -160,7 +151,7 @@ def addOTPHashes(url, clientid, otpid, pups):
|
||||
|
||||
# Add hashes to policy
|
||||
if hashes_to_add:
|
||||
policyf.addHashReal(url, allowlist, hashes_to_add)
|
||||
policyf.addHash(url, allowlist, hashes_to_add)
|
||||
|
||||
# Update 'hash_added' column
|
||||
activities["hash_added"] = activities.apply(
|
||||
@@ -171,3 +162,39 @@ def addOTPHashes(url, clientid, otpid, pups):
|
||||
|
||||
# Save the updated DataFrame
|
||||
activities.to_parquet(path)
|
||||
|
||||
def generateOTP(url, agentid):
|
||||
purpose = input(ct.colorText(" Please enter the purpose for the OTP: ", "white"))
|
||||
|
||||
possible_durations = [15, 60, 360, 1440, 10080]
|
||||
duration_selected = " "
|
||||
|
||||
print(ct.colorText("Please select a duration:", "white"))
|
||||
for i, option in enumerate(possible_durations, start=1):
|
||||
print(f"{i}. {option}")
|
||||
|
||||
try:
|
||||
choice = int(input("Enter the number of your choice: "))
|
||||
if 1 <= choice <= len(possible_durations):
|
||||
duration_selected = possible_durations[choice - 1]
|
||||
print(ct.colorText(f"You selected: {duration_selected}", "yellow"))
|
||||
else:
|
||||
print(ct.colorText("Invalid choice.", "red"))
|
||||
except ValueError:
|
||||
print(ct.colorText("Invalid input. Please enter a number.", "red"))
|
||||
|
||||
endpoint = url + '/v1/otp/retrieve'
|
||||
payload = {
|
||||
"duration" : f"{duration_selected}",
|
||||
"agentid" : f"{agentid}",
|
||||
"purpose" : f"{purpose}"
|
||||
}
|
||||
|
||||
headers = {"X-APIKey": os.getenv('APIKEY')}
|
||||
payload = json.dumps(payload)
|
||||
|
||||
|
||||
response = requests.post(endpoint, headers=headers, data=payload, verify=False)
|
||||
result = json.loads(response.text)
|
||||
otpcode = result["response"]["otpcode"]
|
||||
print(ct.colorText(f"The OPT code is: {otpcode}", "yellow"))
|
||||
Reference in New Issue
Block a user