Last active
November 26, 2018 17:06
-
-
Save dilin993/5da0803991cb2371fecc97fdb6ed8cc6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate Suspicious login - Login after consecutive failed logins | |
def generateSuspiciousLoginScenario1(df): | |
global currentTime, usernames, ipAddressesForUsers, index | |
username = usernames[random.randrange(NUMBER_OF_USERS)] | |
contextID = uuid.uuid4() | |
currentTime = currentTime + datetime.timedelta(seconds=random.randrange(3000)) | |
failureCount = random.randrange(4, 7) | |
generateFailedLogin(df, failureCount, currentTime, username, contextID) | |
index = index + failureCount | |
currentTime = currentTime + datetime.timedelta(seconds=random.randrange(3)) | |
generateSuccessfulLogin(df, currentTime, username, contextID, isSuspicious=True) | |
index = index + 1 | |
# Generate Suspicious login 2 - Login from suspicious IP | |
def generateSuspiciousLoginScenario2(df): | |
global currentTime, usernames, ipAddressesForUsers, index | |
username = usernames[random.randrange(NUMBER_OF_USERS)] | |
# contextID = uuid.uuid4() | |
currentTime = currentTime + datetime.timedelta(seconds=random.randrange(3000)) | |
ip = generateRandomIPV4() | |
geoLoc = None | |
while geoLoc is None: | |
while ip in geoLocationForIP: | |
ip = generateRandomIPV4() | |
geoLoc = geolocation.getGelocation(ip) | |
if geoLoc.latitude == geoLocationForIP[ipAddressesForUsers[username]].latitude and geoLoc.longitude == \ | |
geoLocationForIP[ipAddressesForUsers[username]].longitude: | |
geoLoc = None | |
ip = generateRandomIPV4() | |
geoLocationForIP[ip] = geoLoc | |
generateSuccessfulLogin(df, currentTime, username) | |
index = index + 1 | |
currentTime = currentTime + datetime.timedelta(seconds=random.randrange(60)) | |
generateSuccessfulLogin(df, currentTime, username, ip, isSuspicious=True) | |
index = index + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment