Skip to content

Commit

Permalink
Added check for currently logged in users
Browse files Browse the repository at this point in the history
  • Loading branch information
hnzlmnn committed Sep 7, 2017
1 parent 2cea2d2 commit dc03aeb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/diag_login_brute_force.py
Expand Up @@ -176,6 +176,16 @@ def get_rand(length):
return ''.join(choice(letters) for _ in range(length))


def is_duplicate_login(response):
if response[SAPDiag].get_item("APPL4", "DYNT", "DYNT_ATOM"):
for item in response[SAPDiag].get_item("APPL4", "DYNT", "DYNT_ATOM"):
if item.item_value:
for atom in item.item_value.items:
if atom.dlg_flag_1 is 0 and atom.dlg_flag_2 is 0 and atom.field2_text:
if "is already logged on in" in atom.field2_text:
return True, atom.field2_text
return False, ""

def login(host, port, terminal, route, username, password, client, verbose, results):
"""
Perform a login try with the username and password.
Expand All @@ -201,6 +211,10 @@ def login(host, port, terminal, route, username, password, client, verbose, resu
elif status == "E: Log on with a dialog user":
success = True
status = "No Dialog user (log on with RFC)"
# Check if the user is already logged in
elif is_duplicate_login(response)[0]:
status = is_duplicate_login(response)[1]
success = True
# If the ST_USER USERNAME item is set to the username, the login was successful
elif response[SAPDiag].get_item("APPL", "ST_USER", "USERNAME"):
st_username = response[SAPDiag].get_item("APPL", "ST_USER", "USERNAME")[0].item_value
Expand All @@ -216,6 +230,7 @@ def login(host, port, terminal, route, username, password, client, verbose, resu
else:
status = "Unknown error"


# Close the connection
connection.close()

Expand Down

0 comments on commit dc03aeb

Please sign in to comment.