I'm currently working on helping with the development of a website. Someone this past weekend attempted to hack into the website, but failed. However, since the entire site was rewritten this last summer, there was no way to store their movements within the site and to catch the user's IP before they gave up.
Is there a way to track a users actions (such as which links they visit) while in a website and store it into a file (the website is small) in order to make sure we have a record of the actions, if anyone ever attempts to hack it again?
To see if I could do this, I started using logging, but ran into issues with how exactly I am supposed to record the users actions with logging. My setup is below, and it works, I just don't know what to put in place of the string currently inside of logging.info() to record the movements of the user. Thanks in advance for any help you can provide.
from ipware.ip import get_ip
import logging
def IPCatcher(request):
ip = get_ip(request)
if ip is not None:
print("We have an IP address for user")
print(ip)
logging.basicConfig(filename='log_recording.txt',
level=logging.DEBUG,format='%(asctime)s %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p')
logging.info('This is working')
else:
print("we don't have an IP address for user")